function restore() { global $config, $lang; if (!isset($_POST['file'])) { $_POST['file'] = $_GET['file']; } @set_error_handler("SXD_errorHandler", E_ALL ^ E_NOTICE); $buttons = ""; echo tpl_page(tpl_process($lang['dumper_18']), $buttons); $this->SET['last_action'] = 1; $this->SET['last_db_restore'] = DBNAMES; $file = isset($_POST['file']) ? $_POST['file'] : ''; $file = str_replace("\\", "/", $file); $file = str_replace("..", "", $file); $file = str_replace("/", "", $file); if (stripos($file, "php") !== false) { die("Hacking attempt!"); } $db = $this->SET['last_db_restore']; if (!$db) { echo tpl_l($lang['dumper_19'], C_ERROR); exit; } echo tpl_l("{$lang['dumper_20']} `{$db}`."); mysql_select_db($db) or trigger_error($lang['dumper_4'] . mysql_error(), E_USER_ERROR); // Определение формата файла if (preg_match("/^(.+?)\\.sql(\\.(bz2|gz))?\$/", $file, $matches)) { if (isset($matches[3]) && $matches[3] == 'bz2') { $this->SET['comp_method'] = 2; } elseif (isset($matches[2]) && $matches[3] == 'gz') { $this->SET['comp_method'] = 1; } else { $this->SET['comp_method'] = 0; } $this->SET['comp_level'] = ''; if (!file_exists(PATH . "/{$file}")) { echo tpl_l($lang['dumper_21'], C_ERROR); exit; } echo tpl_l("{$lang['dumper_22']} `{$file}`."); $file = $matches[1]; } else { echo tpl_l($lang['dumper_21'], C_ERROR); exit; } echo tpl_l(str_repeat("-", 60)); $fp = $this->fn_open($file, "r"); $this->file_cache = $sql = $table = $insert = ''; $is_skd = $query_len = $execute = $q = $t = $i = $aff_rows = 0; $limit = 300; $index = 4; $tabs = 0; $cache = ''; $info = array(); $convert = false; // Установка кодировки соединения if ($this->mysql_version > 40101 && (CHARSET != 'auto' || $this->forced_charset)) { // Кодировка по умолчанию, если в дампе не указана кодировка mysql_query("SET NAMES '" . $this->restore_charset . "'") or trigger_error($lang['dumper_6'] . mysql_error(), E_USER_ERROR); echo tpl_l("{$lang['dumper_7']} `" . $this->restore_charset . "`.", C_WARNING); $last_charset = $this->restore_charset; } else { $last_charset = ''; } $last_showed = ''; while (($str = $this->fn_read_str($fp)) !== false) { if (empty($str) || preg_match("/^(#|--)/", $str)) { if (!$is_skd && preg_match("/^#SKD101\\|/", $str)) { $info = explode("|", $str); echo tpl_s(0, $t / $info[4]); $is_skd = 1; } continue; } $query_len += strlen($str); if (!$insert && preg_match("/^(INSERT INTO `?([^` ]+)`? .*?VALUES)(.*)\$/i", $str, $m)) { if ($table != $m[2]) { $table = $m[2]; $tabs++; $cache .= tpl_l("Таблица `{$table}`."); $last_showed = $table; $i = 0; if ($is_skd) { echo tpl_s(100, $t / $info[4]); } } $insert = $m[1] . ' '; $sql .= $m[3]; $index++; $info[$index] = isset($info[$index]) ? $info[$index] : 0; $limit = round($info[$index] / 20); $limit = $limit < 300 ? 300 : $limit; if ($info[$index] > $limit) { echo $cache; $cache = ''; echo tpl_s(0 / $info[$index], $t / $info[4]); } } else { $sql .= $str; if ($insert) { $i++; $t++; if ($is_skd && $info[$index] > $limit && $t % $limit == 0) { echo tpl_s($i / $info[$index], $t / $info[4]); } } } if (!$insert && preg_match("/^CREATE TABLE (IF NOT EXISTS )?`?([^` ]+)`?/i", $str, $m) && $table != $m[2]) { $table = $m[2]; $insert = ''; $tabs++; $is_create = true; $i = 0; } if ($sql) { if (preg_match("/;\$/", $str)) { $sql = rtrim($insert . $sql, ";"); if (empty($insert)) { if ($this->mysql_version < 40101) { $sql = preg_replace("/ENGINE\\s?=/", "TYPE=", $sql); } elseif (preg_match("/CREATE TABLE/i", $sql)) { // Выставляем кодировку соединения if (preg_match("/(CHARACTER SET|CHARSET)[=\\s]+(\\w+)/i", $sql, $charset)) { if (!$this->forced_charset && $charset[2] != $last_charset) { if (CHARSET == 'auto') { if ($config['charset'] == "utf-8" and $charset[2] == "cp1251") { $convert = true; $charset[2] = "utf8"; $this->restore_charset = "utf8"; } mysql_query("SET NAMES '" . $charset[2] . "'") or trigger_error("{$lang['dumper_6']}{$sql}<BR>" . mysql_error(), E_USER_ERROR); $cache .= tpl_l("{$lang['dumper_7']} `" . $charset[2] . "`.", C_WARNING); $last_charset = $charset[2]; } else { $cache .= tpl_l($lang['dumper_8'], C_ERROR); $cache .= tpl_l($lang['dumper_9'] . ' `' . $table . '` -> ' . $charset[2] . ' (' . $lang['dumper_10'] . ' ' . $this->restore_charset . ')', C_ERROR); } } // Меняем кодировку если указано форсировать кодировку if ($this->forced_charset or $convert) { $sql = preg_replace("/(\\/\\*!\\d+\\s)?((COLLATE)[=\\s]+)\\w+(\\s+\\*\\/)?/i", '', $sql); $sql = preg_replace("/((CHARACTER SET|CHARSET)[=\\s]+)\\w+/i", "\\1" . $this->restore_charset . $this->restore_collate, $sql); } } elseif (CHARSET == 'auto') { // Вставляем кодировку для таблиц, если она не указана и установлена auto кодировка $sql .= ' DEFAULT CHARSET=' . $this->restore_charset . $this->restore_collate; if ($this->restore_charset != $last_charset) { mysql_query("SET NAMES '" . $this->restore_charset . "'") or trigger_error("{$lang['dumper_6']}{$sql}<BR>" . mysql_error(), E_USER_ERROR); $cache .= tpl_l("{$lang['dumper_7']} `" . $this->restore_charset . "`.", C_WARNING); $last_charset = $this->restore_charset; } } } if ($last_showed != $table) { $cache .= tpl_l("{$lang['dumper_9']} `{$table}`."); $last_showed = $table; } } elseif ($this->mysql_version > 40101 && empty($last_charset)) { // Устанавливаем кодировку на случай если отсутствует CREATE TABLE mysql_query("SET {$this->restore_charset} '" . $this->restore_charset . "'") or trigger_error("{$lang['dumper_6']}{$sql}<BR>" . mysql_error(), E_USER_ERROR); echo tpl_l("{$lang['dumper_7']} `" . $this->restore_charset . "`.", C_WARNING); $last_charset = $this->restore_charset; } $insert = ''; $execute = 1; } if ($query_len >= 65536 && preg_match("/,\$/", $str)) { $sql = rtrim($insert . $sql, ","); $execute = 1; } if ($execute) { $q++; if ($convert) { $sql = iconv('WINDOWS-1251', 'UTF-8//IGNORE', $sql); } mysql_query($sql) or trigger_error($lang['dumper_23'] . mysql_error(), E_USER_ERROR); if (preg_match("/^insert/i", $sql)) { $aff_rows += mysql_affected_rows(); } $sql = ''; $query_len = 0; $execute = 0; } } } echo $cache; echo tpl_s(1, 1); echo tpl_l(str_repeat("-", 60)); echo tpl_l($lang['dumper_24'], C_RESULT); if (isset($info[3])) { echo tpl_l("{$lang['dumper_25']} {$info[3]}", C_RESULT); } echo tpl_l("{$lang['dumper_26']} {$q}", C_RESULT); echo tpl_l("{$lang['dumper_27']} {$tabs}", C_RESULT); echo tpl_l("{$lang['dumper_28']} {$aff_rows}", C_RESULT); $this->tabs = $tabs; $this->records = $aff_rows; $this->size = filesize(PATH . $this->filename); $this->comp = $this->SET['comp_method'] * 10 + $this->SET['comp_level']; $this->fn_close($fp); }
function main() { $this->comp_levels = array('9' => 'Level 9 (Cao nhất)', '8' => 'Level 8', '7' => 'Level 7', '6' => 'Level 6', '5' => 'Level 5 (Trung bình)', '4' => 'Level 4', '3' => 'Level 3', '2' => 'Level 2', '1' => 'Level 1 (Bình thường)', '0' => 'Không tối ưu hóa '); if (function_exists("bzopen")) { $this->comp_methods[2] = 'BZip2'; } if (function_exists("gzopen")) { $this->comp_methods[1] = 'GZip'; } $this->comp_methods[0] = 'No compression'; if (count($this->comp_methods) == 1) { $this->comp_levels = array('0' => 'No compression'); } $dbs = $this->db_select(); $this->vars['db_backup'] = $this->fn_select($dbs, $this->SET['last_db_backup']); $this->vars['db_restore'] = $this->fn_select($dbs, $this->SET['last_db_restore']); $this->vars['comp_levels'] = $this->fn_select($this->comp_levels, $this->SET['comp_level']); $this->vars['comp_methods'] = $this->fn_select($this->comp_methods, $this->SET['comp_method']); $this->vars['tables'] = $this->SET['tables']; $this->vars['files'] = $this->fn_select($this->file_select(), ''); $buttons = "<INPUT TYPE=submit VALUE=Okie><INPUT TYPE=button VALUE='Thoát' onClick=\"location.href = '" . $_SERVER['PHP_SELF'] . "?reload'\">"; echo tpl_page(tpl_main(), $buttons); }
// clear permissions runSQL('DELETE FROM ' . TBL_PERMISSIONS . ' WHERE from_uid = ' . $del); $message = $lang['msg_userdel']; $smarty->assign('alert', true); } // current user permissions $result = runSQL('SELECT id, name, permissions, email FROM ' . TBL_USERS . ' ORDER BY name'); foreach ($result as $user) { // is guest ? $user['guest'] = $user['id'] == $config['guestid'] ? 1 : 0; // don't show guest user if guest is disabled if ($config['denyguest'] && $user['guest']) { continue; } // collect and separate permission information $user['read'] = $user['permissions'] & PERM_READ; $user['write'] = $user['permissions'] & PERM_WRITE; $user['admin'] = $user['permissions'] & PERM_ADMIN; $user['adult'] = $user['permissions'] & PERM_ADULT; $userlist[] = $user; } // make sure caches are clean clear_permission_cache(); // prepare templates tpl_page('usermanager'); $smarty->assign('userlist', $userlist); $smarty->assign('message', $message); // display templates tpl_display('users.tpl');
/** * Help Page * * Browses the manual * * @package videoDB * @author Andreas Gohr <*****@*****.**> * @version $Id: help.php,v 1.10 2004/09/20 15:15:41 andig2 Exp $ */ require_once './core/functions.php'; function _replace_anchors_callback($matches) { if (!preg_match('=^https?://=', $matches[2])) { $matches[2] = 'help.php?page=' . $matches[2]; } return $matches[1] . $matches[2] . $matches[3]; } if (empty($page)) { $page = 'index.html'; } $page = 'doc/manual/' . $page; $html = file_get_contents($page); $html = preg_replace_callback("/(<a\\s+.*?href\\s*=\\s*\")(.*?)(\".*?>)/is", '_replace_anchors_callback', $html); preg_match('=<body.*?>(.*)</body>=is', $html, $matches); $html = $matches[1]; // prepare templates tpl_page(); $smarty->assign('helptext', $html); // display templates tpl_display('help.tpl');
function main() { $this->comp_levels = array('9' => '9 (максимальная)', '8' => '8', '7' => '7', '6' => '6', '5' => '5 (средняя)', '4' => '4', '3' => '3', '2' => '2', '1' => '1 (минимальная)', '0' => 'Без сжатия'); if (function_exists("bzopen")) { $this->comp_methods[2] = 'BZip2'; } if (function_exists("gzopen")) { $this->comp_methods[1] = 'GZip'; } $this->comp_methods[0] = 'Без сжатия'; if (count($this->comp_methods) == 1) { $this->comp_levels = array('0' => 'Без сжатия'); } $dbs = $this->db_select(); $this->vars['db_backup'] = $this->fn_select($dbs, $this->SET['last_db_backup']); $this->vars['db_restore'] = $this->fn_select($dbs, $this->SET['last_db_restore']); $this->vars['comp_levels'] = $this->fn_select($this->comp_levels, $this->SET['comp_level']); $this->vars['comp_methods'] = $this->fn_select($this->comp_methods, $this->SET['comp_method']); $this->vars['tables'] = $this->SET['tables']; $this->vars['files'] = $this->fn_select($this->file_select(), ''); $buttons = "<INPUT TYPE=submit VALUE=Применить><INPUT TYPE=button VALUE=Выход onClick=\"location.href = 'dumper.php?reload'\">"; echo tpl_page(tpl_main(), $buttons); }
function main() { $this->comp_levels = array('9' => '9 (Maximum)', '8' => '8', '7' => '7', '6' => '6', '5' => '5 (Medium)', '4' => '4', '3' => '3', '2' => '2', '1' => '1 (Minimum)', '0' => 'No compression '); if (function_exists("bzopen")) { $this->comp_methods[2] = 'BZip2'; } if (function_exists("gzopen")) { $this->comp_methods[1] = 'GZip'; } $this->comp_methods[0] = 'No compression'; if (count($this->comp_methods) == 1) { $this->comp_levels = array('0' => 'No compression'); } $dbs = $this->db_select(); $this->vars['db_backup'] = $this->fn_select($dbs, $this->SET['last_db_backup']); $this->vars['db_restore'] = $this->fn_select($dbs, $this->SET['last_db_restore']); $this->vars['comp_levels'] = $this->fn_select($this->comp_levels, $this->SET['comp_level']); $this->vars['comp_methods'] = $this->fn_select($this->comp_methods, $this->SET['comp_method']); $this->vars['tables'] = $this->SET['tables']; $this->vars['files'] = $this->fn_select($this->file_select(), ''); $buttons = "<INPUT TYPE=submit VALUE=Apply><INPUT TYPE=button VALUE='Cancel' onClick=\"location.href = '" . $_SERVER['PHP_SELF'] . "?reload'\">"; echo tpl_page(tpl_main(), $buttons); }
$title = preg_replace('/(' . $q . ')/Ui', '<em>\\1</em>', $title); $ret .= "<li id='" . $item['id'] . "'>" . $title . "</li>"; } $ret = "<ul>{$ret}</ul>"; echo $ret; exit; } // store query result in session for prev/next navigation session_set('query_result', array_extract($result, 'id')); } // process asynchronous refresh if ($ajax_render) { ajax_render(); } // prepare templates tpl_page('search', $q); tpl_list($result); $smarty->assign('q', $q); $smarty->assign('q_q', formvar($q)); $smarty->assign('search_fields', $search_fields); $smarty->assign('genreselect', out_genres($genres)); $smarty->assign('genres', out_genres2($genres)); //2015-10-6 Alex ADD start $smarty->assign('studioselect', out_studios($studios)); $smarty->assign('studios', out_studios2($studios)); //2015-10-6 Alex ADD end $smarty->assign('engine', $config['engine']); $smarty->assign('actors', prepare_cast($actors)); // person search? if ($isname && $config['actorpics']) { $smarty->assign('imgurl', getActorThumbnail(urldecode(preg_replace('/"|"/', '', formvar($q)))));
created, !ISNULL(' . TBL_USERSEEN . '.video_id) AS seen, ' . TBL_MEDIATYPES . '.name AS mediatypename FROM ' . TBL_DATA . ' LEFT JOIN ' . TBL_USERS . ' ON ' . TBL_DATA . '.owner_id = ' . TBL_USERS . '.id LEFT JOIN ' . TBL_USERSEEN . ' ON ' . TBL_DATA . '.id = ' . TBL_USERSEEN . '.video_id AND ' . TBL_USERSEEN . '.user_id = ' . get_current_user_id() . ' LEFT JOIN ' . TBL_LENT . ' ON ' . TBL_DATA . '.diskid = ' . TBL_LENT . '.diskid LEFT JOIN ' . TBL_MEDIATYPES . ' ON ' . TBL_DATA . '.mediatype = ' . TBL_MEDIATYPES . '.id' . "\n {$JOINS} \n WHERE {$WHERES}\n ORDER BY {$ORDER}\n\t\t {$LIMIT}"; $result = runSQL($SQL); // store query result in session for prev/next navigation session_set('query_result', array_extract($result, 'id')); // process asynchronous refresh if ($ajax_render) { ajax_render(); } // prepare tpl_page('browse'); tpl_list($result); tpl_filters($filter, $showtv); // caching enabled? if ($config['http_caching']) { require_once './core/httpcache.php'; httpCacheCaptureStart(); } $smarty->assign('moreless', true); // show more/less control in list view // allow data export foreach (array('xls', 'pdf', 'xml', 'rss') as $export) { if ($config[$export]) { $smarty->assign($export, 'index.php?'); } }
// Check that user entered stuff in username and password boxes if (!empty($username) && !empty($password)) { // Lets check the format of username to make sure its ok if (!preg_match('/[a-z]/i', $username)) { $error = $lang['msg_invalidchar']; } else { $res = runSQL("SELECT passwd, id FROM " . TBL_USERS . " WHERE name='{$username}'"); // if the md5 of the entered password = whats in the database then // set all the cookies up again if (md5($password) == $res[0]['passwd']) { $userid = $res[0]['id']; login_as($userid, $permanent); $login = true; } else { $error = $lang['msg_loginfailed']; } } } if ($login) { if (empty($refer)) { $refer = 'index.php'; } redirect(urldecode($refer)); } else { // prepare templates tpl_page('multiuser'); $smarty->assign('error', $error); $smarty->assign('refer', $refer); // display templates tpl_display('login.tpl'); }
* iframe modes * 0: "classic" mode - no use of iframes * 1: "iframe" mode * used to display template containing iframe * 2: "iframe" mode * used to display iframe contents */ if ($iframe == 1) { // mode 1: display template with url $url = request(true); } else { // mode 0 or 2: fetch data for display // fetch URL $fetchtime = time(); $page = request(); $fetchtime = time() - $fetchtime; // convert HTML for output $page = fixup_HTML($page); } if ($iframe == 2) { // mode 2: display data into iframe echo $page; exit; } // mode 0 or 1: prepare templates tpl_page('imdbbrowser'); $smarty->assign('url', $url); $smarty->assign('page', $page); $smarty->assign('fetchtime', $fetchtime); // display templates tpl_display('trace.tpl');
if (sizeof($breadcrumbs['crumbs']) > 10) { $breadcrumbs['crumbs'] = array_slice($breadcrumbs['crumbs'], 0, -10); } $breadcrumbs['current'] = $id; $breadcrumbs['crumbs'][] = array('id' => $id, 'title' => $video['title']); $size = sizeof($breadcrumbs['crumbs']); for ($i; $i < $size - 1; $i++) { if ($breadcrumbs['crumbs'][$i]['id'] == $id) { unset($breadcrumbs['crumbs'][$size - 1]); break; } } session_set('breadcrumbs', $breadcrumbs); } // prepare templates tpl_page('detailview', $video['title']); if (!empty($id)) { tpl_show($video); } // caching enabled? if ($config['http_caching']) { require_once './core/httpcache.php'; httpCacheCaptureStart(); } // display templates smarty_display('header.tpl'); if (!$config['http_caching']) { flush(); } if (!empty($id)) { smarty_display('show.tpl', $id);
// set default engine to imdb if not set if (empty($config['enginedefault'])) { $config['enginedefault'] = 'imdb'; } // check permissions again - they may have changed if (!check_permission(PERM_ADMIN)) { redirect('login.php'); } // destroy cookies if required if ($_COOKIE['VDBusername'] && !$config['multiuser']) { setcookie('VDBpassword', '', time() - 7200); setcookie('VDBusername', '', time() - 7200); setcookie('VDBuserid', '', time() - 7200); } // cache maintenance if ($cacheempty) { // clear thumbnail cache runSQL('DELETE FROM ' . TBL_CACHE); // clean HTTP cache cache_prune_folders(CACHE . '/' . CACHE_HTML . '/', 0, true, false, '*', (int) $config['hierarchical']); // clean Smarty as well $smarty->clearAllCache(); } // prepare options $setup = setup_mkOptions(false); // prepare templates tpl_page('configview'); $smarty->assign('setup', $setup); $smarty->assign('cacheclear', $cacheempty); // display templates tpl_display('setup.tpl');
$user_id = get_current_user_id(); // really shouldn't happen if (empty($user_id)) { errorpage('Access denied', 'You don\'t have enough permissions to access this ' . 'page. Please <a href="login.php">login</a> first. ' . '(This feature is not available in Single User Mode)'); } // save data if ($save) { // convert languages array back into string $languageflags = @join('::', $languages); // insert data foreach ($SETUP_USER as $opt) { $SQL = "REPLACE INTO " . TBL_USERCONFIG . " (user_id, opt, value) \n VALUES ('" . addslashes($user_id) . "', '{$opt}', '" . addslashes(${$opt}) . "')"; runSQL($SQL); } // update session variables update_session(); // reload config load_config(true); /* // clear compiled templates for new template AG: should not be required $smarty->clear_compiled_tpl(null, $config['cacheid']); */ } // prepare options $setup = setup_mkOptions(true); // prepare templates tpl_page('profile'); $smarty->assign('setup', $setup); // display templates tpl_display('profile.tpl');
function main() { $this->comp_levels = array('9' => TEXT_DUMPER_MAX, '8' => '8', '7' => '7', '6' => '6', '5' => TEXT_DUMPER_MED, '4' => '4', '3' => '3', '2' => '2', '1' => TEXT_DUMPER_MIN, '0' => TEXT_DUMPER_NO); // if (function_exists("bzopen")) { // $this->comp_methods[2] = 'BZip2'; // } if (function_exists("gzopen")) { $this->comp_methods[1] = 'GZip'; } $this->comp_methods[0] = TEXT_DUMPER_NO; if (count($this->comp_methods) == 1) { $this->comp_levels = array('0' => TEXT_DUMPER_NO); } $dbs = $this->db_select(); $this->vars['db_backup'] = $this->fn_select($dbs, $this->SET['last_db_backup']); $this->vars['db_restore'] = $this->fn_select($dbs, $this->SET['last_db_restore']); $this->vars['comp_levels'] = $this->fn_select($this->comp_levels, $this->SET['comp_level']); $this->vars['comp_methods'] = $this->fn_select($this->comp_methods, $this->SET['comp_method']); $this->vars['tables'] = $this->SET['tables']; $this->vars['files'] = $this->fn_select($this->file_select(), ''); $buttons = "<span class=button><button type=submit value=" . TEXT_DUMPER_SUBMIT . ">" . TEXT_DUMPER_SUBMIT . "</button></span>"; echo tpl_page(tpl_main(), $buttons); }