public static function validate($data) { $validator = new Gio_Core_Validator(); foreach ($data as $index => $value) { if (gettype($value) == 'string') { $data[$index] = trim($value); } } $data['messages']['title'] = $validator->setString($data['title'])->validate(array('notNull'), array('notNull' => 'article_title_notnull')); $data['messages']['slug'] = $validator->setString($data['slug'])->validate(array('notNull', 'isSlug'), array('notNull' => 'article_slug_notnull', 'notNull' => 'article_slug_invalid')); $descriptionTemp = Gio_Core_String::stripTags($data['description'], null); $data['messages']['description'] = $validator->setString($descriptionTemp)->validate(array('notNull'), array('notNull' => 'article_description_notnull')); $contentTemp = Gio_Core_String::stripTags($data['content'], null); $data['messages']['content'] = $validator->setString($contentTemp)->validate(array('notNull'), array('notNull' => 'article_content_notnull')); $data['messages']['category_id'] = $validator->setString($data['category_id'])->validate(array('isNumeric'), array('isNumeric' => 'article_category_id_invalid')); $error = false; foreach ($data['messages'] as $index => $message) { if ($message) { $data['messages_error'] = true; return $data; } } $data['messages_error'] = false; return $data; }
/** * @param array $links * @param string $lang * @return array */ public static function filter($content, $webId = null) { switch ($webId) { case 'vnexpress': $content = str_replace('file","/', 'file","http://vnexpress.net/', $content); $content = str_replace('SWFObject("', 'SWFObject("http://vnexpress.net', $content); //$content = str_replace('playlistfile=/', 'playlistfile=http://vnexpress.net/', $content); $content = str_replace("swfobject.embedSWF('", "swfobject.embedSWF('http://vnexpress.net", $content); $content = str_replace('/Service/FlashVideo/Playlist2.asp?Id=', 'http://vnexpress.net/Service/FlashVideo/Playlist2.asp?Id=', $content); $content = str_replace('"skin","/Library/Common/AdsPlayer/classic/classic.xml"', '"skin","http://vnexpress.net/Library/Common/AdsPlayer/classic/classic.xml"', $content); $content = str_replace('skin=/Library/Common/AdsPlayer/classic/classic.xml', 'skin=http://vnexpress.net/Library/Common/AdsPlayer/classic/classic.xml', $content); $content = str_replace('http://vnexpress.nethttp', 'http', $content); break; case 'ngoisao': $content = str_replace('file","/', 'file","http://ngoisao.net', $content); $content = str_replace('SWFObject("', 'SWFObject("http://ngoisao.net', $content); $content = str_replace("swfobject.embedSWF('", "swfobject.embedSWF('http://ngoisao.net", $content); $content = str_replace('/Service/FlashVideo/Playlist2.asp?Id=', 'http://ngoisao.net/Service/FlashVideo/Playlist2.asp?Id=', $content); break; case 'thethaovanhoa': $content = str_replace('/images/mediaplayer.swf', 'http://thethaovanhoa.vn/images/mediaplayer.swf', $content); $content = str_replace('/scripts/swfobject', 'http://thethaovanhoa.vn/scripts/swfobject', $content); break; case 'haisao': case 'bongda': case 'nguoilaodong': require_once LIB_DIR . DS . 'htmlpurifier' . DS . 'HTMLPurifier.auto.php'; $purifier = new HTMLPurifier(); $content = $purifier->purify($content); break; case 'haitugio': $configs = Gio_Core_Config_Xml::getConfig('web'); $content = str_replace('//<![CDATA[', '', $content); $content = str_replace('//]]>', '', $content); $content = str_replace('flashWrite("/', 'flashWrite("' . $configs->url . '/flash.php?url=http://24h.com.vn/', $content); //$content = str_replace('500', '480', $content); //$content = str_replace('477', '400', $content); break; case 'zing': $content = '<script type="text/javascript">o_ChannelRoot = null;</script>' . $content; break; } if ($webId) { $content = Gio_Core_String::stripTags($content, array('a')); } return $content; }
private function _tintuconline($article) { ini_set("max_execution_time", 100); ini_set("memory_limit", "256M"); $website = 'http://www.tintuconline.com.vn'; if (isset($article['link_source']) && $article['link_source']) { $html = null; if (($htmlString = @file_get_contents($article['link_source'])) === false) { return $article; } $html = str_get_html($htmlString); $pageContent = $html->find('div[id=newsContent]', 0); $container = $pageContent; if ($container) { $content = $container->innertext; $tablesRelate = $container->find('.newsRelate'); for ($i = 0; $i < count($tablesRelate); $i++) { $content = str_replace($tablesRelate[$i]->outertext, '', $content); } $images = $container->find('img'); for ($i = 0; $i < count($images); $i++) { if (strpos($images[$i]->src, 'http://') === false) { $content = str_replace($images[$i]->src, $website . $images[$i]->src, $content); } } $photoAlbum = $html->find('div[id=photoAlbum]', 0); if (isset($photoAlbum->innertext) && $photoAlbum->innertext != null) { $imagesAlbum = $photoAlbum->find('.image'); $titlesAlbum = $photoAlbum->find('.title'); for ($i = 0; $i < count($imagesAlbum); $i++) { $imageAlbum = $imagesAlbum[$i]->find('img', 0); $src = $imageAlbum->src; if (strpos($imageAlbum->src, 'http://') === false) { $src = $website . $imageAlbum->src; } $content .= '<p><img src="' . $src . '" alt="" /></p>'; $title = isset($titlesAlbum[$i]) ? $titlesAlbum[$i]->plaintext : null; $content .= '<p>' . $title . '</p>'; } } $htmlContent = str_get_html($content); $images = $htmlContent->find('img'); $content = Gio_Core_String::stripTags($content, array('a')); $article['content'] = $content; $article['image_url'] = count($images) > 0 ? $images[0]->src : $article['image_url']; } } return $article; }
public function suggestAction() { $this->setNoRender(); $this->disableLayout(); $request = $this->getRequest(); $q = $request->getParam('q'); $q = Gio_Core_String::stripTags($q, array('.')); $limit = $request->getParam('limit', 10); $limit = (int) $limit ? $limit : 10; if (null == $q) { return; } $condition = array('keyword' => $q, 'status' => 'active'); $articles = Modules_News_Services_Article::find(0, $limit, $condition); $return = ''; foreach ($articles as $article) { $return .= $article['title'] . '|' . $article['article_id'] . '|' . $this->view->url('news_article_details', $article) . "\n"; } $this->getResponse()->setBody($return); }