Пример #1
0
    while ($row = $db->sql_fetchrow($result)) {
        $txt .= str_pad($row[0], 50);
        for ($j = 1; $j < $numfields; $j++) {
            $txt .= str_pad($row[$j], 30);
        }
        $txt .= "\n";
    }
    file_put_contents(BASEDIR . 'cache/sql_result.txt', $txt);
}
switch ($mode) {
    case 'BackupDB':
        if (empty($tablelist)) {
            cpg_error('No tables found');
        }
        require_once CORE_PATH . 'classes/sqlctrl.php';
        SQLCtrl::backup($dbname, $tablelist, $filename, isset($_POST['dbstruct']), isset($_POST['dbdata']), isset($_POST['drop']), isset($_POST['gzip']), $full);
        break;
    case 'OptimizeDB':
        if (DB_TYPE == 'postgresql') {
            $db->sql_query('VACUUM ANALYZE');
            $query = 'SELECT cl.relname as tablename, st.* FROM pg_class AS cl, pg_statistic AS st WHERE st.starelid=cl.relfilenode AND cl.relkind IN(\'r\') AND cl.relname NOT LIKE \'pg_%\' AND cl.relname NOT LIKE \'sql_%\' ORDER by cl.relname';
        } else {
            $query = "{$type} TABLE " . implode(", ", $tablelist);
        }
        //		register_shutdown_function('run_sql_in_background', $dbname, $type, $db, $query);
        show($mode, $dbname, $tablelist, $query);
        break;
    case 'CheckDB':
        if (DB_TYPE == 'postgresql') {
            show($mode, $tablelist, null);
            break;
Пример #2
0
         define('ADMIN_MOD_INSTALL', 1);
         include 'modules/' . $class . '/sql/cpg_inst.php';
     } else {
         if (file_exists(BASEDIR . 'modules/' . $class . '/cpg_inst.php')) {
             define('ADMIN_MOD_INSTALL', 1);
             include 'modules/' . $class . '/cpg_inst.php';
         }
     }
     if (defined('ADMIN_MOD_INSTALL') && class_exists($class)) {
         $module = new $class();
         $tables = array();
         require_once CORE_PATH . 'classes/sqlctrl.php';
         foreach ($module->dbtables as $table) {
             $tables[] = $prefix . '_' . $table;
         }
         SQLCtrl::backup($dbname, $tables, str_replace(' ', '_', $module->modname) . '.sql');
     }
 } else {
     if (isset($_POST['save'])) {
         if ($CPG_SESS['admin']['page'] != 'modules') {
             cpg_error(_ERROR_BAD_LINK, _SEC_ERROR);
         }
         $mid = intval($_POST['save']);
         $custom_title = Fix_Quotes($_POST['custom_title'], true);
         $view = intval($_POST['view']);
         $inmenu = intval($_POST['inmenu']);
         $blocks = intval($_POST['blocks']);
         $result = $db->sql_query('SELECT title FROM ' . $prefix . "_modules WHERE mid={$mid}");
         if ($db->sql_numrows($result) > 0) {
             list($title) = $db->sql_fetchrow($result);
             if ($title == 'Your_Account') {