public function actionAdd() { $data = array(); $form = new RuleForm('add'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $form->attributes = $_POST['RuleForm']; if ($form->validate()) { $values = array('rule' => trim($form->rule)); yii_insert_row($this->_table, $values); createMessage('Thêm mới nhóm người dùng thành công'); $this->redirect($this->createUrl('index')); } } $data['form'] = $form; $this->render('add', array('data' => $data)); }
public function actionAdd() { $data = array(); 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_insert_row($this->_table, $params); createMessage('Thêm mới 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']; } $this->render('add', array('data' => $data)); }
public function actionAdd() { $data = array(); $form = new AddAdsForm(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $form->setAttributes($_POST['AddAdsForm']); if ($form->validate()) { $start_time = 0; $end_time = 0; if ($form->campaign_type == 1) { $start_time = $form->start_time; $arr = explode('/', $start_time); $arr = array_reverse($arr); $date = implode('/', $arr) . ' 00:00:00'; $start_time = strtotime($date); } else { $arrDate = explode(' - ', $form->range_time); $start_time = $arrDate[0]; $arr = explode('/', $start_time); $arr = array_reverse($arr); $date = implode('/', $arr) . ' 00:00:00'; $start_time = strtotime($date); $start_time2 = $arrDate[1]; $arr = explode('/', $start_time2); $arr = array_reverse($arr); $date = implode('/', $arr) . ' 00:00:00'; $end_time = strtotime($date); } $image = $this->saveAppIcon($form->image); $values = array('uid' => $this->user['id'], 'bundle_id' => trim($form->bundle_id), 'apple_id' => trim($form->apple_id), 'app_name' => trim($form->app_name), 'image' => $image, 'os' => intval($form->os), 'install_number' => intval($form->install_number), 'url_post_back' => trim($form->url_post_back), 'campaign_type' => intval($form->campaign_type), 'start_time' => $start_time, 'end_time' => $end_time); yii_insert_row($this->_table, $values); createMessage('Tạo quảng cáo thành công, quảng cáo của bạn sẽ được Admin duyệt trong vòng 24h'); $this->redirect($this->createUrl('index')); } } $data['form'] = $form; $this->render('add', array('data' => $data)); }
public function actionDetail() { $query = "SELECT * FROM tbl_link WHERE source_id = " . $this->_source_id . " AND status = 0 ORDER BY id LIMIT 1"; $row = $this->db_crawler->createCommand($query)->queryRow(); if (empty($row)) { die('het roi'); } echo "<pre>" . print_r($row, true) . "</pre>"; $url = $row['url']; $response = fectchContent($url); $html = str_get_html($response); $title = trim($html->find('title', 0)->innertext()); $title = str_replace(' - CNET', '', $title); $thumbnail = trim($html->find('meta[property="og:image"]', 0)->content); $meta_keywords = $html->find('meta[itemprop="keywords"]', 0); if (!empty($meta_keywords)) { $meta_keywords = trim($meta_keywords->content); } $meta_description = $html->find('meta[name="description"]', 0); if (!empty($meta_description)) { $meta_description = trim($meta_description->content); } //page 1 $content1 = $html->find('#editorReview', 0); $this->processContent($title, $content1); //page 2 $url .= '2/'; $html = file_get_html($url); $content2 = $html->find('#editorReview', 0); $this->processContent($title, $content2); $content = $content1 . $content2; $tags = array(); $list_images = array(); $values = array('parent_id' => $row['parent_id'], 'cate_id' => $row['cate_id'], 'title' => str_replace(' - CNET', '', $title), 'thumbnail' => $thumbnail, 'gallery' => json_encode($list_images), 'tags' => json_encode($tags), 'content' => $content, 'source_id' => $this->_source_id, 'source_url' => $row['url'], 'short_text' => $row['short_text'], 'meta_keywords' => $meta_keywords, 'meta_description' => $meta_description, 'created' => time()); yii_insert_row('archive', $values, 'db_crawler'); $this->crawlerSuccess($row); }
public function actionAdd() { $data = array(); $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') { $vl = md5(trim($vl)); } $values[$key] = trim($vl); } $values['created'] = time(); yii_insert_row($this->_table, $values); $uid = $this->db->lastInsertID; $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('Thêm mới người dùng thành công'); $this->redirect($this->createUrl('index')); } } $data['rule'] = $this->getListRule(); $data['form'] = $form; $this->render('add', array('data' => $data)); }
public function actionDetail() { $query = "SELECT * FROM tbl_link WHERE source_id = " . $this->_source_id . " AND status = 0 ORDER BY id LIMIT 1"; $row = $this->db_crawler->createCommand($query)->queryRow(); if (empty($row)) { die('het roi'); } echo "<pre>" . print_r($row, true) . "</pre>"; $url = $row['url']; $response = fectchContent($url); $html = str_get_html($response); if (empty($html)) { echo 'Error'; $this->crawlerSuccess($row, 2); die; } //div.article-main-body:first //.col-8:first //thumbnail $thumbnail = trim($html->find('meta[property="og:image"]', 0)->content); $content = $html->find('.article-body', 0); $list_images = array(); // $gallery = $content->find('div.gallery', 0); // if (!empty($gallery)) { // $gallery_href = trim($gallery->find('.imageLinkWrapper', 0)->href); // $list_images = $this->getImages($gallery_href); // } $remove_elements = array(); if (!empty($remove_elements)) { foreach ($content->find(implode(', ', $remove_elements)) as $item) { $item->outertext = ''; } } // $attr = 'data-original'; // $imgs = $content->find('.originalImage img, .imageContainer img'); // if (!empty($imgs)) { // foreach ($imgs as $item) { // $src = trim($item->src); // if (empty($src)) { // $item->src = trim($item->$attr); // $item->$attr = ''; // } // } // } $links = $content->find('a'); foreach ($links as $item) { $href = trim($item->href); if (empty($href) | strpos($href, '#') === 0) { $item->outertext = ''; } else { $inner_text = trim($item->innertext()); $item->outertext = '<strong class="txt-bold">' . $inner_text . '</strong>'; } } //lay danh sach tags $tags = array(); // $html_tags = $html->find('div.collections-topics-and-tags a'); // if (!empty($html_tags)) { // foreach ($html_tags as $item) { // $tags[] = trim($item->innertext()); // } // } $title = trim($html->find('title', 0)->innertext()); //meta_keywords //meta itemprop="keywords" $meta_keywords = $html->find('meta[itemprop="keywords"]', 0); if (!empty($meta_keywords)) { $meta_keywords = trim($meta_keywords->content); } $meta_description = $html->find('meta[name="description"]', 0); if (!empty($meta_description)) { $meta_description = trim($meta_description->content); } $values = array('parent_id' => $row['parent_id'], 'cate_id' => $row['cate_id'], 'title' => str_replace(' | Windows Central', '', $title), 'thumbnail' => $thumbnail, 'gallery' => json_encode($list_images), 'tags' => json_encode($tags), 'content' => $content->outertext, 'source_id' => $this->_source_id, 'source_url' => $url, 'short_text' => $row['short_text'], 'meta_keywords' => $meta_keywords, 'meta_description' => $meta_description, 'created' => time()); yii_insert_row('archive', $values, 'db_crawler'); $this->crawlerSuccess($row); }
private function searchVideo($args) { //ini_set('memory_limit', '-1'); $db2 = EduDataBase::getConnection('db2'); if (isset($args[1])) { $query = "SELECT * FROM {{video_search}} WHERE is_run = 0 ORDER BY id " . $args[1] . " LIMIT 1"; } else { $query = "SELECT * FROM {{video_search}} WHERE is_run = 0 LIMIT 1"; } $row = $db2->createCommand($query)->queryRow(); if (empty($row)) { die('Het du lieu roi'); } $query = "SELECT * FROM {{video_source}}"; $list = $db2->createCommand($query)->queryAll(); $list_source = array(); $search_result = array(); $total_source = 0; $count_run = 0; echo "Tim kiem video: " . $row['keywords'] . "\n"; foreach ($list as $item) { //`video_search_id`, `source_id`, `html_data` $result = $this->findVideo($item, $row); if ($result == false) { continue; } $have_data = $result['have_data']; unset($result['have_data']); yii_insert_row('source_html', $result, 'db2', true); if ($have_data == 1) { $total_source++; } $count_run++; $search_result[$item['id']] = $have_data; } //`search_result`, `total_source`, `is_run` $update = "UPDATE {{video_search}} SET count_run = :count_run, search_result = :search_result, total_source = :total_source, is_run = :is_run WHERE id = :id"; $values = array(':search_result' => json_encode($search_result), ':total_source' => $total_source, ':is_run' => 1, ':count_run' => $count_run, ':id' => $row['id']); $db2->createCommand($update)->bindValues($values)->execute(); echo "Done\n\n"; sleep(1); echo "------------------------------------------------\n"; echo "Chay them lan nua\n"; echo "------------------------------------------------\n"; $args[0] = 'search'; $this->run($args); }
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']))); }
public function actionTest() { $time = date('d/m/Y H:i:s'); $values = array('created' => $time); yii_insert_row('test_crawler', $values, 'db_crawler'); }
public function actionDetail() { $query = "SELECT * FROM tbl_link WHERE source_id = " . $this->_source_id . " AND status = 0 ORDER BY id LIMIT 1"; $row = $this->db_crawler->createCommand($query)->queryRow(); if (empty($row)) { die('het roi'); } $url = $row['url']; $response = fectchContent($url); $html = str_get_html($response); //div.article-main-body:first //.col-8:first //thumbnail $thumbnail = trim($html->find('meta[property="og:image"]', 0)->content); //lay thong tin gallery $gallery = array(); $html_gallery = $html->find('.slideshowify', 0); if (!empty($html_gallery)) { $imgs = $html_gallery->find('img'); foreach ($imgs as $img) { $attr = 'data-full-size-image'; $gallery['images'][] = trim($img->{$attr}); } } //content $content = $html->find('div.article-entry', 0); if (empty($content)) { echo '<h1>Error</h1>'; $this->crawlerSuccess($row, 2); die; } $remove_elements = array('.byline', '.inset-ad', '.inset-sm', '.social-share', '.slideshowify', '.aside-related-articles', '.native-ad-mobile', 'script', 'small'); foreach ($content->find(implode(', ', $remove_elements)) as $item) { $item->outertext = ''; } //cancel link in content $links = $content->find('a'); foreach ($links as $item) { $href = trim($item->href); if (empty($href) | strpos($href, '#') === 0) { $item->outertext = ''; } else { $inner_text = trim($item->innertext()); $item->outertext = '<strong class="txt-bold">' . $inner_text . '</strong>'; } } //lay danh sach tags $tags = array(); $html_tags = $html->find('div.accordion a'); if (!empty($html_tags)) { foreach ($html_tags as $item) { $tags[] = trim($item->innertext()); } } else { $html_tags = $html->find('.article-header .tag-item'); if (!empty($html_tags)) { foreach ($html_tags as $item) { $obj = $item->find('a', 0); $tags[] = trim($obj->innertext()); } } } $title = trim($html->find('title', 0)->innertext()); $parent = "/\\s+/ims"; $title = preg_replace($parent, ' ', $title); //meta_keywords //meta itemprop="keywords" $meta_keywords = $html->find('meta[itemprop="keywords"]', 0); if (!empty($meta_keywords)) { $meta_keywords = trim($meta_keywords->content); } $meta_description = $html->find('meta[name="description"]', 0); if (!empty($meta_description)) { $meta_description = trim($meta_description->content); } $content = str_replace('<!-- Begin: Wordpress Article Content -->', '', $content->outertext); $content = str_replace('<!-- End: Wordpress Article Content -->', '', $content); $values = array('parent_id' => $row['parent_id'], 'cate_id' => $row['cate_id'], 'title' => str_replace(' | TechCrunch', '', $title), 'thumbnail' => $thumbnail, 'tags' => json_encode($tags), 'content' => $content, 'source_id' => $this->_source_id, 'source_url' => $url, 'short_text' => $row['short_text'], 'meta_keywords' => $meta_keywords, 'meta_description' => $meta_description, 'gallery' => json_encode($gallery), 'created' => time()); echo "<pre>" . print_r($row, true) . "</pre>"; yii_insert_row('archive', $values, 'db_crawler'); $this->crawlerSuccess($row); }
public function actionDetail() { $query = "SELECT * FROM tbl_link WHERE source_id = " . $this->_source_id . " AND status = 0 ORDER BY id LIMIT 1"; $row = $this->db_crawler->createCommand($query)->queryRow(); if (empty($row)) { die('het roi'); } echo "<pre>" . print_r($row, true) . "</pre>"; // die; $url = $row['url']; // $url = 'http://techz24.vn/abc.html'; $response = fectchContent($url); $html = str_get_html($response); if (empty($html)) { echo 'Error'; $this->crawlerSuccess($row, 2); die; } //div.article-main-body:first //.col-8:first //thumbnail $thumbnail = trim($html->find('meta[property="og:image"]', 0)->content); $content = $html->find('.article-body', 0); if (empty($content)) { echo 'Error'; $this->crawlerSuccess($row, 2); die; } $list_images = array(); //lay thong tin anh neu co $media = $content->find('.media-gallery', 0); if (!empty($media)) { $attr = 'data-big'; $imgs = $media->find('img'); $list_images['title'] = ''; foreach ($imgs as $img) { $list_images['images'][] = $this->_domain . trim($img->{$attr}); } } $remove_elements = array('script', 'noscript', '.media-gallery', '.devicebox', 'style'); if (!empty($remove_elements)) { foreach ($content->find(implode(', ', $remove_elements)) as $item) { $item->outertext = ''; } } $links = $content->find('a'); foreach ($links as $item) { $href = trim($item->href); if (empty($href) | strpos($href, '#') === 0) { $item->outertext = ''; } else { $inner_text = trim($item->innertext()); $item->outertext = '<strong class="txt-bold">' . $inner_text . '</strong>'; } } //lay danh sach tags $tags = array(); $title = trim($html->find('title', 0)->innertext()); //meta_keywords //meta itemprop="keywords" $meta_keywords = $html->find('meta[itemprop="keywords"]', 0); if (!empty($meta_keywords)) { $meta_keywords = trim($meta_keywords->content); } $meta_description = $html->find('meta[name="description"]', 0); if (!empty($meta_description)) { $meta_description = trim($meta_description->content); } $values = array('parent_id' => $row['parent_id'], 'cate_id' => $row['cate_id'], 'title' => str_replace(' | Android Central', '', $title), 'thumbnail' => $thumbnail, 'gallery' => json_encode($list_images), 'tags' => json_encode($tags), 'content' => $content->outertext, 'source_id' => $this->_source_id, 'source_url' => $url, 'short_text' => $row['short_text'], 'meta_keywords' => $meta_keywords, 'meta_description' => $meta_description, 'created' => time()); yii_insert_row('archive', $values, 'db_crawler'); $this->crawlerSuccess($row); }
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')); }
private function registerProcess() { $registerForm = new AdvertiseRegisterForm(); $registerForm->attributes = $_POST['AdvertiseRegisterForm']; if ($registerForm->validate()) { $values = array('fullname' => trim($registerForm->fullname), 'email' => trim($registerForm->email), 'mobile' => trim($registerForm->mobile), 'password' => md5(trim($registerForm->password)), 'created' => time(), 'is_advertiser' => 1, 'status' => 1); yii_insert_row($this->_table, $values); $values['id'] = $this->db->lastInsertID; Yii::app()->session['advertiser'] = $values; $this->redirect($this->createUrl('index/index')); } return $registerForm; }