";
if (isset($f)){
//echo "you seem to have pushed $f ";
switch ($f){
//SETTINGS
case "about":
include ('./settings/setting_about.php');
break;
case "help":
include ('./settings/setting_help.php');
break;
//TOOLS
case "search":
include ('./tools/tool_search.php');
break;
case "colorextract":
include ('./tools/tool_colorextract.php');
break;
case "itemwizard":
include ('./tools/tool_itemwizard.php');
break;
case "backupdb":
include ('./tools/tool_backupdb.php');
break;
case "upload":
include ('./tools/tool_upload.php');
break;
case "linkcheck":
include ('./tools/tool_linkcheck.php');
break;
case "rssfeeds":
include ('./tools/tool_rssfeeds.php');
break;
case "itemqueue":
include ('./tools/tool_itemqueue.php');
break;
case "tools":
include ('./tools/tool_tools.php');
break;
case "fillshelf":
include ('./tools/tool_fillshelf.php');
break;
case "groupwizard":
include ('./tools/tool_groupwizard.php');
break;
case "folderscan":
include ('./tools/tool_folderscan.php');
break;
case "optimize":
include ('./tools/tool_optimize.php');
break;
case "bindview":
include ('./tools/tool_bindview.php');
break;
case "clean":
include ('./tools/tool_clean.php');
break;
case "reset":
include ('./tools/tool_reset.php');
break;
case "seed":
include ('./tools/tool_seed.php');
break;
case "statscount":
include ('./tools/tool_statscount.php');
break;
case "keywordwizard":
include ('./tools/tool_keywordwizard.php');
break;
case "newswizard":
include ('./tools/tool_newswizard.php');
break;
case "filegrab":
include ('./tools/tool_filegrab.php');
break;
case "thumbnails":
include ('./tools/tool_thumbnails.php');
break;
case "bindcount":
include ('./tools/tool_bindcount.php');
break;
case "openinghours":
include ('./tools/tool_openinghours.php');
break;
//TABLES
default:
switch ($a){
/*
case "show_change":
$f=$_POST['f'];
$thisid=$_POST['id'];
$show=$_POST['show'];
//connect to db
require ("./include/connect_db.php");
mysql_select_db($globalConfig['dbname'], $link) or die("couldn't select database");
mysql_query("UPDATE $f SET show=$show WHERE id='$thisid'");
echo "
Item $thisid from table $f has been changed
";
break;
*/
case "delete":
$thisid=$_GET['id'];
echo "
Item $thisid from table $f has been deleted
";
echo "
message
";
//connect to db
require ("./include/connect_db.php");
mysql_select_db($globalConfig['dbname'], $link) or die("couldn't select database");
if ($f=="files"){
$result=mysql_query("SELECT * FROM ".$globalConfig['dbprefix']."files WHERE id='$thisid'");
$resultrow=mysql_fetch_array($result);
$folderid=$resultrow[folderid];
$file="$resultrow[file]";
$result=mysql_query("SELECT * FROM ".$globalConfig['dbprefix']."folders WHERE id='$folderid'");
$resultrow=mysql_fetch_array($result);
$mydir="$foliodomain/files/$resultrow[folder]";
unlink($mydir."/".$file);
echo "
#
actual file $file from $mydir deleted from harddisk
";
//update the folderinfo
folderscan($mydir);
echo "
#
folder information for $resultrow[folder] updated
";
}
if ($f=="folders"){
//remove corresponding files from binder
$result=mysql_query("SELECT * FROM ".$globalConfig['dbprefix']."files WHERE folderid='$thisid'");
while($resultrow=mysql_fetch_array($result)){
$fileid=$resultrow[id];
mysql_query("DELETE FROM ".$globalConfig['dbprefix']."binder WHERE table1='files' AND record1='$fileid'");
mysql_query("DELETE FROM ".$globalConfig['dbprefix']."binder WHERE table2='files' AND record2='$fileid'");
}
echo "
#
all files out of this folder removed from binder
";
//remove all files for folderid
mysql_query("DELETE FROM ".$globalConfig['dbprefix']."files WHERE folderid=$thisid");
echo "
#
all file entries out of this folder removed
";
//get folder location
$result=mysql_query("SELECT * FROM ".$globalConfig['dbprefix']."folders WHERE id='$thisid'");
$resultrow=mysql_fetch_array($result);
$mydir="$resultrow[folder]";
//remove folder and its contents physically
RemoveDirectory($mydir);
echo "
#
actual folder and all its files removed from harddisk
";
}
//delete folder
mysql_query("DELETE FROM ".$globalConfig['dbprefix']."folders WHERE folder='$mydir'");
mysql_query("OPTIMIZE TABLE folders");
//delete db entry
mysql_query("DELETE FROM ".$globalConfig['dbprefix']."$f WHERE id=$thisid");
echo "
";
echo " click here to go back to $f";
break;
case "comment":
global $dblang, $lang, $cat, $page, $mode, $news, $dbname, $ezdb, $globalConfig, $userid, $sessionid, $admin, $f, $Fname, $Fvalue;
$posttable=$_POST['posttable'];
$postrecord=$_POST['postrecord'];
$postcom=$_POST['postcom'];
$postvote=$_POST['postvote'];
$ezdb->query("INSERT INTO ".$globalConfig['dbprefix']."comments VALUES (NULL, NOW(), '0', '1', '$postcom', '$postvote', '$sessionid', '$userid')");
$varid=$ezdb->get_var("SELECT id FROM ".$globalConfig['dbprefix']."comments WHERE comment='$postcom' AND vote='$postvote' AND sessionid='$sessionid' AND userid='$userid' ");
$ezdb->query("INSERT INTO ".$globalConfig['dbprefix']."binder VALUES (NULL, NOW(), '0', '1', '$posttable', '$postrecord', 'comments', '$varid', '', '', '$userid')");
echo "
";
//updating one by one since it's the only thing that seems to work for now
$updatequery.=" WHERE id='$thisid'";
mysql_query($updatequery);
//echo $updatequery." ";
echo " click here to go back to $f";
echo " click here to edit $thisid in $f";
break;
case "new":
echo "
Post a new item for $f
";
$colorpicker=0; //color picker has not been printed yet, only print one time
echo " cancel
";
//connect to database
// requires the class
require "./classes/datepicker/class.datepicker.php";
require "./classes/folio_color_picker/color_picker.php";
require ("./include/connect_db.php");
mysql_select_db($globalConfig['dbname'], $link) or die("couldn't select database");
$jobs=mysql_query("SELECT * FROM ".$globalConfig['dbprefix']."$f LIMIT 1");
//make form to submit changes
echo "";
break;
case "insert":
echo "
";
$mysqlstring.=",'".$fieldvalue."'";
//if it's a folder, also create the actual folder
if (($f=="folders") AND ($_POST['fieldname'][$i]=="folder")){
$folderpath="$foliodomain/files/$fieldvalue";
mkdir($folderpath);
chmod($folderpath,0777);
}
}
echo "
";
echo " click here to go back to $f";
echo " post a new item in $f";
//echo " $mysqlstring";
//connect to database
global $globalConfig;
$dbname=$globalConfig['dbname'];
$dbprefix=$globalConfig['dbprefix'];
require ("./include/connect_db.php");
mysql_select_db($dbname, $link) or die("couldn't select database");
mysql_query("INSERT INTO ".$dbprefix."$f VALUES(NULL,NOW(),'' $mysqlstring ,'$userid')");
//echo " DB UPDATED";
$lastid=$ezdb->get_var("SELECT id FROM ".$globalConfig['dbprefix']."$f ORDER BY id DESC LIMIT 1");
echo " click here to edit $lastid in $f";
break;
default:
echo "
Overview of $f
";
//CountBindingsTable($f);
if( ($f<>"files") AND ($f<>"sessions") AND ($f<>"stats") AND ($f<>"log") ){
echo " post a new item in $f
";
}
$db=new mysql_dialog("1");
$db->connect($globalConfig['dbhost'],$globalConfig['dbuser'], $globalConfig['dbpass'], $globalConfig['dbname']);
//FILTER
$Fname=$_GET['Fname'];
$Fvalue=$_GET['Fvalue'];
if ((isset($Fname)) AND (isset($Fvalue)) AND ($Fname<>NULL) AND ($Fvalue<>NULL)){
$condition="WHERE $Fname='$Fvalue'";
} else {
$condition="";
}
//PAGINATION
$page=$_GET['page'];
$perpage=$globalConfig['adminperpage'];
//pagination buttons
$result=mysql_query("SELECT * FROM ".$globalConfig['dbprefix']."$f $condition");
$totalrows=mysql_num_rows($result);
$pages=ceil($totalrows/$perpage);
echo "items: $totalrows | ";
for( $i=1;$i<=$pages;$i++) {
echo "page $i | ";
}
//pagination filter
if (isset($page)){
$offset=($page*$perpage)-$perpage;
$pagination="LIMIT $perpage OFFSET $offset";
}else{
$pagination="LIMIT $perpage";
}
//SORT
$Sname=$_GET['Sname'];
$Svalue=$_GET['Svalue'];
if ((isset($Sname)) AND (isset($Svalue)) AND ($Sname<>NULL) AND ($Svalue<>NULL)){
$sorting="ORDER BY $Sname $Svalue";
} else {
$sorting="ORDER BY id DESC";
}
//CountBindings($f, $Fvalue);
$SQL="SELECT * FROM ".$globalConfig['dbprefix']."$f $condition $sorting $pagination";
$db->speak($SQL);
$db->onscreen($SQL);
if(isset($f) AND ($Fname=="id")){
echo "
"; //end recorddetailview
*/
}
break;
}//ending the switch a
} //ending the switch f
echo "
"; //ending page_middle
} else {
echo "
Welcome to the Folio CMS admin section. Please select from menu.";
echo ""; //ending page_middle
}
/**
* Returns true if the string or array of string is encoded in UTF8.
*
* Example of use. If you want to know if a file is saved in UTF8 format :
* $array = file('one file.txt');
* $isUTF8 = isUTF8($array);
* if (!$isUTF8) --> we need to apply utf8_encode() to be in UTF8
* else --> we are in UTF8 :)
*
* @param mixed A string, or an array from a file() function.
* @return boolean
*/
function isUTF8($string)
{
if (is_array($string))
{
$enc = implode('', $string);
return @!((ord($enc[0]) != 239) && (ord($enc[1]) != 187) && (ord($enc[2]) != 191));
}
else
{
return (utf8_encode(utf8_decode($string)) == $string);
}
}
function MovePantone(){
$dbprefix="folio_";
require ("./include/connect_db.php");
mysql_select_db($globalConfig['dbname'], $link) or die("couldn't select database");
mysql_query("UPDATE ".$globalConfig['dbprefix']."colors SET hex=trim(hex)");
$result=mysql_query("SELECT * FROM ".$globalConfig['dbprefix']."colors WHERE pms<>''");
while($resultrow=mysql_fetch_array($result)){
$pmsvalue=$resultrow[pms];
$hexvalue=$resultrow[hex];
$oldid=$resultrow[id];
echo $pmsvalue." ".$hexvalue." ".$oldid;
$result2=mysql_query("SELECT * FROM ".$globalConfig['dbprefix']."colors WHERE hex='$hexvalue' AND id<>$oldid");
if(mysql_num_rows($result2)>0){
mysql_query("UPDATE ".$globalConfig['dbprefix']."colors SET pms='$pmsvalue' WHERE hex='$hexvalue' AND id<>$oldid");
echo " move and delete ";
mysql_query("DELETE FROM ".$globalConfig['dbprefix']."colors WHERE id='$oldid' LIMIT 1");
} else {
echo " keep ";
}
}
}
?>