• Resolved Terry J

    (@texasbiz)


    Your plugin is great, thank you for sharing.

    If I go to playground and enter in prompt: write php code for simple text file based cms

    I end up with jumbled up code like:

    $title = "My CMS";$content = "Welcome to my content management system.";echo "<h1>".$title."</h1>";echo $content;$title = "My CMS";$body = "This is my content";$fp = fopen("content.txt", "w");fwrite($fp, $title."\n".$body);fclose($fp);echo "Done";$file = "content.txt";$content = file_get_contents($file);echo $content;$file = "content.txt";$content = file_get_contents($file);if (isset($_POST['content'])) { $content = $_POST['content']; file_put_contents($file, $content);}?><form action="" method="post"> <textarea name="content" rows="10" cols="100"><?php echo $content; ?></textarea><br> <input type="submit" value="Save"></form><?php$text_file = 'text.txt';$text = file_get_contents($text_file);echo $text;<?php$file = 'file.txt';$content = file_get_contents($file);$lines = explode("\n", $content);$data = array();foreach($lines as $line) { $line = trim($line); if(!empty($line)) { list($key, $value) = explode("=", $line); $data[$key] = $value; }}?>$title = " Simple Text File CMS";$content = "This is a simple text file CMS.";$footer = "Thank you for using Simple Text File CMS!";?>$title = "My Simple CMS";$content = "Welcome to my simple CMS!";if (isset($_GET['page'])) { $page = $_GET['page'];} else { $page = 'home';}if ($page == 'home') { echo $title; echo $content;} elseif ($page == 'about') { echo "About My Simple CMS";} else { echo "404 - Page Not Found";}

    Is your plugin not designed to write code?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author senols

    (@senols)

    Hi @texasbiz

    Our plugin uses OpenAI GPT-3 models. So all responses are coming from there. It is not something that our plugin can control.

    Thread Starter Terry J

    (@texasbiz)

    Of course you can format the output from the ai engine. I am using another ai plugin here from www.remarpro.com and code output is just fine:

    <?php 
    
    // create a form to allow user to choose a file
    echo '<form action="" method="post" enctype="multipart/form-data">
        <input type="file" name="fileToUpload" id="fileToUpload">
        <input type="submit" value="Upload File" name="submit">
    </form>';
    
    if (isset($_POST['submit'])) {
    
        // get file details
        $fileName = $_FILES['fileToUpload']['name'];
        $fileSize = $_FILES['fileToUpload']['size'];
        $fileTmpName = $_FILES['fileToUpload']['tmp_name'];
        $fileType = $_FILES['fileToUpload']['type'];
        $fileError = $_FILES['fileToUpload']['error'];
        $fileExt = explode('.',$fileName);
        $fileActualExt = strtolower(end($fileExt));
    
        // allowed file types
        $allowed = array('enc');
    
        // check for errors
        if ($fileError !== 0) {
            echo "An error occurred";
        }
        else {
            // check file type
            if (in_array($fileActualExt, $allowed)) {
                // read file contents
                $fileContent = file_get_contents($fileTmpName);
    
                // decode content using base64_decode
                $decodedContent = base64_decode($fileContent);
    
                // decrypt content using openssl
                $key = "your_key_here";
                $decryptedContent = openssl_decrypt($decodedContent, 'aes-256-cbc', $key);
    
                // echo decrypted content
                echo $decryptedContent;
            }
            else {
                echo "Invalid file type";
            }
        }
    }
    
    ?>

    You can use the playground at openai and the out is formatted too.

    I can write a simple PHP CURL script that outputs formatted code.

    Anyway, wishing you the best.

    Plugin Author senols

    (@senols)

    Ahh got it

    Ok will format the output in coming releases ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Writing code requests’ is closed to new replies.