public function getParam($name, $defaultValue = null) { $string = new Gio_Core_String(); if (isset($this->_params[$name]) && $this->_params[$name] && $this->_params[$name] != 'GLOBAL') { return $string->escape($this->_params[$name]); } elseif (isset($this->_postParams[$name])) { return $this->_postParams[$name]; } return $defaultValue; }
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; }
/** * @return Gio_Core_Application */ public static function getInstance() { if (null == self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
public function format($row) { if (isset($row['created_date']) && $row['created_date']) { $timeStamp = strtotime($row['created_date']); $row['year'] = date('Y', $timeStamp); $row['month'] = date('m', $timeStamp); } $json = new Services_JSON(); $images = $json->decode($row['image_url_data']); if (!empty($images)) { foreach ($images as $index => $image) { $row['image_' . $index] = $image->url; } } if (null == trim($row['description']) || trim($row['description']) == '') { $string = new Gio_Core_String(); $description = $string->subString($row['content'], 50); $row['description'] = $description; } return $row; }
public function addAction() { $request = $this->getRequest(); if ($request->isPost()) { $type = strtolower($request->getPost('type')); switch ($type) { case 'ajax': $this->disableLayout(); $this->setNoRender(); $tagText = trim($request->getPost('tag_text')); $tagText = $this->view->STRING->escape($tagText); //$tagText = Gio_Core_String::stripTags($tagText, array('.')); $response = array('status' => 'RESULT_NOT_OK', 'tag_text' => null, 'tag_id' => null); $json = new Services_JSON(); if ($tagText) { if (Modules_Tag_Services_Tag::checkExist($tagText)) { $response['status'] = 'RESULT_EXIST'; } else { $tag = array('tag_text' => $tagText, 'slug' => Gio_Core_String::removeSign($tagText, '-', true), 'created_date' => date('Y-m-d H:i:s')); $tagId = Modules_Tag_Services_Tag::add($tag); $response['status'] = 'RESULT_OK'; $response['tag_text'] = $tagText; $response['tag_id'] = $tagId; } } $this->getResponse()->setBody($json->encodeUnsafe($response)); return; break; default: $tagData = $request->getPost('tag'); $tagData = Modules_Tag_Services_Tag::validate($tagData); if (isset($tagData['messages_error']) && $tagData['messages_error']) { $this->view->errorMessages = $tagData['messages']; $this->view->tagData = $tagData; return; } if (Modules_Tag_Services_Tag::checkExist($tagData['tag_text'])) { $this->view->tagData = $tagData; $this->view->existMessage = true; return; } $tag = array('tag_text' => $this->view->STRING->escape($tagData['tag_text']), 'slug' => $tagData['slug'], 'created_date' => date('Y-m-d H:i:s')); $tagId = Modules_Tag_Services_Tag::add($tag); Gio_Core_Messenger::getInstance()->addMessage($this->view->TRANSLATOR->translator('tag_actions_add_success')); $this->redirect($this->view->url('tag_tag_add')); break; } } }
public function __construct($blocks = array()) { $this->setBlocks($blocks); $configs = Gio_Core_Config_Xml::getConfig(); /** * Not installed GioCMS */ if (!Gio_Core_Application::_initInstallChecker()) { $request = Gio_Core_Request::getInstance(); $configs->server->static = $request->getBaseUrl(); $configs->server->resource = $request->getBaseUrl(); $configs->web->url = $request->getBaseUrl(); } $this->APP_STATIC_SERVER = (string) $configs->server->static; $this->APP_RESOURCE_SERVER = (string) $configs->server->resource; $this->APP_WEB_URL = (string) $configs->web->url; $this->APP_WEB_NAME = (string) $configs->web->name; $this->APP_TEMPLATE = (string) $configs->web->template; $this->APP_SKIN = (string) $configs->web->skin; $this->APP_META_KEYWORD = (string) $configs->web->meta->keyword; $this->APP_META_DESCRIPTION = (string) $configs->web->meta->description; $defaultLanguage = (string) $configs->web->language; //$lang = Gio_Core_Request::getInstance()->getParam('lang'); //$this->APP_LANG = ($lang && $defaultLanguage != $lang) ? $lang : $defaultLanguage; $this->APP_LANG = $defaultLanguage; $routes = Gio_Core_Route::getInstance(); $this->routes = $routes; $string = Gio_Core_String::getInstance(); $this->STRING = $string; $translator = new Gio_Core_Translator(); $this->TRANSLATOR = $translator; if (Gio_Core_Application::_initInstallChecker() == true) { $acl = Gio_Core_Acl::getIntance(); $this->ACL = $acl; } $messenger = Gio_Core_Messenger::getInstance(); $this->MESSENGER = $messenger; if (Gio_Core_Application::_initInstallChecker()) { $user = Gio_Core_Session::getUser(); $this->USER = $user; } /** * JSON */ $json = new Services_JSON(); $this->JSON = $json; $this->CONFIG = $configs; }
/** * @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 tintuconline($linkId) { ini_set("memory_limit", "256M"); $conn = Gio_Db_Connection::getConnection(); if ($linkId) { $ext = $linkId == -1 ? null : ' AND cron_id = ' . (int) $linkId; $sql = 'SELECT * FROM ' . $conn->_tablePrefix . 'news_cron WHERE website_name="tintuconline" AND is_locked = 0 AND status = "active"' . $ext; } else { $numCategories = isset($this->_configs['auto_update_num_category']) ? $this->_configs['auto_update_num_category'] : 5; $sql = 'SELECT * FROM ' . $conn->_tablePrefix . 'news_cron WHERE status = "active" AND TIMESTAMPDIFF(SECOND, last_update, "' . date('Y-m-d H:i:s') . '") > frequency AND website_name = "tintuconline" AND is_locked = 0 ORDER BY priority LIMIT ' . (int) $numCategories; } $rsSql = $conn->query($sql); $addArticles = array(); $addCategories = array(); $articleDao = new Modules_News_Models_Mysql_Article(); $articleDao->setConnection($conn); while ($row = $conn->fetchAll($rsSql)) { /** * Check time */ $rssData = simplexml_load_file($row['source']); $articles = $rssData->channel->item; $categories = explode('-', $row['category_ids']); foreach ($articles as $index => $item) { $title = trim($item->title); $title = Gio_Core_String::stripCdata($title); $description = Gio_Core_String::stripCdata($item->description); $description = strip_tags($description); $link = Gio_Core_String::stripCdata($item->link); $link = trim($link); $date = Gio_Core_String::stripCdata($item->pubDate); $date = trim($date); /** * Check article exists */ $existsArticle = $articleDao->getBySlug(Gio_Core_String::removeSign(trim($title), '-', true)); if (null == $existsArticle) { $article = array('title' => $title, 'slug' => Gio_Core_String::removeSign($title, '-', true), 'description' => $description, 'created_date' => date('Y-m-d H:i:s', strtotime($date)), 'link_source' => $link, 'image_url' => null, 'category_ids' => $row['category_ids'], 'website' => 'tintuconline', 'article_photo' => 0, 'article_video' => 0); $addArticles[] = $article; $addCategories[] = $categories; } } /** * Update time for cron */ $sql = 'UPDATE ' . $conn->_tablePrefix . 'news_cron SET last_update = "' . date('Y-m-d H:i:s') . '" WHERE cron_id = ' . $conn->escape($row['cron_id']); $rsUpdate = $conn->query($sql); $conn->freeResult($rsUpdate); } $conn->freeResult($rsSql); /** * Add articles, Add Categories */ if ($addArticles && $addCategories) { $this->addArticles[] = $addArticles; $this->addCategories[] = $addCategories; } }
public function forgotpasswordAction() { $configs = Gio_Core_Config_Xml::getConfig('web'); $this->setTemplate($configs->admin->template); $this->setLayout('forgotpassword'); $request = $this->getRequest(); if ($request->isPost()) { $email = $request->getPost('email'); if (!$email) { $this->view->error = $this->view->TRANSLATOR->translator('user_forgotpassword_email_notnull'); return; } $user = Modules_Core_Services_User::checkEmailExist($email); if (null == $user) { $this->view->error = $this->view->TRANSLATOR->translator('user_forgotpassword_email_notexist'); return; } $code = Gio_Core_String::generateString(50); $user['code'] = $code; Modules_Core_Services_User::update($user); Modules_Core_Services_User::sendPassword($user['username'], $user['email'], $code); Gio_Core_Messenger::getInstance()->addMessage($this->view->TRANSLATOR->translator('user_forgotpassword_send_success')); $this->redirect($this->view->url('core_user_forgotpassword')); } }
public function count($condition = array()) { /** * Language is index column */ $sql = 'SELECT COUNT(a.language) as num_articles FROM ' . $this->_conn->_tablePrefix . 'news_article AS a WHERE a.language = "' . $this->_conn->escape($this->getLang()) . '"'; if (isset($condition['category_id']) && $condition['category_id']) { $sql .= ' AND a.article_id IN (SELECT article_id FROM ' . $this->_conn->_tablePrefix . 'news_article_category_assoc AS acs WHERE acs.category_id = "' . $this->_conn->escape($condition['category_id']) . '")'; } if (isset($condition['status']) && $condition['status']) { $sql .= ' AND a.status = "' . $this->_conn->escape($condition['status']) . '"'; } if (isset($condition['keyword']) && $condition['keyword']) { $sql .= ' AND (a.title LIKE "%' . $this->_conn->escape($condition['keyword']) . '%"'; //$sql .= ' OR a.description LIKE "%' . $this->_conn->escape($condition['keyword']) . '%"'; //$sql .= ' OR a.content LIKE "%' . $this->_conn->escape($condition['keyword']) . '%"'; $keywordNoSign = Gio_Core_String::removeSign($condition['keyword'], '-', true); //$sql .= ' OR a.slug LIKE "%' . $this->_conn->escape($keywordNoSign) . '%"'; $sql .= ')'; } if (isset($condition['article_id']) && $condition['article_id']) { $sql .= ' AND a.article_id = "' . $this->_conn->escape($condition['article_id']) . '"'; } if (isset($condition['article_hot'])) { $sql .= ' AND a.article_hot = ' . (int) $condition['article_hot']; } if (isset($condition['article_sticky']) && $condition['article_sticky'] == 1) { $sql .= ' AND a.article_sticky = 1'; } if (isset($condition['article_photo']) && $condition['article_photo'] == 1) { $sql .= ' AND a.article_photo = 1'; } if (isset($condition['created_date_from']) && $condition['created_date_from']) { $sql .= ' AND a.created_date >= "' . $this->_conn->escape($condition['created_date_from']) . '"'; } if (isset($condition['created_date_to']) && $condition['created_date_to']) { $sql .= ' AND a.created_date <= "' . $this->_conn->escape($condition['created_date_to']) . '"'; } if (isset($condition['web_id']) && $condition['web_id']) { $sql .= ' AND a.web_id = "' . $this->_conn->escape($condition['web_id']) . '"'; } if (isset($condition['user_id']) && $condition['user_id']) { $sql .= ' AND a.user_id = "' . $this->_conn->escape($condition['user_id']) . '"'; } $rs = $this->_conn->query($sql); $row = $this->_conn->fetchAll($rs); /** * Free result */ $this->_conn->freeResult($rs); return $row['num_articles']; }
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); }
public static function update($menu, $items = array(), $sourceItem = null) { $conn = Gio_Db_Connection::getConnection(); $dao = new Modules_Menu_Models_Mysql_Menu(); $dao->setConnection($conn); $dao->update($menu); /** * Update translation relation */ $json = new Services_JSON(); $source = self::getSource($menu); $translation = array('item_id' => $menu['menu_id'], 'item_class' => get_parent_class($dao), 'source_item_id' => !isset($source['menu_id']) || $source['menu_id'] == '' ? $menu['menu_id'] : $source['menu_id'], 'language' => $menu['language'], 'source_language' => !isset($source['language']) || '' == $source['language'] ? null : $source['language']); $sourceItem = $json->decode($sourceItem); if ($sourceItem != null) { $translation['source_item_id'] = $sourceItem->id; $translation['source_language'] = $sourceItem->language; } if ($source != null) { Modules_Core_Services_Translation::update($translation); } else { Modules_Core_Services_Translation::add($translation); } /** * Delete all menu items */ Modules_Menu_Services_Item::delete($menu['menu_id']); $string = new Gio_Core_String(); /** * Add menu item */ if (!empty($items)) { foreach ($items as $index => $item) { $item = (array) $item; $menuItem = array('item_id' => $item['item_id'], 'label' => $string->escape($item['label']), 'link' => $string->escape($item['link']), 'menu_id' => $menu['menu_id'], 'left_id' => $item['left_id'], 'right_id' => $item['right_id'], 'parent_id' => $item['parent_id']); Modules_Menu_Services_Item::add($menuItem); } } }