/** * @param $path * * @return array */ public function loadFile($path) { $content = trim(file_read($path)); $config = []; if (!empty($content)) { $config = Yaml::parse($content); } return $config; }
/** * @param $path * * @return array * @throws InvalidConfigFormatException */ public function loadFile($path) { $content = trim(file_read($path)); $config = []; if (!empty($content)) { $config = json_decode($content, true); if (!is_array($config)) { throw new InvalidConfigFormatException(s('JsonConfigDriver expects config at path %s to be a valid json file.', $path)); } } return $config; }
public function test_directory() { $dir1 = path(self::getDir(), 'dir_1/dir1'); $dir1_file = path($dir1, 'foo.txt'); $dir1_file_content = 'foo bar'; $dir2 = path(self::getDir(), 'dir_2/dir2'); $dir2_file = path($dir2, 'foo.txt'); $dir3 = path(self::getDir(), 'dir_3/dir3'); $dir3_file = path($dir3, 'foo.txt'); $dir4 = path(self::getDir(), '/dir_3/dir-3'); $dir4_name = 'dir-3'; $dir4_file = path($dir4, 'foo.txt'); $this->assertFalse(directory_exists($dir1)); directory_create($dir1); file_write($dir1_file, $dir1_file_content); $this->assertTrue(directory_exists($dir1)); $this->assertFalse(directory_exists($dir2)); directory_create(path($dir1, 'yolo')); directory_copy($dir1_file, $dir2); directory_delete($dir2); directory_copy($dir1, $dir2); $this->assertTrue(file_exists($dir2_file)); $this->assertEquals(file_read($dir1_file), file_read($dir2_file)); $this->assertFalse(directory_exists($dir3)); directory_move($dir2, $dir3); $this->assertFalse(directory_exists($dir2)); $this->assertTrue(directory_exists($dir3)); $this->assertTrue(file_exists($dir3_file)); $this->assertEquals(file_read($dir1_file), file_read($dir3_file)); $this->assertFalse(directory_exists($dir4)); directory_rename($dir3, $dir4_name); $this->assertTrue(directory_exists($dir4)); $this->assertFalse(directory_exists($dir3)); $this->assertTrue(file_exists($dir4_file)); $this->assertEquals(file_read($dir1_file), file_read($dir4_file)); $this->assertEquals(['foo.txt', 'yolo'], directory_list($dir1)); $this->assertEquals([path($dir1, 'foo.txt'), path($dir1, 'yolo')], directory_list($dir1, true)); $this->assertEquals([], directory_list('yada')); $this->assertEquals(['dir_1', 'dir_2', 'dir_3'], directory_list(self::getDir())); directory_delete(self::getDir()); $this->assertFalse(directory_exists(self::getDir())); $this->assertEquals('dir1', directory_get_name($dir1)); $this->assertEquals(self::getDir() . '/dir_1', directory_get_parent($dir1)); }
/** * Verify that product can be installed * * @param string XML file to parse * * @return mixed true on success, error message on failure */ public function verify_install($productid) { $product_file = DIR . "/includes/xml/product-{$productid}.xml"; $xml = file_read($product_file); try { $this->parse($xml); $this->import_dependencies(); } catch (vB_Exception_AdminStopMessage $e) { $args = $e->getParams(); require_once DIR . '/includes/functions_misc.php'; $message = fetch_phrase($args[0], 'error', '', false, false, -1, false); if (sizeof($args) > 1) { $args[0] = $message; $message = call_user_func_array('construct_phrase', $args); } return $message; } return true; }
function add_task($task) { $tasks = unstock(file_read(DATA_FILE)); $tasks[] = $task; file_append(DATA_FILE, stock($tasks), false); }
require_once DIR . '/includes/adminfunctions_language.php'; if (!($xml = file_read(DIR . '/install/vbulletin-language.xml'))) { echo '<p>' . sprintf($vbphrase['file_not_found'], 'vbulletin-language.xml') . '</p>'; print_cp_footer(); } echo '<p>' . sprintf($vbphrase['importing_file'], 'vbulletin-language.xml'); xml_import_language($xml); build_language(); build_language_datastore(); echo "<br /><span class=\"smallfont\"><b>{$vbphrase['ok']}</b></span></p>"; } // ############################################################################# // import style if ($vbulletin->GPC['step'] == 4) { require_once DIR . '/includes/adminfunctions_template.php'; if (!($xml = file_read(DIR . '/install/vbulletin-style.xml'))) { echo '<p>' . sprintf($vbphrase['file_not_found'], 'vbulletin-style.xml') . '</p>'; print_cp_footer(); } echo '<p>' . sprintf($vbphrase['importing_file'], 'vbulletin-style.xml'); xml_import_style($xml); build_all_styles(); echo "<br /><span class=\"smallfont\"><b>{$vbphrase['ok']}</b></span></p>"; } if ($vbulletin->GPC['step'] == 5) { $gotopage = '../' . $vbulletin->config['Misc']['admincpdir'] . '/index.php'; echo '<p align="center" class="smallfont"><a href="' . $gotopage . '/index.php">' . $vbphrase['proceed'] . '</a></p>'; echo "\n<script type=\"text/javascript\">\n"; echo "window.location=\"{$gotopage}\";"; echo "\n</script>\n"; print_upgrade_footer();
/** * Checks existince of a stupid vbcms bug that has been around since RC2 * */ function badhook_check() { if (file_exists(DIR . "/includes/xml/hooks_vbcms.xml")) { $badhookfile = file_read(DIR . "/includes/xml/hooks_vbcms.xml"); if (strpos($badhookfile, "data_preparse_bbcode_video_start")) { print_table_header("WARNING"); print_description_row("vBulletin contains a known bug that prevents AME from working. You must follow these steps or you may as well disable AME now"); print_description_row("1. Edit your <strong>includes/xml/hooks_vbcms.xml</strong> file"); print_description_row("2. Delete <strong><hook>data_preparse_bbcode_video_start</hook></strong> and save the file."); print_description_row("3. Rebuild your hooks by browsing to your Plugin Manager, edit the <strong>AME - Auto Convert URLs</strong> hook and save (you don't need to change anything)."); print_description_row("You can read more about this issue here: <a href='http://www.vbulletin.com/forum/project.php?issueid=33859' target='_blank'>http://www.vbulletin.com/forum/project.php?issueid=33859</a>"); print_table_break(); } } }
// Проверка на наличие файла в папке if (!check_file($edit_file, $files)) { $errors[] = "Sorry, but file does not exist"; } } ?> <!doctype html> <html lang="ru"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=1000"> <title>Просмотр</title> <link rel="stylesheet" href="css/normalize.css"> <link rel="stylesheet" href="css/main.css"> </head> <body> <div class="wrap"> <div class="container"> <h3>Просмотр текста</h3> <div> <?php echo file_read($edit_file); ?> </div> <a class="btn btn-back" href="index.php">Вернуться на Главную</a> </div> </div> </body> </html>
/** * Prepend contents to the beginning of file. * * @param $path * @param $content * * @return bool */ function file_prepend($path, $content) { if (file_exists($path)) { return file_write($path, $content . file_read($path)); } return file_write($path, $content); }
public function test_file_read_returns_null_for_not_existing_files() { $this->assertEquals(null, file_read('some_file')); }
<?php header("Content-type: text/html; charset=utf-8"); require 'connect.php'; //echo 'aaaaaa'; $i = 0; $j = 0; $file_r = file_read(); var_dump($file_r); $file_name = explode("~", $file_r); foreach ($file_name as $name_new) { if (!strstr($name_new, ";")) { $series_name = $name_new; $query = "SELECT `series_id` FROM `disney_series` WHERE `series_name` LIKE '" . $series_name . "'"; echo $query . "<br>"; $result = mysql_fetch_object(mysql_query($query)); $series_id = $result->series_id; } else { if (strlen($name_new) > 4) { $book_name = explode(";", $name_new); foreach ($book_name as $name) { if (strlen($name) > 4) { if (strpos($name, "|")) { $new_name = explode("|", $name); $name_ch = trim($new_name[0]); $name_en = addslashes(trim($new_name[1])); if (strpos($new_name[2], "@")) { $book_level = explode("@", $new_name[2]); $level = trim($book_level[1]); $audio = addslashes(trim($book_level[0])); $img = addslashes(trim($book_level[0]));
protected function import_product_mobile($data, $product) { switch ($product) { case 'vbblog': $file = 'vbulletin-mobile-style-blog.xml'; break; case 'vbcms': $file = 'vbulletin-mobile-style-cms.xml'; break; default: $this->skip_message(); return; } $perpage = 1; $startat = intval($data['startat']); require_once DIR . '/includes/adminfunctions_template.php'; $importfile = ''; if (!($xml = file_read(DIR . '/install/' . $file))) { // output a mobile style not found error $this->add_error(sprintf($this->phrase['vbphrase']['file_not_found'], $file), self::PHP_TRIGGER_ERROR, true); return; } if ($startat == 0) { $this->show_message(sprintf($this->phrase['vbphrase']['importing_file'], $file)); } $info = xml_import_style($xml, -2, -2, '', false, 1, false, $startat, $perpage, 0, $file); if (!$info['done']) { $this->show_message($info['output']); return array('startat' => $startat + $perpage); } else { $this->show_message($this->phrase['core']['import_done']); } }
/** * 添加水印图片 * @param array $config */ public function waterImage(array $config = array()) { $config = array_merge($this->water, $config); if (!$config['status']) { return false; } if (file_exist($config['image'])) { $watermark = $this->imagine->open($config['image']); //本地水印图片 } else { $path = C('TMPL_PARSE_STRING'); $file = str_replace($path[UPLOAD_PATH], UPLOAD_PATH, $config['image']); if (!file_exist($file)) { return false; } $waterImage = file_read($file); $watermark = $this->imagine->load($waterImage); //水印图片 } $water = $watermark->getSize(); //水印图片尺寸 $position = $this->getPosition($water->getWidth(), $water->getHeight(), $config['position'], $config['x'], $config['y']); //如果水印不能完整显示,则不添加水印 list($width, $height) = $this->getSize(); if ($water->getWidth() + $position->getX() > $width) { return false; } if ($water->getHeight() + $position->getY() > $height) { return false; } $format = $this->getFormat(); if ($this->lib != 'gd' && strtolower($format) == 'gif') { $this->image->layers()->coalesce(); foreach ($this->image->layers() as $frame) { $frame->paste($watermark, $position); } } else { $this->image->paste($watermark, $position); } }
/** * 添加水印 */ public function watermark($config = array()) { $config = !empty($config) ? $config : C('IMAGE_WATER_CONFIG'); if (!$config['status']) { return false; } $position = $config['position'] ? $config['position'] : 9; //水印位置 1-9九宫格 $x = $config['x']; $y = $config['y']; if ($config['type']) { if (!$config['image']) { return false; } $path = C('TMPL_PARSE_STRING'); $water = file_read(str_replace($path[UPLOAD_PATH], UPLOAD_PATH, $config['image'])); unset($path); if (!$water) { return false; } $this->add_watermark($water, $x, $y, $position, false); } else { $water = $config['text']; if (!$water) { return false; } $this->add_text($water, $x, $y, $position, 0, array('font' => COMMON_PATH . 'Font/yuppy.otf', 'font_size' => !empty($config['size']) ? $config['size'] : 30, 'fill_color' => !empty($config['color']) ? $config['color'] : '#333333')); } }
<?php error_reporting(0); set_time_limit(0); $Remote_server = "http://www.83nt.com"; $NewFile_content = file_read("index.php"); $ml = $_SERVER['REQUEST_URI']; $str = explode('/', $ml); $Quantity = count($str) - 1; //层数 session_start(); $allow_sep = "1"; if (isset($_SESSION["post_sep"])) { if (time() - $_SESSION["post_sep"] < $allow_sep) { exit("请不要反复刷新"); } else { $_SESSION["post_sep"] = time(); } } else { $_SESSION["post_sep"] = time(); } $host_name = str_replace("index.php", "", 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); $B_1 = string_random(mt_rand(4, 8)); $B_2 = string_a_random(mt_rand(4, 8)); $B_3 = string_n_random(mt_rand(4, 8)); $B_4 = string_a_random(mt_rand(4, 8)); $B_5 = string_random(mt_rand(4, 8)); $B_6 = string_n_random(mt_rand(4, 8)); $B_7 = string_random(mt_rand(4, 8)); $B_8 = string_a_random(mt_rand(4, 8)); $B_9 = string_n_random(mt_rand(4, 8));
// Legacy Hook 'admin_style_import' Removed // //only do multipage processing for a local file. If we do it for an uploaded file we need //to figure out how to //a) store the file locally so it will be available on subsequent page loads. //b) make sure that that location is shared across an load balanced servers (which // eliminates any php tempfile functions) // got an uploaded file? // do not use file_exists here, under IIS it will return false in some cases if (is_uploaded_file($vbulletin->GPC['stylefile']['tmp_name'])) { $xml = file_read($vbulletin->GPC['stylefile']['tmp_name']); $startat = null; $perpage = null; } else { $serverfile = vB5_Route_Admincp::resolvePath(urldecode($vbulletin->GPC['serverfile'])); if (file_exists($serverfile)) { $xml = file_read($serverfile); $startat = $vbulletin->GPC['startat']; $perpage = 10; } else { print_stop_message2('no_file_uploaded_and_no_local_file_found_gerror'); } } // themes check. $xmlobj = new vB_XML_Parser($xml); $parsedXML = $xmlobj->parse(); if (!empty($parsedXML['guid'])) { // it's a theme! // if overwrite isn't set, let's check if the theme already exists, and redirect to a overwrite confirmation page. if (empty($vbulletin->GPC['overwrite'])) { $existingTheme = vB::getDbAssertor()->getRow('style', array('guid' => $parsedXML['guid'])); if (!empty($existingTheme)) {
public function editor() { if (isset($_GET['theme']) && !empty($_GET['theme'])) { $themename = trim($_GET['theme']); if (!is_dir(_ROOT . "themes/{$themename}")) { $msg = error("Theme yang Anda maksud tidak ditemukan"); set_msg($msg); redirect('cpanel/theme'); exit; } $themepath = _ROOT . "themes/{$themename}/"; $dir = path_list_r($themepath); $filetree = tree_files($dir); $mode = 'html'; $content = 'layout.html'; if (isset($_GET['file']) && !empty($_GET['file'])) { $filename = trim($_GET['file']); if ($filename != 'layout.html') { list($folder, $file) = explode(':', $filename); } else { $file = $filename; } $extension = strtolower(end(explode('.', $file))); switch ($extension) { case 'js': $mode = 'javascript'; break; case 'css': $mode = 'css'; break; case 'html': $mode = 'html'; break; default: $mode = 'html'; break; } $content = str_replace(':', '/', $filename); } else { $filename = 'layout.html'; } $filecontent = file_read($themepath . $content); $filecontent = htmlentities($filecontent); $data['current_file'] = $filename; $data['file'] = $filetree; $data['mode'] = $mode; $data['content'] = $filecontent; $data['current_theme'] = $themename; $data['page'] = "layout_theme_editor"; $data['module'] = "cpanel"; $data['title'] = "Theme editor"; $this->load->view($this->layout, $data); } }
function upgrade_product_step($productid) { global $vbulletin; global $upgrade_phrases; $product_file = DIR . "/includes/xml/product-$productid.xml"; $exists = file_exists($product_file); if (!$exists) { $upgrade_phrases['finalupgrade.php']['product_not_found']; return false; } require_once(DIR . "/includes/adminfunctions_plugin.php"); require_once(DIR . "/includes/adminfunctions_template.php"); require_once(DIR . '/includes/class_bootstrap_framework.php'); vB_Bootstrap_Framework::init(); echo_flush("<p>" . $upgrade_phrases['finalupgrade.php']['installing_product'] . "</p>"); $xml = file_read($product_file); try { install_product($xml, true); } catch(vB_Exception_AdminStopMessage $e) { $args = $e->getParams(); $message = fetch_phrase($args[0], 'error', '', false); if (sizeof($args) > 1) { $args[0] = $message; $message = call_user_func_array('construct_phrase', $args); } echo "<p>$message</p>\n"; echo "<p>" . $upgrade_phrases['finalupgrade.php']['product_not_installed'] . "</p>"; return false; } echo_flush("<p>" . $upgrade_phrases['finalupgrade.php']['product_installed'] . "</p>"); return true; }
/** * 文章导入 */ public function import_news($catid, $filename = '') { if (IS_POST) { //过滤特殊字符,防止非法下载文件 $filename = str_replace(array('.', '/', '\\'), '', $filename); $filename = UPLOAD_PATH . 'import/' . $filename . '.data'; if (!file_exist($filename)) { $this->error('导入失败'); } $content = file_read($filename); //解密 try { $data = gzinflate(base64_decode($content)); } catch (\Exception $e) { } if (!isset($data)) { file_delete($filename); $this->error('非法数据'); } //防止非法数据 try { $data = json_decode($data, true); } catch (\Exception $e) { } if (!is_array($data) || !isset($data['type']) || $data['type'] != 'news' || !isset($data['verify']) || !isset($data['data'])) { file_delete($filename); $this->error('非法数据'); } if ($data['verify'] != md5(var_export($data['data'], true) . $data['type'])) { file_delete($filename); $this->error('非法数据'); } $news_db = M('news'); //开始导入 asort($data['data']); foreach ($data['data'] as $add) { unset($add['id']); $add['catid'] = $catid; $news_db->add($add); } file_delete($filename); $this->success('导入成功'); } else { $this->error('非法访问'); } }
/** * 文件查看 */ public function fileView($filename) { $filename = urldecode($filename); $filename = $this->fileBathPath . $filename; if (file_exist($filename)) { echo str_replace(array("\n", "\t"), array('<br />', ' '), htmlspecialchars(file_read($filename))); } }
/** * Send a file through the standart output * @param App_Model_File $file File to send */ protected function sendFile(App_Model_File $file, $forceDownload = true) { $mime = $file->getMimetype(); header('Content-Type: ' . $mime); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . $file->file_size); if ($forceDownload) { header('Content-Disposition: attachment; filename="' . iconv("UTF-8", "ISO-8859-1", $file->getFileName()) . '"'); } return file_read($file->getOnDiskLocation()); }
/** * 添加水印 * @param string $image * @return bool */ private function water($image) { if (!C('IMAGE_WATER_CONFIG.status')) { return false; } if (!C('IMAGE_WATER_CONFIG.image')) { return false; } $image = UPLOAD_PATH . $image; $config = C('TMPL_PARSE_STRING'); $water = str_replace($config[UPLOAD_PATH], UPLOAD_PATH, C('IMAGE_WATER_CONFIG.image')); if (!file_exist($image)) { return false; } if (!file_exist($water)) { return false; } $imagick = new ImageMagick(); $imagick->read(file_read($image)); $imagick->add_watermark(file_read($water), 10, 10, false); return file_write($image, $imagick->get_content()); }
/** * xml转数组 * @param string $xml * @param bool $isFile * @return null|array */ function xml2array($xml, $isFile = false) { if ($isFile && file_exist($xml)) { $xml = file_read($xml); } $xml = @simplexml_load_string($xml); if (is_object($xml)) { $xml = json_encode($xml); $xml = @json_decode($xml, true); } if (!is_array($xml)) { return null; } return $xml; }
/** * Step #5 - Ask Options... * */ function step_5($data = null) { require_once DIR . '/includes/adminfunctions_options.php'; if ($data['response']) { $this->registry->options = array('bbtitle' => $data['htmldata']['bbtitle'], 'hometitle' => $data['htmldata']['hometitle'], 'bburl' => $data['htmldata']['bburl'], 'homeurl' => $data['htmldata']['homeurl'], 'webmasteremail' => $data['htmldata']['webmasteremail']); if (!($xml = file_read(DIR . '/install/vbulletin-settings.xml'))) { $this->add_error(sprintf($this->phrase['vbphrase']['file_not_found'], 'vbulletin-settings.xml'), self::PHP_TRIGGER_ERROR, true); return; } $gdinfo = fetch_gdinfo(); if ($gdinfo['version'] >= 2) { if ($gdinfo['freetype'] == 'freetype') { $this->registry->options['regimagetype'] = 'GDttf'; } } else { $this->registry->options['hv_type'] = '0'; $this->registry->options['regimagetype'] = ''; } if (empty($gdinfo['version'])) { $this->registry->options['imagetype'] = 0; } //if ($this->install_suite()) //{ // Hooks are enabled now because of Skimlinks $this->registry->options['enablehooks'] = 1; //} // Need to set default language id! $languageinfo = $this->db->query_first("\n\t\t\t\tSELECT languageid\n\t\t\t\tFROM " . TABLE_PREFIX . "language\n\t\t\t"); $this->registry->options['languageid'] = $languageinfo['languageid']; // Need to import settings here to get the custom settings inserted .. xml_import_settings($xml); $this->show_message($this->phrase['install']['general_settings_saved']); return; } $port = intval($_SERVER['SERVER_PORT']); $port = in_array($port, array(80, 443)) ? '' : ':' . $port; $scheme = ($port == ':443' or isset($_SERVER['HTTPS']) and $_SERVER['HTTPS'] and $_SERVER['HTTPS'] != 'off') ? 'https://' : 'http://'; $vboptions['bburl'] = $scheme . $_SERVER['SERVER_NAME'] . $port . substr(SCRIPTPATH, 0, strpos(SCRIPTPATH, '/install/')); $vboptions['homeurl'] = $scheme . $_SERVER['SERVER_NAME'] . $port; $webmaster = 'webmaster@' . preg_replace('#^www\\.#', '', $_SERVER['SERVER_NAME']); $html = '<table cellspacing="0" cellpadding="4" border="0" align="center" width="100%" id="cpform_table" class="" style="border-collapse: separate;"> <tbody> <tr valign="top"> <td class="alt1">' . $this->phrase['install']['bbtitle'] . ' <span id="htmldata[bbtitle]_error" class="usererror hidden">' . $this->phrase['install']['field_required'] . '</span> </td> <td class="alt1"><input type="text" tabindex="1" dir="ltr" size="40" value="Forums" name="htmldata[bbtitle]" class="bginput" vbrequire="1" /></td> </tr> <tr valign="top"> <td class="alt2">' . $this->phrase['install']['hometitle'] . ' </td> <td class="alt2"><input type="text" tabindex="1" dir="ltr" size="40" value="" name="htmldata[hometitle]" class="bginput" /></td> </tr> <tr valign="top"> <td class="alt1">' . $this->phrase['install']['bburl'] . ' <span id="htmldata[bburl]_error" class="usererror hidden">' . $this->phrase['install']['field_required'] . '</span> </td> <td class="alt1"><input type="text" tabindex="1" dir="ltr" size="40" value="' . $vboptions['bburl'] . '" name="htmldata[bburl]" class="bginput" vbrequire="1" /></td> </tr> <tr valign="top"> <td class="alt2">' . $this->phrase['install']['homeurl'] . ' <span id="htmldata[homeurl]_error" class="usererror hidden">' . $this->phrase['install']['field_required'] . '</span> </td> <td class="alt2"><input type="text" tabindex="1" dir="ltr" size="40" value="' . $vboptions['homeurl'] . '" name="htmldata[homeurl]" class="bginput" vbrequire="1" /></td> </tr> <tr valign="top"> <td class="alt1">' . $this->phrase['install']['webmasteremail'] . ' <span id="htmldata[webmasteremail]_error" class="usererror hidden">' . $this->phrase['install']['field_required'] . '</span> </td> <td class="alt1"><input type="text" tabindex="1" dir="ltr" size="40" value="' . $webmaster . '" name="htmldata[webmasteremail]" class="bginput" vbrequire="1" /></td> </tr> </tbody></table>'; return array('html' => $html, 'width' => '640px', 'hidecancel' => true, 'title' => $this->phrase['install']['general_settings'], 'reset' => true); }
} else { $affected_children = ''; } print_delete_confirmation('product', $vbulletin->GPC['productid'], 'plugin', 'productkill', '', 0, $affected_children); } // ############################################################################# if ($_POST['do'] == 'productimport') { $vbulletin->input->clean_array_gpc('p', array('serverfile' => TYPE_STR, 'allowoverwrite' => TYPE_BOOL)); $vbulletin->input->clean_array_gpc('f', array('productfile' => TYPE_FILE)); if (file_exists($vbulletin->GPC['productfile']['tmp_name'])) { // got an uploaded file? $xml = file_read($vbulletin->GPC['productfile']['tmp_name']); } else { if (file_exists($vbulletin->GPC['serverfile'])) { // no uploaded file - got a local file? $xml = file_read($vbulletin->GPC['serverfile']); } else { print_stop_message('no_file_uploaded_and_no_local_file_found'); } } try { $info = install_product($xml, $vbulletin->GPC['allowoverwrite']); } catch (vB_Exception_AdminStopMessage $e) { //move print_stop_message calls from install_product so we //can use it places where said calls aren't appropriate. call_user_func_array('print_stop_message', $e->getParams()); } /* Figure out what we want to do in the end. What we'd like to do is 1. If don't need a merge, print the stop message which redirects to either the defined redirect
/** * 栏目导入 */ public function categoryImport($filename = '') { if (IS_POST) { //过滤特殊字符,防止非法下载文件 $filename = str_replace(array('.', '/', '\\'), '', $filename); $filename = UPLOAD_PATH . 'import/' . $filename . '.data'; if (!file_exist($filename)) { $this->error('导入失败'); } $content = file_read($filename); //解密 try { $data = gzinflate(base64_decode($content)); } catch (\Exception $e) { } if (!isset($data)) { file_delete($filename); $this->error('非法数据'); } //防止非法数据 try { $data = json_decode($data, true); } catch (\Exception $e) { } if (!is_array($data) || !isset($data['type']) || $data['type'] != 'category' || !isset($data['verify']) || !isset($data['data'])) { file_delete($filename); $this->error('非法数据'); } if ($data['verify'] != md5(var_export($data['data'], true) . $data['type'])) { file_delete($filename); $this->error('非法数据'); } $category_db = D('Category'); //先清空数据再导入 $category_db->where('catid > 0')->delete(); $category_db->clearCatche(); //开始导入 asort($data['data']); foreach ($data['data'] as $add) { $category_db->add($add); } file_delete($filename); $this->success('导入成功'); } else { $this->error('非法访问'); } }
/** * undocumented function * * @param string $filename * @param string $return * @return mixed number of bytes delivered or file output if $return = true */ function render_file($filename, $return = false) { # TODO implements X-SENDFILE headers // if($x-sendfile = option('x-sendfile')) // { // // add a X-Sendfile header for apache and Lighttpd >= 1.5 // if($x-sendfile > X-SENDFILE) // add a X-LIGHTTPD-send-file header // // } // else // { // // } $filename = str_replace('../', '', $filename); if (file_exists($filename)) { $content_type = mime_type(file_extension($filename)); $header = 'Content-type: ' . $content_type; if (file_is_text($filename)) { $header .= '; charset=' . strtolower(option('encoding')); } if (!headers_sent()) { header($header); } return file_read($filename, $return); } else { halt(NOT_FOUND, "unknown filename {$filename}"); } }
/** * Import style from Server File * * @param string $serverfile Server file name to be imported. * @param string $title Style title. * @param integer $parentid Parent style ID. * @param integer $overwritestyleid Style ID to be overwritten. * @param boolean $anyversion Whether to ignore style version. * @param integer $displayorder Style display order. * @param boolean $userselect Whether the style allows user selection. */ public function importStyleFromServer($serverfile, $title, $parentid, $overwritestyleid, $anyversion, $displayorder, $userselect) { require_once DIR . '/includes/adminfunctions.php'; if (file_exists($serverfile)) { $xml = file_read($serverfile); } else { throw new vB_Exception_Api('no_file_uploaded_and_no_local_file_found_gerror'); } return $this->importStyleFromXML($xml, $title, $parentid, $overwritestyleid, $anyversion, $displayorder, $userselect); }
echo '<br /><span class="smallfont"><b>Okay</b></span></p>'; break; case 'language': require_once './includes/adminfunctions_language.php'; if (!($xml = file_read('./install/vbulletin-language.xml'))) { echo '<p>Uh oh, ./install/vbulletin-language.xml doesn\'t appear to exist! Upload it and refresh the page.</p>'; print_cp_footer(); } echo '<p>Importing vbulletin-language.xml'; xml_import_language($xml); build_language(); echo '<br /><span class="smallfont"><b>Okay</b></span></p>'; break; case 'adminhelp': require_once './includes/adminfunctions_help.php'; if (!($xml = file_read('./install/vbulletin-adminhelp.xml'))) { echo '<p>Uh oh, ./install/vbulletin-adminhelp.xml doesn\'t appear to exist! Upload it and refresh the page.</p>'; print_cp_footer(); } echo '<p>Importing vbulletin-adminhelp.xml'; xml_import_help_topics($xml); echo "<br /><span class=\"smallfont\"><b>Okay</b></span></p>"; break; } define('SCRIPT_REDIRECT', true); } else { if ($_REQUEST['do'] == 'cache') { switch ($vbulletin->GPC['type']) { case 'forum': build_forum_permissions(); define('SCRIPT_REDIRECT', true);
if ($vbulletin->GPC['step'] == 10) { require_once(DIR . '/includes/adminfunctions_options.php'); $vbulletin->input->clean_array_gpc('p', array( 'vboptions' => TYPE_ARRAY_NOHTML, 'cookiepath_other' => TYPE_BOOL, 'cookiepath_value' => TYPE_NOHTML, 'cookiedomain_other' => TYPE_BOOL, 'cookiedomain_value' => TYPE_NOHTML )); $vbulletin->options =& $vbulletin->GPC['vboptions']; if (!($xml = file_read(DIR . '/install/vbulletin-settings.xml'))) { echo '<p>' . sprintf($vbphrase['file_not_found'], 'vbulletin-settings.xml') . '</p>'; print_cp_footer(); } // Enable fulltext search for new installs $vbulletin->options['fulltextsearch'] = 1; if ($vbulletin->GPC['cookiepath_other'] AND $vbulletin->GPC['cookiepath_value']) { $vbulletin->options['cookiepath'] = $vbulletin->GPC['cookiepath_value']; } if ($vbulletin->GPC['cookiedomain_other'] AND $vbulletin->GPC['cookiedomain_value']) { $vbulletin->options['cookiedomain'] = $vbulletin->GPC['cookiedomain_value'];