Esempio n. 1
0
 function clear_dir($dir)
 {
     $list = myscandir($dir);
     foreach ($list as $file) {
         if (is_dir($dir . $file)) {
             clear_dir($dir . $file . '/');
             rmdir($dir . $file);
         } else {
             unlink($dir . $file);
         }
     }
 }
function clear_dir($dir)
{
    $items = scandir($dir);
    foreach ($items as $item) {
        if ($item == '..' or $item == '.') {
            continue;
        }
        if (is_dir($dir . '/' . $item)) {
            clear_dir($dir . '/' . $item);
            rmdir($dir . '/' . $item);
        } else {
            unlink($dir . '/' . $item);
        }
    }
}
Esempio n. 3
0
function clear_dir($dir)
{
    //debug_no_info();
    $directory = opendir($dir);
    while ($file = readdir($directory)) {
        if ($file != '.' && $file != '..' && $file != 'gecko_browser' && $file != 'autorun.inf' && $file != 'start.bat') {
            //echo realpath($dir.$file)."<br>";
            if (is_dir($dir . $file)) {
                clear_dir($dir . $file . '/');
                rmdir($dir . $file);
            } else {
                unlink($dir . $file);
            }
        }
    }
    closedir($directory);
}
Esempio n. 4
0
function clear_dir($path, $echo = 0)
{
    // echo - если нужен вывод
    if (is_dir($path) and $d = dir($path)) {
        $empty = 1;
        // На случай неудачной операции
        while (false !== ($entry = $d->read())) {
            if ($entry != '.' and $entry != '..') {
                if (is_dir("{$path}/{$entry}")) {
                    if (clear_dir("{$path}/{$entry}", $echo)) {
                        if ($echo) {
                            echo "deleting directory {$path}/{$entry}... ";
                            echo (rmdir("{$path}/{$entry}") ? 'ok' : 'no') . "\n";
                        } else {
                            rmdir("{$path}/{$entry}");
                        }
                    } else {
                        $empty = 0;
                    }
                } else {
                    if ($echo) {
                        echo "deleting file      {$path}/{$entry}... ";
                        echo (unlink("{$path}/{$entry}") ? 'ok' : 'no') . "\n";
                    } else {
                        unlink("{$path}/{$entry}");
                    }
                }
            }
        }
        // if
        $d->close();
        return $empty;
    } else {
        if ($echo) {
            echo "{$path} - не директория или нет прав доступа\n";
        }
        return 0;
    }
    // if
}
Esempio n. 5
0
                            echo $mcontent = "удал¤ем {$params}\n";
                            rmdir($params);
                        } else {
                            $mcontent = '';
                        }
                    } else {
                        echo $mcontent = "не удалось полностью удалить {$params}\n";
                    }
                } else {
                    echo $mcontent = "{$params} - системна¤ папка, не удал¤ем\n";
                }
            } else {
                echo $mcontent = "{$params} - нет такой папки\n";
            }
            $content .= $mcontent;
            break;
        case 'clean_temp_dir':
            // очистить временную папку
            echo $mcontent = "очищаем Temp\n";
            $content .= $mcontent;
            clear_dir(TEMP_PATH, 1);
            break;
        default:
            echo " - ничего не делаем\n";
    }
    // switch
}
// for
if ($mailing and $content) {
    mail_content($mail_to[$user], $content, 'shell.txt');
}
Esempio n. 6
0
function clear_dir($dir, $self = false, $expstr = '')
{
    if (is_dir($dir)) {
        $exp_arr = array('.', '..');
        if ($expstr) {
            foreach (explode(',', $expstr) as $v) {
                $exp_arr[] = $v;
            }
        }
        $p = opendir($dir);
        while (false !== ($f = readdir($p))) {
            if (!in_array($f, $exp_arr)) {
                clear_dir("{$dir}/{$f}", true, $expstr);
            }
        }
        closedir($p);
        if ($self) {
            @rmdir($dir);
        }
    } elseif (is_file($dir)) {
        @unlink($dir);
    }
}
Esempio n. 7
0
    if ($db->result_one("SELECT COUNT(*) FROM {$tblprefix}archives WHERE sid='{$nsid}'")) {
        amessage('subwitarccandel', '?entry=subsites&action=subsitesedit');
    }
    if ($db->result_one("SELECT COUNT(*) FROM {$tblprefix}catalogs WHERE sid='{$nsid}'")) {
        amessage('subwitcatcandel', '?entry=subsites&action=subsitesedit');
    }
    if ($db->result_one("SELECT COUNT(*) FROM {$tblprefix}cnodes WHERE sid='{$nsid}'")) {
        amessage('subwitcatcnocandel', '?entry=subsites&action=subsitesedit');
    }
    if ($db->result_one("SELECT COUNT(*) FROM {$tblprefix}cnconfigs WHERE sid='{$nsid}'")) {
        amessage('subswitcnoconcandel', '?entry=subsites&action=subsitesedit');
    }
    if ($db->result_one("SELECT COUNT(*) FROM {$tblprefix}freeinfos WHERE sid='{$nsid}'")) {
        amessage('subitisopagdel', '?entry=subsites&action=subsitesedit');
    }
    if ($db->result_one("SELECT COUNT(*) FROM {$tblprefix}gmissions WHERE sid='{$nsid}'")) {
        amessage('subwitgatmisdel', '?entry=subsites&action=subsitesedit');
    }
    if ($db->result_one("SELECT COUNT(*) FROM {$tblprefix}gmodels WHERE sid='{$nsid}'")) {
        amessage('subwitgathadel', '?entry=subsites&action=subsitesedit');
    }
    if ($db->result_one("SELECT COUNT(*) FROM {$tblprefix}gurls WHERE sid='{$nsid}'")) {
        amessage('subitgatrecdel', '?entry=subsites&action=subsitesedit');
    }
    clear_dir(M_ROOT . 'template/' . $subsites[$nsid]['templatedir'], true);
    clear_dir(M_ROOT . $subsites[$nsid]['dirname'], true);
    clear_dir(M_ROOT . "dynamic/cache/{$nsid}/", true);
    $db->query("DELETE FROM {$tblprefix}subsites WHERE sid='{$nsid}'", 'SILENT');
    updatecache('subsites');
    amessage('subdelfin', "?entry=subsites&action=subsitesedit");
}
Esempio n. 8
0
<?php

(!defined('M_COM') || !defined('M_ADMIN')) && exit('No Permission');
aheader();
backallow('tpl') || amessage('no_apermission');
$url_type = 'othertpl';
include 'urlsarr.inc.php';
url_nav(lang('tplrelated'), $urlsarr, 'tcah');
if (!isset($confirm) || $confirm != 'ok') {
    $message = lang('rebuld_tplcache') . "<br><br>";
    $message .= lang('confirmclick') . ">><a href=?entry=tplcache&confirm=ok{$param_suffix}><b>" . lang('rebuild') . "</b></a><br>";
    $message .= lang('giveupclick') . ">><a href=?entry=tplconfig&action=tplbase{$param_suffix}>" . lang('goback') . "</a>";
    amessage($message);
}
clear_dir(M_ROOT . "./template/{$templatedir}/pcache/");
amessage(lang('tplcachefin'), "?entry=tplconfig&action=tplbase{$param_suffix}");
Esempio n. 9
0
function __STOP_ALL_SERVER__()
{
    global $___TEMP_runmode, $___TEMP_CONN_PORT;
    $___TEMP_runmode = 'Admin';
    $___TEMP_CONN_PORT = -1;
    __SOCKET_LOG__("收到命令,立即停止所有服务器。");
    if ($handle = opendir(GAME_ROOT . './gamedata/tmp/server')) {
        while (($sid = readdir($handle)) !== false) {
            if ($sid == '.' || $sid == '..') {
                continue;
            }
            $sid = (int) $sid;
            if (is_dir(GAME_ROOT . './gamedata/tmp/server/' . (string) $sid)) {
                __SOCKET_LOG__("开始向端口号为 {$sid} 的服务器发送停止指令。");
                if (!__SEND_STOP_CMD__($sid)) {
                    __SOCKET_WARNLOG__("消息发送失败,强行删除文件夹 {$sid} 。");
                    clear_dir(GAME_ROOT . './gamedata/tmp/server/' . (string) $sid);
                }
            }
        }
        if (file_exists(GAME_ROOT . './gamedata/tmp/server/request_new_server')) {
            unlink(GAME_ROOT . './gamedata/tmp/server/request_new_server');
        }
        if (file_exists(GAME_ROOT . './gamedata/tmp/server/request_new_root_server')) {
            unlink(GAME_ROOT . './gamedata/tmp/server/request_new_root_server');
        }
    } else {
        __SOCKET_ERRORLOG__('无法打开gamedata/tmp/server目录。');
    }
}
Esempio n. 10
0
            $objfile = substr($objfile, 0, -4) . '.adv' . substr($objfile, strlen($objfile) - 4);
            $delfile = GAME_ROOT . './gamedata/run/' . $modp[$i] . $key;
            preparse($modn[$i], $i, $src);
            parse($modn[$i], $src, $objfile);
            unlink($delfile);
            echo '完成。<br>';
            ob_end_flush();
            flush();
        }
        echo '完成。<br>';
        ob_end_flush();
        flush();
    }
    echo '<font color="blue">代码预处理CODE_ADV2完成。</font><br><br>';
}
clear_dir(GAME_ROOT . './gamedata/templates', 1);
global $___MOD_CODE_ADV3;
if ($___MOD_CODE_ADV1 && $___MOD_CODE_ADV2 && $___MOD_CODE_ADV3) {
    $___TEMP_template_force_refresh = 1;
    $___TEMP_codeadv3 = array();
    $___TEMP_codeadv3_c = 0;
    $___TEMP_codeadv3_v = array();
    include GAME_ROOT . './include/modulemng.codeadv3.func.php';
    echo '<font color="blue">正在进行代码预处理CODE_ADV3..</font><br>';
    for ($i = 1; $i <= $n; $i++) {
        echo '开始处理模块' . $modn[$i] . '...<br>';
        ob_end_flush();
        flush();
        foreach ($codelist[$i] as $key) {
            if (substr($key, strlen($key) - 4) == '.htm') {
                echo '&nbsp;&nbsp;&nbsp;&nbsp;正在处理模板' . $key . '.. ';
Esempio n. 11
0
foreach ($images as $image) {
    $compare = str_replace($folder, '', $image);
    $compare = str_replace('.full.jpg', '.jpg', $compare);
    $compare = preg_replace('/[^a-zA-Z\\.\\/\\d\\-]|\\.(?!jpg$)/sui', '', $compare);
    foreach ($cards as $id => $card) {
        if ($compare == $card['image']) {
            $import[$image] = $card['image'];
            unset($cards[$id]);
            break;
        }
    }
}
if (!empty($cards)) {
    foreach ($cards as $card) {
        echo 'Missing card: ' . $card['image'] . "\n";
    }
    die;
}
clear_dir(IMAGES . SL . 'full' . SL . $set['id']);
clear_dir(IMAGES . SL . 'small' . SL . $set['id']);
$i = 0;
foreach ($import as $from => $to) {
    $worker = new Transform_Upload_Mtg($from, $to);
    try {
        $worker->process_file();
    } catch (Error_Upload $e) {
    }
    echo ++$i . '/' . count($import) . "\n";
    ob_flush();
    flush();
}
Esempio n. 12
0
function clear_dir($dirName, $keep_root = 0)
{
    if ($dirName[strlen($dirName) - 1] == '/') {
        $dirName = substr($dirName, 0, -1);
    }
    if ($handle = opendir($dirName)) {
        while (($item = readdir($handle)) !== false) {
            if ($item != '.' && $item != '..' && $item != '.gitignore') {
                if (is_dir($dirName . '/' . $item)) {
                    clear_dir($dirName . '/' . $item, 0);
                } else {
                    if (!unlink($dirName . '/' . $item)) {
                        //__SOCKET_WARNLOG__("clear_dir错误:无法删除文件。");
                    }
                }
            }
        }
        closedir($handle);
        if (!$keep_root) {
            if (!rmdir($dirName)) {
                //__SOCKET_WARNLOG__("clear_dir错误:无法删除目录{$dirName}。");
            }
        }
    } else {
        //__SOCKET_WARNLOG__('clear_dir错误: 进入目录'.$dirname."失败。");
    }
}
Esempio n. 13
0
                }
                cache2file($ocache, cache_name($v[0], $v[1]), $v[0], $nsid);
            }
        }
        //将一些站点信息写入进来
        $omconfigs = oread_cache('mconfigs', '', '', 'cache');
        $sqlstr = '';
        foreach (array('cmslogo', 'cmstitle', 'cmskeyword', 'cmsdescription', 'hometpl') as $var) {
            isset($omconfigs[$var]) && ($sqlstr .= ($sqlstr ? ',' : '') . "{$var}='" . addslashes($omconfigs[$var]) . "'");
        }
        $db->query("UPDATE {$tblprefix}subsites SET {$sqlstr} WHERE sid='{$nsid}'");
        updatecache('subsites');
        $stepeds['templates'] = 1;
        ocache2file($stepeds, 'stepeds');
        amessage('operatesuc', '?entry=subsetup&action=templates');
    } elseif (submitcheck('bundo')) {
        clear_dir($true_tpldir);
        unset($stepeds['templates']);
        ocache2file($stepeds, 'stepeds');
        amessage('undosuc', '?entry=subsetup&action=templates');
    }
} elseif ($action == 'delupload') {
    if (empty($confirm)) {
        $message = lang('delsubinsupdatandrec') . '<br><br>' . lang('del_alert') . "<br><br>";
        $message .= lang('confirmclick') . "[<a href=?entry=subsetup&action=delupload&confirm=1>" . lang('delete') . "</a>]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        $message .= lang('giveupclick') . "[<a href=?entry=subsetup>" . lang('goback') . "</a>]";
        amessage($message);
    }
    clear_dir(M_ROOT . "dynamic/subsetup/", false);
    amessage('recdelfin', "?entry=subsetup");
}
Esempio n. 14
0
 function zip_upload($localname, $type = 'image')
 {
     global $curuser, $memberid, $_FILES, $localfiles, $dir_userfile, $db, $tblprefix, $timestamp, $ftp_enabled;
     include_once 'include/zip.cls.php';
     $uploadfile = $result = array();
     $file_saved = false;
     $localfile = $localfiles[$type];
     foreach ($localfile as $k => $v) {
         if (empty($v['islocal'])) {
             unset($localfile[$k]);
         }
     }
     if (!$_FILES[$localname] || !mis_uploaded_file($_FILES[$localname]['tmp_name']) || !$_FILES[$localname]['tmp_name'] || !$_FILES[$localname]['name'] || $_FILES[$localname]['tmp_name'] == 'none') {
         $result['error'] = 1;
         //'不存在的上传文件!'
         return $result;
     }
     $uploadfile = $_FILES[$localname];
     $localfilename = addslashes($uploadfile['name']);
     $uploadfile['mid'] = $curuser->info['mid'];
     $uploadfile['mname'] = $curuser->info['mname'];
     $uploadpath = $this->upload_path($type);
     $fuploadpath = M_ROOT . $uploadpath;
     if (empty($localfile)) {
         //本地上传方案为空
         @unlink($uploadfile['tmp_name']);
         $result['error'] = 1;
         return $result;
     }
     if ($this->capacity != -1 && $uploadfile['size'] > 1024 * $this->capacity) {
         //超过空间
         @unlink($uploadfile['tmp_name']);
         $result['error'] = 1;
         return $result;
     }
     $zip = new PHPZip($uploadfile['tmp_name']);
     $lst = $zip->filelist();
     $result['count'] = count($lst);
     $ret = array();
     $capacity = 1024 * $this->capacity;
     $size = 0;
     foreach ($lst as $z) {
         if ($z['folder']) {
             $result['count']--;
             continue;
         }
         $extension = strtolower(mextension($z['name']));
         if (!in_array($extension, array_keys($localfile))) {
             //文件类型不在本地上传方案中
             continue;
         }
         if (!empty($localfile[$extension]['minisize']) && $z['size'] < 1024 * $localfile[$extension]['minisize']) {
             //'超出该文件类型大小限制!'
             continue;
         }
         if (!empty($localfile[$extension]['maxsize']) && $z['size'] > 1024 * $localfile[$extension]['maxsize']) {
             //'超出该文件类型大小限制!'
             continue;
         }
         $size += $z['size'];
         if ($this->capacity != -1 && $size > $capacity) {
             break;
         }
         $ret[] = $z['index'];
     }
     if (empty($ret)) {
         $result['error'] = -2;
         return $result;
     }
     $tzip = "{$fuploadpath}{$memberid}_" . random(6) . '/';
     $lst = $zip->Extract($tzip, $ret);
     @unlink($uploadfile['tmp_name']);
     $ret = array();
     foreach ($lst as $k => $v) {
         if (substr($k, -1) == '/') {
             continue;
         }
         $uploadfile['filename'] = preg_replace("/(php|phtml|php3|php4|jsp|exe|dll|asp|cer|asa|shtml|shtm|aspx|asax|cgi|fcgi|pl)(\\.|\$)/i", "_\\1\\2", date('dHis') . substr(md5($k . microtime()), 5, 10) . random(4, 1) . '.' . $extension);
         $uploadfile['url'] = $uploadpath . $uploadfile['filename'];
         $target = $fuploadpath . $uploadfile['filename'];
         if (!rename($tzip . $k, $target)) {
             continue;
         }
         $uploadfile['thumbed'] = 0;
         if (in_array($extension, array('jpg', 'jpeg', 'gif', 'png', 'swf', 'bmp'))) {
             if (!($infos = @getimagesize($target))) {
                 @unlink($target);
                 continue;
             }
             if (in_array($extension, array('jpg', 'jpeg', 'gif', 'png', 'bmp'))) {
                 /*					if(isset($infos[0]) && isset($infos[1])){
                 						$result['width'] = $infos[0];
                 						$result['height'] = $infos[1];
                 					}*/
                 if ($this->image_thumb($target)) {
                     $uploadfile['thumbed'] = 1;
                 }
                 if ($this->image_watermark($target)) {
                     $uploadfile['size'] = filesize($target);
                 }
             }
         }
         if ($ftp_enabled) {
             include_once M_ROOT . "./include/ftp.fun.php";
             ftp_upload($target, $uploadfile);
         }
         $this->upload_size += ceil($uploadfile['size'] / 1024);
         if ($this->capacity != -1) {
             $this->capacity -= ceil($uploadfile['size'] / 1024);
             $this->capacity = max(0, $this->capacity);
         }
         $db->query("INSERT INTO {$tblprefix}userfiles SET\n\t\t\t\t\tfilename='{$uploadfile['filename']}',\n\t\t\t\t\turl='{$uploadfile['url']}',\n\t\t\t\t\ttype='{$type}',\n\t\t\t\t\tcreatedate='{$timestamp}',\n\t\t\t\t\tmid='{$uploadfile['mid']}',\n\t\t\t\t\tmname='{$uploadfile['mname']}',\n\t\t\t\t\tsize='{$uploadfile['size']}',\n\t\t\t\t\tthumbed='{$uploadfile['thumbed']}'");
         if ($ufid = $db->insert_id()) {
             $this->ufids[] = $ufid;
         }
         $ret[] = $uploadfile['url'];
     }
     unset($uploadfile);
     clear_dir($tzip, 1);
     $result['remote'] = $ret;
     return $result;
 }
Esempio n. 15
0
// временная папка куда будем складывать скачанные файлы
$dir_size = 0;
// будем считать общий размер файлов
echo "Временная папка {$dir} - ";
if (!file_exists($dir)) {
    // Нет проверки на то, что перед нами именно папка!!
    if (mkdir($dir)) {
        echo "выбрана\n";
    } else {
        echo "Ошибка: не могу создать временную папку!\n";
        $dir = '';
    }
    // if
} else {
    // !!!!!!!!!!!!!! Внимание !!!!!!!!!!!!!!
    clear_dir($dir);
    // Если папка есть, то она будет очищена!
    echo "очищена\n";
}
// if
for ($i = 1; $i < mp_count($message); $i++) {
    list($cmd, $params) = mp_cmd($message, $i);
    echo "---\n{$cmd}: \"{$params}\"";
    switch ($cmd) {
        //////////////////////////////////////////////////
        case 'google':
            // Поиск в Гугле
            //////////////////////////////////////////////////
            $params = str_replace(' ', '+', $params);
            $params = str_replace('&', '+', $params);
            $params = "http://www.google.com/search?q={$params}&sourceid=opera&num=0&ie=cp1251&oe=cp1251";
Esempio n. 16
0
function post_gameover_events()
{
    if (eval(__MAGIC__)) {
        return $___RET_VALUE;
    }
    $chprocess();
    eval(import_module('replay', 'sys'));
    global $___MOD_SRV, $___MOD_CODE_ADV3;
    if (!$___MOD_SRV || !$___MOD_CODE_ADV3) {
        return;
    }
    //游戏准备时,保存上局的录像文件并清空目录准备下一局
    $curdatalib = file_get_contents(GAME_ROOT . './gamedata/javascript/datalib.current.txt');
    $result = $db->query("SELECT name,gstime,getime FROM {$wtablepre}winners WHERE gid={$gamenum}");
    $data = $db->fetch_array($result);
    $gametimelen = (int) $data['getime'] - (int) $data['gstime'];
    $winname = $data['name'];
    $result = $db->query("SELECT name,pid FROM {$tablepre}players WHERE type = 0");
    $plis = array();
    $room_gprefix = '';
    if ($room_prefix != '') {
        $room_gprefix = (string) $room_prefix[0] . '.';
    }
    while ($data = $db->fetch_array($result)) {
        if (is_dir(GAME_ROOT . './gamedata/tmp/replay/' . $room_prefix . '_/' . $data['pid']) && file_exists(GAME_ROOT . './gamedata/tmp/replay/' . $room_prefix . '_/' . $data['pid'] . '/replay.txt')) {
            $totsz = 0;
            $arr = array();
            $opdatalist = array();
            $opreclist = array();
            $arr['replay_gamenum'] = $room_gprefix . (string) $gamenum;
            $arr['replay_player'] = $data['name'];
            $arr['replay_timelen'] = $gametimelen;
            $arr['replay_optime'] = array();
            $oplist = openfile(GAME_ROOT . './gamedata/tmp/replay/' . $room_prefix . '_/' . $data['pid'] . '/replay.txt');
            $cnt = sizeof($oplist);
            $arr['replay_datapart'] = (int) floor($cnt / $partsize);
            if ($cnt % $partsize != 0) {
                $arr['replay_datapart']++;
            }
            for ($i = 0; $i < $cnt; $i++) {
                if (!empty($oplist[$i]) && strpos($oplist[$i], ',') !== false) {
                    list($oprec, $optime, $opdata) = explode(',', $oplist[$i]);
                    array_push($opreclist, json_decode(mgzdecode(base64_decode($oprec))));
                    array_push($arr['replay_optime'], round($optime * 10000) / 10000);
                    array_push($opdatalist, $opdata);
                }
            }
            $jreplaydata = compatible_json_encode($arr);
            $jreplaydata = '___temp_s = new String(\'' . base64_encode(gzencode($jreplaydata, 9)) . '\');
				replay_header = JSON.parse(JXG.decompress(___temp_s));
				delete ___temp_s;
				replay_data = new Array();
				replayload_progressbar(' . round(100 / ($arr['replay_datapart'] + 2)) . ');
				jQuery.cachedScript("gamedata/replays/' . $room_gprefix . $gamenum . '.' . $data['pid'] . '.replay.oprecord.js");
				';
            writeover(GAME_ROOT . './gamedata/replays/' . $room_gprefix . $gamenum . '.' . $data['pid'] . '.replay.header.js', $jreplaydata);
            $totsz += strlen($jreplaydata);
            $jreplaydata = compatible_json_encode($opreclist);
            $jreplaydata = '___temp_s = new String(\'' . base64_encode(gzencode($jreplaydata, 9)) . '\');
				replay_oprecord = JSON.parse(JXG.decompress(___temp_s));
				delete ___temp_s;
				replay_data = new Array();
				replayload_progressbar(' . round(100 / ($arr['replay_datapart'] + 2) * 2) . ');
				jQuery.cachedScript("gamedata/replays/' . $room_gprefix . $gamenum . '.' . $data['pid'] . '.replay.data.0.js");
				';
            writeover(GAME_ROOT . './gamedata/replays/' . $room_gprefix . $gamenum . '.' . $data['pid'] . '.replay.oprecord.js', $jreplaydata);
            $totsz += strlen($jreplaydata);
            for ($i = 0; $i < $arr['replay_datapart']; $i++) {
                $i_start = $i * $partsize;
                $i_end = min($cnt - 1, $i_start + $partsize - 1);
                $xdata = array();
                for ($k = $i_start; $k <= $i_end; $k++) {
                    array_push($xdata, json_decode(mgzdecode(base64_decode(file_get_contents($opdatalist[$k]))), true));
                }
                $jreplaydata = compatible_json_encode($xdata);
                $jreplaydata = '___temp_s = new String(\'' . base64_encode(gzencode($jreplaydata, 9)) . '\');
					replay_part = JSON.parse(JXG.decompress(___temp_s));
					replay_data = replay_data.concat(replay_part);
					delete replay_part;
					delete ___temp_s;
					replayload_progressbar(' . round(100 / ($arr['replay_datapart'] + 2) * ($i + 3)) . ');
					';
                if ($i + 1 < $arr['replay_datapart']) {
                    $jreplaydata .= 'jQuery.cachedScript("gamedata/replays/' . $room_gprefix . $gamenum . '.' . $data['pid'] . '.replay.data.' . ($i + 1) . '.js");';
                } else {
                    $jreplaydata .= 'replay_init();';
                }
                writeover(GAME_ROOT . './gamedata/replays/' . $room_gprefix . $gamenum . '.' . $data['pid'] . '.replay.data.' . $i . '.js', $jreplaydata);
                $totsz += strlen($jreplaydata);
            }
            $totsz = round($totsz / 1024 * 10) / 10 . 'KB';
            writeover(GAME_ROOT . './gamedata/replays/' . $room_gprefix . $gamenum . '.' . $data['pid'] . '.rep', base64_encode($curdatalib) . ',' . $gamenum . ',' . base64_encode($data['name']) . ',' . $totsz . ',' . $cnt . ',');
            //生成缩略图
            $pic_len = 1000;
            $pix_time = $gametimelen / $pic_len;
            $cur = 0;
            $ca = count($arr['replay_optime']);
            $content = array();
            for ($i = 0; $i < $pic_len * 4; $i++) {
                for ($j = 0; $j < 3; $j++) {
                    $content[$i][$j] = 255;
                }
            }
            for ($i = 0; $i < $pic_len * 4; $i++) {
                $csz[$i] = 0;
            }
            for ($i = 0; $i < $pic_len; $i++) {
                $cz = 0;
                while ($cur < $ca && $arr['replay_optime'][$cur] <= $pix_time * ($i + 1)) {
                    $cz++;
                    $cur++;
                }
                //对相邻像素的渲染强度
                if ($pix_time <= 1.2) {
                    $render_strength = 0.6;
                } else {
                    if ($pix_time <= 2) {
                        $render_strength = 0.35;
                    } else {
                        if ($pix_time <= 3) {
                            $render_strength = 0.15;
                        } else {
                            $render_strength = 0;
                        }
                    }
                }
                //单像素最高标准是0.3秒一次操作
                $color = 255 * $cz / ($pix_time / 0.3);
                //对相邻像素渲染
                $r = $render_strength;
                $cs = $i;
                while ($r > 0.1 && $cs + 1 < $pic_len) {
                    $cs++;
                    $csz[$cs] += $r * $color;
                    $r *= $render_strength;
                }
                $r = $render_strength;
                $cs = $i;
                while ($r > 0.1 && $cs > 0) {
                    $cs--;
                    $csz[$cs] += $r * $color;
                    $r *= $render_strength;
                }
                $csz[$i] += $color;
            }
            for ($i = 0; $i < $pic_len; $i++) {
                if ($csz[$i] >= 255) {
                    $csz[$i] = 255;
                }
                $csz[$i] = (int) round($csz[$i]);
                $content[$i][1] = 255 - $csz[$i];
                $content[$i][2] = 255 - $csz[$i];
            }
            file_put_contents(GAME_ROOT . './gamedata/replays/' . $room_gprefix . $gamenum . '.' . $data['pid'] . '.rep.bmp', \bmp_util\gen_bmp($content, $pic_len, 1));
            $data['opnum'] = -$cnt;
            if ($data['name'] == $winname) {
                $data['opnum'] = -2000000000;
            }
            array_push($plis, $data);
        }
    }
    $hs = array();
    foreach ($plis as $key) {
        if (!isset($hs[$key['opnum']])) {
            $hs[$key['opnum']] = array();
        }
        array_push($hs[$key['opnum']], $key);
    }
    ksort($hs);
    $sstr = '';
    foreach ($hs as $key => $value) {
        foreach ($value as $wz) {
            $sstr .= $wz['pid'] . ',';
        }
    }
    file_put_contents(GAME_ROOT . './gamedata/replays/' . $room_gprefix . $gamenum . '.rep.index', $sstr);
    clear_dir(GAME_ROOT . './gamedata/tmp/replay/' . $room_prefix . '_/', 1);
    global $___MOD_TMP_FILE_DIRECTORY;
    clear_dir($___MOD_TMP_FILE_DIRECTORY . $room_prefix . '_/', 1);
}
Esempio n. 17
0
 if ($_POST['install'] || $_POST['install_upload']) {
     clear_dir($module_content_folder);
     // download zip file from update.atutor.ca and write into module content folder
     if ($_POST["install_upload"]) {
         $local_module_zip_file = $module_content_folder . $_FILES['modulefile']['name'];
     } else {
         $local_module_zip_file = $module_content_folder . $module_list_array[$_POST["id"]]['history'][0]['filename'];
     }
     $fp = fopen($local_module_zip_file, "w");
     fwrite($fp, $file_content);
     fclose($fp);
     // unzip uploaded file to module's content directory
     include_once AT_INCLUDE_PATH . '/classes/pclzip.lib.php';
     $archive = new PclZip($local_module_zip_file);
     if ($archive->extract(PCLZIP_OPT_PATH, $module_content_folder) == 0) {
         clear_dir($module_content_folder);
         $msg->addError('CANNOT_UNZIP');
     }
     if (!$msg->containsErrors()) {
         // find unzip module folder name
         clearstatcache();
         if ($dh = opendir($module_content_folder)) {
             while (($module_folder = readdir($dh)) !== false) {
                 if ($module_folder != "." && $module_folder != ".." && is_dir($module_content_folder . $module_folder)) {
                     break;
                 }
             }
             closedir($dh);
         }
         if ($module_folder == "." || $module_folder == ".." || !isset($module_folder)) {
             $msg->addError('EMPTY_ZIP_FILE');
Esempio n. 18
0
<?php

(!defined('M_COM') || !defined('M_ADMIN')) && exit('No Permission');
aheader();
backallow('other') || amessage('no_apermission');
if (!submitcheck('brebuilds')) {
    tabheader($sid ? lang('refsubsyca') : lang('refmssyscac'), $actionid . 'rebuilds', "?entry=rebuilds{$param_suffix}", 2);
    trbasic(lang('bassyscac'), '', "<input class=\"checkbox\" type=\"checkbox\" name=\"arcdeal[based]\" value=\"1\" checked disabled>", '');
    trbasic(lang('catcnocac'), '', "<input class=\"checkbox\" type=\"checkbox\" name=\"arcdeal[cnode]\" value=\"1\">", '');
    !$sid && trbasic(lang('allsitecac'), '', "<input class=\"checkbox\" type=\"checkbox\" name=\"arcdeal[allsite]\" value=\"1\">", '');
    tabfooter('brebuilds');
    a_guide('rebuildcache');
} else {
    $exceptstr = '';
    if (empty($arcdeal['cnode'])) {
        $exceptstr .= ($exceptstr ? ',' : '') . 'cnodes';
    }
    if (!empty($arcdeal['allsite'])) {
        clear_dir(M_ROOT . './dynamic/cache', false, $exceptstr);
    }
    rebuild_cache(empty($arcdeal['allsite']) ? $sid : '-1', $exceptstr);
    amessage(($sid ? 'subsite' : 'msite') . 'syscacreffin', M_REFERER);
}
Esempio n. 19
0
/**
 * 删除目录下所有文件
 * <br/>
 * @param string $path
 */
function clear_dir($dirname)
{
    if ($dir = @dir($dirname)) {
        $dir->rewind();
        while ($file = $dir->read()) {
            if (!in_array($file, array('.', '..', '.svn', '.gitignore', 'Thumbs.db'))) {
                if (is_dir($dirname . '/' . $file)) {
                    clear_dir($dirname . '/' . $file);
                    !@rmdir($dirname . '/' . $file);
                } else {
                    !@unlink($dirname . '/' . $file);
                }
            }
        }
        $dir->close();
    }
}
if (isset($_GET['search_st'])) {
    if (isset($_POST['search'])) {
        search_file($_POST['search'], $_POST['dir']);
    }
    exit;
}
if (isset($_GET['rename_all'])) {
    echo "<center><table border=\"1\" width=600 rules=\"groups\">\n  <thead><br>\n    <tr><td>";
    rename_all(urldecode($_POST['d']), $_POST['prefix'], $_POST['name'], $_POST['del']);
    exit;
}
if (isset($_GET['special_d'])) {
    echo "<center><table border=\"1\" width=600 rules=\"groups\">\n  <thead><br>\n    <tr><td>";
    $way = $_POST['way'];
    if ($way == "1") {
        clear_dir($_GET['file']);
        exit;
    }
    if ($way == "2") {
        echo "<center><table border=\"1\" width=600 rules=\"groups\">\n  <thead><br>\n\n    <tr><td>";
        ?>
<form action=<?php 
        echo $surl;
        ?>
?&<?php 
        echo $word;
        ?>
&rename_all method="post">
Prefix:<br><input type="text" name="prefix"><br>
Name:<br><input type="text" name="name"><br>
<input type="hidden" name="d" value=<?php 
Esempio n. 21
0
 if ($_POST['install'] || $_POST['import']) {
     clear_dir($theme_content_folder);
     // download zip file from update.atutor.ca and write into theme content folder
     if ($_POST["import"]) {
         $local_theme_zip_file = $theme_content_folder . $filename;
     } else {
         $local_theme_zip_file = $theme_content_folder . $theme_list_array[$_POST["id"]]['history'][0]['filename'];
     }
     $fp = fopen($local_theme_zip_file, "w");
     fwrite($fp, $file_content);
     fclose($fp);
     // unzip uploaded file to theme's content directory
     include_once AT_INCLUDE_PATH . '/classes/pclzip.lib.php';
     $archive = new PclZip($local_theme_zip_file);
     if ($archive->extract(PCLZIP_OPT_PATH, $theme_content_folder) == 0) {
         clear_dir($theme_content_folder);
         $msg->addError('CANNOT_UNZIP');
     }
     if (!$msg->containsErrors()) {
         // find unzip theme folder name
         clearstatcache();
         if ($dh = opendir($theme_content_folder)) {
             while (($this_theme_folder = readdir($dh)) !== false) {
                 if ($this_theme_folder != "." && $this_theme_folder != ".." && is_dir($theme_content_folder . $this_theme_folder)) {
                     break;
                 }
             }
             closedir($dh);
         }
         if ($this_theme_folder == "." || $this_theme_folder == ".." || !isset($this_theme_folder)) {
             $msg->addError('EMPTY_ZIP_FILE');
Esempio n. 22
0
 function arc_delete($isuser = 0)
 {
     global $db, $tblprefix, $enablestatic, $cotypes;
     if (empty($this->aid)) {
         return false;
     }
     $this->basic_data();
     if ($isuser && $this->archive['checked']) {
         return false;
     }
     //删除相应的txt存储文本
     $this->detail_data();
     foreach ($this->namepres as $k) {
         txtunlink($k);
     }
     $wherestr = "WHERE aid='" . $this->aid . "'";
     foreach (array('comments', 'favorites', 'subscribes', 'answers', 'arecents', 'purchases', 'offers', 'replys') as $var) {
         //????????????????
         $db->query("DELETE FROM {$tblprefix}{$var} {$wherestr}", 'UNBUFFERED');
     }
     $db->query("DELETE FROM {$tblprefix}albums WHERE aid='" . $this->aid . "' OR pid='" . $this->aid . "'", 'UNBUFFERED');
     //合辑关系全部删除
     //删除相关已生成的静态文件
     $arcurl = arc_format($this->archive);
     for ($i = 1; $i <= $this->channel['addnum']; $i++) {
         m_unlink(m_parseurl($arcurl, array('addno' => $i)));
     }
     $db->query("DELETE FROM {$tblprefix}archives_" . $this->archive['chid'] . " {$wherestr}", 'UNBUFFERED');
     $db->query("DELETE FROM {$tblprefix}archives_sub {$wherestr}", 'UNBUFFERED');
     $db->query("DELETE FROM {$tblprefix}archives_rec {$wherestr}", 'UNBUFFERED');
     $db->query("DELETE FROM {$tblprefix}archives {$wherestr}", 'UNBUFFERED');
     //数量统计
     $this->auser->basedeal('archive', 0);
     $this->archive['checked'] && $this->auser->basedeal('check', 0);
     $uploadsize = 0;
     $query = $db->query("SELECT * FROM {$tblprefix}userfiles WHERE tid='1' AND aid='" . $this->aid . "'");
     while ($item = $db->fetch_array($query)) {
         $ufile = local_file($item['url']);
         @unlink($ufile);
         clear_dir($ufile . '_s', true);
         $uploadsize += ceil($item['size'] / 1024);
     }
     $this->auser->updateuptotal($uploadsize, 'reduce', 1);
     $db->query("DELETE FROM {$tblprefix}userfiles {$wherestr}", 'UNBUFFERED');
     $this->init();
     return true;
 }