Viewing file: index.php (44.19 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/********************************************************************************
- MemHT Portal -
Copyright (C) 2007-2008 by Miltenovik Manojlo
http://www.memht.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your opinion) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see <http://www.gnu.org/licenses/> (GPLv2)
or write to the Free Software Foundation, Inc., 51 Franklin Street,
Fifth Floor, Boston, MA02110-1301, USA.
********************************************************************************/
if (!defined("_LOAD_PAGE_")) {
die("<table style='padding: 2px; border: 1px solid #999; background-color: #EEE; font-family: Verdana; font-size: 10px;' align='center'><tr><td><b>Error:</b> This file cannot be opened directly!</td></tr></table>");
}
if (isset($_GET['op'])) { $op = inCode($_GET['op']); } else { $op = ""; }
if (isset($_GET['id'])) { $id = intval($_GET['id']); } else { $id = 0; }
if (isset($_GET['ok'])) { $ok = inCode($_GET['ok']); } else { $ok = false; }
if (isset($_POST['nome'])) { $nome = eregi_replace("[/_']","-",inCode($_POST['nome'])); } else { $nome = ""; }
if (isset($_POST['titolo'])) { $titolo = eregi_replace("[/_']","-",inCode($_POST['titolo'])); } else { $titolo = ""; }
if (isset($_POST['description'])) { $description = inCode($_POST['description']); } else { $description = ""; }
if (isset($_POST['keywords'])) { $keywords = inCode($_POST['keywords']); } else { $keywords = ""; }
if (isset($_POST['fullscreen'])) { $fullscreen = intval($_POST['fullscreen']); } else { $fullscreen = 0; }
if (isset($_POST['enabled'])) { $enabled = intval($_POST['enabled']); } else { $enabled = 0; }
if (isset($_GET['dir'])) { $dir = inCode($_GET['dir']); } else { $dir = ""; }
if (isset($_POST['rank'])) { $rank = inCode($_POST['rank']); } else { $rank = 0; }
if (isset($_GET['subop'])) { $subop = inCode($_GET['subop']); } else { $subop = ""; }
if (isset($_POST['content'])) { $content = inCode($_POST['content']); } else { $content = ""; }
if (isset($_POST['version'])) { $version = intval($_POST['version']); } else { $version = 0; }
if (isset($_POST['updatefrom'])) { $updatefrom = inCode($_POST['updatefrom']); } else { $updatefrom = ""; }
function pageList() {
global $dblink;
$n = 0;
echo "<table width='100%' align='center' cellspacing='1' cellpadding='0' class='std_nicetable'>";
echo "<thead>\n";
echo "<tr><td>"._TITLE_."</td><td>"._FILE_."</td><td width='1%'> </td></tr>\n";
echo "</thead>\n";
echo "<tbody>\n";
if ($result = $dblink->get_list("SELECT * FROM memht_pagine ORDER BY titolo")) {
foreach ($result as $row) {
$id = intval($row['id']);
$nome = outCode($row['nome']);
$titolo = outCode($row['titolo']);
$fullscreen = intval($row['fullscreen']);
$rank = intval($row['rank']);
$enabled = intval($row['enabled']);
$rankimg = "";
switch ($rank) {
case 0: $rankimg = "guest"; $ranktitle = _LEVEL_.": "._GUEST_; break;
case 1: $rankimg = "user"; $ranktitle = _LEVEL_.": "._USER_; break;
case 2: $rankimg = "poweruser"; $ranktitle = _LEVEL_.": "._POWERUSER_; break;
case 3: $rankimg = "admin"; $ranktitle = _LEVEL_.": "._ADMIN_; break;
case 4: $rankimg = "superadmin"; $ranktitle = _LEVEL_.": "._SUPERADMIN_; break;
}
switch ($fullscreen) {
case 0: $preinfo = "<img src='images/stdscreen.gif' alt='"._STANDARD_."' title='"._STANDARD_."'>"; break;
case 1: $preinfo = "<img src='images/halfscreen.gif' alt='"._HALFSCREEN_."' title='"._HALFSCREEN_."'>"; break;
case 2: $preinfo = "<img src='images/fullscreen.gif' alt='"._FULLSCREEN_."' title='"._FULLSCREEN_."'>"; break;
}
$info = ($enabled!=1) ? " <img src='images/off.gif' alt='"._OFF_."' title='"._OFF_."'>" : " <img src='images/on.gif' alt='"._ON2_."' title='"._ON2_."'>" ;
$class = (($n++%2)!=0) ? "hlight" : "clean" ;
echo "<tr><td class='$class'><a href='index.php?page=$nome' title='$titolo'><b>$titolo</b></a></td><td class='$class'>$nome</td><td class='$class' nowrap><a href='admin.php?page=addons&op=editPage&id=$id' title='"._MODIFY_."'><img src='images/edit.gif' alt='Edit' border='0'></a> <a href='admin.php?page=addons&op=deletePage&id=$id' title='"._DELETE_."'><img src='images/delete.gif' alt='Delete' border='0'></a> - <img src='images/rank_$rankimg.gif' title='$ranktitle' border='0'> - $preinfo - <a href='admin.php?page=addons&op=switch&id=$id' title='"._ON_OFF_."'><img src='images/on_off.gif' alt='On off' border='0'></a> $info</td></tr>\n";
}
} else {
echo "<tr><td class='clean' align='center' id='errorText' colspan='3'><b>"._EMPTY_."</b></td></tr>\n";
}
echo "</tbody>\n";
echo "</table>";
}
function add($nome,$titolo,$description,$keywords,$fullscreen,$rank,$enabled,$ok=false) {
global $dblink;
if (!$ok) {
echo "<table width='100%' align='center' cellspacing='0' cellpadding='1'>";
echo "<form name='addadminform' method='post' action='admin.php?page=addons&op=addPage&ok=true'>";
echo "<tr><td width='25%'><b>"._FILE_."</b></td><td>";
echo "<select name='nome'>\n";
unset($filearray);
$filearray = array();
$handle = opendir('pages/');
$fileAvailable = false;
$inputMode="";
while (false !== ($file = readdir($handle))) {
if ($file != "." AND $file != ".." AND !eregi("html",$file) AND !pageInstalled($file)) {
$filearray[] = $file;
// At least one addon available to add
$fileAvailable = true;
}
}
closedir($handle);
// Is there at least one addon available to add?
if ($fileAvailable) {
// Yes, sort the array and add all files to the combobox
@sort($filearray);
@reset($filearray);
foreach(@$filearray as $file) {
echo "<option value='$file'>$file</option>\n";
}
}
else {
// No, add just one message to the combobox saying no addons are available
echo "<option value='"._NO_AVAILABLE_ADDONS_."'>"._NO_AVAILABLE_ADDONS_."</option>\n";
$inputMode="disabled";
}
echo "</select></td></tr>\n";
echo "<tr><td><b>"._TITLE_."</b></td><td><input type='text' name='titolo' size='40' maxlength='255'></td></tr>\n";
echo "<tr valign='top'><td><b>"._METATAGS_.":</b> "._DESCRIPTION_."</td><td><div align='right'>";
textarea("description","100%","70px",0,"");
echo "</div></td></tr>\n";
echo "<tr valign='top'><td><b>"._METATAGS_.":</b> "._KEYWORDS_."<div id='info'>("._SEPARATEDBYCOMMAS_.")</div></td><td><div align='right'>";
textarea("keywords","100%","70px",0,"");
echo "</div></td></tr>\n";
echo "<tr><td><b>"._SIZE_."</b></td><td>";
echo "<select name='fullscreen'>\n";
echo "<option value='0' selected>"._STANDARD_."</option>\n";
echo "<option value='1'>"._HALFSCREEN_."</option>\n";
echo "<option value='2'>"._FULLSCREEN_."</option>\n";
echo "</select></td></tr>\n";
echo "<tr><td><b>"._REQUIREDRANK_."</b></td><td>";
echo "<select name='rank'>\n";
echo "<option value='0' selected>"._GUEST_."</option>\n";
echo "<option value='1'>"._USER_."</option>\n";
echo "<option value='2'>"._POWERUSER_."</option>\n";
echo "<option value='3'>"._ADMIN_."</option>\n";
echo "<option value='4'>"._SUPERADMIN_."</option>\n";
echo "</select></td></tr>\n";
echo "<tr><td><b>"._ENABLED_."</b></td><td>";
echo "<select name='enabled'>\n";
echo "<option value='1' selected>"._YES_."</option>\n";
echo "<option value='0'>"._NO_."</option>\n";
echo "</select></td></tr>\n";
echo "<tr><td colspan='2'><input ".$inputMode." type='submit' name='Submit' value='"._INSTALL_."'>\n";
echo "</form>\n";
echo "</table>\n";
} else {
$save = true;
if ($nome=="") { $save = false; $msg = _FILE_." ".strtolower(_FIELD_)." ".strtolower(_REQUIRED_); }
if ($titolo=="") { $save = false; $msg = _TITLE_." ".strtolower(_FIELD_)." ".strtolower(_REQUIRED_); }
if ($save) {
$dblink->query("INSERT INTO memht_pagine (id,nome,titolo,description,keywords,fullscreen,rank,enabled)
VALUES (null,'$nome','$titolo','$description','$keywords','$fullscreen','$rank','$enabled')");
echo "<meta http-equiv='refresh' content='0;URL=admin.php?page=addons'>";
} else {
echo "<div align='center' id='errorText'><b>$msg</b></div>";
}
}
}
function edit($id,$nome,$titolo,$description,$keywords,$fullscreen,$rank,$enabled,$ok=false) {
global $dblink;
$id = intval($id);
if (!$ok) {
$row_page = $dblink->get_row("SELECT * FROM memht_pagine WHERE id=$id");
$nome = outCode($row_page['nome']);
$titolo = outCode($row_page['titolo']);
$description = outCode($row_page['description']);
$keywords = outCode($row_page['keywords']);
$fullscreen = intval($row_page['fullscreen']);
$rank = intval($row_page['rank']);
$enabled = intval($row_page['enabled']);
echo "<table width='100%' align='center' cellspacing='0' cellpadding='1'>";
echo "<form name='form_arg' method='post' action='admin.php?page=addons&op=editPage&id=$id&ok=true'></td></tr>\n";
echo "<tr><td width='25%'><b>"._FILE_."</b></td><td>";
echo "<select name='nome'>\n";
unset($filearray);
$filearray = array();
$handle = opendir('pages/');
while (false !== ($file = readdir($handle))) {
if ($file != "." AND $file != ".." AND !eregi("html",$file)) {
$filearray[] = $file;
}
}
closedir($handle);
@sort($filearray);
@reset($filearray);
foreach($filearray as $file) {
if ($nome==$file) {
echo "<option value='$file' selected>$file</option>\n";
} else {
echo "<option value='$file'>$file</option>\n";
}
}
echo "</select></td></tr>\n";
echo "<tr><td><b>"._TITLE_."</b></td><td><input type='text' name='titolo' size='40' maxlength='255' value=\"$titolo\">\n";
echo "<tr valign='top'><td><b>"._METATAGS_.":</b> "._DESCRIPTION_."</td><td><div align='right'>";
textarea("description","100%","70px",0,"",$description);
echo "</div></td></tr>\n";
echo "<tr valign='top'><td><b>"._METATAGS_.":</b> "._KEYWORDS_."<div id='info'>("._SEPARATEDBYCOMMAS_.")</div></td><td><div align='right'>";
textarea("keywords","100%","70px",0,"",$keywords);
echo "</div></td></tr>\n";
echo "<tr><td><b>"._SIZE_."</b></td><td>";
echo "<select name='fullscreen'>\n";
switch ($fullscreen) {
case 0:
echo "<option value='0' selected>"._STANDARD_."</option>\n";
echo "<option value='1'>"._HALFSCREEN_."</option>\n";
echo "<option value='2'>"._FULLSCREEN_."</option>\n";
break;
case 1:
echo "<option value='0'>"._STANDARD_."</option>\n";
echo "<option value='1' selected>"._HALFSCREEN_."</option>\n";
echo "<option value='2'>"._FULLSCREEN_."</option>\n";
break;
case 2:
echo "<option value='0'>"._STANDARD_."</option>\n";
echo "<option value='1'>"._HALFSCREEN_."</option>\n";
echo "<option value='2' selected>"._FULLSCREEN_."</option>\n";
break;
}
echo "</select></td></tr>\n";
echo "<tr><td><b>"._REQUIREDRANK_."</b></td><td>";
echo "<select name='rank'>\n";
$selected = ($rank==0) ? " selected" : "" ;
echo "<option value='0'{$selected}>"._GUEST_."</option>\n";
$selected = ($rank==1) ? " selected" : "" ;
echo "<option value='1'{$selected}>"._USER_."</option>\n";
$selected = ($rank==2) ? " selected" : "" ;
echo "<option value='2'{$selected}>"._POWERUSER_."</option>\n";
$selected = ($rank==3) ? " selected" : "" ;
echo "<option value='3'{$selected}>"._ADMIN_."</option>\n";
$selected = ($rank==4) ? " selected" : "" ;
echo "<option value='4'{$selected}>"._SUPERADMIN_."</option>\n";
echo "</select></td></tr>\n";
echo "<tr><td><b>"._ENABLED_."</b></td><td>";
echo "<select name='enabled'>\n";
if ($enabled==1) {
echo "<option value='1' selected>"._YES_."</option>\n";
echo "<option value='0'>"._NO_."</option>\n";
} else {
echo "<option value='1'>"._YES_."</option>\n";
echo "<option value='0' selected>"._NO_."</option>\n";
}
echo "</select></td></tr>\n";
echo "<tr><td colspan='2'><input type='submit' name='Submit' value='"._MODIFY_."'>\n";
echo "</form>\n";
echo "</table>\n";
} else {
$save = true;
if ($nome=="") { $save = false; $msg = _FILE_." ".strtolower(_FIELD_)." ".strtolower(_REQUIRED_); }
if ($titolo=="") { $save = false; $msg = _TITLE_." ".strtolower(_FIELD_)." ".strtolower(_REQUIRED_); }
if ($save) {
$dblink->query("UPDATE memht_pagine SET nome='$nome',titolo='$titolo',description='$description',keywords='$keywords',fullscreen='$fullscreen',rank='$rank',enabled='$enabled' WHERE id=$id");
echo "<meta http-equiv='refresh' content='0;URL=admin.php?page=addons'>";
} else {
echo "<div align='center' id='errorText'><b>$msg</b></div>";
}
}
}
function delete($id,$ok=false) {
global $dblink;
if ($ok) {
$dblink->query("DELETE FROM memht_pagine WHERE id=$id");
echo "<meta http-equiv='refresh' content='0;URL=admin.php?page=addons'>";
} else {
echo "<div align='center'><b>"._SUREDELETEPAGE_."</b><br><a href='admin.php?page=addons&op=deletePage&id=$id&ok=true' title='"._YES_."'>"._YES_."</a> - <a href='admin.php?page=addons' title='"._NO_."'>"._NO_."</a></div>";
}
}
function changeStatus($id) {
global $dblink;
$id = intval($id);
$row_stat = $dblink->get_row("SELECT * FROM memht_pagine WHERE id=$id");
$enabled = intval($row_stat['enabled']);
$newStatus = ($enabled==1) ? 0 : 1 ;
$dblink->query("UPDATE memht_pagine SET enabled='$newStatus' WHERE id=$id");
echo "<meta http-equiv='refresh' content='0;URL=admin.php?page=addons'>";
}
function virtualPages($id,$nome,$titolo,$content,$version,$updatefrom,$description,$keywords,$fullscreen,$rank,$enabled,$subop,$ok=false) {
global $dblink;
openTable();
echo "<div align='center' class='box'>";
echo "<a href='admin.php?page=addons&op=virtualPages' title='"._LIST_."'><img src='admin/icons/pages.png' border='0' title='"._LIST_."' align='top'> "._LIST_."</a>";
echo " - <a href='admin.php?page=addons&op=virtualPages&subop=addPage' title='"._CREATE_."'><img src='admin/icons/newpage.png' border='0' title='"._CREATE_."' align='top'> "._CREATE_."</a>";
echo " - <a href='admin.php?page=addons&op=virtualPages&subop=installFromFile' title='"._INSTALL_FROM_FILE_."'><img src='admin/icons/newpage.png' border='0' title='"._INSTALL_FROM_FILE_."' align='top'> "._INSTALL_FROM_FILE_."</a>";
echo " - <a href='admin.php?page=addons&op=virtualPages&subop=checkUpdates' title='"._CHECKUPDATES_."'><img src='admin/icons/update.png' border='0' title='"._CHECKUPDATES_."' align='top'> "._CHECKUPDATES_."</a>";
echo "</div>";
closeTable();
switch($subop) {
default:
$n = 0;
echo "<table width='100%' align='center' cellspacing='1' cellpadding='0' class='std_nicetable'>";
echo "<thead>\n";
echo "<tr><td>"._TITLE_."</td><td width='1%'> </td></tr>\n";
echo "</thead>\n";
echo "<tbody>\n";
if ($result = $dblink->get_list("SELECT * FROM memht_virtualpages ORDER BY title")) {
foreach ($result as $row) {
$id = intval($row['id']);
$name = outCode($row['name']);
$title = outCode($row['title']);
$fullscreen = intval($row['fullscreen']);
$rank = intval($row['rank']);
$enabled = intval($row['enabled']);
$rankimg = "";
switch ($rank) {
case 0: $rankimg = "guest"; $ranktitle = _LEVEL_.": "._GUEST_; break;
case 1: $rankimg = "user"; $ranktitle = _LEVEL_.": "._USER_; break;
case 2: $rankimg = "poweruser"; $ranktitle = _LEVEL_.": "._POWERUSER_; break;
case 3: $rankimg = "admin"; $ranktitle = _LEVEL_.": "._ADMIN_; break;
case 4: $rankimg = "superadmin"; $ranktitle = _LEVEL_.": "._SUPERADMIN_; break;
}
switch ($fullscreen) {
case 0: $preinfo = "<img src='images/stdscreen.gif' alt='"._STANDARD_."' title='"._STANDARD_."'>"; break;
case 1: $preinfo = "<img src='images/halfscreen.gif' alt='"._HALFSCREEN_."' title='"._HALFSCREEN_."'>"; break;
case 2: $preinfo = "<img src='images/fullscreen.gif' alt='"._FULLSCREEN_."' title='"._FULLSCREEN_."'>"; break;
}
$info = ($enabled!=1) ? " <img src='images/off.gif' alt='"._OFF_."' title='"._OFF_."'>" : " <img src='images/on.gif' alt='"._ON2_."' title='"._ON2_."'>" ;
$class = (($n++%2)!=0) ? "hlight" : "clean" ;
echo "<tr><td class='$class'><a href='index.php?page=$name' title='$title'><b>$title</b></a></td><td class='$class' align='right' nowrap><a href='admin.php?page=addons&op=virtualPages&subop=updateFromFile&id=$id' title='"._UPDATE_FROM_FILE_."'><img src='images/file.gif' alt='File' border='0'></a> <a href='admin.php?page=addons&op=virtualPages&subop=editPage&id=$id' title='"._MODIFY_."'><img src='images/edit.gif' alt='Edit' border='0'></a> <a href='admin.php?page=addons&op=virtualPages&subop=deletePage&id=$id' title='"._DELETE_."'><img src='images/delete.gif' alt='Delete' border='0'></a> - <img src='images/rank_$rankimg.gif' title='$ranktitle' border='0'> - $preinfo - <a href='admin.php?page=addons&op=virtualPages&subop=switch&id=$id' title='"._ON_OFF_."'><img src='images/on_off.gif' alt='On off' border='0'></a> $info</td></tr>\n";
}
} else {
echo "<tr><td colspan='2' id='errorText' align='center' class='clean'><b>"._EMPTY_."</b></td></tr>\n";
}
echo "</tbody>\n";
echo "</table>";
break;
case "addPage":
if (!$ok) {
echo "<table width='100%' align='center' cellspacing='0' cellpadding='1'>";
echo "<form name='form' method='post' action='admin.php?page=addons&op=virtualPages&subop=addPage&ok=true'>";
echo "<tr><td width='25%'><b>"._TITLE_."</b></td><td><input type='text' name='titolo' size='40' maxlength='255'></td></tr>\n";
echo "<tr><td><b>"._NAME_."</b> <img src='images/info.gif' alt='Info' title=\"header=["._INFORMATIONS_."] body=[<b>index.php?page=".strtoupper(_NAME_)."</b><br><font color='#990000'>"._WARNING_PAGE_CONFLICT_."</font>]\"></td><td><input type='text' name='nome' size='40' maxlength='255'></td></tr>\n";
echo "<tr valign='top'><td colspan='2'><b>"._CONTENT_."</b> <img src='images/info.gif' title=\"header=["._INFORMATIONS_."] body=["._CONTENT_INFO_."]\"><div align='right'>";
textarea("content","100%","600px",0,"");
echo "</div></td></tr>\n";
echo "<tr valign='top'><td><b>"._METATAGS_.":</b> "._DESCRIPTION_."</td><td><div align='right'>";
textarea("description","100%","70px",0,"");
echo "</div></td></tr>\n";
echo "<tr valign='top'><td><b>"._METATAGS_.":</b> "._KEYWORDS_."<div id='info'>("._SEPARATEDBYCOMMAS_.")</div></td><td><div align='right'>";
textarea("keywords","100%","70px",0,"");
echo "</div></td></tr>\n";
echo "<tr><td><b>"._VERSION_."</b> <img src='images/info.gif' title=\"header=["._INFORMATIONS_."] body=["._VERSION_INFO_."]\"></td><td><input type='text' name='version' size='20' maxlength='255'></td></tr>\n";
echo "<tr><td><b>"._UPDATEFROM_."</b> <img src='images/info.gif' alt='Info' title=\"header=["._INFORMATIONS_."] body=["._UPDATEFROM_INFO_."]\"></td><td><input type='text' name='updatefrom' size='40' maxlength='255'></td></tr>\n";
echo "<tr><td><b>"._SIZE_."</b></td><td>";
echo "<select name='fullscreen'>\n";
echo "<option value='0' selected>"._STANDARD_."</option>\n";
echo "<option value='1'>"._HALFSCREEN_."</option>\n";
echo "<option value='2'>"._FULLSCREEN_."</option>\n";
echo "</select></td></tr>\n";
echo "<tr><td><b>"._REQUIREDRANK_."</b></td><td>";
echo "<select name='rank'>\n";
echo "<option value='0' selected>"._GUEST_."</option>\n";
echo "<option value='1'>"._USER_."</option>\n";
echo "<option value='2'>"._POWERUSER_."</option>\n";
echo "<option value='3'>"._ADMIN_."</option>\n";
echo "<option value='4'>"._SUPERADMIN_."</option>\n";
echo "</select></td></tr>\n";
echo "<tr><td><b>"._ENABLED_."</b></td><td>";
echo "<select name='enabled'>\n";
echo "<option value='1' selected>"._YES_."</option>\n";
echo "<option value='0'>"._NO_."</option>\n";
echo "</select></td></tr>\n";
echo "<tr><td colspan='2'><input type='submit' name='Submit' value='"._CREATE_."'>\n";
echo "</form>\n";
echo "</table>\n";
} else {
$save = true;
if ($nome=="") { $save = false; $msg = _FILE_." ".strtolower(_FIELD_)." ".strtolower(_REQUIRED_); }
if ($titolo=="") { $save = false; $msg = _TITLE_." ".strtolower(_FIELD_)." ".strtolower(_REQUIRED_); }
if ($content=="") { $save = false; $msg = _CONTENT_." ".strtolower(_FIELD_)." ".strtolower(_REQUIRED_); }
if ($version=="") { $version = 0; }
if ($save) {
$dblink->query("INSERT INTO memht_virtualpages (id,name,title,content,description,keywords,version,updatefrom,fullscreen,rank,enabled)
VALUES (null,'$nome','$titolo','$content','$description','$keywords','$version','$updatefrom','$fullscreen','$rank','$enabled')");
echo "<meta http-equiv='refresh' content='0;URL=admin.php?page=addons&op=virtualPages'>";
} else {
echo "<div align='center' id='errorText'><b>$msg</b></div>";
}
}
break;
case "editPage":
if (!$ok) {
$row = $dblink->get_row("SELECT * FROM memht_virtualpages WHERE id=$id");
$name = outCode($row['name']);
$title = outCode($row['title']);
$content = stripslashes($row['content']);
$description = outCode($row['description']);
$keywords = outCode($row['keywords']);
$version = intval($row['version']);
$updatefrom = outCode($row['updatefrom']);
$fullscreen = intval($row['fullscreen']);
$rank = intval($row['rank']);
$enabled = intval($row['enabled']);
echo "<table width='100%' align='center' cellspacing='0' cellpadding='1'>";
echo "<form name='form' method='post' action='admin.php?page=addons&op=virtualPages&subop=editPage&id=$id&ok=true'>";
echo "<tr><td width='25%'><b>"._TITLE_."</b></td><td><input type='text' name='titolo' value=\"$title\" size='40' maxlength='255'></td></tr>\n";
echo "<tr><td><b>"._NAME_."</b> <img src='images/info.gif' title=\"header=["._INFORMATIONS_."] body=[<b>index.php?page=".strtoupper(_NAME_)."</b><br><font color='#990000'>"._WARNING_PAGE_CONFLICT_."</font>]\"></td><td><input type='text' name='nome' value=\"$name\" size='40' maxlength='255'></td></tr>\n";
echo "<tr valign='top'><td colspan='2'><b>"._CONTENT_."</b> <img src='images/info.gif' title=\"header=["._INFORMATIONS_."] body=["._CONTENT_INFO_."]\"><div align='right'>";
textarea("content","100%","600px",0,"",$content);
echo "</div></td></tr>\n";
echo "<tr valign='top'><td><b>"._METATAGS_.":</b> "._DESCRIPTION_."</td><td><div align='right'>";
textarea("description","100%","70px",0,"",$description);
echo "</div></td></tr>\n";
echo "<tr valign='top'><td><b>"._METATAGS_.":</b> "._KEYWORDS_."<div id='info'>("._SEPARATEDBYCOMMAS_.")</div></td><td><div align='right'>";
textarea("keywords","100%","70px",0,"",$keywords);
echo "</div></td></tr>\n";
echo "<tr><td><b>"._VERSION_."</b> <img src='images/info.gif' title=\"header=["._INFORMATIONS_."] body=["._VERSION_INFO_."]\"></td><td><input type='text' name='version' value=\"$version\" size='20' maxlength='255'></td></tr>\n";
echo "<tr><td><b>"._UPDATEFROM_."</b> <img src='images/info.gif' alt='Info' title=\"header=["._INFORMATIONS_."] body=["._UPDATEFROM_INFO_."]\"></td><td><input type='text' name='updatefrom' value=\"$updatefrom\" size='40' maxlength='255'></td></tr>\n";
echo "<tr><td><b>"._SIZE_."</b></td><td>";
echo "<select name='fullscreen'>\n";
switch ($fullscreen) {
case 0:
echo "<option value='0' selected>"._STANDARD_."</option>\n";
echo "<option value='1'>"._HALFSCREEN_."</option>\n";
echo "<option value='2'>"._FULLSCREEN_."</option>\n";
break;
case 1:
echo "<option value='0'>"._STANDARD_."</option>\n";
echo "<option value='1' selected>"._HALFSCREEN_."</option>\n";
echo "<option value='2'>"._FULLSCREEN_."</option>\n";
break;
case 2:
echo "<option value='0'>"._STANDARD_."</option>\n";
echo "<option value='1'>"._HALFSCREEN_."</option>\n";
echo "<option value='2' selected>"._FULLSCREEN_."</option>\n";
break;
}
echo "</select></td></tr>\n";
echo "<tr><td><b>"._REQUIREDRANK_."</b></td><td>";
echo "<select name='rank'>\n";
$selected = ($rank==0) ? " selected" : "" ;
echo "<option value='0'{$selected}>"._GUEST_."</option>\n";
$selected = ($rank==1) ? " selected" : "" ;
echo "<option value='1'{$selected}>"._USER_."</option>\n";
$selected = ($rank==2) ? " selected" : "" ;
echo "<option value='2'{$selected}>"._POWERUSER_."</option>\n";
$selected = ($rank==3) ? " selected" : "" ;
echo "<option value='3'{$selected}>"._ADMIN_."</option>\n";
$selected = ($rank==4) ? " selected" : "" ;
echo "<option value='4'{$selected}>"._SUPERADMIN_."</option>\n";
echo "</select></td></tr>\n";
echo "<tr><td><b>"._ENABLED_."</b></td><td>";
echo "<select name='enabled'>\n";
if ($enabled==1) {
echo "<option value='1' selected>"._YES_."</option>\n";
echo "<option value='0'>"._NO_."</option>\n";
} else {
echo "<option value='1'>"._YES_."</option>\n";
echo "<option value='0' selected>"._NO_."</option>\n";
}
echo "</select></td></tr>\n";
echo "<tr><td colspan='2'><input type='submit' name='Submit' value='"._MODIFY_."'>\n";
echo "</form>\n";
echo "</table>\n";
} else {
$save = true;
if ($nome=="") { $save = false; $msg = _FILE_." ".strtolower(_FIELD_)." ".strtolower(_REQUIRED_); }
if ($titolo=="") { $save = false; $msg = _TITLE_." ".strtolower(_FIELD_)." ".strtolower(_REQUIRED_); }
if ($content=="") { $save = false; $msg = _CONTENT_." ".strtolower(_FIELD_)." ".strtolower(_REQUIRED_); }
if ($version=="") { $version = 0; }
if ($save) {
$dblink->query("UPDATE memht_virtualpages SET name='$nome',title='$titolo',content='$content',description='$description',keywords='$keywords',version='$version',updatefrom='$updatefrom',fullscreen='$fullscreen',rank='$rank',enabled='$enabled' WHERE id=$id");
echo "<meta http-equiv='refresh' content='0;URL=admin.php?page=addons&op=virtualPages'>";
} else {
echo "<div align='center' id='errorText'><b>$msg</b></div>";
}
}
break;
case "deletePage":
if ($ok) {
$dblink->query("DELETE FROM memht_virtualpages WHERE id=$id");
echo "<meta http-equiv='refresh' content='0;URL=admin.php?page=addons&op=virtualPages'>";
} else {
echo "<div align='center'><b>"._SUREDELETEPAGE_."</b><br><a href='admin.php?page=addons&op=virtualPages&subop=deletePage&id=$id&ok=true' title='"._YES_."'>"._YES_."</a> - <a href='admin.php?page=addons&op=virtualPages' title='"._NO_."'>"._NO_."</a></div>";
}
break;
case "switch":
$row_stat = $dblink->get_row("SELECT enabled FROM memht_virtualpages WHERE id=$id");
$enabled = intval($row_stat['enabled']);
$newStatus = ($enabled==1) ? 0 : 1 ;
$dblink->query("UPDATE memht_virtualpages SET enabled='$newStatus' WHERE id=$id");
echo "<meta http-equiv='refresh' content='0;URL=admin.php?page=addons&op=virtualPages'>";
break;
case "installFromFile":
if (!$ok) {
echo "<table width='100%' align='center' cellspacing='0' cellpadding='1'>";
echo "<form name='form' method='post' action='admin.php?page=addons&op=virtualPages&subop=installFromFile&ok=true' enctype='multipart/form-data'>";
echo "<tr><td><b>"._SOURCEFILE_."</b></td><td><input type='file' name='filepath' size='25'></td></tr>\n";
echo "<tr valign='top'><td><b>"._METATAGS_.":</b> "._DESCRIPTION_."</td><td><div align='right'>";
textarea("description","100%","70px",0,"");
echo "</div></td></tr>\n";
echo "<tr valign='top'><td><b>"._METATAGS_.":</b> "._KEYWORDS_."<div id='info'>("._SEPARATEDBYCOMMAS_.")</div></td><td><div align='right'>";
textarea("keywords","100%","70px",0,"");
echo "</div></td></tr>\n";
echo "<tr><td><b>"._SIZE_."</b></td><td>";
echo "<select name='fullscreen'>\n";
echo "<option value='0' selected>"._STANDARD_."</option>\n";
echo "<option value='1'>"._HALFSCREEN_."</option>\n";
echo "<option value='2'>"._FULLSCREEN_."</option>\n";
echo "</select></td></tr>\n";
echo "<tr><td><b>"._REQUIREDRANK_."</b></td><td>";
echo "<select name='rank'>\n";
echo "<option value='0' selected>"._GUEST_."</option>\n";
echo "<option value='1'>"._USER_."</option>\n";
echo "<option value='2'>"._POWERUSER_."</option>\n";
echo "<option value='3'>"._ADMIN_."</option>\n";
echo "<option value='4'>"._SUPERADMIN_."</option>\n";
echo "</select></td></tr>\n";
echo "<tr><td><b>"._ENABLED_."</b></td><td>";
echo "<select name='enabled'>\n";
echo "<option value='1' selected>"._YES_."</option>\n";
echo "<option value='0'>"._NO_."</option>\n";
echo "</select></td></tr>\n";
echo "<tr><td colspan='2'><input type='submit' name='Submit' value='"._INSTALL_."'>\n";
echo "</form>\n";
echo "</table>\n";
} else {
$save = true;
require_once("inc/class/uploadFile.class.php");
$upload = new uploadFile();
$upload->show_errors = false;
$upload->mime = array('text/xml');
$upload->path = "inc/installed/addons/";
$upload->field = "filepath";
$upload->overwrite = true;
if (!$xmlfile = $upload->upload()) { $save = false; $msg = $upload->error; }
$xmlfullpath = "inc/installed/addons/$xmlfile";
if ($save) {
if ($xmlc = get_xml_file_content($xmlfullpath)) {
if (isset($xmlc['instructions']['install'])) {
//Show
echo "<div class='box' style='background-color: #C8E8CA;'>";
echo inCode($xmlc['instructions']['install']);
echo "</div>";
echo "<table width='100%' align='center' cellspacing='0' cellpadding='1'>";
echo "<form name='form' method='post' action='admin.php?page=addons&op=virtualPages&subop=installFromFileC'>";
echo "<tr><td><input type='submit' name='Submit' value='"._INSTALL_."'>\n";
echo "<input type='hidden' name='description' value='$description'>\n";
echo "<input type='hidden' name='keywords' value='$keywords'>\n";
echo "<input type='hidden' name='fullscreen' value='$fullscreen'>\n";
echo "<input type='hidden' name='rank' value='$rank'>\n";
echo "<input type='hidden' name='enabled' value='$enabled'>\n";
echo "<input type='hidden' name='xmlfullpath' value='$xmlfullpath'>\n";
echo "</form>\n";
echo "</table>\n";
} else {
//Install immediately
$nome = inCode(@$xmlc['component']['name']);
$titolo = inCode(@$xmlc['component']['title']);
$content = inCode(@$xmlc['code']['content']);
$version = intval(@$xmlc['component']['version']);
$updatefrom = inCode(@$xmlc['component']['updatefrom']);
$dblink->query("INSERT INTO memht_virtualpages (id,name,title,content,description,keywords,version,updatefrom,xmlfile,fullscreen,rank,enabled)
VALUES (null,'$nome','$titolo','$content','$description','$keywords','$version','$updatefrom','$xmlfullpath','$fullscreen','$rank','$enabled')");
if ($installop = inCode(@$xmlc['code']['install'])) {
@eval($installop);
}
echo "<div align='center' class='box' style='background-color: #C8E8CA;'><b>"._INSTALLEDSUCCESSFULLY_."</b></div>";
echo "<meta http-equiv='refresh' content='3;URL=admin.php?page=addons&op=virtualPages'>";
}
} else {
echo "<div align='center' id='errorText'><b>"._FILECANNOTPARSED_."</b></div>";
}
} else {
echo "<div align='center' id='errorText'>$msg</div>";
}
}
break;
case "installFromFileC":
if (isset($_POST['xmlfullpath'])) {
if ($xmlc = get_xml_file_content(inCode($_POST['xmlfullpath']))) {
$nome = inCode(@$xmlc['component']['name']);
$titolo = inCode(@$xmlc['component']['title']);
$content = inCode(@$xmlc['code']['content']);
$version = intval(@$xmlc['component']['version']);
$updatefrom = inCode(@$xmlc['component']['updatefrom']);
$dblink->query("INSERT INTO memht_virtualpages (id,name,title,content,description,keywords,version,updatefrom,xmlfile,fullscreen,rank,enabled)
VALUES (null,'$nome','$titolo','$content','$description','$keywords','$version','$updatefrom','".inCode($_POST['xmlfullpath'])."','$fullscreen','$rank','$enabled')");
if ($installop = @$xmlc['code']['install']) {
@eval($installop);
}
echo "<div align='center' class='box' style='background-color: #C8E8CA;'><b>"._INSTALLEDSUCCESSFULLY_."</b></div>";
echo "<meta http-equiv='refresh' content='3;URL=admin.php?page=addons&op=virtualPages'>";
} else {
echo "<div align='center' id='errorText'><b>"._FILECANNOTPARSED_."</b></div>";
}
} else {
echo "<div align='center' id='errorText'><b>"._ERROR_NOFILESELECTED_."</b></div>";
}
break;
case "checkUpdates":
$n = 0;
echo "<table width='100%' align='center' cellspacing='1' cellpadding='0' class='std_nicetable'>";
echo "<thead>\n";
echo "<tr><td width='20%'>"._TITLE_."</td><td width='1%'>"._VERSION_."</td><td width='70%'>"._UPDATEFROM_."</td><td width='10%' nowrap>"._REMOTEVERSION_."</td><td width='1%'> </td></tr>\n";
echo "</thead>\n";
echo "<tbody>\n";
if ($result = $dblink->get_list("SELECT * FROM memht_virtualpages ORDER BY title")) {
foreach ($result as $row) {
$id = intval($row['id']);
$name = outCode($row['name']);
$title = outCode($row['title']);
$version = intval($row['version']);
$updatefrom = outCode($row['updatefrom']);
if ($version=="") { $version = "-"; }
if ($updatefrom=="") { $updatefrom = "-"; }
$info = "";
$check = true;
if (!validate($updatefrom,"url")) { $check = false; $info = "?"; }
if ($check) {
if ($xmlc = get_xml_file_content($updatefrom)) {
$remoteversion = intval(@$xmlc['component']['version']);
if ($remoteversion>$version) {
$text = explode("<br>",_UPDATEREQUIRED_);
$text = $text[0];
$info = "<a href='admin.php?page=addons&op=virtualPages&subop=update&id=$id' title='$text'><img src='images/check-green.gif' alt='"._YES_."' border='0'></a>";
} else {
$info = "<img src='images/delete.gif' alt='"._NO_."' border='0' title='"._NOUPDATEREQUIRED_."'>";
}
} else {
$info = "?";
$remoteversion = "?";
}
} else {
$remoteversion = "?";
}
$class = (($n++%2)!=0) ? "hlight" : "clean" ;
echo "<tr><td class='$class' nowrap><a href='index.php?page=$name' title='$title'><b>$title</b></a></td><td class='$class' align='center'>$version</td><td class='$class'><a href='$updatefrom' target='_blank'>$updatefrom</a></td><td class='$class' align='center'>$remoteversion</td><td class='$class' align='center' nowrap>$info</td></tr>\n";
}
} else {
echo "<tr><td colspan='2' id='errorText' align='center' class='clean'><b>"._EMPTY_."</b></td></tr>\n";
}
echo "</tbody>\n";
echo "</table>";
break;
case "update":
if ($row = $dblink->get_row("SELECT * FROM memht_virtualpages WHERE id=$id")) {
$id = intval($row['id']);
$name = outCode($row['name']);
$title = outCode($row['title']);
$version = intval($row['version']);
$updatefrom = outCode($row['updatefrom']);
if ($xmlc = get_xml_file_content($updatefrom)) {
$remoteversion = intval(@$xmlc['component']['version']);
if ($remoteversion>$version) {
if (isset($xmlc['instructions']['update'])) {
//Show
echo "<div class='box' style='background-color: #C8E8CA;'>";
echo inCode($xmlc['instructions']['update']);
echo "</div>";
echo "<table width='100%' align='center' cellspacing='0' cellpadding='1'>";
echo "<form name='form' method='post' action='admin.php?page=addons&op=virtualPages&subop=updateC&id=$id'>";
echo "<tr><td><input type='submit' name='Submit' value='"._UPDATE_."'>\n";
echo "<input type='hidden' name='updatefrom' value='$updatefrom'>\n";
echo "</form>\n";
echo "</table>\n";
} else {
//Update immediately
$remotecontent = inCode(@$xmlc['code']['content']);
$dblink->query("UPDATE memht_virtualpages SET version='$remoteversion',content='$remotecontent',updatefrom='$updatefrom' WHERE id=$id");
if ($updateop = @$xmlc['code']['update']) {
@eval($updateop);
}
echo "<div align='center' class='box' style='background-color: #C8E8CA;'><b>"._PAGE_UPDATED_SUCCESS_."</b></div>";
echo "<meta http-equiv='refresh' content='3;URL=admin.php?page=addons&op=virtualPages'>";
}
} else {
echo "<div id='errorText' align='center' class='box' style='background-color: #EAC6C6;'><b>"._NOUPDATEREQUIRED_."</b></div>";
}
} else {
echo "<div id='errorText' align='center' class='box' style='background-color: #EAC6C6;'><b>"._CONNECTION_FAILED_."</b><br>$versioninfo</div>";
}
} else {
echo "<meta http-equiv='refresh' content='0;URL=admin.php?page=addons&op=virtualPages'>";
}
break;
case "updateC":
if (isset($_POST['updatefrom'])) {
if ($xmlc = get_xml_file_content(inCode($_POST['updatefrom']))) {
$content = inCode(@$xmlc['code']['content']);
$version = intval(@$xmlc['component']['version']);
$updatefrom = inCode(@$xmlc['component']['updatefrom']);
//
$dblink->query("UPDATE memht_virtualpages SET version='$version',content='$content',updatefrom='$updatefrom' WHERE id=$id");
if ($updateop = @$xmlc['code']['update']) {
@eval($updateop);
}
echo "<div align='center' class='box' style='background-color: #C8E8CA;'><b>"._PAGE_UPDATED_SUCCESS_."</b></div>";
echo "<meta http-equiv='refresh' content='3;URL=admin.php?page=addons&op=virtualPages'>";
} else {
echo "<div align='center' id='errorText'><b>"._FILECANNOTPARSED_."</b></div>";
}
} else {
echo "<div align='center' id='errorText'><b>"._ERROR_NOFILESELECTED_."</b></div>";
}
break;
case "updateFromFile":
if (!$ok) {
echo "<table width='100%' align='center' cellspacing='0' cellpadding='1'>";
echo "<form name='form' method='post' action='admin.php?page=addons&op=virtualPages&subop=updateFromFile&id=$id&ok=true' enctype='multipart/form-data'>";
echo "<tr><td><b>"._SOURCEFILE_."</b></td><td><input type='file' name='filepath' size='25'></td></tr>\n";
echo "<tr><td colspan='2'><input type='submit' name='Submit' value='"._UPDATE_."'>\n";
echo "</form>\n";
echo "</table>\n";
} else {
if ($row = $dblink->get_row("SELECT * FROM memht_virtualpages WHERE id=$id")) {
$version = intval($row['version']);
$save = true;
require_once("inc/class/uploadFile.class.php");
$upload = new uploadFile();
$upload->show_errors = true;
$upload->mime = array('text/xml');
$upload->path = "inc/installed/addons/";
$upload->field = "filepath";
$upload->overwrite = true;
if (!$xmlfile = $upload->upload()) { $save = false; $msg = $upload->error; }
$xmlfullpath = "inc/installed/addons/$xmlfile";
if ($save) {
if ($xmlc = get_xml_file_content($xmlfullpath)) {
$remoteversion = intval(@$xmlc['component']['version']);
if ($remoteversion>$version) {
if (isset($xmlc['instructions']['update'])) {
//Show
echo "<div class='box' style='background-color: #C8E8CA;'>";
echo inCode($xmlc['instructions']['update']);
echo "</div>";
echo "<table width='100%' align='center' cellspacing='0' cellpadding='1'>";
echo "<form name='form' method='post' action='admin.php?page=addons&op=virtualPages&subop=updateFromFileC&id=$id'>";
echo "<tr><td><input type='submit' name='Submit' value='"._UPDATE_."'>\n";
echo "<input type='hidden' name='xmlfullpath' value='$xmlfullpath'>\n";
echo "</form>\n";
echo "</table>\n";
} else {
//Update immediately
$content = inCode(@$xmlc['code']['content']);
$version = intval(@$xmlc['component']['version']);
$updatefrom = inCode(@$xmlc['component']['updatefrom']);
//
$dblink->query("UPDATE memht_virtualpages SET version='$version',content='$content',updatefrom='$updatefrom' WHERE id=$id");
if ($updateop = @$xmlc['code']['update']) {
@eval($updateop);
}
echo "<div align='center' class='box' style='background-color: #C8E8CA;'><b>"._PAGE_UPDATED_SUCCESS_."</b></div>";
echo "<meta http-equiv='refresh' content='3;URL=admin.php?page=addons&op=virtualPages'>";
//
}
} else {
echo "<div id='errorText' align='center' class='box' style='background-color: #EAC6C6;'><b>"._NOUPDATEREQUIRED_."</b></div>";
}
} else {
echo "<div align='center' id='errorText'><b>"._FILECANNOTPARSED_."</b></div>";
}
} else {
echo "<div align='center' id='errorText'>$msg</div>";
}
} else {
echo "<meta http-equiv='refresh' content='0;URL=admin.php?page=addons&op=virtualPages'>";
}
}
break;
case "updateFromFileC":
if (isset($_POST['xmlfullpath'])) {
if ($xmlc = get_xml_file_content(inCode($_POST['xmlfullpath']))) {
$content = inCode(@$xmlc['code']['content']);
$version = intval(@$xmlc['component']['version']);
$updatefrom = inCode(@$xmlc['component']['updatefrom']);
//
$dblink->query("UPDATE memht_virtualpages SET version='$version',content='$content',updatefrom='$updatefrom' WHERE id=$id");
if ($updateop = @$xmlc['code']['update']) {
@eval($updateop);
}
echo "<div align='center' class='box' style='background-color: #C8E8CA;'><b>"._PAGE_UPDATED_SUCCESS_."</b></div>";
echo "<meta http-equiv='refresh' content='3;URL=admin.php?page=addons&op=virtualPages'>";
} else {
echo "<div align='center' id='errorText'><b>"._FILECANNOTPARSED_."</b></div>";
}
} else {
echo "<div align='center' id='errorText'><b>"._ERROR_NOFILESELECTED_."</b></div>";
}
break;
}
}
require_once("admin/inc/inc_header.php");
admin_page_title($page);
openTable();
echo "<div align='center' class='box'>";
echo "<a href='admin.php?page=addons' title='"._LIST_."'><img src='admin/icons/pages.png' border='0' title='"._LIST_."' align='top'> "._LIST_."</a>";
echo " - <a href='admin.php?page=addons&op=addPage' title='"._INSTALL_ADDON_."'><img src='admin/icons/newpage.png' border='0' title='"._INSTALL_ADDON_."' align='top'> "._INSTALL_ADDON_."</a>";
echo " - <a href='admin.php?page=addons&op=virtualPages' title='"._VIRTUAL_PAGES_."'><img src='admin/icons/pages.png' border='0' title='"._VIRTUAL_PAGES_."' align='top'> "._VIRTUAL_PAGES_."</a>";
echo "</div>";
closeTable();
openTable();
switch($op) {
case "addPage":
add($nome,$titolo,$description,$keywords,$fullscreen,$rank,$enabled,$ok);
break;
case "deletePage":
delete($id,$ok);
break;
case "editPage":
edit($id,$nome,$titolo,$description,$keywords,$fullscreen,$rank,$enabled,$ok);
break;
case "switch":
changeStatus($id);
break;
case "virtualPages":
virtualPages($id,$nome,$titolo,$content,$version,$updatefrom,$description,$keywords,$fullscreen,$rank,$enabled,$subop,$ok);
break;
default:
pageList();
break;
}
closeTable();
require_once("admin/inc/inc_footer.php");
?>
|