Exemplo n.º 1
0
function main()
{
    if (empty($_REQUEST['domain']) || empty($_REQUEST['page'])) {
        errback('Domain and page required.');
    }
    if ($_REQUEST['delete'] == true) {
        $count = delete($_REQUEST['domain'], $_REQUEST['page']);
        delete_cache($_REQUEST['domain'], $_REQUEST['page']);
        if (@$_REQUEST['return'] == 'text' || @$_REQUEST['callback']) {
            callback($count . ' deleted');
        } else {
            return_image($count > 0);
        }
    } else {
        errback('Really?');
    }
}
Exemplo n.º 2
0
 /** Updates settings.json files from both plugins and themes
  *  ORI stands for origin, DAT for data
  *  @param {array} &$datFile - data file in /data/other/custom_settings
  *  @param {array} &$oriFile - data file that accompanies plugins/themes
  */
 public static function versionUpdate(array &$datFile, array &$oriFile)
 {
     $vDat =& $datFile['tab']['version'];
     $vOri =& $oriFile['tab']['version'];
     // convert both versions to float numbers for easy comparison
     $v1 = (double) (substr($vDat, 0, 2) . str_replace('.', '', substr($vDat, 2)));
     $v2 = (double) (substr($vOri, 0, 2) . str_replace('.', '', substr($vOri, 2)));
     // only update settings if no version in the data folder file is present or
     // if the version is older than the one included with the theme or plugin
     if (isset($vOri) && (!isset($vDat) || $v2 > $v1)) {
         $vDat = $vOri;
         if (function_exists('delete_cache')) {
             delete_cache();
         }
         // map both plugin/ theme and data file to lookup-based key arrays
         $oriS = self::mapToKeys($oriFile['settings']);
         $datS = self::mapToKeys($datFile['settings']);
         $merged = array();
         foreach ($oriS as $ori) {
             // if the setting already existed and is not a section title (those are always overwritten)
             if (array_key_exists($ori['lookup'], $datS) && $datS[$ori['lookup']]['type'] !== 'section-title') {
                 // if the type of setting has changed, overwrite the old setting completely
                 if ($ori['type'] !== $datS[$ori['lookup']]['type']) {
                     array_push($merged, $ori);
                 } else {
                     $oldVal = @$datS[$ori['lookup']]['value'];
                     $mixS = $ori;
                     $mixS['value'] = $oldVal;
                     array_push($merged, $mixS);
                 }
                 // if the setting didn't exist, just create a new one
             } else {
                 array_push($merged, $ori);
             }
         }
         $datFile['settings'] = $merged;
     }
 }
Exemplo n.º 3
0
$query = array('SELECT' => 'ex_header,ex_footer', 'FROM' => "{$dbprefix}stats");
$result = $SQL->build($query);
//is there any change !
$affected = false;
while ($row = $SQL->fetch($result)) {
    $ex_header = isset($_POST['ex_header']) ? $_POST['ex_header'] : $row['ex_header'];
    $ex_footer = isset($_POST['ex_footer']) ? $_POST['ex_footer'] : $row['ex_footer'];
    //when submit !!
    if (isset($_POST['submit'])) {
        $ex_header = htmlspecialchars_decode($ex_header);
        $ex_footer = htmlspecialchars_decode($ex_footer);
        //update
        $update_query = array('UPDATE' => "{$dbprefix}stats", 'SET' => "ex_header = '" . $SQL->escape($ex_header) . "', ex_footer = '" . $SQL->escape($ex_footer) . "'");
        $SQL->build($update_query);
        if ($SQL->affected()) {
            $affected = true;
            //delete cache ..
            delete_cache('data_extra');
        }
    } else {
        $ex_header = htmlspecialchars($ex_header);
        $ex_footer = htmlspecialchars($ex_footer);
    }
}
$SQL->free($result);
//after submit
if (isset($_POST['submit'])) {
    kleeja_admin_info($affected ? $lang['EXTRA_UPDATED'] : $lang['NO_UP_CHANGE_S'], true, '', true, $action);
}
//secondary menu
$go_menu = array('he' => array('name' => $lang['ADD_HEADER_EXTRA'], 'link' => ADMIN_PATH . '?cp=extra&smt=he', 'goto' => 'he', 'current' => $current_smt == 'he'), 'fe' => array('name' => $lang['ADD_FOOTER_EXTRA'], 'link' => ADMIN_PATH . '?cp=extra&smt=fe', 'goto' => 'fe', 'current' => $current_smt == 'fe'));
Exemplo n.º 4
0
	if(!$users->AsSquidAdministrator){die("NO PRIVS");}
	if(isset($_GET["smp-js"])){smp_js();exit;}
	if(isset($_POST["DEFAULT_CACHE_SAVE_TRUE"])){squid_cache_save_default();exit;} //toujours en premier !
	if(isset($_GET["squid-caches-status"])){squid_cache_status();exit;}
	if(isset($_POST["cachesDirectory"])){squid_cache_save();exit;}
	if(isset($_POST["rebuild-caches"])){rebuild_caches();exit;}
	if(isset($_POST["reindex-caches"])){reindex_caches();exit;}
	if(isset($_POST["cache_directory"])){add_new_disk_save();exit;}
	
	if(isset($_POST["verify-caches"])){verify_caches();exit;}
	if(isset($_GET["add-new-disk-popup"])){add_new_disk_popup();exit;}
	if(isset($_GET["button-mode"])){button_mode();exit;}
	if(isset($_GET["add-new-disk-js"])){add_new_disk_js();exit;}
	if(isset($_GET["verify-caches-logs"])){verfiy_caches_logs();exit;}
	if(isset($_GET["verify-cache-events"])){verfiy_caches_events();exit;}
	if(isset($_POST["delete-cache"])){delete_cache();exit;}
	if(isset($_POST["DisableAnyCache"])){DisableAnyCache();exit;}
	if(isset($_GET["license-explain"])){license_explain();exit;}
	
	if(isset($_POST["BackTo1CPU"])){BackTo1CPU();exit;}
	if(isset($_GET["slider-t"])){slider_t();exit;}
	if(isset($_GET["slider-results"])){slider_results();exit;}
	if(isset($_GET["Byjs"])){Byjs();exit();}
	
	page();

function Byjs(){
	$page=CurrentPageName();
	header("content-type: application/x-javascript");
	echo "YahooWin4('900','$page?DisableChecks=yes&uuid={$_GET["uuid"]}','Caches - CPU 1 -')";
	
Exemplo n.º 5
0
        $arr[] = array('lang_id' => $row['lang_id'], 'word' => $row['word'], 'trans' => $transs[$row['word']]);
        //when submit
        if (isset($_POST['submit'])) {
            //del
            if ($del[$row['word']]) {
                $query_del = array('DELETE' => "{$dbprefix}lang", 'WHERE' => "word='" . $SQL->escape($row['word']) . "' AND lang_id='" . $lang_id . "'");
                $SQL->build($query_del);
            }
            //update
            $update_query = array('UPDATE' => "{$dbprefix}lang", 'SET' => "trans = '" . $SQL->escape($transs[$row['word']]) . "'", 'WHERE' => "word='" . $SQL->escape($row['word']) . "' AND lang_id='" . $lang_id . "'");
            $SQL->build($update_query);
        }
    }
    $SQL->freeresult($result);
} else {
    //no result ...
    $no_results = true;
}
//pages
$total_pages = $Pager->getTotalPages();
$page_nums = $Pager->print_nums(basename(ADMIN_PATH) . '?cp=' . basename(__FILE__, '.php'), 'onclick="javascript:get_kleeja_link($(this).attr(\'href\'), \'#content\'); return false;"');
//after submit
if (isset($_POST['submit'])) {
    $text = $lang['NO_UP_CHANGE_S'];
    if ($SQL->affected()) {
        delete_cache('data_lang');
        $text = $lang['WORDS_UPDATED'];
    }
    $text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . $action . '\');", 2000);</script>' . "\n";
    $stylee = "admin_info";
}
Exemplo n.º 6
0
function klj_clean_old_files($from = 0)
{
    global $config, $SQL, $stat_last_f_del, $dbprefix;
    $return = false;
    ($hook = kleeja_run_hook('klj_clean_old_files_func')) ? eval($hook) : null;
    //run hook
    if ((int) $config['del_f_day'] <= 0 || $return) {
        return;
    }
    if (!$stat_last_f_del || empty($stat_last_f_del)) {
        $stat_last_f_del = time();
    }
    if (time() - $stat_last_f_del >= 86400) {
        $totaldays = time() - $config['del_f_day'] * 86400;
        $not_today = time() - 86400;
        #This feature will work only if id_form is not empty or direct !
        $query = array('SELECT' => 'f.id, f.last_down, f.name, f.type, f.folder, f.time, f.size, f.id_form', 'FROM' => "{$dbprefix}files f", 'WHERE' => "f.last_down < {$totaldays} AND f.time < {$not_today} AND f.id > {$from} AND f.id_form <> '' AND f.id_form <> 'direct'", 'ORDER BY' => 'f.id ASC', 'LIMIT' => '20');
        ($hook = kleeja_run_hook('qr_select_klj_clean_old_files_func')) ? eval($hook) : null;
        //run hook
        $result = $SQL->build($query);
        $num_of_files_to_delete = $SQL->num_rows($result);
        if ($num_of_files_to_delete == 0) {
            //update $stat_last_f_del !!
            $update_query = array('UPDATE' => "{$dbprefix}stats", 'SET' => "last_f_del ='" . time() . "'");
            ($hook = kleeja_run_hook('qr_update_lstf_del_date_kcof')) ? eval($hook) : null;
            //run hook
            $SQL->build($update_query);
            //delete stats cache
            delete_cache("data_stats");
            update_config('klj_clean_files_from', '0');
            $SQL->freeresult($result);
            return;
        }
        $last_id_from = $files_num = $imgs_num = $real_num = $sizes = 0;
        $ids = array();
        $ex_ids = array();
        //$ex_types = explode(',', $config['livexts']);
        ($hook = kleeja_run_hook('beforewhile_klj_clean_old_files_func')) ? eval($hook) : null;
        //run hook
        //phpfalcon plugin
        $exlive_types = explode(',', $config['imagefolderexts']);
        //delete files
        while ($row = $SQL->fetch_array($result)) {
            $continue = true;
            $real_num++;
            $last_id_from = $row['id'];
            $is_image = in_array(strtolower(trim($row['type'])), array('gif', 'jpg', 'jpeg', 'bmp', 'png')) ? true : false;
            /*
            //excpetions
            if(in_array($row['type'], $ex_types) || $config['id_form'] == 'direct')
            {
            	$ex_ids[] = $row['id'];
            	continue;
            }
            */
            //excpetions
            //if($config['id_form'] == 'direct')
            //{
            //$ex_ids[] = $row['id'];
            //move on
            //continue;
            //}
            //your exepctions
            ($hook = kleeja_run_hook('while_klj_clean_old_files_func')) ? eval($hook) : null;
            //run hook
            //phpfalcon plugin
            if (in_array($row['type'], $exlive_types)) {
                $ex_ids[] = $row['id'];
                if ($real_num != $num_of_files_to_delete) {
                    $continue = false;
                }
            }
            if ($continue) {
                //delete from folder ..
                if (file_exists($row['folder'] . "/" . $row['name'])) {
                    @kleeja_unlink($row['folder'] . "/" . $row['name']);
                }
                //delete thumb
                if (file_exists($row['folder'] . "/thumbs/" . $row['name'])) {
                    @kleeja_unlink($row['folder'] . "/thumbs/" . $row['name']);
                }
                $ids[] = $row['id'];
                if ($is_image) {
                    $imgs_num++;
                } else {
                    $files_num++;
                }
                $sizes += $row['size'];
            }
        }
        #END WHILE
        $SQL->freeresult($result);
        if (sizeof($ex_ids)) {
            $update_query = array('UPDATE' => "{$dbprefix}files", 'SET' => "last_down = '" . (time() + 2 * 86400) . "'", 'WHERE' => "id IN (" . implode(',', $ex_ids) . ")");
            ($hook = kleeja_run_hook('qr_update_lstdown_old_files')) ? eval($hook) : null;
            //run hook
            $SQL->build($update_query);
        }
        if (sizeof($ids)) {
            $query_del = array('DELETE' => "{$dbprefix}files", 'WHERE' => "id IN (" . implode(',', $ids) . ")");
            //update number of stats
            $update_query = array('UPDATE' => "{$dbprefix}stats", 'SET' => "sizes=sizes-{$sizes},files=files-{$files_num}, imgs=imgs-{$imgs_num}");
            ($hook = kleeja_run_hook('qr_del_delf_old_files')) ? eval($hook) : null;
            //run hook
            $SQL->build($query_del);
            $SQL->build($update_query);
        }
        update_config('klj_clean_files_from', $last_id_from);
    }
    //stat_del
}
Exemplo n.º 7
0
function update_config($name, $value = '', $escape = true, $group = false)
{
    global $SQL, $dbprefix, $d_groups, $user, $plugin;
    $value = $escape ? $SQL->escape($value) : $value;
    $table = "{$dbprefix}config";
    #what if this config is a group-configs related ?
    $group_id_sql = '';
    if (array_key_exists($name, $d_groups[$user->data['group_id']]['configs'])) {
        $table = "{$dbprefix}groups_data";
        if ($group == -1) {
            $group_id_sql = ' AND group_id=' . $userinfo['group_id'];
        } else {
            if ($group) {
                $group_id_sql = ' AND group_id=' . intval($group);
            }
        }
    }
    $update_query = array('UPDATE' => $table, 'SET' => "value='" . ($escape ? $SQL->escape($value) : $value) . "'", 'WHERE' => 'name = "' . $SQL->escape($name) . '"' . $group_id_sql);
    ($hook = $plugin->run_hook('update_sql_update_config_func')) ? eval($hook) : null;
    //run hook
    $SQL->build($update_query);
    if ($SQL->affected()) {
        if ($table == "{$dbprefix}groups_data") {
            $d_groups[$userinfo['group_id']]['configs'][$name] = $value;
            delete_cache('data_groups');
            return true;
        }
        $config[$name] = $value;
        delete_cache('data_config');
        return true;
    }
    return false;
}
Exemplo n.º 8
0
$affected = false;
$H_FORM_KEYS = kleeja_add_form_key('adm_ban');
//
// Check form key
//
if (isset($_POST['submit'])) {
    if (!kleeja_check_form_key('adm_ban')) {
        kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
    }
}
$query = array('SELECT' => 'ban', 'FROM' => "{$dbprefix}stats");
$result = $SQL->build($query);
while ($row = $SQL->fetch_array($result)) {
    $ban = isset($_POST["ban_text"]) ? htmlspecialchars($_POST['ban_text']) : $row['ban'];
    //when submit
    if (isset($_POST['submit'])) {
        //update
        $update_query = array('UPDATE' => "{$dbprefix}stats", 'SET' => "ban='" . $SQL->escape($ban) . "'");
        $SQL->build($update_query);
        if ($SQL->affected()) {
            $affected = true;
            delete_cache('data_ban');
        }
    }
}
$SQL->freeresult($result);
//after submit
if (isset($_POST['submit'])) {
    $text = ($affected ? $lang['BAN_UPDATED'] : $lang['NO_UP_CHANGE_S']) . '<meta HTTP-EQUIV="REFRESH" content="0; url=' . basename(ADMIN_PATH) . '?cp=' . basename(__FILE__, '.php') . '">' . "\n";
    $stylee = "admin_info";
}
Exemplo n.º 9
0
                if (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '>')) {
                    $text = sprintf($lang['UPDATE_NOW_S'], KLEEJA_VERSION, strtolower($version_data)) . '<br /><br />' . $lang['UPDATE_KLJ_NOW'];
                }
            }
        }
        #lets decode it
        $v = @unserialize($config['new_version']);
        #To prevent expected error [ infinit loop ]
        if (isset($_GET['show_msg'])) {
            $query_get = array('SELECT' => '*', 'FROM' => "{$dbprefix}config", 'WHERE' => "name = 'new_version'");
            $result_get = $SQL->build($query_get);
            if (!$SQL->num($result_get)) {
                //add new config value
                add_config('new_version', '');
            }
        }
        $data = array('version_number' => $version_data, 'last_check' => time(), 'msg_appeared' => isset($_GET['show_msg']) ? true : false, 'copyrights' => !empty($b_data[1]) && strpos($b_data[1], 'yes') !== false ? true : false);
        $data = serialize($data);
        update_config('new_version', $SQL->escape($data), false);
        delete_cache('data_config');
    }
    //then go back  to start
    if (isset($_GET['show_msg'])) {
        redirect(ADMIN_PATH . '?update_done=1');
        $SQL->close();
        exit;
    }
    #end current_smt == general
}
//secondary menu
$go_menu = array('general' => array('name' => $lang['R_CHECK_UPDATE'], 'link' => ADMIN_PATH . '?cp=check_update&amp;smt=general', 'goto' => 'general', 'current' => $current_smt == 'general'), 'howto' => array('name' => $lang['HOW_UPDATE_KLEEJA'], 'link' => ADMIN_PATH . '?cp=check_update&amp;smt=howto', 'goto' => 'howto', 'current' => $current_smt == 'howto'), 'site' => array('name' => 'Kleeja.com', 'link' => ADMIN_PATH . '?cp=check_update&amp;smt=site', 'goto' => 'site', 'current' => $current_smt == 'site'));
 function saveit($filname, $folderee, $sizeee, $typeee, $real_filename = '')
 {
     global $SQL, $dbprefix, $config, $lang;
     // sometime cant see file after uploading.. but ..
     @chmod($folderee . '/' . $filname, 0644);
     //0644
     $name = (string) $SQL->escape($filname);
     $size = (int) $sizeee;
     $type = (string) strtolower($SQL->escape($typeee));
     $folder = (string) $SQL->escape($folderee);
     $timeww = (int) time();
     $user = (int) $this->id_user;
     $code_del = (string) md5(time());
     $ip = get_ip();
     $realf = (string) $SQL->escape($real_filename);
     $insert_query = array('INSERT' => '`name` ,`size` ,`time` ,`folder` ,`type`,`user`,`code_del`,`user_ip`, `real_filename`', 'INTO' => "`{$dbprefix}files`", 'VALUES' => "'{$name}', '{$size}', '{$timeww}', '{$folder}','{$type}', '{$user}', '{$code_del}', '{$ip}', '{$realf}'");
     ($hook = kleeja_run_hook('qr_insert_new_file_kljuploader')) ? eval($hook) : null;
     //run hook
     $SQL->build($insert_query);
     $this->name_for_url = $name;
     $this->id_for_url = $SQL->insert_id();
     //calculate stats ..s
     $update_query = array('UPDATE' => "{$dbprefix}stats", 'SET' => "`files`=files+1,`sizes`=sizes+" . $size . ",`last_file`='" . $folder . "/" . $name . "'");
     ($hook = kleeja_run_hook('qr_update_no_files_kljuploader')) ? eval($hook) : null;
     //run hook
     $SQL->build($update_query);
     //delete cache of stats !
     delete_cache('data_stats');
     //inforantion of file
     $file_info = array('::ID::' => $this->id_for_url, '::NAME::' => $this->name_for_url, '::DIR::' => $folderee, '::FNAME::' => $realf);
     //show del code link
     $extra_del = '';
     if ($config['del_url_file']) {
         $extra_del = get_up_tpl_box('del_file_code', array('b_title' => $lang['URL_F_DEL'], 'b_code_link' => kleeja_get_link('del', array('::CODE::' => $code_del))));
     }
     //show imgs
     if (in_array(strtolower($this->typet), array('png', 'gif', 'jpg', 'jpeg', 'tif', 'tiff'))) {
         //make thumbs
         $img_html_result = '';
         if ($config['thumbs_imgs'] != 0 && in_array(strtolower($this->typet), array('png', 'jpg', 'jpeg', 'gif'))) {
             list($thmb_dim_w, $thmb_dim_h) = @explode('*', $config['thmb_dims']);
             $this->createthumb($folderee . '/' . $filname, strtolower($this->typet), $folderee . '/thumbs/' . $filname, $thmb_dim_w, $thmb_dim_h);
             $img_html_result .= get_up_tpl_box('image_thumb', array('b_title' => $lang['URL_F_THMB'], 'b_url_link' => kleeja_get_link('image', $file_info), 'b_img_link' => kleeja_get_link('thumb', $file_info)));
         }
         //write on image
         if ($config['write_imgs'] != 0 && in_array(strtolower($this->typet), array('gif', 'png', 'jpg', 'jpeg'))) {
             $this->watermark($folderee . "/" . $filname, strtolower($this->typet));
         }
         //then show
         $img_html_result .= get_up_tpl_box('image', array('b_title' => $lang['URL_F_IMG'], 'b_bbc_title' => $lang['URL_F_BBC'], 'b_url_link' => kleeja_get_link('image', $file_info)));
         $img_html_result .= $extra_del;
         ($hook = kleeja_run_hook('saveit_func_img_res_kljuploader')) ? eval($hook) : null;
         //run hook
         $this->total++;
         $this->errs[] = array($lang['IMG_DOWNLAODED'] . '<br />' . $img_html_result, 'index_info');
     } else {
         //then show other files
         $else_html_result = get_up_tpl_box('file', array('b_title' => $lang['URL_F_FILE'], 'b_bbc_title' => $lang['URL_F_BBC'], 'b_url_link' => kleeja_get_link('file', $file_info)));
         $else_html_result .= $extra_del;
         ($hook = kleeja_run_hook('saveit_func_else_res_kljuploader')) ? eval($hook) : null;
         //run hook
         $this->total++;
         $this->errs[] = array($lang['FILE_DOWNLAODED'] . '<br />' . $else_html_result, 'index_info');
     }
     ($hook = kleeja_run_hook('saveit_func_kljuploader')) ? eval($hook) : null;
     //run hook
     if (isset($_POST['submitr'])) {
         if (isset($_SESSION['FIILES_NOT_DUPLI'])) {
             unset($_SESSION['FIILES_NOT_DUPLI']);
         }
         $_SESSION['FIILES_NOT_DUPLI'] = $_FILES;
     } elseif (isset($_POST['submittxt'])) {
         if (isset($_SESSION['FIILES_NOT_DUPLI_LINKS'])) {
             unset($_SESSION['FIILES_NOT_DUPLI_LINKS']);
         }
         $_SESSION['FIILES_NOT_DUPLI_LINKS'] = $_POST;
     }
     unset($filename, $folderee, $sizeee, $typeee);
     //unset ($_SESSION['NO_UPLOADING_YET']);
 }
Exemplo n.º 11
0
 /**
  * 数据库导出方法
  */
 private function export_database($sizelimit, $action, $fileid, $random, $tableid, $startfrom)
 {
     set_time_limit(0);
     $fileid = $fileid != '' ? $fileid : 1;
     $c_data = get_cache('bakup_tables');
     $tables = $c_data['tables'];
     $time = $c_data['time'];
     if (empty($tables)) {
         $this->show_message('数据缓存不存在,请重新选择备份');
     }
     if ($fileid == 1) {
         $random = mt_rand(1000, 9999);
     }
     $tabledump = '';
     $tableid = $tableid != '' ? $tableid : 0;
     $startfrom = $startfrom != '' ? intval($startfrom) : 0;
     for ($i = $tableid; $i < count($tables) && strlen($tabledump) < $sizelimit * 1000; $i++) {
         $offset = 100;
         if (!$startfrom) {
             $tabledump .= "DROP TABLE IF EXISTS `{$tables[$i]}`;\n";
             $createtable = $this->db->query("SHOW CREATE TABLE `{$tables[$i]}` ")->fetchAll();
             $tabledump .= $createtable[0]['Create Table'] . ";\n\n";
             $tabledump = preg_replace("/(DEFAULT)*\\s*CHARSET=[a-zA-Z0-9]+/", "DEFAULT CHARSET=utf8", $tabledump);
         }
         $numrows = $offset;
         while (strlen($tabledump) < $sizelimit * 1000 && $numrows == $offset) {
             $sql = "SELECT * FROM `{$tables[$i]}` LIMIT {$startfrom}, {$offset}";
             $fields_data = $this->db->query("SHOW COLUMNS FROM `{$tables[$i]}`")->fetchAll();
             $rows = $this->db->query($sql)->fetchAll();
             $numfields = count($fields_data);
             $numrows = count($rows);
             $fields_name = array();
             foreach ($fields_data as $r) {
                 $fields_name[$r['Field']] = $r['Type'];
             }
             $name = array_keys($fields_name);
             if ($rows) {
                 foreach ($rows as $row) {
                     $comma = "";
                     $tabledump .= "INSERT INTO `{$tables[$i]}` VALUES(";
                     for ($j = 0; $j < $numfields; $j++) {
                         $tabledump .= $comma . "'" . mysql_escape_string($row[$name[$j]]) . "'";
                         $comma = ",";
                     }
                     $tabledump .= ");\n";
                 }
             }
             $startfrom += $offset;
         }
         $tabledump .= "\n";
         $startfrom = $numrows == $offset ? $startfrom : 0;
     }
     $i = $startfrom ? $i - 1 : $i;
     $dir = DATA_DIR . 'bakup' . DIRECTORY_SEPARATOR;
     if (!is_dir($dir)) {
         mkdir($dir, 0777);
         file_put_contents($dir . 'index.html', '');
     }
     $bakfile_path = $dir . DIRECTORY_SEPARATOR . $time . DIRECTORY_SEPARATOR;
     if (trim($tabledump)) {
         $tabledump = "# xiaocms bakfile\n# version:xiaocms x1 \n# time:" . date('Y-m-d H:i:s') . "\n# http://www.xiaocms.com\n# ----------------------------------------\n\n\n" . $tabledump;
         $tableid = $i;
         $filename = 'xiaocmstables_' . date('Ymd') . '_' . $random . '_' . $fileid . '.sql';
         $altid = $fileid;
         $fileid++;
         if (!is_dir($bakfile_path)) {
             mkdir($bakfile_path, 0777);
         }
         $bakfile = $bakfile_path . $filename;
         file_put_contents($bakfile, $tabledump);
         @chmod($bakfile, 0777);
         $url = url('database/index', array('size' => $sizelimit, 'action' => $action, 'fileid' => $fileid, 'random' => $random, 'tableid' => $tableid, 'startfrom' => $startfrom));
         $this->show_message("备份{$filename}", 1, $url, 100);
     } else {
         file_put_contents($bakfile_path . 'index.html', '');
         delete_cache('bakup_tables');
         $this->show_message("备份完成", 1, url('database/index'));
     }
 }
Exemplo n.º 12
0
 /**
  * delete any content from any template , this will used in plugins
  * used in unistall tag at plugin xml file
  *
  * todo : use file handler, require ftp info at uninstalling
  */
 function delete_ch_tpl($template_name, $delete_txt = array())
 {
     global $dbprefix, $lang, $config, $STYLE_PATH_ADMIN, $STYLE_PATH, $THIS_STYLE_PATH;
     if (is_array($template_name)) {
         foreach ($template_name as $tn) {
             $this->delete_ch_tpl($tn, $delete_txt);
         }
         return;
     }
     $style_path = substr($template_name, 0, 6) == 'admin_' ? $STYLE_PATH_ADMIN : $THIS_STYLE_PATH;
     $is_admin_template = substr($template_name, 0, 6) == 'admin_' ? true : false;
     //if template not found and default style is there and not admin tpl
     $template_path = $style_path . $template_name . '.html';
     if (!file_exists($template_path)) {
         if ($config['style'] != 'default' && !$is_admin_template) {
             $template_path_alternative = str_replace('/' . $config['style'] . '/', '/default/', $template_path);
             if (file_exists($template_path_alternative)) {
                 $template_path = $template_path_alternative;
             }
         }
     }
     if (file_exists($template_path)) {
         $d_contents = file_get_contents($template_path);
     } else {
         $d_contents = '';
     }
     include_once "s_strings.php";
     $finder = new sa_srch();
     $finder->find_word = $delete_txt;
     $finder->another_word = '<!-- deleted ' . md5(implode(null, $delete_txt)) . ' -->';
     $finder->text = trim($d_contents);
     $finder->do_search(2);
     $cached_instructions = array();
     if ($d_contents != '' && md5($finder->text) != md5($d_contents) && is_writable($style_path)) {
         //update
         $this->f->_write($style_path . $template_name . '.html', $finder->text);
         //delete cache ..
         delete_cache('tpl_' . $template_name);
     } else {
         $cached_instructions[$template_name] = array('action' => 'replace_with', 'find' => $finder->find_word[0] . '(.*?)' . $finder->find_word[1], 'action_text' => $finder->another_word);
     }
     //add cached instuctions to cache if there
     if (sizeof($cached_instructions) > 0) {
         //fix
         if (file_exists(PATH . 'cache/styles_cached.php')) {
             $cached_content = file_get_contents(PATH . 'cache/styles_cached.php');
             $cached_content = kleeja_base64_decode($cached_content);
             $cached_content = unserialize($cached_content);
             $cached_instructions += $cached_content;
         }
         $filename = @fopen(PATH . 'cache/styles_cached.php', 'w');
         fwrite($filename, kleeja_base64_encode(serialize($cached_instructions)));
         fclose($filename);
     }
     if ($this->f_method === 'zfile') {
         if ($this->f->check()) {
             $this->zipped_files = $this->f->push($plugin_name);
         }
     }
     return true;
 }
Exemplo n.º 13
0
 public function delete_data_id($data_id)
 {
     list($hash, $storage_id) = explode("-", $data_id);
     $this->db->where('id', $storage_id)->delete('file_storage');
     if (file_exists($this->file($data_id))) {
         unlink($this->file($data_id));
     }
     $dir = $this->folder($data_id);
     if (file_exists($dir)) {
         if (count(scandir($dir)) == 2) {
             rmdir($dir);
         }
     }
     delete_cache("{$data_id}_thumb_150");
 }
Exemplo n.º 14
0
         $insert_query = array('INSERT' => 'ext ,group_id, size', 'INTO' => "{$dbprefix}groups_exts", 'VALUES' => "'{$new_ext}', {$req_group}, {$default_size}");
         $SQL->build($insert_query);
         #done
         $ADDED_EXT = $GE_INFO = 2;
         delete_cache('data_groups');
     }
     #if submit/update
     if (isset($_POST['editexts'])) {
         $ext_ids = $_POST['size'];
         if (is_array($ext_ids)) {
             foreach ($ext_ids as $e_id => $e_val) {
                 $update_query = array('UPDATE' => "{$dbprefix}groups_exts", 'SET' => "size=" . intval($e_val) * 1024, 'WHERE' => "ext_id=" . intval($e_id) . " AND group_id=" . $req_group);
                 $SQL->build($update_query);
             }
             #delete cache ..
             delete_cache('data_groups');
             kleeja_admin_info($lang['UPDATED_EXTS'], true, '', true, $action);
         }
     }
     #show exts
     $query = array('SELECT' => 'ext_id, ext, size', 'FROM' => "{$dbprefix}groups_exts", 'WHERE' => 'group_id=' . $req_group, 'ORDER BY' => 'ext_id ASC');
     $result = $SQL->build($query);
     $exts = array();
     while ($row = $SQL->fetch($result)) {
         $exts[] = array('ext_id' => $row['ext_id'], 'ext_name' => $row['ext'], 'ext_size' => round((int) $row['size'] / 1024), 'ext_icon' => file_exists(PATH . "images/filetypes/" . $row['ext'] . ".png") ? PATH . "images/filetypes/" . $row['ext'] . ".png" : PATH . 'images/filetypes/file.png');
     }
     $SQL->free($result);
     break;
     #show users (from search keyword)
 #show users (from search keyword)
 case 'show_su':
Exemplo n.º 15
0
$gr_exts_arr = ch_g('new_ext_group', 9);
//after submit
if (isset($_POST['submit'])) {
    if (!is_array($_POST['gsz'])) {
        $_POST['gsz'] = array();
    }
    $affected = false;
    foreach ($_POST['gsz'] as $n => $v) {
        $update_query = array('UPDATE' => "{$dbprefix}exts", 'SET' => "gust_size = '" . round(intval($_POST['gsz'][$n]) * 1024) . "', " . "gust_allow = '" . (isset($_POST['gal'][$n]) ? 1 : 0) . "', " . "user_size = '" . round(intval($_POST['usz'][$n]) * 1024) . "', " . "user_allow = '" . (isset($_POST['ual'][$n]) ? 1 : 0) . "'", 'WHERE' => "id=" . intval($n));
        $SQL->build($update_query);
        if ($SQL->affected()) {
            $affected = true;
        }
    }
    //delete cache ..
    delete_cache('data_exts');
    $text = ($affected ? $lang['UPDATED_EXTS'] : $lang['NO_UP_CHANGE_S']) . '<meta HTTP-EQUIV="REFRESH" content="2; url=' . basename(ADMIN_PATH) . '?cp=' . basename(__FILE__, '.php') . '&amp;page=' . (isset($_GET['page']) ? intval($_GET['page']) : '1') . '">' . "\n";
    $stylee = "admin_info";
} else {
    if (isset($_GET['add_new_ext'])) {
        $new_ext_i = $SQL->escape($_POST['new_ext']);
        $ext_gr_i = intval($_POST['new_ext_group']);
        $ext_gr_i = $ext_gr_i == 0 ? 9 : $ext_gr_i;
        //default
        $gust_size = '1024000';
        //1 mega
        $user_size = '1024000';
        //1 mega
        if (empty($new_ext_i)) {
            $text = $lang['EMPTY_EXT_FIELD'];
            $stylee = 'admin_info';
Exemplo n.º 16
0
                         $plg_dsc['description'] = array($plg_dsc['description']);
                     }
                     $p_desc = array();
                     foreach ($plg_dsc['description'] as $in) {
                         $p_desc[$in['attributes']['lang']] = $in['value'];
                     }
                 }
                 $installed_plugins[] = array('p_file' => $file, 'p_name' => htmlspecialchars($gtree['kleeja']['info']['plugin_name']['value']), 'p_ver' => htmlspecialchars($gtree['kleeja']['info']['plugin_version']['value']), 'p_des' => isset($p_desc[getlang()]) ? $p_desc[getlang()] : $p_desc['en']);
                 //we dont care about the return value here !
                 $plg->add_plugin($contents);
             }
         }
     }
     $plg->atend();
     //clean cache
     delete_cache(null, true);
     echo gettpl('plugins_done.html');
 } else {
     $plugins = array();
     $dh = opendir($pl_path);
     while (($file = readdir($dh)) !== false) {
         $e = @explode(".", $file);
         $e = strtolower($e[sizeof($e) - 1]);
         if ($e == "klj") {
             $contents = @file_get_contents($pl_path . '/' . $file);
             $gtree = $XML->xml_to_array($contents);
             if ($gtree != false) {
                 $plg_dsc = $gtree['kleeja']['info']['plugin_description'];
                 if (isset($plg_dsc)) {
                     if (is_array($plg_dsc['description']) && array_key_exists("attributes", $plg_dsc['description'])) {
                         $plg_dsc['description'] = array($plg_dsc['description']);
Exemplo n.º 17
0
            case 'upd':
                // updated success
                $text = $lang['PLUGIN_UPDATED_SUCCESS'];
                break;
                #--->weiredooo stuff
            #--->weiredooo stuff
            case 'inst':
                $text = $lang['NEW_PLUGIN_ADDED'];
                $text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=' . basename(__FILE__, '.php') . '&do_plg=' . $plg->plg_id . '&m=4&' . $GET_FORM_KEY . '\');", 2000);</script>' . "\n";
                break;
            case 'zipped':
                $text = sprintf($lang['PLUGIN_ADDED_ZIPPED'], '<a target="_blank" href="' . basename(ADMIN_PATH) . '?cp=' . basename(__FILE__, '.php') . '&amp;do_plg=' . $plg->plg_id . '&amp;m=6&amp;fn=' . $plg->zipped_files . '&amp;' . $GET_FORM_KEY . '">', '</a>');
                $text .= '<br /><br /><a onclick="javascript:get_kleeja_link(this.href); return false;" href="' . basename(ADMIN_PATH) . '?cp=' . basename(__FILE__, '.php') . '">' . $lang['GO_BACK_BROWSER'] . '</a>';
                break;
            case 'zipped/inst':
                $text = sprintf($lang['PLUGIN_ADDED_ZIPPED_INST'], '<a target="_blank" href="' . basename(ADMIN_PATH) . '?cp=' . basename(__FILE__, '.php') . '&amp;do_plg=' . $plg->plg_id . '&amp;m=6&amp;fn=' . $plg->zipped_files . '&amp;' . $GET_FORM_KEY . '">', '</a>', '<a onclick="javascript:get_kleeja_link(this.href); return false;" href="' . basename(ADMIN_PATH) . '?cp=' . basename(__FILE__, '.php') . '&amp;do_plg=' . $plg->plg_id . '&amp;m=4&amp;' . $GET_FORM_KEY . '">', '</a>');
                $text .= '<br /><br /><a onclick="javascript:get_kleeja_link(this.href); return false;" href="' . basename(ADMIN_PATH) . '?cp=' . basename(__FILE__, '.php') . '">' . $lang['GO_BACK_BROWSER'] . '</a>';
                break;
            default:
                kleeja_admin_err($lang['ERR_IN_UPLOAD_XML_FILE'], true, '', true, basename(ADMIN_PATH) . '?#!cp=' . basename(__FILE__, '.php'));
        }
    }
    $cache->clean(array('__changes_files__', '__plugins_icons__'));
    delete_cache(array('data_plugins', 'data_config'));
    $stylee = "admin_info";
}
//secondary menu
//$go_menu = array(
//				'general' => array('name'=>$lang['R_PLUGINS'], 'link'=> basename(ADMIN_PATH) . '?cp=j_plugins&amp;smt=general', 'goto'=>'general', 'current'=> $current_smt == 'general'),
//				'newplg' => array('name'=>$lang['ADD_NEW_PLUGIN'], 'link'=> basename(ADMIN_PATH) . '?cp=j_plugins&amp;smt=newplg', 'goto'=>'newplg', 'current'=> $current_smt == 'newplg'),
//	);
Exemplo n.º 18
0
         $link = basename(ADMIN_PATH) . '?cp=' . basename(__FILE__, '.php') . '&amp;style_choose=' . $style_id . '&amp;method=1';
         $text = sprintf($lang['TPL_BK_RETURNED'], $tpl_name) . '<br /> <a href="' . $link . '">' . $lang['GO_BACK_BROWSER'] . '</a><meta HTTP-EQUIV="REFRESH" content="1; url=' . $link . '">' . "\n";
         $stylee = "admin_info";
     }
     break;
     //show cached temaplte process ...
     //that came from plugins or return backup or even if style folder
     //is not writable
 //show cached temaplte process ...
 //that came from plugins or return backup or even if style folder
 //is not writable
 case 'cached':
     $cached_file = PATH . 'cache/styles_cached.php';
     //delete cached styles
     if (isset($_GET['del'])) {
         delete_cache('styles_cached');
         $text = $lang['CACHED_STYLES_DELETED'];
         $stylee = 'admin_info';
     } elseif (!file_exists($cached_file)) {
         $text = $lang['NO_CACHED_STYLES'];
         $stylee = 'admin_info';
     } else {
         $content = file_get_contents($cached_file);
         $content = kleeja_base64_decode($content);
         $content = unserialize($content);
         ob_start();
         foreach ($content as $template_name => $do) {
             echo '<strong>' . $lang['OPEN'] . '</strong> : <br /> ' . (substr($template_name, 0, 6) == 'admin_' ? $STYLE_PATH_ADMIN : $STYLE_PATH) . $template_name . '<br />';
             switch (trim($do['action'])) {
                 case 'replace_with':
                     echo '<strong> ' . $lang['SEARCH_FOR'] . '<strong> : <br />';
Exemplo n.º 19
0
            }
            $ids[] = $row['id'];
            $num++;
            $sizes += $row['size'];
        }
    }
    $SQL->free($result);
    //no files to delete
    if (isset($ids) && sizeof($ids)) {
        $query_del = array('DELETE' => "{$dbprefix}files", 'WHERE' => "`id` IN (" . implode(',', $ids) . ")");
        $SQL->build($query_del);
        //update number of stats
        $update_query = array('UPDATE' => "{$dbprefix}stats", 'SET' => "sizes=sizes-{$sizes}, imgs=imgs-{$num}");
        $SQL->build($update_query);
        if ($SQL->affected()) {
            delete_cache('data_stats');
            $affected = true;
        }
    }
    //after submit
    $text = ($affected ? $lang['FILES_UPDATED'] : $lang['NO_UP_CHANGE_S']) . '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . ADMIN_PATH . '?cp=' . basename(__FILE__, '.php') . '&page=' . (isset($_GET['page']) ? intval($_GET['page']) : '1') . '\');", 2000);</script>' . "\n";
    $current_template = "info.php";
} else {
    $query = array('SELECT' => 'COUNT(f.id) AS total_files', 'FROM' => "{$dbprefix}files f", 'ORDER BY' => 'f.id DESC');
    #if user system is default, we use users table
    if ((int) $config['user_system'] == 1) {
        $query['JOINS'] = array(array('LEFT JOIN' => "{$dbprefix}users u", 'ON' => 'u.id=f.user'));
    }
    $img_types = array('gif', 'jpg', 'png', 'bmp', 'jpeg', 'GIF', 'JPG', 'PNG', 'BMP', 'JPEG');
    #
    # There is a bug with IN statment in MySQL and they said it will solved at 6.0 version
Exemplo n.º 20
0
    //
    case 'sync_users':
        $query_w = array('SELECT' => 'name', 'FROM' => "{$dbprefix}users");
        $result_w = $SQL->build($query_w);
        $user_number = 0;
        while ($row = $SQL->fetch_array($result_w)) {
            $user_number++;
        }
        $SQL->freeresult($result_w);
        $update_query = array('UPDATE' => "{$dbprefix}stats", 'SET' => "users=" . $user_number);
        $result = $SQL->build($update_query);
        delete_cache('data_stats');
        $text = sprintf($lang['SYNCING'], $lang['USERS_ST']);
        $text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=r_repair' . '\');", 2000);</script>' . "\n";
        $stylee = 'admin_info';
        break;
        //
        //clear all cache ..
        //
    //
    //clear all cache ..
    //
    case 'clearc':
        #clear cache
        delete_cache('', true);
        #show done, msg
        $text .= '<li>' . $lang['REPAIRE_CACHE'] . '</li>';
        $text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=r_repair' . '\');", 2000);</script>' . "\n";
        $stylee = 'admin_info';
        break;
}
Exemplo n.º 21
0
//
// Check form key
//
if (isset($_POST['submit'])) {
    if (!kleeja_check_form_key('adm_rules')) {
        kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
    }
}
$query = array('SELECT' => 'rules', 'FROM' => "{$dbprefix}stats");
$result = $SQL->build($query);
while ($row = $SQL->fetch_array($result)) {
    $rulesw = isset($_POST['rules_text']) ? $_POST['rules_text'] : $row['rules'];
    $rules = htmlspecialchars($rulesw);
    //when submit
    if (isset($_POST['submit'])) {
        //update
        $update_query = array('UPDATE' => "{$dbprefix}stats", 'SET' => "rules = '" . $SQL->real_escape($rulesw) . "'");
        $SQL->build($update_query);
        if ($SQL->affected()) {
            $affected = true;
            delete_cache('data_rules');
        }
    }
}
$SQL->freeresult($result);
//after submit
if (isset($_POST['submit'])) {
    $text = $affected ? $lang['RULES_UPDATED'] : $lang['NO_UP_CHANGE_S'];
    $text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=' . basename(__FILE__, '.php') . '\');", 2000);</script>' . "\n";
    $stylee = "admin_info";
}
Exemplo n.º 22
0
    exit;
}
if (isset($_GET["addcache-js"])) {
    addcache_js();
    exit;
}
if (isset($_GET["addcache-popup"])) {
    addcache_popup();
    exit;
}
if (isset($_GET["delete-cache-js"])) {
    delete_cache_js();
    exit;
}
if (isset($_POST["delete-cache"])) {
    delete_cache();
    exit;
}
if (isset($_GET["abort-delete-cache-js"])) {
    delete_cache_abort_js();
    exit;
}
if (isset($_POST["abort-delete-cache"])) {
    delete_cache_abort();
    exit;
}
if (isset($_GET["disable-js"])) {
    disable_js();
    exit;
}
if (isset($_GET["events-js"])) {
Exemplo n.º 23
0
        $date = date('Ymd');
        if ($mdate === $date) {
            return true;
        } else {
            return false;
        }
    }
}
function delete_cache($cache_path)
{
    if (file_exists($cache_path)) {
        unlink($cache_path);
    }
}
function create_cache($cache_path, $rss_url)
{
    $rss_data = file_get_contents($rss_url);
    $xml = simplexml_load_string($rss_data);
    $json = json_encode($xml);
    $object = json_decode($json);
    $image_tag = $object->entry[0]->content;
    preg_match('/src="([^"]+)"/', $image_tag, $m);
    $image_url = $m[1];
    file_put_contents($cache_path, file_get_contents($image_url));
}
if (!cache_exists($cache_path)) {
    delete_cache($cache_path);
    create_cache($cache_path, $rss_url);
}
header('Content-Type: image/gif');
echo file_get_contents($cache_path);