## new 4
/*This software is under licence and can only be used with permission granted
from Globel Limited. */
// GET ENV SETTINGS
//REMOVE $BOT AFTER ALL UPDATES!
global $BOT;
## NEW
global $COM; // FOR COMMON VARS IN MOTHER SCRIPT
global $PRIME; // replaces $BOT as primary setup and functions
global $SITE; // new website or blog individual setup!
// global $PRIME, $SITE;
error_reporting(true);
$MYNAME = $_SERVER["PHP_SELF"]; // produces www/test/test/index.html
$tempstring = pathinfo($MYNAME); // returns an associative array containing information about path
$MYDIRNAME = $tempstring['dirname']; //produces "www/test/test"
if ($MYDIRNAME == "\\"){$MYDIRNAME = "";}
$SCRIPTNAME = $tempstring['basename'];
$WORKINGDIR = $_SERVER["SCRIPT_FILENAME"];
$WORKINGDIR = str_replace("\\", "/", $WORKINGDIR); //full working directory
$ROOTDIR = str_replace($MYNAME, "", $WORKINGDIR); //base directory
$WORKINGDIR = str_replace($SCRIPTNAME, "", $WORKINGDIR); //full working directory
$ROOTURL = $_SERVER["HTTP_HOST"];
$ROOTURL = "http://".$ROOTURL;
$WORKINGURL = $ROOTURL.$MYDIRNAME;
//$COM[MODE] = "WEBSITE";
/// PRIMARY SETUP CHECK HERE AND/OR ENTER SETUP?
if (file_exists($ROOTDIR."/bot_includes/setup.php") == false){ENTERsetup();}
else{include_once($ROOTDIR."/bot_includes/setup.php");}
/// SECTION SELECT PHP TO SELECT TYPE OF DIR
//if (file_exists($WORKINGDIR."index.temp") == true)
// {}
if (file_exists($ROOTDIR."/bot_includes/setup.website.php") == true)
{include_once($ROOTDIR."/bot_includes/setup.website.php");}
// ENTER ADMIN
elseif (file_exists($ROOTDIR."/bot_includes/setup.admin.php") == false){ENTERsetup();}
else {include_once($ROOTDIR."/bot_includes/setup.admin.php"); }
$COM = array(
VMAJOR => "1", #VERSION
VMINOR => "0", #VERSION
VREVISION => "2", #VERSION
VUPGRADE => "2", #VERSION AUTO UPGRADE COM
1 => "",
2 => "",
3 => "",
FORM => "",
TITLE => "",
HEADING => "",
LOGGED => "0",
EDITPAGE => "1", // THIS WILL BE SET IN USER DEFAULTS
EDITORNAME => $PRIME[MASTEREDITORNAME], // THIS WILL BE SET IN USER DEFAULTS
);
//////// function to renew target royaladmin.php and make copy in local dir ///
// IF UPDATED JUMP OUT OF THIS SCRIPT AND GO THERE AGAIN!
if (file_exists($SITE[INCLUDES].'checkme.php') == true)
{include_once($SITE[INCLUDES].'checkme.php');
if (CHECKme()){$header = "Location: $WORKINGURL\n\n"; header($header); Exit;}
}
else {print "Warning! could not check Myself?"; exit;}
/// LATER TURN THIS INTO THE PRIMARY SCRIPT AND THE FOLLOWING INTO AN INCLUDE
/// FILE, THIS WAY THE TARGET CAN ALWAYS UPDATE ITSELF AUTOMATICLY
///////////////////////////////////////////////////////////////////////////////
////////// END GLOBALS BUILD /////////
$COM[LOGGED] = CHECKlogged();
destroystuff();
//////////////
//print $PRIME[ERRORFILE];
//exit;
if ((file_exists($SITE[INCLUDERROR].$PRIME[ERRORFILE])) and ($COM[LOGGED] == "0"))
{
include_once($SITE[INCLUDERROR].$PRIME[ERRORFILE]);
switch ($ERROR[TYPE])
{
case 301:
header("HTTP/1.1 301");
header("Location: ".$ERROR[SENDURL]);
exit();
case REDIR:
echo "NOTHING YET";
break;
}
}
if (($_POST['cmd'] == "logon") or ($_GET['cmd'] == "logon"))
{if (file_exists($SITE[INCLUDES].'logon.php') == true)
{include_once($SITE[INCLUDES].'logon.php'); LOGON();}
else{showerror("There is a logon error please contact globel!");}}
elseif ($_GET['cmd'] == "logoff")
{if (file_exists($SITE[INCLUDES].'logon.php') == true)
{include_once($SITE[INCLUDES].'logon.php'); LOGOFF();}
else{showerror("There is a logoff error please contact globel!");}}
elseif (($_GET['cmd'] == "error_manager") and (file_exists($SITE[INCLUDES].'error.manager.php')) and ($COM[LOGGED]))
{include_once($SITE[INCLUDES].'error.manager.php'); RUNerrormanager();}//;
elseif (($_GET['cmd'] == "change_access") and ($COM[LOGGED])){GETcontent(); if ($_GET['action'] == "alwaccess")
{unlink($PRIME[WORKINGDIR].'NOWEBACCESSLLOWED');} elseif ($_GET['action'] == "stopaccess")
{CREATEfile($PRIME[WORKINGDIR].'NOWEBACCESSLLOWED','NOWEBACCESSLLOWED');}}
elseif (($_GET['cmd'] == "images") and (file_exists($SITE[INCLUDES].'image.manager.php')) and ($COM[LOGGED]))
{include_once($SITE[INCLUDES].'image.manager.php'); RUNimagemanager();}
elseif (($_POST['cmd'] == "Edit HTML") and ($COM[LOGGED]))
{
if ($_POST['action'] == "content")
{
GETcontent();
$COM[FORM] = $_POST['item'];
if ($_POST['item'] == "1"){$COM[1] = EDITHTML($COM[1], "Content", $_POST['item']);}
elseif ($_POST['item'] == "2"){$COM[2] = EDITHTML($COM[2], "Content", $_POST['item']);}
elseif ($_POST['item'] == "3"){$COM[3] = EDITHTML($COM[3], "Content", $_POST['item']);}
}
}
elseif (($_POST['cmd'] == "EDITOR") and ($COM[LOGGED]))
{
if ($_POST['action'] == "content")
{
GETcontent();
$COM[FORM] = $_POST['item'];
if ($_POST['item'] == "1"){$COM[1] = EDITOR($COM[1], "Content", $_POST['item']);}
elseif ($_POST['item'] == "2"){$COM[2] = EDITOR($COM[2], "Content", $_POST['item']);}
elseif ($_POST['item'] == "3"){$COM[3] = EDITOR($COM[3], "Content", $_POST['item']);}
}
}
elseif (($_POST['cmd'] == "SAVE") and ($COM[LOGGED]))
{
if ($_POST['action'] == "content")
{
GETcontent();
//echo $RAWHTML['editedarea']."HH"; //$OUTFILE .= "$RAWHTML{'editedarea'}";
if ($_POST['item'] == "1"){$COM[1] = $_POST['content'];}
elseif ($_POST['item'] == "2"){$COM[2] = $_POST['content'];}
elseif ($_POST['item'] == "3"){$COM[3] = $_POST['content'];}
SAVEcontent($COM[1], $COM[2], $COM[3]);
$header = "Location: $WORKINGURL\n\n"; header($header); Exit;
}
}
else {GETcontent();}
//echo "changed 2";
//echo $COM[LOGGED];
#foreach($GLOBALS as $ITEM){echo $ITEM;}
OUTPUTpage($COM[1],$COM[2],$COM[3],$COM[TITLE],$COM[HEADING],$COM[LOGGED]);
exit(0);
/////////////////////////// SCRIPT END ////////////////////////////////
###########################################################################
function showerror($errormsg)
{
global $PRIME, $SITE;
$BOT_PAGETITLE = "Error";
$BOT_PAGEHEADING = "Error";
$BOT_CONTENT1 = $errormsg;
OUTPUTpage("$errormsg","0","0","$BOT_PAGETITLE","$BOT_PAGEHEADING",'0');
exit;
}
///////////////////////////////////////////////////////////////////////////
function destroystuff()
{
global $PRIME, $SITE;
// destroy old versions ########
if ($PRIME[DESTROYFILE1] != "")
{if (file_exists($PRIME[WORKINGDIR].$PRIME[DESTROYFILE1]) == true)
{unlink($PRIME[WORKINGDIR].$PRIME[DESTROYFILE1]);}}
if ($PRIME[DESTROYFILE2] != "")
{if (file_exists($PRIME[WORKINGDIR].$PRIME[DESTROYFILE2]) == true)
{unlink($PRIME[WORKINGDIR].$PRIME[DESTROYFILE2]);}}
}
##############################################
function ENTERsetup()
{
$FAIL = false;
// CHECK DEFAULT DIRS
if (@is_dir ($GLOBALS[ROOTDIR]."/bot_includes/") == false)
{if (mkdir($GLOBALS[ROOTDIR]."/bot_includes/") == false){$FAIL = true;}}
if ($FAIL){echo "If you are seeing this message I was unable to create my directories? This is usually because the proper permissions have not been set to allow me to do this, please change your settings to read/write!"; exit;}
/*if (file_exists($GLOBALS[ROOTDIR]."/bot_includes/setup.default.php") == false)
{
$handle = fopen("http://www.globel.co.uk/programs/defaults/setup.default.txt", "rb");
$contents = stream_get_contents($handle);
fclose($handle);
$FH = fopen($GLOBALS[ROOTDIR]."/bot_includes/setup.default.php", 'wb') or die("Can't Create file");
fwrite($FH, $contents);
fclose($FH);
$header = "Location: $GLOBALS[WORKINGURL]\n\n"; header($header); Exit;
}
else {include_once($GLOBALS[ROOTDIR]."/bot_includes/setup.default.php");}
*/
############ START setup.default.php###########
if ((@is_dir ($GLOBALS[ROOTDIR]."/bot_online/") == false))
{
if ($_GET['create'] == "structure")
{
if (@is_dir ($GLOBALS[ROOTDIR]."/bot_online/") == false)
{if (mkdir($GLOBALS[ROOTDIR]."/bot_online/") == false){$FAIL = true;}}
if ($FAIL){echo "If you are seeing this message I was unable to create my directories? This is usually because the proper permissions have not been set to allow me to do this, please change your settings to read/write!"; exit;}
else {$header = "Location: $GLOBALS[WORKINGURL]\n\n"; header($header); Exit;}
}
else {echo "Setup not complete #1 Click Here to create structure.";}
}
elseif (file_exists($GLOBALS[ROOTDIR]."/bot_includes/pclzip.lib.php") == false)
{
if ($_GET['create'] == "include")
{
$handle = fopen("http://www.globel.co.uk/programs/defaults/pclzip.lib.txt", "rb");
$contents = stream_get_contents($handle);
fclose($handle);
$FH = fopen($GLOBALS[ROOTDIR]."/bot_includes/pclzip.lib.php", 'wb') or die("Can't Create file");
fwrite($FH, $contents);
fclose($FH);
$header = "Location: $GLOBALS[WORKINGURL]\n\n"; header($header); Exit;
}
else {echo "Setup not complete #2 Click Here to create include file.";}
}
elseif ((@is_dir ($GLOBALS[ROOTDIR]."/bot_skin/admin/") == false) or
(@is_dir ($GLOBALS[ROOTDIR]."/bot_skin/default/") == false))
{
if ($_GET['create'] == "defskins")
{
$handle = fopen("http://www.globel.co.uk/programs/defaults/defaultskins.zip", "rb");
$contents = stream_get_contents($handle);
fclose($handle);
$FH = fopen($GLOBALS[ROOTDIR]."/defaultskins.zip", 'wb') or die("Can't Create file");
fwrite($FH, $contents);
fclose($FH);
if (file_exists($GLOBALS[ROOTDIR]."/defaultskins.zip") == true)
{
require_once($GLOBALS[ROOTDIR]."/bot_includes/pclzip.lib.php");
$archive = new PclZip($GLOBALS[ROOTDIR]."/defaultskins.zip");
if ($archive->extract() == 0){die("Error : ".$archive->errorInfo(true));}
unlink($GLOBALS[ROOTDIR]."/defaultskins.zip"); /// CLEAN UP
$header = "Location: $GLOBALS[WORKINGURL]\n\n"; header($header); Exit;
}
else {echo "Could not create default skin webpage!"; exit;}
}
else {echo "Setup not complete #3 Click Here to create default skin webpage.";}
}
elseif (file_exists($GLOBALS[ROOTDIR]."/bot_includes/setup.php") == false)
{
if ($_GET['create'] == "setup")
{
$handle = fopen("http://www.globel.co.uk/programs/defaults/setup.txt", "rb");
if ($handle)
{
$contents = stream_get_contents($handle);
fclose($handle);
$FH = fopen($GLOBALS[ROOTDIR]."/bot_includes/setup.php", 'wb') or die("Can't Create file");
fwrite($FH, $contents);
fclose($FH);
$header = "Location: $GLOBALS[WORKINGURL]\n\n"; header($header); Exit;
}
else {echo "Failed to import setup? Notify Globel."; exit;}
}
else {echo "Setup not complete #4 Click Here to create new setup file.";}
}
elseif (file_exists($GLOBALS[ROOTDIR]."/bot_includes/setup.admin.php") == false)
{
if ($_GET['create'] == "admin")
{
$handle = fopen("http://www.globel.co.uk/programs/defaults/setup.admin.txt", "rb");
if ($handle)
{
$contents = stream_get_contents($handle);
fclose($handle);
$FH = fopen($GLOBALS[ROOTDIR]."/bot_includes/setup.admin.php", 'wb') or die("Can't Create file");
fwrite($FH, $contents);
fclose($FH);
$header = "Location: $GLOBALS[WORKINGURL]\n\n"; header($header); Exit;
}
else {echo "Failed to import Administration? Notify Globel."; exit;}
}
else {echo "Setup not complete #5 Click Here to create new Administration Program.";}
}
else {echo "in else mode!";}
//echo "Oh Dear? start setup!";
exit;
############ END setup.default.php###########
exit;
}
///////////////////////////////////////////////////////////////////////
//if (!function_exists('fetch_remote_file')) {}
#setcookie ("cookiename", "", time( ) - 1); //to delete cookie
#setcookie ("cookiename", "This text will be in the cookie", time( ) + 3600); //persistant time in seconds
# setcookie ("cookiename", "This text will be in the cookie"); //session only!
?>