public function actionCategory() { $cate_id = urlGETParams('cate_id', VARIABLE_NUMBER); $query = "SELECT * FROM tbl_category WHERE id = " . $cate_id; $category = $this->db->createCommand($query)->queryRow(); $category_url = $category['cnet_url']; echo "<pre>" . print_r($category, true) . "</pre>"; echo $category_url . '<br />'; $response = fectchContent($category_url); $html = str_get_html($response); $data = array(); for ($i = 1; $i <= 100; $i++) { $item = $html->find('div[section="prod' . $i . '"]', 0); if (!empty($item)) { $a = $item->find('a', 0); $link_url = $this->_domain . trim($a->href); $dek = $item->find('.dek', 0); if (!empty($dek)) { $data[$link_url] = trim($dek->innertext()); } } } if (empty($data)) { echo 'Khong co du lieu vui long kiem tra lai'; } $params = array(); foreach ($data as $link_url => $dek) { $params[] = array('cate_id' => $cate_id, 'url' => $link_url, 'md5url' => md5($link_url), 'source_id' => $this->_source_id, 'short_text' => $dek, 'parent_id' => $category['parent_id']); } $params = array_reverse($params); yii_insert_multiple('link', $params, 'db_crawler'); echo "<pre>" . print_r($params, true) . "</pre>"; }
public function actionIndex() { $data = array(); $alias = urlGETParams('alias'); $query = "SELECT * FROM tbl_archive WHERE alias = :alias"; $values = array('alias' => $alias); $data['row'] = $this->db->createCommand($query)->bindValues($values)->queryRow(); if (empty($data['row'])) { $this->redirect($this->createUrl('index/index')); } if ($data['row']['cate_id'] == 20) { $redirect_url = $this->createUrl('detail/index', $data['row']); $this->redirect($redirect_url); } $data['source'] = $this->getSource(); if (!empty($data['row']['tags'])) { $str_tag = trim($data['row']['tags'], ','); $data['tags'] = $this->getListTags(explode(',', $str_tag)); } //lay thong tin danh muc cua bai viet $query = "SELECT * FROM tbl_category WHERE id = " . $data['row']['cate_id']; $data['category'] = $this->db->createCommand($query)->queryRow(); $data['relate_post'] = $this->getRelatedPost($data['row']); $this->_meta = array('title' => $data['row']['title'] . ' - Techz24', 'description' => $data['row']['meta_description'], 'keywords' => $data['row']['meta_keywords'], 'image' => $data['row']['thumbnail']); $this->_style_class = 'page right-sidebar singular fade-imgs-in-appear one-side-wide both-sidebars archive-page'; $this->render('index', array('data' => $data)); }
public function actionTag() { $data = array(); $alias = urlGETParams('alias'); $query = "SELECT * FROM tbl_tags_youtube WHERE alias = :alias"; $values = array(':alias' => $alias); $row = $this->db->createCommand($query)->bindValues($values)->queryRow(); if (empty($row)) { $this->redirect($this->createUrl('video/index')); } $data['row'] = $row; $tag_id = $row['id']; $where = " AND tags LIKE '%," . $tag_id . ",%' "; $query_count = "SELECT COUNT(id) FROM tbl_youtube WHERE 1 " . $where; $item_count = $this->db->createCommand($query_count)->queryScalar(); $pages = new CPagination($item_count); $perPage = 30; $pages->setPageSize($perPage); $page = isset($_GET['page']) ? intval($_GET['page']) : 0; if ($page <= 0) { $page = 1; } $offset = ($page - 1) * $perPage; $query = "SELECT * FROM tbl_youtube WHERE 1 " . $where . " " . " ORDER BY id DESC " . "LIMIT " . $offset . "," . $perPage; $data['listVideo'] = $this->db->createCommand($query)->queryAll(); $title = $data['row']['name'] . ' videos'; if ($page > 1) { $title .= ' - page ' . $page; } $this->_meta = array('title' => $title . ' - Techz24', 'description' => 'All videos in topic . ' . $data['row']['name'] . ' on Techz24'); $this->_style_class = 'page right-sidebar singular fade-imgs-in-appear one-side-wide both-sidebars archive-page'; $this->render('tag', array('data' => $data, 'item_count' => $item_count, 'page_size' => $perPage, 'pages' => $pages)); }
public function actionEdit() { $data = array(); $id = urlGETParams('id', VARIABLE_NUMBER); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $remove_gallery = intval($_POST['remove_gallery']); $params = $_POST; unset($params['remove_gallery']); if ($remove_gallery == 1) { $params['gallery'] = ''; } if (!empty($params['tags'])) { $tags = explode(', ', $params['tags']); trim_array($tags); $params['tags'] = json_encode($tags); } $params['have_video'] = intval($_POST['have_video']); yii_update_row('archive', $params, 'id = ' . $id); createMessage('Cập nhật thành công'); $this->redirect($this->createUrl('index')); } $data['category'] = $this->getCategory(true); $query = "SELECT * FROM tbl_archive WHERE id = " . $id; $data['row'] = $this->db->createCommand($query)->queryRow(); $this->render('edit', array('data' => $data)); }
public function actionEdit() { $uid = urlGETParams('id', VARIABLE_NUMBER); $record = $this->getRow($uid); if (empty($record)) { createMessage('Hệ thống không tìm thấy nội dung bạn yêu cầu', 'danger'); $this->redirect($this->createUrl('index')); } $data = array(); $data['user'] = $record; $form = new UserForm(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $form->attributes = $_POST['UserForm']; if ($form->validate()) { $values = array(); foreach ($form->attributes as $key => $vl) { if ($key == 're_password') { continue; } if ($key == 'password') { if (empty($vl)) { continue; } $vl = md5(trim($vl)); } $values[$key] = trim($vl); } yii_update_row($this->_table, $values, 'id = ' . $uid); //user rule //xoa rule hien tai $query = "DELETE FROM {{user_rule}} WHERE uid = " . $uid; $this->db->createCommand($query)->execute(); $user_rule = formPostParams('rule', VARIABLE_ARRAY); if (!empty($user_rule)) { $params = array(); foreach ($user_rule as $rule_id) { $params[] = array('uid' => $uid, 'rule_id' => $rule_id); } yii_insert_multiple('user_rule', $params); } createMessage('Sửa thông tin người dùng thành công'); $this->redirect($this->createUrl('index')); } } else { $form->attributes = $record; $form->password = ''; } $data['rule'] = $this->getListRule(); //lay danh sach quyen $query = "SELECT rule_id FROM {{user_rule}} WHERE uid = " . $uid; $data['listRole'] = $this->db->createCommand($query)->queryColumn(); $data['form'] = $form; $this->render('add', array('data' => $data)); }
public function actionCategory() { $page = isset($_GET['page']) ? intval($_GET['page']) : 1; if ($page < 1) { $page = 1; } $cate_id = urlGETParams('cate_id', VARIABLE_NUMBER); $query = "SELECT * FROM tbl_category WHERE id = " . $cate_id; $category = $this->db->createCommand($query)->queryRow(); $category_url = $category['techcrunch_url']; if ($page > 1) { $category_url .= 'page/' . $page . '/'; //http://techcrunch.com/mobile/page/5/ } echo "<pre>" . print_r($_GET, true) . "</pre>"; echo $category_url . '<br />'; $response = fectchContent($category_url); $html = str_get_html($response); $contents = $html->find('.block-content'); $data = array(); foreach ($contents as $item) { $a = $item->find('.post-title a', 0); $excerpt = $item->find('.excerpt', 0); $excerpt->find('a', 0)->outertext = ''; $link_url = trim($a->href); $data[$link_url] = trim($excerpt->innertext()); } if (empty($data)) { echo 'Khong co du lieu vui long kiem tra lai'; } $params = array(); $remove_link = array(); foreach ($data as $link_url => $dek) { $break = false; foreach ($remove_link as $prefix) { if (strpos($link_url, $prefix) !== false) { $break = true; unset($data[$link_url]); break; } } if ($break) { continue; } $params[] = array('cate_id' => $cate_id, 'url' => $link_url, 'md5url' => md5($link_url), 'source_id' => $this->_source_id, 'short_text' => $dek, 'parent_id' => $category['parent_id']); echo $link_url . '<br />'; } $params = array_reverse($params); yii_insert_multiple('link', $params, 'db_crawler'); // echo "<pre>" . print_r($params, true) . "</pre>"; }
public function actionCategory() { $page = isset($_GET['page']) ? intval($_GET['page']) : 1; if ($page < 1) { $page = 1; } $cate_id = urlGETParams('cate_id', VARIABLE_NUMBER); $query = "SELECT * FROM tbl_category WHERE id = " . $cate_id; $category = $this->db->createCommand($query)->queryRow(); $category_url = $category['wpcentral_url']; if ($page > 1) { $category_url .= '?pg=' . $page; } echo $category_url . '<br />'; $response = fectchContent($category_url); $html = str_get_html($response); $content = $html->find('.articles-simple-list', $page == 1 ? 1 : 0); $data = array(); $assets = $content->find('.rf-entry'); foreach ($assets as $item) { $a = $item->find('.rf-image', 0); $link_url = $this->_domain . trim($a->href); $dek = $item->find('.rf-body', 0); if (!empty($dek)) { $data[$link_url] = trim($dek->innertext()); } } if (empty($data)) { echo 'Khong co du lieu vui long kiem tra lai'; } $params = array(); $remove_link = array(); foreach ($data as $link_url => $dek) { // $break = false; // foreach ($remove_link as $prefix) { // if (strpos($link_url, $prefix) !== false) { // $break = true; // unset($data[$link_url]); // break; // } // } // if ($break) { // continue; // } $params[] = array('cate_id' => $cate_id, 'url' => $link_url, 'md5url' => md5($link_url), 'source_id' => $this->_source_id, 'short_text' => $dek, 'parent_id' => $category['parent_id']); } $params = array_reverse($params); yii_insert_multiple('link', $params, 'db_crawler'); echo "<pre>" . print_r($params, true) . "</pre>"; }
public function actionIndex() { $data = array(); $alias = urlGETParams('alias'); $query = "SELECT * FROM tbl_tags WHERE alias = :alias"; $values = array(':alias' => $alias); $row = $this->db->createCommand($query)->bindValues($values)->queryRow(); if (empty($row)) { $this->redirect($this->createUrl('index/index')); } $data['row'] = $row; $tag_id = $row['id']; $where = " AND tags LIKE '%," . $tag_id . ",%' "; $query_count = "SELECT COUNT(id) FROM tbl_archive WHERE 1 " . $where; $item_count = $this->db->createCommand($query_count)->queryScalar(); $pages = new CPagination($item_count); $perPage = 20; $pages->setPageSize($perPage); $page = isset($_GET['page']) ? intval($_GET['page']) : 0; if ($page <= 0) { $page = 1; } $offset = ($page - 1) * $perPage; $query = "SELECT id, cate_id, title, alias, thumbnail,short_text,created,tags FROM tbl_archive WHERE 1 " . $where . " " . " ORDER BY id DESC " . "LIMIT " . $offset . "," . $perPage; $data['newpost'] = $this->db->createCommand($query)->queryAll(); $tags = array(); if (!empty($data['newpost'])) { foreach ($data['newpost'] as $item) { $arr = explode(',', trim($item['tags'], ',')); if (!empty($arr)) { foreach ($arr as $t) { $tags[] = $t; } } } $tags = array_unique($tags); $data['tags'] = $this->getListTags($tags); } $data['category'] = $this->getListCategory(); $title = $data['row']['name'] . ' News'; if ($page > 1) { $title .= ' - page ' . $page; } $this->_meta = array('title' => $title . ' - Techz24', 'description' => 'Techz24 news editors and reporters provide top ' . $data['row']['name'] . ' news, with in-depth coverage of issues and events.'); $this->_style_class = 'page right-sidebar singular fade-imgs-in-appear one-side-wide both-sidebars archive-page'; $this->render('index', array('data' => $data, 'item_count' => $item_count, 'page_size' => $perPage, 'pages' => $pages)); }
public function actionAppInfo() { $bundle_id = urlGETParams('bundle_id'); $data = $this->cURLAppleGetAppInfo($bundle_id); $response = array(); if ($data['resultCount'] != 1) { $response['status'] = -1; echo json_encode($response); die; } $response['status'] = 1; $row = array_shift($data['results']); $response['apple_id'] = $row['trackId']; $response['bundle_id'] = $row['bundleId']; $response['app_name'] = $row['trackName']; $response['image'] = $row['artworkUrl512']; echo json_encode($response); }
public function actionVideo() { $data = array(); $keyword = urlGETParams('keyword'); $where = " AND title LIKE '%" . addslashes($keyword) . "%' "; $query_count = "SELECT COUNT(id) FROM tbl_youtube WHERE 1 " . $where; $item_count = $this->db->createCommand($query_count)->queryScalar(); $pages = new CPagination($item_count); $perPage = 30; $pages->setPageSize($perPage); $page = isset($_GET['page']) ? intval($_GET['page']) : 0; if ($page <= 0) { $page = 1; } $offset = ($page - 1) * $perPage; $query = "SELECT * FROM tbl_youtube WHERE 1 " . $where . " " . " ORDER BY created DESC " . "LIMIT " . $offset . "," . $perPage; $data['listVideo'] = $this->db->createCommand($query)->queryAll(); $tags = array(); if (!empty($data['listVideo'])) { foreach ($data['listVideo'] as $item) { $arr = explode(',', trim($item['tags'], ',')); if (!empty($arr)) { foreach ($arr as $t) { $tags[] = $t; } } } $tags = array_unique($tags); $data['tags'] = $this->getListTags($tags); } $title = $keyword . ' search results'; if ($page > 1) { $title .= ' - page ' . $page; } $this->_meta = array('title' => $title . ' - Techz24'); $this->_style_class = 'page right-sidebar singular fade-imgs-in-appear one-side-wide both-sidebars archive-page'; $this->render('video', array('data' => $data, 'item_count' => $item_count, 'page_size' => $perPage, 'pages' => $pages)); }
public function actionEdit() { $data = array(); $id = urlGETParams('id', VARIABLE_NUMBER); $query = "SELECT * FROM tbl_category WHERE id = " . $id; $row = $this->db->createCommand($query)->queryRow(); if (empty($row)) { $this->redirect($this->createUrl('index')); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { //`parent_id`, `name`, `alias`, `meta_keywords`, `meta_description`, `meta_title`, `status` $params = array('parent_id' => formPostParams('parent_id', VARIABLE_NUMBER), 'name' => formPostParams('name'), 'alias' => change_url_seo(formPostParams('name')), 'meta_keywords' => formPostParams('meta_keywords'), 'meta_description' => formPostParams('meta_description'), 'meta_title' => formPostParams('meta_title'), 'status' => formPostParams('status', VARIABLE_NUMBER), 'is_feature' => formPostParams('is_feature', VARIABLE_NUMBER), 'weight' => formPostParams('weight', VARIABLE_NUMBER), 'cnet_url' => formPostParams('cnet_url'), 'techcrunch_url' => formPostParams('techcrunch_url'), 'wpcentral_url' => formPostParams('wpcentral_url'), 'android_center_url' => formPostParams('android_center_url')); yii_update_row($this->_table, $params, 'id = ' . $id); createMessage('Sửa danh mục thành công'); $this->redirect($this->createUrl('index')); } $query = "SELECT id, name FROM tbl_category WHERE parent_id = 0"; $result = $this->db->createCommand($query)->queryAll(); foreach ($result as $item) { $data['category'][$item['id']] = $item['name']; } $data['row'] = $row; $this->render('add', array('data' => $data)); }
<div class="mom_breadcrumb breadcrumb breadcrumbs"> <div class="breadcrumbs-plus"> <span itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"> <a itemprop="url" href="<?php echo $this->createUrl('index/index'); ?> " class="home"> <span itemprop="title">Home</span> </a> </span> <span class="separator"> <i class="sep fa-icon-double-angle-right"></i> </span> <?php $keyword = isset($_GET['keyword']) ? urlGETParams('keyword') : ''; echo $keyword; ?> </div> </div> </div> <?php foreach ($data['newpost'] as $item) { $detail_url = $this->createUrl('detail/index', $item); $category = $data['category'][$item['cate_id']]; $category_url = $this->createUrl('category/index', array('alias' => $category['alias'])); ?> <div class="base-box blog-post default-blog-post bp-horizontal-share" itemscope="" itemtype="http://schema.org/Article">
public function actionIndex() { $data = array(); $alias = urlGETParams('alias'); $categories = $this->getListCategory(); $category_feature = array(); $cate = array(); foreach ($categories as $item) { if ($item['alias'] == $alias) { $cate = $item; break; } } if (empty($cate)) { $this->redirect($this->createUrl('index/index')); } $cate_id = $cate['id']; $data['cur_cate'] = $cate; $data['category'] = $categories; $where = " AND cate_id = " . $cate_id; $query_count = "SELECT COUNT(id) FROM tbl_archive WHERE 1 " . $where; $item_count = $this->db->createCommand($query_count)->queryScalar(); $pages = new CPagination($item_count); $perPage = 20; if ($cate_id == 20) { $perPage = 100; } $pages->setPageSize($perPage); $page = isset($_GET['page']) ? intval($_GET['page']) : 0; if ($page <= 0) { $page = 1; } $offset = ($page - 1) * $perPage; $query = "SELECT id, cate_id, title, alias, thumbnail,short_text,created,tags FROM tbl_archive WHERE 1 " . $where . " " . " ORDER BY id DESC " . "LIMIT " . $offset . "," . $perPage; $data['newpost'] = $this->db->createCommand($query)->queryAll(); $tags = array(); if (!empty($data['newpost'])) { foreach ($data['newpost'] as $item) { $arr = explode(',', trim($item['tags'], ',')); if (!empty($arr)) { foreach ($arr as $t) { $tags[] = $t; } } } $tags = array_unique($tags); $data['tags'] = $this->getListTags($tags); } $title = $cate['meta_title']; if ($page > 1) { $title .= ' - page ' . $page; } $this->_meta = array('title' => $title . ' | Techz24', 'description' => $cate['meta_description'], 'keywords' => $cate['meta_keywords']); // echo "<pre>" . print_r($data, true) . "</pre>"; // die; if ($cate_id == 20) { $this->_style_class = 'page right-sidebar singular fade-imgs-in-appear one-side-wide both-sidebars review-page'; $this->render('review', array('data' => $data)); return; } $this->_style_class = 'page right-sidebar singular fade-imgs-in-appear one-side-wide both-sidebars archive-page'; $this->render('index', array('data' => $data, 'item_count' => $item_count, 'page_size' => $perPage, 'pages' => $pages)); }
public function actionCategory() { $page = isset($_GET['page']) ? intval($_GET['page']) : 1; if ($page < 1) { $page = 1; } // $cate_id = 1; // $category_url = 'http://www.cnet.com/apple/'; // $cate_id = 2; // $category_url = 'http://www.cnet.com/tags/google/'; // $cate_id = 3; // $category_url = 'http://www.cnet.com/tags/microsoft/'; $cate_id = urlGETParams('cate_id', VARIABLE_NUMBER); $query = "SELECT * FROM tbl_category WHERE id = " . $cate_id; $category = $this->db->createCommand($query)->queryRow(); $category_url = $category['cnet_url']; if ($page > 1) { $category_url .= $page; } echo "<pre>" . print_r($_GET, true) . "</pre>"; echo $category_url . '<br />'; $response = fectchContent($category_url); $html = str_get_html($response); $content = $html->find('.col-8', 0); $remove_elements = array('.latestGalleries', '.curated-hero'); foreach ($content->find(implode(', ', $remove_elements)) as $item) { $item->outertext = ''; } $data = array(); $assets = $content->find('.asset'); foreach ($assets as $item) { $a = $item->find('.assetThumb a', 0); $link_url = $this->_domain . trim($a->href); $dek = $item->find('p.dek', 0); if (!empty($dek)) { $data[$link_url] = trim($dek->innertext()); } } if (empty($data)) { echo 'Khong co du lieu vui long kiem tra lai'; } $params = array(); $remove_link = array('products', 'videos', 'pictures'); foreach ($data as $link_url => $dek) { $break = false; foreach ($remove_link as $prefix) { if (strpos($link_url, $prefix) !== false) { $break = true; unset($data[$link_url]); break; } } if ($break) { continue; } $params[] = array('cate_id' => $cate_id, 'url' => $link_url, 'md5url' => md5($link_url), 'source_id' => $this->_source_id, 'short_text' => $dek, 'parent_id' => $category['parent_id']); } $params = array_reverse($params); yii_insert_multiple('link', $params, 'db_crawler'); echo "<pre>" . print_r($params, true) . "</pre>"; }
public function actionCategory() { $page = isset($_GET['page']) ? intval($_GET['page']) : 1; if ($page < 0) { $page = 0; } $cate_id = urlGETParams('cate_id', VARIABLE_NUMBER); $query = "SELECT * FROM tbl_category WHERE id = " . $cate_id; $category = $this->db->createCommand($query)->queryRow(); $category_url = $category['android_center_url']; $category_url .= $page; // echo $category_url . '<br />'; if ($cate_id == 21) { $response = $this->fectchDataFromUrl($category_url); if (empty($response)) { die('Error Khong lay duoc noi dung'); } $html = str_get_html($response); $items = $html->find('.grid_item'); $data = array(); foreach ($items as $item) { $a = $item->find('.grid_title a', 0); $link_url = $this->_domain . trim($a->href); if (strpos($link_url, 'forums.androidcentral.com') !== false) { continue; } $dek = $item->find('.grid_summary', 0); if (!empty($dek)) { $str_desc = $dek->innertext(); $str_desc = strip_tags($str_desc); $data[$link_url] = trim($str_desc); } } } else { $response = fectchContent($category_url); $html = str_get_html($response); $content = $html->find('.content', 0); $items = $content->find('.node-article'); foreach ($items as $item) { $a = $item->find('h2 a', 0); $link_url = $this->_domain . trim($a->href); if (strpos($link_url, 'forums.androidcentral.com') !== false) { continue; } $dek = $item->find('.body', 0); if (!empty($dek)) { $str_desc = $dek->innertext(); $str_desc = strip_tags($str_desc); $data[$link_url] = trim($str_desc); } } } if (empty($data)) { echo 'Khong co du lieu vui long kiem tra lai'; die; } $params = array(); foreach ($data as $link_url => $dek) { $params[] = array('cate_id' => $cate_id, 'url' => $link_url, 'md5url' => md5($link_url), 'source_id' => $this->_source_id, 'short_text' => $dek, 'parent_id' => $category['parent_id']); } $params = array_reverse($params); yii_insert_multiple('link', $params, 'db_crawler'); echo "<pre>" . print_r($params, true) . "</pre>"; }
public function actionApprove() { $id = urlGETParams('id', VARIABLE_NUMBER); $query = "SELECT * FROM tbl_youtube WHERE id = " . $id; $row = $this->db_crawler->createCommand($query)->queryRow(); if (!empty($row['tags'])) { $tags = json_decode($row['tags'], true); trim_array($tags); $tags = $this->createTags($tags); } unset($row['id']); unset($row['is_approve']); $row['alias'] = $this->checkAlias(change_url_seo($row['title'])); $row['tags'] = $tags; $row['viewer'] = rand(123, 5000); $row['is_feature'] = intval($_GET['is_feature']); $publishedAt = trim($row['publishedAt'], '"'); $row['created'] = strtotime($publishedAt); yii_insert_row('youtube', $row); createMessage('Approve video: ' . $row['title'] . ' thành công'); $query = "UPDATE tbl_youtube SET is_approve = 1 WHERE id = " . $id; $this->db_crawler->createCommand($query)->execute(); $this->redirect($this->createUrl('reviewyt/index')); }
public function actionPermission() { $data = array(); $rule_id = urlGETParams('id', VARIABLE_NUMBER); $record = $this->getRow($rule_id); if (empty($record)) { createMessage('Nội dung bạn yêu cầu không tồn tại'); $this->redirect($this->createUrl('index')); } $data['rule'] = $record; $system = isset($_GET['system']) ? trim($_GET['system']) : 'backend'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (!empty($_POST)) { $query_delete = "DELETE FROM {{permission}} WHERE rule_id = :rule_id AND system = :system"; $values = array(':rule_id' => $rule_id, ':system' => $system); $this->db->createCommand($query_delete)->bindValues($values)->execute(); $params = array(); foreach ($_POST as $controller => $actions) { $params[] = array('system' => $system, 'rule_id' => $rule_id, 'controller' => $controller, 'actions' => serialize($actions)); } if (!empty($params)) { yii_insert_multiple('permission', $params); } } createMessage('Cập nhật thành công'); $this->redirect($_SERVER['HTTP_REFERER']); } $query = "SELECT * FROM {{permission}} WHERE system = :system AND rule_id = :rule_id"; $values = array(':system' => 'backend', ':rule_id' => $rule_id); $listController = $this->db->createCommand($query)->bindValues($values)->queryAll(); $data['listController'] = array(); if (!empty($listController)) { foreach ($listController as $item) { $data['listController'][$item['controller']] = unserialize($item['actions']); } } $myPath = ROOT_PATH . '/protected/controllers/' . $system; $controller_ignore = $this->controllerIgnore(); $dir = new DirectoryIterator($myPath); $listClass = array(); foreach ($dir as $fileinfo) { $pattern = '/.*\\.(php)/i'; if (!$fileinfo->isDot() && $fileinfo->isFile()) { if (preg_match($pattern, $fileinfo->getFilename())) { $filename = $fileinfo->getFilename(); //var_dump(file_exists($path . '/' . $filename)); //echo $myPath . '/' . $filename . '<br />'; include_once $myPath . '/' . $filename; $filename = substr($filename, 0, strlen($filename) - 4); $filename_tmp = str_replace('Controller', '', $filename); if (in_array(strtolower($filename_tmp), $controller_ignore[$system])) { continue; } $listClass[] = $filename; } } } $listAction = array(); foreach ($listClass as $class) { $controller = strtolower(str_replace('Controller', '', $class)); $listAction[$controller]['name'] = $class; $refClass = new ReflectionClass($class); $doc = $refClass->getDocComment(); preg_match_all('#@desc(.*?)\\n#s', $doc, $desc); $listAction[$controller]['description'] = trim($desc[1][0]); $listAction[$controller]['controller'] = $controller; $actions = array(); $class_methods = get_class_methods(new $class()); foreach ($class_methods as $method) { $reflect = new ReflectionMethod($class, $method); if (strpos($method, 'action') === 0 && $reflect->isPublic() && $method != 'actions') { $actions[] = strtolower(substr($method, 6, strlen($method))); } } $listAction[$controller]['actions'] = $actions; } $data['listItem'] = $listAction; $this->render('permission', array('data' => $data)); }
public function actionTag() { $action = urlGETParams('action'); if ($action == 'changefeature') { return $this->changeFeatureAction(); } if ($action == 'edit') { return $this->editTagAction(); } $data = array(); $where = ""; $feature = urlGETParams('feature', VARIABLE_NUMBER); if ($feature == 1) { $where .= " AND is_feature = 1 "; } $query_count = "SELECT COUNT(id) FROM tbl_tags_youtube WHERE 1 " . $where; $item_count = $this->db->createCommand($query_count)->queryScalar(); $pages = new CPagination($item_count); $perPage = 50; $pages->setPageSize($perPage); $page = isset($_GET['page']) ? intval($_GET['page']) : 0; if ($page <= 0) { $page = 1; } $offset = ($page - 1) * $perPage; $order = 'total_video'; $query = "SELECT * FROM tbl_tags_youtube WHERE 1 " . $where . " " . " ORDER BY " . $order . " DESC " . "LIMIT " . $offset . "," . $perPage; $data['listItem'] = $this->db->createCommand($query)->queryAll(); $this->render('tag', array('data' => $data, 'item_count' => $item_count, 'page_size' => $perPage, 'pages' => $pages)); }
public function actionResetPassword() { $id = urlGETParams('id'); $base64Data = base64_decode($id); $arr = explode('<>', $base64Data); if (count($arr) < 3) { $this->redirect($this->createUrl('index')); } if ($arr[2] <= time()) { createMessage('URL hết hạn', 'danger'); $this->redirect($this->createUrl('index')); } $query = "SELECT * FROM {{" . $this->_table . "}} WHERE id = :id AND email = :email AND is_advertiser = 1 LIMIT 1"; $values = array(':email' => $arr[1], ':id' => $arr[0]); $row = $this->db->createCommand($query)->bindValues($values)->queryRow(); if (empty($row)) { $this->redirect($this->createUrl('index')); } $data = array('user' => $row); $resetForm = new AdvertiseResetPasswordForm(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $resetForm->setAttributes($_POST['AdvertiseResetPasswordForm']); if ($resetForm->validate()) { $query = "UPDATE {{" . $this->_table . "}} SET password = :password WHERE id = " . $arr[0]; $values = array(':password' => md5($resetForm->password)); $this->db->createCommand($query)->bindValues($values)->execute(); Yii::app()->session['reset_passsword'] = $row['email']; $this->redirect($this->createUrl('success')); } } $data['form'] = $resetForm; $this->render('resetpassword', array('data' => $data)); }
public function actionApprove() { $id = urlGETParams('id', VARIABLE_NUMBER); $query = "SELECT * FROM tbl_archive WHERE id = " . $id; $row = $this->db_crawler->createCommand($query)->queryRow(); if (!empty($row['tags'])) { $tags = json_decode($row['tags'], true); trim_array($tags); $tags = $this->createTags($tags); } //`tags`, `meta_keywords`, `meta_description`, `gallery`, `source_id`, `source_url`, `status` $values = array('cate_id' => $row['cate_id'], 'title' => $row['title'], 'alias' => $this->checkAlias(change_url_seo($row['title'])), 'thumbnail' => $row['thumbnail'], 'short_text' => $row['short_text'], 'content' => $row['content'], 'gallery' => $row['gallery'], 'meta_keywords' => $row['meta_keywords'], 'meta_description' => $row['meta_description'], 'source_id' => $row['source_id'], 'source_url' => $row['source_url'], 'have_video' => $row['have_video'], 'status' => 1, 'tags' => $tags, 'created' => time()); yii_insert_row('archive', $values); createMessage('Approve noi dung: ' . $row['title'] . ' thành công'); $query = "DELETE FROM tbl_archive WHERE id = " . $id; $this->db_crawler->createCommand($query)->execute(); $this->redirect($this->createUrl('review/index', array('source' => $row['source_id']))); }
<div class="row"> <div class="col-md-12"> <p>Tổng số có <strong><?php echo $item_count; ?> </strong> video cần duyệt</p> <form method="GET" action=""> <?php $name = urlGETParams('name'); $feature = urlGETParams('feature', VARIABLE_NUMBER); $order = urlGETParams('order', VARIABLE_NUMBER); $error = urlGETParams('error', VARIABLE_NUMBER); ?> Tiêu đề video <input class="form-control" style="width: 200px; display: inline-block" type="text" name="name" value="<?php echo CHtml::encode($name); ?> " /> <label><input type="checkbox" name="feature" value="1" <?php if ($feature == 1) { echo 'checked=""'; } ?> /> Feature</label> <label><input type="checkbox" name="order" value="1" <?php if ($order == 1) { echo 'checked=""'; } ?> /> Order created</label>