Thursday, December 12, 2013

Technical information on developing plug-in's

Technical information on developing plug-in's:

Plug-in's allows for various operations of the core to enhance the website or additions to the administrative user addition options and control of the website and its content.

All plug-in's need to be located at this directory path: '/core/systems/plugins/' Each added plug-in must be place in its unique folder within this directory. All plug-in scripts and images need to be placed within this folder. Each plug-in needs to be identified by a script named 'plugin_name.php'. The menu for the plug-in will also be placed in this script. The plug-in menu will need to be disabled during the core's search for plug-in's installed. Below is code to disable this during that time.

if($plugin_off !== "off") { place plug-in menu code here within these brackets }


The menu HTML code should be developed in nested tables as to not effect the structure and CSS of the menu displaying this data, this menu will be included into the menu displaying it. Below is example of HTML plug-in menu code, it is important that the overall width of these tables to be set at 100% and not a set pixel width so it can fit into the displaying menu consistently with all other plug-in menus and not effect the width of the displaying menu.

$plugin_name="RSS Feed v1.0";

$plugin_menu="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">
<tr>
<td> <center><div class=\"text_1\" style=\"border-bottom:#000000 solid 1px; width:100%; text-align:center\"><b>Menu for RSS Feed v1.0</b>
</div></center>
<div class=\"text_1\"><br />Before the RSS (Atom v1.0) will validate it needs a valid email address.<br />
The feed is located at:<br />
<b>http://".$domain_name."/rss_feed/?<span style=\"color:#0000FF;\"> [ name of the page ]</span></b>
</div></td>
</tr>
</table><form action=\"plugins.php\" method=\"post\" enctype=\"application/x-www-form-urlencoded\" name=\"rss_feed\">
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">
<tr>
<td width=\"65\" align=\"left\" valign=\"middle\"><div class=\"text_1\">email addres:</div></td>
<td align=\"left\" valign=\"middle\"><input class=\"detail\" name=\"rss_email_address\" type=\"text\" value=\"".$array_values[1]."\" /></td>
<td width=\"65\" align=\"right\" valign=\"middle\"><input class=\"button\" style=\"cursor:pointer; font-size:10px; font-family:Arial, Helvetica, sans-serif; color:#0000FF; font-weight:bold;\" name=\"submit_rss_email\" type=\"submit\" value=\" Save \"></td>
</tr>
</table>
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">
<tr>
<td align=\"left\" valign=\"middle\"><div class=\"text_1\">To delete this plug-in click on this delete button.</div></td>
<td width=\"65\" align=\"right\" valign=\"middle\"><input class=\"button\" onClick=\"return confirm('Are you sure you want to delete this plug-in?')\" style=\"cursor:pointer; font-size:10px; font-family:Arial, Helvetica, sans-serif; color:#FF0000; font-weight:bold;\" name=\"delete_rss_feed\" type=\"submit\" value=\"Delete\" /></td>
</tr>
</table><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">
<tr>
<td><center><div style=\"border-bottom:#000000 solid 1px; width:100%; text-align:center;\"></div></center></td>
</tr>
</table></form><br />";
The two variables that the core will be gathering data from are: '$plugin_name' and '$plugin_menu'.

Delete plug-in function must have this exact code below and all buttons on this menu must ust the exact CSS and style as this button as well.

<input class=\"button\" onClick=\"return confirm('Are you sure you want to delete this plug-in?')\" style=\"cursor:pointer; font-size:10px; font-family:Arial, Helvetica, sans-serif; color:#FF0000; font-weight:bold;\" name=\"delete_rss_feed\" type=\"submit\" value=\"Delete\" />

The code to delete the plug-in must also have certain elemts included for the delete to function properly. Below is an example of a delete script, all that needs be changed is the directories, folders and file names of the plug-in to be deleted.

<?php
ini_set('display_errors', 'off');
$con=mysql_connect($db_host,$db_user,$db_pass);
@mysql_select_db($db_name, $con) or die(mysql_error());

@mysql_query("DELETE QUICK FROM wpc_core WHERE pagename = sys.email_rss");

mysql_close($con);

function deleteFiles($dir,$doc_r) {
str_replace('.', '', $dir, $true);
if($true == 0) {$dirct=$doc_r.$dir.'/'; $file_list=scandir($dirct);}
$cnt=2;
while(strlen($file_list[$cnt]) > 0) {
str_replace('.', '', $file_list[$cnt], $true);
if (file_exists($dirct.$file_list[$cnt]) && $true > 0)
 {unlink($dirct.$file_list[$cnt]); $file_list[$cnt]=NULL;}
$cnt++;
}
$cnt=2;
$elmt=count($file_list)+1;
while($elmt > $cnt) {
if(strlen($file_list[$cnt]) > 0) {$folder=$file_list[$cnt];}
$cnt++;}
return $folder;
}

$base_dir='/core/system/plugins/rss_feed';
$start_dir=$base_dir;
$run=scandir($doc_root.$base_dir.'/');
while(strlen($run[2]) > 0) {
$run=scandir($doc_root.$base_dir.'/');
$rem_dir=deleteFiles($start_dir,$doc_root);
$nxt=0;
while(strlen($rem_dir) > 0 || strlen($files_s) > 0) {
$dir_add=$base_dir.'/'.$rem_dir;
$dir_fldrs[$nxt]=$doc_root.$dir_add; $nxt++;
$rem_dir=deleteFiles($dir_add,$doc_root);
str_replace('.', '', $rem_dir, $true);
if($true == 0 && strlen($rem_dir) > 0) {$files_s=scandir($doc_root.$dir_add.'/');}
} $nxt=count($dir_fldrs);
while($nxt > 0) {
if(strlen($dir_fldrs[$nxt-1]) > 0) {
if (file_exists($dir_fldrs[$nxt-1])) {$files_l=scandir($dir_fldrs[$nxt-1].'/');}
if(strlen($files_l[2]) == 0) {
if (file_exists($dir_fldrs[$nxt-1])) {rmdir($dir_fldrs[$nxt-1]);}}}
$nxt--;
}}
if (file_exists($doc_root.$base_dir)) {$files_l=scandir($doc_root.$base_dir.'/');}
if(strlen($files_l[2]) == 0) {
if (file_exists($doc_root.$base_dir)) {rmdir($doc_root.$base_dir);}}

$base_dir='/core/system/fortomb/secure/menu/rss_feed_menu';
$start_dir=$base_dir;
$run=scandir($doc_root.$base_dir.'/');
while(strlen($run[2]) > 0) {
$run=scandir($doc_root.$base_dir.'/');
$rem_dir=deleteFiles($start_dir,$doc_root);
$nxt=0;
while(strlen($rem_dir) > 0 || strlen($files_s) > 0) {
$dir_add=$base_dir.'/'.$rem_dir;
$dir_fldrs[$nxt]=$doc_root.$dir_add; $nxt++;
$rem_dir=deleteFiles($dir_add,$doc_root);
str_replace('.', '', $rem_dir, $true);
if($true == 0 && strlen($rem_dir) > 0) {$files_s=scandir($doc_root.$dir_add.'/');}
} $nxt=count($dir_fldrs);
while($nxt > 0) {
if(strlen($dir_fldrs[$nxt-1]) > 0) {
if (file_exists($dir_fldrs[$nxt-1])) {$files_l=scandir($dir_fldrs[$nxt-1].'/');}
if(strlen($files_l[2]) == 0) {
if (file_exists($dir_fldrs[$nxt-1])) {rmdir($dir_fldrs[$nxt-1]);}}}
$nxt--;
}}
if (file_exists($doc_root.$base_dir)) {$files_l=scandir($doc_root.$base_dir.'/');}
if(strlen($files_l[2]) == 0) {
if (file_exists($doc_root.$base_dir)) {rmdir($doc_root.$base_dir);}}

unlink($doc_root.'/rss_feed/index.php');
chdir ($doc_root);
rmdir($doc_root.'/rss_feed');

$meta_refresh="<meta http-equiv=\"refresh\" content=\"1;url=http://".$domain_name."/core/system/fortomb/secure/menu/gui_cms_menu/plugins.php\">";
?>

Database entries must be deleted as well if any as seen above. This script must be placed into the root folder of the plug-in folder. Meta refresh is used to return to the GUI CMS Menu.