“myCode” Documentation by “KVendrik” v1.0


“myCode”

Created: 05/30/2012
By: KVendrik
Email: Contact

GFXFree.Net - Download Web Templates

Thank you for purchasing myCode. If you have any questions that are beyond the scope of this help file, please feel free to email via my user page contact form here.


Contents

  1. Installation
  2. Javascript
  3. CSS
  4. PHP View Pages (PHP View Pages Explaination)
  5. PHP Code Pages (PHP Code Pages Exaplaination)
  6. Troubleshooting

A) Installation - top

First you need to open myCode/Login.php and edit the username and password to something of your choice. After this the only thing you have to do is uploading the myCode folder to your server's root directory. Now go to yourwebsiteurl.com/myCode/ and you can start using myCode right away.


B) Javascript - top

myCode contains JS, CSS and PHP files. Let's start by explaning the Javascript. The only JS code that myCode uses is to save or create files from the createfile/createcontent.php and the editfile.php pages. You can find the JS code in these files. The jQuery file that both of these files use can be found in the JS folder.


C) CSS - top

The CSS file can be found in the CSS folder and is named style.css. You can use this file to modify the layout of myCode. While editing the menu buttons in the HTML file you will note that the buttons are in a order from right to left. while the extual buttons are from left to right. This is because the CSS code tells this class that it should float: right;. This is just one of the examples that you might run into. If you have any questions about the CSS modification of myCode then just contact me trough my Envato page. I'll be happy to help you out.

Shortcodes

Button

					
I'm a Button

Attention Red

					
AttentionRed

Attention Green

					
AttentionGreen

D) PHP View Pages - top

The PHP pages contain the code for the processing of commands such as file creation and file editing but they also contain the content of the pages. You can find the layout of the file lists in the index.php and open.php files. Below you can find the php code of these pages with an explaination.

index.php Explaination

                    
                    
					echo "
Files
LogoutUpload ZIPUpload FileCreate FolderCreate File
// Navigation Menu, this menu has a float: right element wich causes that it will be displayed from right to left "; if ($handle = opendir('.')) { while (false !== ($entry = readdir($handle))) { if (is_dir($entry) && $entry != "." && $entry != "..") { echo ""; echo ""; // The code above will get al the files from the current directory. It will also filter the files and display only the directories using the is_dir function. } if (is_file($entry) && $entry != "." && $entry != "..") { echo ""; $filetype = substr($entry, strrpos($entry, '.') + 1); if ($filetype=="html") echo ""; elseif ($filetype=="php") echo ""; elseif ($filetype=="css") echo ""; elseif ($filetype=="js") echo ""; elseif ($filetype=="xml") echo ""; elseif ($filetype=="sql") echo ""; elseif ($filetype=="txt") echo ""; else echo ""; // The code above will check if the file is a directory or not. // If it's a file then it will check the extension. // If it is a HTML, PHP, CSS, JS, XML, SQL or TXT file // it will display a menu to edit or delete the file with the right icon // If the file has another extension then it will display a // custom icon and only show a delete button and not a edit button. // You can easily add file extensions by copying the elseif statement of // a extension and past it below that extension and changing // it to your desired extension. // I added an example below this code explaination. } } // The code below closes the dir so it will not get // into a loop of reading the directory. // If this happens then the page will not stop loading. closedir($handle); } echo "
$entry\n Open
$entry\n Edit Delete$entry\n Edit Delete$entry\n Edit Delete$entry\n Edit Delete$entry\n Edit Delete$entry\n Edit Delete$entry\n Edit Delete$entry\n Delete
"; // The code below will trigger when you press // the Download Files as ZIP button. // It will pack the current directory as a ZIP and // force the browser to download the file using the header element. if (isset($_POST['Submit'])) { // increase script timeout value ini_set("max_execution_time", 300); // create object $zip = new ZipArchive(); // open archive if ($zip->open("Backup.zip", ZIPARCHIVE::CREATE) !== TRUE) { die ("Could not open archive"); } // initialize an iterator // pass it the directory to be processed $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(".")); // iterate over the directory // add each file found to the archive foreach ($iterator as $key=>$value) { $zip->addFile(realpath($key), $key) or die ("Could not add file: $key"); } // close and save archive $zip->close(); header("Content-type: application/zip"); header("Content-Disposition: attachment; filename=Backup.zip"); header("Pragma: no-cache"); header("Expires: 0"); readfile("Backup.zip"); unlink("Backup.zip"); exit; } // Below you'll find the button that will trigger the ZIP file download script echo "
";

Adding an Extension Example

                    
elseif ($filetype=="txt")
	  echo "$entry\n Edit Delete";
      
// TXT is the last extension in the list after this the else statement will trigger
// If you want to add an extension for example PNG then the code would be

elseif ($filetype=="png")
	  echo "$entry\n Edit Delete";
      
// Note that not only the extension is changed but also the 
// icon by changing the class to fileother instead of filetxt
// Also note that this code should be directly below the 
// last extension and not after the else statement
      
					

open.php Explaination

The PHP code in the open.php file is almost the same the only diffrence is that it also keeps track of the folder path to make sure that it won't try to open for example a file within a subdirectory from within the root directory. This is done by the $_GET['dir'] . "/" code. This code gets the previous directory given by the index.php file. It also adds a / to it so you get a working path to the file.



E) PHP Code Pages - top

The PHP pages that are being used for pure code are the createfile.php and the editfile.php page. Most of the other PHP codes can be found op the viewing pages. The only reason that the code to create and edit files are not in the same file as the viewing page is in is because jQuery requires an external file for the form action in order to work properly. Below you can find the code from the editfile.php and createfile.php pages.

editfile.php Explaination

           
           

		

createfile.php Explaination

        
        

		


F) Troubleshooting - top

Q: I can't use the upload function, when I upload a file it just doesn't appear in the file list.

A: If something like this happens then you should make sure the target directory has a 777 CHMOD value. If you can't get it fixed on your own then don't hasitate to contact me.


Once again, thank you so much for purchasing myCode. As I said at the beginning, I'd be glad to help you if you have any questions relating to this.

KVendrik

Go To Table of Contents