public static function run($args = NULL, $prefix = "do_") { self::init(); $app = $_GET['app']; $app or $app = 'home'; //in_array($app, self::$apps) OR iPHP::throwException('运行出错!找不到应用程序:' . $app, 1001); $do or $do = $_GET['do'] ? (string) $_GET['do'] : 'iCMS'; if ($_POST['action']) { $do = $_POST['action']; $prefix = 'ACTION_'; } self::$app_name = $app; self::$app_do = $do; self::$app_method = $prefix . $do; self::$app_path = ACP_PATH; self::$app_tpl = ACP_PATH . '/template'; self::$app_file = ACP_PATH . '/' . $app . '.app.php'; define('APP_URI', __ADMINCP__ . '=' . $app); define('APP_FURI', APP_URI . '&frame=iPHP'); define('APP_DOURI', APP_URI . ($do != 'iCMS' ? '&do=' . $do : '')); define('APP_BOXID', self::$app_name . '-box'); define('APP_FORMID', 'iCMS-' . APP_BOXID); is_file(self::$app_file) or iPHP::throwException('运行出错!找不到文件: <b>' . self::$app_name . '.app.php</b>', 1002); iPHP::import(self::$app_file); $appName = self::$app_name . 'App'; self::$app = new $appName(); $app_methods = get_class_methods($appName); in_array(self::$app_method, $app_methods) or iPHP::throwException('运行出错! <b>' . self::$app_name . '</b> 类中找不到方法定义: <b>' . self::$app_method . '</b>', 1003); $method = self::$app_method; $args === null && ($args = self::$app_args); if ($args) { if ($args === 'object') { return self::$app; } return self::$app->{$method}($args); } else { return self::$app->{$method}(); } }
function do_download() { $this->bakdir or iPHP::alert('请选择要下载的备份卷'); @ini_set('memory_limit', '256M'); require iPHP_CORE . '/pclzip.class.php'; //加载zip操作类 $zipname = $this->bakdir . ".zip"; //压缩包的名称 $zipFile = iPHP_APP_CACHE . '/backup/' . $zipname; //压缩包所在路径 $zip = new PclZip($zipFile); $backupdir = iPHP_APP_CACHE . '/backup/' . $this->bakdir; $fileArray = glob($backupdir . '/iCMS_*.sql'); $filelist = implode(',', $fileArray); $v_list = $zip->create($filelist, PCLZIP_OPT_REMOVE_PATH, iPHP_APP_CACHE . '/backup/'); //将文件进行压缩 $v_list == 0 && iPHP::throwException("压缩出错 : " . $zip->errorInfo(true)); //如果有误,提示错误信息。 ob_end_clean(); header("Content-Type: application/force-download"); header("Content-Transfer-Encoding: binary"); header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename=' . $zipname); header('Content-Length: ' . filesize($zipFile)); readfile($zipFile); flush(); ob_flush(); }
public static function get_app($appid = 1) { $rs = iCache::get('iCMS/app/' . $appid); $rs or iPHP::throwException('app no exist', '0005'); return $rs; }
public static function charsetTrans($html, $content_charset, $encode, $out = 'UTF-8') { if (spider::$dataTest || spider::$ruleTest) { echo '<b>规则设置编码:</b>' . $encode . '<br />'; } $encode == 'auto' && ($encode = null); /** * 检测http返回的编码 */ if ($content_charset) { $content_charset = rtrim($content_charset, ';'); if (empty($encode)) { $encode = $content_charset; } else { if (strtoupper($encode) != strtoupper($content_charset)) { $encode = $content_charset; } } if (strtoupper($encode) == $out) { if (spider::$dataTest || spider::$ruleTest) { echo '<b>检测页面编码:</b>' . $encode . '<br />'; } return $html; } } /** * 检测页面编码 */ if (empty($encode)) { preg_match('/<meta[^>]*?charset=(["\']?)([a-zA-z0-9\\-\\_]+)(\\1)[^>]*?>/is', $html, $charset); $encode = str_replace(array('"', "'"), '', trim($charset[2])); } if (function_exists('mb_detect_encoding') && empty($encode)) { $encode = mb_detect_encoding($html, array("ASCII", "UTF-8", "GB2312", "GBK", "BIG5")); } if (spider::$dataTest || spider::$ruleTest) { echo '<b>检测页面编码:</b>' . $encode . '<br />'; } if (strtoupper($encode) == $out) { return $html; } $html = preg_replace('/(<meta[^>]*?charset=(["\']?))[a-z\\d_\\-]*(\\2[^>]*?>)/is', "\\1{$out}\\3", $html, 1); if (function_exists('mb_convert_encoding')) { return mb_convert_encoding($html, $out, $encode); } elseif (function_exists('iconv')) { return iconv($encode, $out, $html); } else { iPHP::throwException('charsetTrans failed, no function'); } }
function charsetTrans($html, $content_charset, $encode, $out = 'UTF-8') { if ($encode == 'auto') { preg_match('/<meta[^>]*?charset=(["\']?)([a-zA-z0-9\\-\\_]+)(\\1)[^>]*?>/is', $html, $charset); $encode = str_replace(array('"', "'"), '', trim($charset[2])); if ($content_charset) { $encode = $content_charset; } if (function_exists('mb_detect_encoding') && empty($encode)) { $encode = mb_detect_encoding($html, array("ASCII", "UTF-8", "GB2312", "GBK", "BIG5")); //var_dump('mb_detect_encoding:'.$encode); } } if ($this->contTest || $this->ruleTest) { echo 'encoding:' . $encode . '<br />'; } if (strtoupper($encode) == 'UTF-8') { return $html; } $html = preg_replace('/(<meta[^>]*?charset=(["\']?))[a-z\\d_\\-]*(\\2[^>]*?>)/is', "\\1{$out}\\3", $html, 1); if (function_exists('mb_convert_encoding')) { return mb_convert_encoding($html, 'UTF-8', $encode); } elseif (function_exists('iconv')) { return iconv($encode, 'UTF-8', $html); } else { iPHP::throwException('charsetTrans failed, no function'); } }