$iNameIndex,
'css_name' => array('forms_adv.css'),
'js_name' => array(),
'header' => _t('_dbcsDeanosToolsHeader'),
'header_text' => _t('_dbcsDeanosToolsHeaderText')
);
$_page_cont[$iNameIndex]['page_main_code'].=$this->DeanoMainCode();
PageCodeAdmin();
}
function DeanoMainCode()
{
global $site;
$settingsv = ' collapsed';
$settingss = ' style="display: none;"';
$saCv = ' collapsed';
$saCs = ' style="display: none;"';
$scCv = ' collapsed';
$scCs = ' style="display: none;"';
$smCv = ' collapsed';
$smCs = ' style="display: none;"';
$stCv = ' collapsed';
$stCs = ' style="display: none;"';
$sqCv = ' collapsed';
$sqCs = ' style="display: none;"';
$pmCv = ' collapsed';
$pmCs = ' style="display: none;"';
$pwCv = ' collapsed';
$pwCs = ' style="display: none;"';
$pbCv = ' collapsed';
$pbCs = ' style="display: none;"';
$peCv = ' collapsed';
$peCs = ' style="display: none;"';
//$otCv = ' collapsed';
//$otCs = ' style="display: none;"';
$cacheC = ' collapsed';
$cacheS = ' style="display: none;"';
$ipC = ' collapsed';
$ipS = ' style="display: none;"';
$sExistedC = _t('_dbcsDeanosToolsBoxHeader', $this->_oDb->getModuleVersion());
$sCss = $this->_oTemplate->addCss('unit.css', true);
$sJs = $this->_oTemplate->addJs('deanostools.js', true);
$sAction = BX_DOL_URL_ROOT . 'modules/?r=deanos_tools/administration/';
$GetLangID = $_GET['LangID'];
if ($GetLangID == '') $GetLangID = 1;
$dbAction = $_REQUEST['saction'];
$section = $_REQUEST['se'];
if(isset($_POST['save']) && isset($_POST['cat'])) {
$section = 'settings';
$this->dbcsClearCache('sys_options');
}
$sCode = '';
switch ($section) {
case "settings":
$settingsv = '';
$settingss = '';
break;
case "sa":
$saCv = '';
$saCs = '';
break;
case "sc":
$scCv = '';
$scCs = '';
break;
case "sm":
$smCv = '';
$smCs = '';
break;
case "st":
$stCv = '';
$stCs = '';
break;
case "sq":
$sqCv = '';
$sqCs = '';
break;
case "pm":
$pmCv = '';
$pmCs = '';
break;
case "pw":
$pwCv = '';
$pwCs = '';
break;
case "pb":
$pbCv = '';
$pbCs = '';
break;
case "pe":
$peCv = '';
$peCs = '';
break;
case "ot":
$otCv = '';
$otCs = '';
break;
case "dc":
$cacheC = '';
$cacheS = '';
break;
case "ip":
$ipC = '';
$ipS = '';
break;
}
switch ($dbAction) {
case "sm":
// set role to member
$dbID = $_POST['id'];
if($dbID > 0) {
$this->_oDb->setMember($dbID);
$sCode .= '
' . MsgBox(_t('_dbcs_DT_Member') . ' ' . $this->_oDb->getNickName($dbID) . ' ' . _t('_dbcs_DT_Member Role'),4) . '
';
$sCode .= ' ';
$this->dbcsClearCache('users');
}
break;
case "sa":
// set role to admin
$dbID = $_POST['id'];
if($dbID > 0) {
$this->_oDb->setAdmin($dbID);
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_Member') . ' ' . $this->_oDb->getNickName($dbID) . ' ' . _t('_dbcs_DT_Admin Role'),4) . '
';
$sCode .= ' ';
$this->dbcsClearCache('users');
}
break;
case "sc":
// save copyright.
$dbID = $this->_oDb->getCopyrightID();
$dbLang=$_GET['LangID'];
$dbText=$_POST['copyright'];
$this->_oDb->saveCopyrightText($dbID,$dbLang,$dbText);
compileLanguage($dblang);
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_Copyright Text Saved'),4) . '
';
$sCode .= ' ';
break;
case "ds":
// delete shoutbox messages.
$dbcnt=0;
foreach($_POST as $name => $value) {
$r=strstr($name, "C_");
if($r) {
$s=explode("_",$r);
$n=$s[1];
$this->_oDb->deleteShoutboxMessage($n);
$dbcnt++;
}
}
if ($dbcnt > 1) {
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_Deleted') . $dbcnt . _t('_dbcs_DT_ShoutboxM1'),4) . '
';
$sCode .= ' ';
}
if ($dbcnt == 1) {
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_Deleted') . $dbcnt . _t('_dbcs_DT_ShoutboxM2'),4) . '
';
$sCode .= ' ';
}
if ($dbcnt == 0) {
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_ShoutboxM3'),4) . '
';
$sCode .= ' ';
}
break;
case "dt":
// delete site tags.
$dbcnt=0;
foreach($_POST as $name => $value) {
$r=strstr($name, "C_");
if($r) {
$s=explode("_",$r);
$n=$s[1];
$b=explode(",",$n);
$a1=base64_decode($b[0]);
$a2=base64_decode($b[1]);
$this->_oDb->deleteTag($a1,$a2);
$dbcnt++;
}
}
if ($dbcnt > 1) {
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_Deleted') . $dbcnt . _t('_dbcs_DT_SiteTagM1'),4) . '
';
$sCode .= ' ';
}
if ($dbcnt == 1) {
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_Deleted') . $dbcnt . _t('_dbcs_DT_SiteTagM2'),4) . '
';
$sCode .= ' ';
}
if ($dbcnt == 0) {
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_SiteTagM3'),4) . '
';
$sCode .= ' ';
}
break;
case "sq":
// sql query.
$dbQuery = $_POST['dbcsDTsqlquery'];
if (get_magic_quotes_gpc()) {
$dbQuery = stripslashes($dbQuery);
}
file_put_contents(BX_DIRECTORY_PATH_ROOT . "tmp/dbsql.sql",$dbQuery);
execSqlFile(BX_DIRECTORY_PATH_ROOT . "tmp/dbsql.sql");
unlink(BX_DIRECTORY_PATH_ROOT . "tmp/dbsql.sql");
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_MySql Query Executed'),4) . '
';
$sCode .= ' ';
break;
case "uf":
$target_path = BX_DIRECTORY_PATH_ROOT . "tmp/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
execSqlFile($target_path);
unlink($target_path);
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_MySql File Uploaded and Executed'),4) . '
';
$sCode .= ' ';
} else{
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_Error_Uploading_File'),4) . '
';
$sCode .= ' ';
}
break;
case "dm":
// delete messages.
$senderID=$_POST['senderid'];
$this->_oDb->deleteMessages($senderID);
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_DeleteM1') . $senderID . _t('_dbcs_DT_DeleteM2'),4) . '
';
$sCode .= ' ';
break;
case "sw":
// Set Page Width.
$iPageWidth=$_POST['pagewidth'];
$this->_oDb->setPageWidth($iPageWidth);
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_PageWidthSet'),4) . '
';
$sCode .= ' ';
$this->dbcsClearCache('sys_page_compose');
$this->dbcsClearCache('sys_options');
break;
case "pb":
// Insert PHP Block.
$s1 = $_POST['phppage'];
$s2 = $_POST['phplkey'];
$s3 = $_POST['phpltext'];
$s4 = process_db_input($_POST['dbcsDTphpcode']);
if (!$this->_oDb->keyExists($s2)) {
// key does not exist. Add it to all installed languages under my catagory.
addStringToLanguage($s2, $s3, -1, $this->_oDb->getLangCat());
}
// now insert the php block on specified page.
$this->_oDb->insertPHPBlock($s1,$s2,$s3,$s4);
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_PHPBlockSaved'),4) . '
';
$sCode .= ' ';
$this->dbcsClearCache('sys_page_compose');
$this->dbcsClearCache('sys_options');
break;
case "pe":
// Edit/Delete PHP Block.
$PHPid = intval($_GET['phpbid']);
if (isset($_POST['B1']) && $PHPid > 0) {
// save button clicked.
$sLkey = $_POST['phplkey'];
$sPHPCode = process_db_input($_POST['dbcsDTphpcode']);
$this->_oDb->updatePHPBlock($PHPid,$sLkey,$sPHPCode);
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_PHPBlockSavedE'),4) . '
';
$sCode .= ' ';
}
if (isset($_POST['B2']) && $PHPid > 0) {
// delete button clicked.
$this->_oDb->deletePHPBlock($PHPid);
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_PHPBlockDeletedE'),4) . '
';
$sCode .= ' ';
}
$this->dbcsClearCache('sys_page_compose');
$this->dbcsClearCache('sys_options');
$_GET['phpbid'] = 0;
break;
case "dc":
// process cache file deletion.
$bSelected = false;
if (isset($_POST['B1'])) {
$sPath = BX_DIRECTORY_PATH_DBCACHE;
$s = $_POST['CacheS'];
if ($s){
$bSelected = true;
foreach ($s as $t){
if (is_file($sPath . $t)) {
unlink($sPath . $t);
}
if (is_dir($sPath . $t)) {
$this->delete_directory($sPath . $t);
}
//$sCode .= $t . '
';
}
}
if ($bSelected) {
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_SelectedCacheDeleted'),4) . '
';
$sCode .= ' ';
} else {
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_NoCacheSelected'),4) . '
';
$sCode .= ' ';
}
}
if (isset($_POST['B2'])) {
$sPath = BX_DIRECTORY_PATH_CACHE_PUBLIC;
$s = $_POST['CachePublicS'];
if ($s){
$bSelected = true;
foreach ($s as $t){
if (is_file($sPath . $t)) {
unlink($sPath . $t);
}
if (is_dir($sPath . $t)) {
$this->delete_directory($sPath . $t);
}
//$sCode .= $t . '
';
}
}
if ($bSelected) {
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_SelectedCachePublicDeleted'),4) . '
';
$sCode .= ' ';
} else {
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_NoCachePublicSelected'),4) . '
';
$sCode .= ' ';
}
}
if (isset($_POST['B3'])) {
$sPath = BX_DIRECTORY_PATH_ROOT . 'tmp/';
$s = $_POST['TmpS'];
if ($s){
$bSelected = true;
foreach ($s as $t){
if (is_file($sPath . $t)) {
unlink($sPath . $t);
}
if (is_dir($sPath . $t)) {
$this->delete_directory($sPath . $t);
}
//$sCode .= $t . '
';
}
}
if ($bSelected) {
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_SelectedTmpDeleted'),4) . '
';
$sCode .= ' ';
} else {
$sCode .= ' ' . MsgBox(_t('_dbcs_DT_NoTmpSelected'),4) . '
';
$sCode .= ' ';
}
}
break;
case "ip":
// IP Addresses.
break;
}
$sCode .= '
';
bx_import('BxDolPageView');
$sActions = BxDolPageView::getBlockCaptionMenu(mktime(), array(
'add_unit' => array('href' => $sAction, 'title' => _t('_dbcs_DT_Refresh Page'), 'onclick' => '', 'active' => 0),
));
return DesignBoxContent($sExistedC, $sCss . $sJs . '' . $sCode . '
', 1, $sActions);
}
function delete_directory($dirname) {
if (is_dir($dirname))
$dir_handle = opendir($dirname);
if (!$dir_handle)
return false;
while($file = readdir($dir_handle)) {
if ($file != "." && $file != "..") {
if (!is_dir($dirname."/".$file))
unlink($dirname."/".$file);
else
$this->delete_directory($dirname.'/'.$file);
}
}
closedir($dir_handle);
rmdir($dirname);
return true;
}
function dbcsClearCache($sSection) {
switch($sSection) {
case 'sys_options':
// Clear for dolphin 7.0.3
$files = glob(BX_DIRECTORY_PATH_CACHE . 'sys_options_*.php');
array_map('unlink', $files);
// Clear for dolphin versions below 7.0.3
$sFileName = BX_DIRECTORY_PATH_CACHE . 'sys_options.php';
if (file_exists($sFileName)) unlink($sFileName);
break;
case 'sys_page_compose':
// Clear for dolphin 7.0.3
$files = glob(BX_DIRECTORY_PATH_CACHE . 'db_sys_page_compose*.php');
array_map('unlink', $files);
// Clear for dolphin versions below 7.0.3
$sFileName = BX_DIRECTORY_PATH_CACHE . 'sys_page_compose.inc';
if (file_exists($sFileName)) unlink($sFileName);
break;
case 'sys_alerts':
// Clear for dolphin 7.0.3
$files = glob(BX_DIRECTORY_PATH_CACHE . 'db_sys_alerts*.php');
array_map('unlink', $files);
// Clear for dolphin versions below 7.0.3
$sFileName = BX_DIRECTORY_PATH_CACHE . 'sys_alerts.inc';
if (file_exists($sFileName)) unlink($sFileName);
break;
case 'users':
$files = glob(BX_DIRECTORY_PATH_CACHE . 'user*.php');
array_map('unlink', $files);
break;
}
}
}
?>