Exemplo n.º 1
0
 /**
  * 这是生成sitemapindex的第二部
  */
 public function sitemapIndex($filename)
 {
     $indexStr = $this->xmlHeader;
     $indexStr .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . $this->sitemapItem . '</sitemapindex>';
     if (!file_exists(dirname($filename))) {
         LJL_File::mkdir(dirname($filename));
     }
     file_put_contents($filename, $indexStr);
     $this->sitemapItem = '';
     unset($indexStr);
 }
Exemplo n.º 2
0
 /**
  * 获取
  *
  * @param mixed $key 配置地址
  * @param mixed $arrKeyName 配置子键,可多维,用.号分隔
  * @param enum $type PHP|INI|EVAL
  * @return array|false
  */
 public static function get($key, $arrKeyName = '', $type = 'PHP')
 {
     if (!defined('PRODUCTION_CONFIG_PATH')) {
         define('PRODUCTION_CONFIG_PATH', PRODUCTION_ROOT . '/Config');
     }
     $fileExt = array('ini' => 'ini', 'php' => 'php', 'eval' => 'php');
     $path = PRODUCTION_CONFIG_PATH . '/' . str_replace('_', '/', $key) . '.' . $fileExt[strtolower($type)];
     if (isset(self::$_cache[$path])) {
         $config = self::$_cache[$path];
     } else {
         if (!LJL_File::exists($path)) {
             self::$_cache[$path] = false;
             return false;
         }
         $type = strtoupper($type);
         switch ($type) {
             case 'INI':
                 $config = parse_ini_file($path);
                 break;
             case 'EVAL':
                 #config中可以有变量,这样可以将变量传入到config中
                 if (is_array($arrKeyName)) {
                     extract($arrKeyName);
                 }
                 $config = (include $path);
                 break;
             default:
             case 'PHP':
                 $config = (include $path);
                 break;
         }
         self::$_cache[$path] = $config;
     }
     if ($arrKeyName && $type != 'EVAL') {
         if (strpos('.', $arrKeyName)) {
             $keyArr = explode('.', $arrKeyName);
             foreach ($keyArr as $key) {
                 if (!$config) {
                     break;
                 }
                 $config = empty($config[$key]) ? false : $config[$key];
             }
         } else {
             $config = empty($config[$arrKeyName]) ? false : $config[$arrKeyName];
         }
     }
     return $config;
 }
Exemplo n.º 3
0
 public function render(LJL_Abstract_View $view)
 {
     $php = $this->_initEngine($view->data);
     if (!LJL_File::exists($php->getTemplate())) {
         throw new LJL_Exception('The template dose not exist or is not readable: ' . $php->getTemplate());
     }
     $variables = $php->getBody();
     if (!empty($variables)) {
         extract($variables);
     }
     ob_start();
     include $php->getTemplate();
     $content = ob_get_contents();
     ob_end_clean();
     return $content;
 }
Exemplo n.º 4
0
 public static function write($message, $type, $hasMark = true)
 {
     if (empty($message)) {
         trigger_error('$message dose not empty! ');
         return false;
     }
     if (empty($type)) {
         trigger_error('$type dose not empty! ');
         return false;
     }
     if (!isset(self::$type[$type])) {
         trigger_error('Unknow log type: ' . $type);
         return false;
     }
     $var = SYSTEM_VAR;
     $path = $var . '/log/' . self::$type[$type] . '/' . date('Y/m/d') . '.log';
     if ($hasMark) {
         $mark = "\n\n===========================================================================\n";
         $mark .= 'time:' . date('Y/m/d H:i:s') . "\n";
         $message = $mark . $message;
     }
     return LJL_File::write($message, $path, FILE_APPEND | LOCK_EX);
 }
Exemplo n.º 5
0
 public static function setCache($html = null, $url = null)
 {
     $key = self::$_cacheKey;
     $html = is_null($html) ? self::$_html : $html;
     if (!$html) {
         return false;
     }
     $html = gzdeflate($html, 9);
     return LJL_File::write($html, $key);
 }
Exemplo n.º 6
0
 public static function get($file, $intoAnArray = false)
 {
     self::$_file = self::exists($file);
     if (!self::$_file) {
         //throw new LJL_Exception('File does not exist or is not readable: '.$file);
         //trigger_error('File does not exist or is not readable: ' . $file);
         return false;
     }
     unset($file);
     if (false == $intoAnArray) {
         return file_get_contents(self::$_file);
     } else {
         return file(self::$_file);
     }
 }
Exemplo n.º 7
0
 public function DoUploadImg(LJL_Request $input, LJL_Response $output)
 {
     $upfile = $input->files('uppic');
     //客户端传过来的文件
     $pos = strpos($upfile['name'], '.') + 1;
     $ext = substr($upfile['name'], $pos);
     //获取后缀名
     $typelist = array("gif", "jpg", "png");
     //限制图片类型
     $imgInfo = LJL_Api::run("Image.DFS.imgStorage", array('rootdir' => UPLOAD_IMG_PATH . 'blog_' . APP_BLOG_NAME . '/'));
     $path = $imgInfo[2];
     //上传到该文件夹
     $webPath = Helper_Blog::getImgWebPath($imgInfo[2]);
     if (!is_dir($path)) {
         LJL_File::mkdir($path);
     }
     //获取图片名
     $picName = $imgInfo[0];
     $result = $this->uploadFile($upfile, $path, $picName, $webPath, $typelist);
     //图片上传函数
     if ($result['status']) {
         //图片表中插入数据
         $imgid = Helper_Blog::insertPic(array('picName' => $picName, 'picExt' => $ext, 'time' => $imgInfo[1]));
         echo '<script language="javascript">window.parent.addPic("' . $result['info'] . '","' . $imgid . '");</script>';
     } else {
         echo '<script language="javascript">window.parent.addPic("error","0");</script>';
     }
 }
Exemplo n.º 8
0
 private function getImgNameDir()
 {
     $imgInfo = LJL_Api::run("Image.DFS.imgStorage", array('rootdir' => $this->uploadRootdir . $this->website . '/'));
     $picName = $imgInfo[0];
     // 0/1时间/2
     $path = $imgInfo[2];
     //上传到该文件夹
     $webPath = $this->getImgWebPath($imgInfo[2]);
     if (!is_dir($path)) {
         LJL_File::mkdir($path);
     }
     return array($picName, $path, $webPath, $imgInfo[1]);
 }
Exemplo n.º 9
0
 public function buildStaticPage(array $data, $template, $filePath)
 {
     if (empty($data)) {
         trigger_error('$data dose not empty!');
         return false;
     }
     if (empty($template)) {
         trigger_error('$template dose not empty!');
         return false;
     }
     if (empty($filePath)) {
         trigger_error('$filePath dose not empty!');
         return false;
     }
     $output = new LJL_Response();
     $output->add($data);
     $output->template = $template;
     $view = new LJL_View_Simple($output);
     LJL_File::write($view->render(), $filePath);
     return false;
 }