Beispiel #1
0
 public function testAction($query_params)
 {
     if (!$this->is_root) {
         header("Location: /index/notfound");
         return;
     }
     $draft_id = isset($query_params[0]) && intval($query_params[0]) > 0 ? intval($query_params[0]) : '';
     $contents = file_exists(DRAFT_PATH . '/draft' . $draft_id . '.tpl') ? TechlogTools::pre_treat_article(file_get_contents(DRAFT_PATH . '/draft' . $draft_id . '.tpl')) : '';
     if (StringOpt::spider_string($contents, '"page-header"', '</div>') === null) {
         $contents = '<div class="page-header"><h1>草稿' . $draft_id . '</h1></div>' . $contents;
     }
     $index = TechlogTools::get_index($contents);
     $params = array('tags' => array(), 'title' => '测试页面', 'contents' => $contents, 'inserttime' => '', 'title_desc' => '仅供测试', 'article_category_id' => 3);
     if (count($index) > 0) {
         $params['indexs'] = $index;
     }
     $this->display(__CLASS__ . '::listAction', $params);
 }
Beispiel #2
0
 }
 $title = Repository::findTitleFromArticle(array('eq' => array('article_id' => $article_id)));
 if ($title == false) {
     LogOpt::set('exception', '草稿原文不存在', 'article_id', $article_id);
     continue;
 }
 echo '是否加载该草稿到日志原文?《' . $title . '》' . '(arctile_id:' . $article_id . ') [y/N]';
 $sure = fgets(STDIN);
 if (trim($sure[0]) != 'Y' && trim($sure[0]) != 'y') {
     continue;
 }
 $draft_file = DRAFT_PATH . '/draft' . $article_id . '.tpl';
 $infos = array();
 $infos['draft'] = file_get_contents($draft_file);
 $contents = TechlogTools::pre_treat_article($infos['draft']);
 $indexs = json_encode(TechlogTools::get_index($contents));
 if ($indexs != null) {
     $infos['indexs'] = $indexs;
 }
 $infos['updatetime'] = 'now()';
 $image_ids = array();
 while (1) {
     $image_path = StringOpt::spider_string($contents, 'img<![&&]>src="', '"', $contents);
     if ($image_path === null || $image_path === false || trim($image_path) == '') {
         break;
     }
     $image_path = trim($image_path);
     if (!file_exists(WEB_PATH . '/resource/' . $image_path)) {
         LogOpt::set('exception', '文中目标图片不存在', 'image_path', $image_path);
         return;
     }