public function actionDetail() { $query = "SELECT * FROM tbl_youtube WHERE status = 0 LIMIT 1"; $row = $this->db_crawler->createCommand($query)->queryRow(); if (empty($row)) { echo 'het roi'; die; } $video_id = $row['video_id']; $url = 'https://www.googleapis.com/youtube/v3/videos?part=snippet&id=' . $video_id . '&key=' . $this->_key; $data = $this->fectchGoogleData($url); if (!empty($data['error'])) { echo "<pre>" . print_r($data, true) . "</pre>"; die; } $video = $data['items'][0]['snippet']; $values = array(); $values['title'] = trim($video['title']); $values['description'] = trim($video['description']); $values['thumbnails'] = json_encode($video['thumbnails']); $values['tags'] = json_encode($video['tags']); $values['publishedAt'] = json_encode($video['publishedAt']); if (!empty($video['channelTitle'])) { $values['channel_name'] = $video['channelTitle']; } $values['status'] = 1; yii_update_row('youtube', $values, 'id = ' . $row['id'], 'db_crawler'); echo "<pre>" . print_r($values, true) . "</pre>"; $query = "SELECT COUNT(id) FROM tbl_youtube WHERE status = 0"; $count = $this->db_crawler->createCommand($query)->queryScalar(); echo '<h1>Count: ' . $count . '</h1>'; echo '<meta http-equiv="refresh" content="1">'; }
public function actionEdit() { $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')); } $form = new RuleForm('edit'); $form->id = $record['id']; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $form->attributes = $_POST['RuleForm']; if ($form->validate()) { $values = array('rule' => trim($form->rule)); yii_update_row($this->_table, $values, 'id = ' . $rule_id); createMessage('Cập nhật nhóm người dùng thành công'); $this->redirect($this->createUrl('index')); } } else { $form->attributes = $record; $form->id = $record['id']; } $data['form'] = $form; $this->render('add', array('data' => $data)); }
public function actionDetail() { $data = array(); $id = urlGETParams('id', VARIABLE_NUMBER); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $params = $_POST; yii_update_row('youtube', $params, 'id = ' . $id, 'db_crawler'); createMessage('Cập nhật thành công'); $this->redirect($this->createUrl('detail', array('id' => $id))); } $query = "SELECT * FROM tbl_youtube WHERE id = " . $id; $data = $this->db_crawler->createCommand($query)->queryRow(); $this->render('detail', array('data' => $data)); }
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)); }
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); } yii_update_row('archive', $params, 'id = ' . $id, 'db_crawler'); createMessage('Cập nhật thành công'); $this->redirect($this->createUrl('detail', array('id' => $id))); } $query = "SELECT * FROM tbl_archive WHERE id = " . $id; $data = $this->db_crawler->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)); }