/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new TianjiUserJson(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['TianjiUserJson'])) { $model->attributes = $_POST['TianjiUserJson']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->userid)); } } $this->render('create', array('model' => $model)); }
public function actionGetURL($start = null, $num = null) { //获取URL地址 if (!empty($start) && !empty($num)) { $ids = $this->getUserIds($start, $num); foreach ($ids as $id) { $url = $this->getURL($id); echo $id . ' : '; //.$url; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1"); curl_setopt($ch, CURLOPT_NOBODY, false); // remove body curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $head = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); switch ($httpCode) { case 200: echo ' 200 ok'; $model = TianjiUserJson::model()->findByPk($id); if ($model === null) { $model = new TianjiUserJson(); $model->userid = $id; $model->json = $head; $model->save(); } break; case 500: echo ' 500'; break; default: echo ' ' . $httpCode; break; } echo "\n"; } } else { echo "Hello World!!!"; } }
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1"); curl_setopt($ch, CURLOPT_NOBODY, false); // remove body curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $head = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); switch ($httpCode) { case 200: echo ' 200 ok'; $model = TianjiUserJson::model()->findByPk($id); if ($model === null) { $model = new TianjiUserJson(); $model->userid = $id; $model->json = $head; $model->save(); } break; case 500: echo ' 500'; break; default: echo ' ' . $httpCode; break; } echo "<br/>"; } } else { echo "Hello World!!!"; } ?>