Example #1
0
function update_file($var, $upload_path, $file_name_prefix, $old_file_name)
{
    if (isset($_REQUEST['is_' . $var]) && $_REQUEST['is_' . $var] && isset($_FILES[$var])) {
        if ($_FILES[$var]['error'] == UPLOAD_ERR_OK) {
            if ($old_file_name != '') {
                delete_file($upload_path, $old_file_name);
            }
            return insert_file($var, $upload_path, $file_name_prefix);
        } else {
            return $old_file_name;
        }
    } else {
        if ($old_file_name != '') {
            delete_file($upload_path, $old_file_name);
        }
        return '';
    }
}
Example #2
0
 * License:     Creative Commons - Attribution-Noncommercial-Share Alike 3.0 Unported
 * Link:        http://creativecommons.org/licenses/by-nc-sa/3.0/
 * -----------------------------------------------------------------------
 * Began:       2011
 * Date:        $Date: 2011-10-24 11:54:02 +0200 $
 * -----------------------------------------------------------------------
 * @author      $Author: Edd, Exinaus, Shw  $
 * @copyright   2011-2012 Edd - Aleksandr Ustinov
 * @link        http://wot-news.com
 * @package     Clan Stat
 * @version     $Rev: 2.2.0 $
 *
 */
if (isset($_POST['recdb'])) {
    recreat_db();
    insert_file(LOCAL_DIR . '/sql/clan.sql');
    if (isset($_POST['clan'])) {
        $config['clan'] = $_POST['clan'];
    } else {
        $config['clan'] = '37';
    }
    if (isset($_POST['lang'])) {
        $config['lang'] = $_POST['lang'];
    } else {
        $config['lang'] = 'ru';
    }
    if (isset($_POST['server'])) {
        $config['server'] = $_POST['server'];
    } else {
        $config['server'] = 'ru';
    }
Example #3
0
                 $extensions = get_extensions();
                 echo "<strong>Valid Types:</strong><pre><ul>{$extensions}</ul></pre>";
                 echo '</div>';
             }
         } elseif (POST('addfinalok') == 'Add File') {
             $tmp_path = POST("tmpname");
             $file_name = POST("fn");
             $file_extension = '.' . pathinfo($file_name, PATHINFO_EXTENSION);
             if (file_exists($tmp_path)) {
                 $category = explode(' - ', POST('category'))[0];
                 $subcategory = explode(' - ', POST('category'))[1];
                 $category_id = get_category_id($category);
                 $subcategory_id = get_subcategory_id($category_id, $subcategory);
                 $license_id = get_license_id(POST('license'));
                 $user_id = get_user_id(SESSION());
                 $file_id = insert_file($file_name, $user_id, $category_id, $subcategory_id, $license_id, POST('description'), POST('fsize'), sha1_file($tmp_path));
                 if ($file_id > 0) {
                     //echo "<code>rename " . $tmp_path . " to " . $DATA_DIR . $file_id . '</code>';
                     rename($tmp_path, $DATA_DIR . $file_id);
                     show_file($file_id, SESSION(), "File added successfully");
                 } else {
                     display_error("Failed to commit file <strong>{$file_extension}</strong>", array('<a href="">Add File</a>', 'Error'), $LSP_URL . '?content=add');
                 }
             } else {
                 display_error("Sorry, the uploaded file is no longer available.", array('<a href="">Add File</a>', 'Error'), $LSP_URL . '?content=add');
             }
         } else {
             display_error("Something went wrong");
         }
     }
 }
Example #4
0
if (!@mysql_select_db($dbname)) {
    die("MYSQL 连接成功,但当前使用的数据库 {$dbname} 不存在<br><A HREF=\"#\" onclick=\"history.back(-1)\">点击返回</A>");
}
$mysqlV = mysql_get_server_info();
if ($mysqlV > '4.1') {
    mysql_query("SET NAMES '{$Charset}'");
}
if (mysql_get_server_info() > '5.0') {
    mysql_query("SET sql_mode=''");
}
if (!$page) {
    setcookie("mysqlconfig", "{$dbhost}\t{$dbuser}\t{$dbpw}\t{$dbname}\t{$Charset}");
}
$page = intval($page);
if (is_file("{$page}.sql")) {
    insert_file("{$page}.sql");
    $page++;
    echo "正在导入第{$page}卷,请稍候...<META HTTP-EQUIV=REFRESH CONTENT='0;URL=?page={$page}'>";
    exit;
} else {
    echo "数据导入完毕,如果你是从旧空间转移数据到新空间,请把旧空间/data/目录下的全部文件移到新空间对应的/data/目录里.但mysql_config.php不必移.因为新的数据库配置与旧的一般不相同,因而你需要手工配置好新空间的这个文件mysql_config.php";
}
function insert_file($file, $replace = '')
{
    global $Charset;
    $readfiles = read_file($file);
    if ($replace) {
        $readfiles = str_replace('$timestamp', "{$timestamp}", $readfiles);
    }
    $detail = explode("\n", $readfiles);
    $count = count($detail);
Example #5
0
function add_multiclan($post, $lang)
{
    global $db, $dbprefix;
    //print_r($post); die;
    unset($post['multiadd']);
    if ($post['id'] && $post['prefix'] && $post['sort']) {
        if (is_numeric($post['id'])) {
            if (preg_match('/^\\d/', $post['prefix']) == 0 && strlen(preg_replace('/(.*)_/', '$1', $post['prefix'])) <= 5) {
                if (ctype_alnum(preg_replace('/(.*)_/', '$1', $post['prefix']))) {
                    $sql = "SELECT COUNT(id) FROM multiclan WHERE id = '" . $post['id'] . "';";
                    $q = $db->prepare($sql);
                    if ($q->execute() == TRUE) {
                        $status_clan = $q->fetchColumn();
                    } else {
                        die(show_message($q->errorInfo(), __LINE__, __FILE__, $sql));
                    }
                    $sql = "SELECT COUNT(id) FROM multiclan WHERE prefix = '" . $post['prefix'] . "';";
                    $q = $db->prepare($sql);
                    if ($q->execute() == TRUE) {
                        $status_prefix = $q->fetchColumn();
                    } else {
                        die(show_message($q->errorInfo(), __LINE__, __FILE__, $sql));
                    }
                    if ($status_clan == 0) {
                        if ($status_prefix == 0) {
                            $sql = "INSERT INTO multiclan (`" . implode("`,`", array_keys($post)) . "`) VALUES ('" . implode("','", $post) . "');";
                            $q = $db->prepare($sql);
                            if ($q->execute() != TRUE) {
                                die(show_message($q->errorInfo(), __LINE__, __FILE__, $sql));
                            }
                            insert_file(LOCAL_DIR . '/sql/clan.sql');
                            $sql = "UPDATE `config` SET \n                                value = '" . $post['id'] . "'\n                                WHERE name = 'clan';";
                            $q = $db->prepare($sql);
                            if ($q->execute() != TRUE) {
                                die(show_message($q->errorInfo(), __LINE__, __FILE__, $sql));
                            }
                            $sql = "UPDATE `config` SET \n                                value = '" . $post['server'] . "'\n                                WHERE name = 'server';";
                            $q = $db->prepare($sql);
                            if ($q->execute() != TRUE) {
                                die(show_message($q->errorInfo(), __LINE__, __FILE__, $sql));
                            }
                            $multi_get = '';
                            if (isset($_GET['multi'])) {
                                $multi_get = '&multi=' . $_GET['multi'];
                            }
                        }
                    }
                }
            }
        }
    }
    header('Location: index.php?page=main#tabs-8' . $multi_get);
    exit;
}
     $file2insert = $cfg["migrate"]["path"] . $subdir_entry . "/doc/" . $match[2][$key];
     $sql = "SELECT *\n                                  FROM site_file\n                                 WHERE fid=" . insert_file($file2insert, $match[3][$key], $file);
     $result = $db->query($sql);
     $data = $db->fetch_array($result, 1);
     $link = $cfg["file"]["base"]["webdir"] . $data["ffart"] . "/" . $data["fid"] . "/" . $data["ffname"];
     $buffer .= "[LINK=" . $link . "]" . $data["funder"] . "[/LINK]" . chr(13) . chr(10);
 }
 if ($buffer != "") {
     $content .= "[DIV=aktuell]\n[P]" . $buffer . "[/P]\n[/DIV]";
 }
 preg_match_all("/##(doc)_(.*);(.*)##/" . $preg_mod, $content, $match);
 $buffer = "";
 $add_menu_items = "";
 foreach ($match[0] as $key => $value) {
     $file2insert = $cfg["migrate"]["path"] . $subdir_entry . "/doc/" . $match[2][$key];
     $sql = "SELECT *\n                                  FROM site_file\n                                 WHERE fid=" . insert_file($file2insert, $match[3][$key], $file);
     $result = $db->query($sql);
     $data = $db->fetch_array($result, 1);
     $link = $cfg["file"]["base"]["webdir"] . $data["ffart"] . "/" . $data["fid"] . "/" . $data["ffname"];
     $buffer .= "[LINK=" . $link . "]" . $data["funder"] . "[/LINK]" . chr(13) . chr(10);
 }
 if ($buffer != "") {
     $add_menu_items = "[P]" . $buffer . "[/P]\n";
 }
 // leere marken werden entfernt
 if (preg_match("/##.*##/" . $preg_mod, $content)) {
     $content = preg_replace("/##.*##/" . $preg_mod, "", $content);
 }
 if (preg_match("/\\[P[^\\[]*\\][\\s]*\\[\\/P\\]/" . $preg_mod, $content)) {
     $content = preg_replace("/\\[P[^\\[]*\\][\\s]*\\[\\/P\\]/" . $preg_mod, "", $content);
 }
Example #7
0
    }
    }else{
    $message['text'] = $lang['admin_con_error'];
    $message['color'] = 'red';
    }

    }  **/
if (isset($_POST['newup'])) {
    $target_path = LOCAL_DIR . '/sql/';
    $target_path = $target_path . basename($_FILES['uploadedfile']['name']);
    if (file_exists($target_path)) {
        $target_path = $target_path . '_' . now();
    }
    if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
        chmod($target_path, 777);
        insert_file($target_path);
        $message['text'] = $lang['admin_db_update_msg'];
        $message['color'] = 'green';
    } else {
        $message['text'] = $lang['admin_msg_upl_3'];
        $message['color'] = 'red';
    }
}
$dir_val = scandir(ROOT_DIR . './theme/');
array_shift($dir_val);
array_shift($dir_val);
$ver = json_decode(get_url('http://wot-news.com/ajax/clanstat', $config), TRUE);
// Config
$config = update_array($config, get_config());
// Scaning /tabs/ directory
$tabs_dir = read_tabs_dir();