public function actionPhoto() { $criteria = new CDbCriteria(); $criteria->limit = 25; $model = Photo::model()->is_publish()->findAll($criteria); $this->setRss($model, 'photo', 'Photo', 'Rss Feed Photo', $this->createUrl('photo')); }
public function actionList() { $request = Yii::app()->getRequest(); $page = $request->getParam("page"); if (!$page) { $page = 1; } $pagenum = $request->getParam("pagenum"); if (!$pagenum) { $pagenum = 12; } $winner = new Winner(); $criteria = new CDbCriteria(); $criteria->select = '*'; $criteria->limit = $pagenum; $criteria->offset = ($page - 1) * $pagenum; $criteria->order = 'month DESC'; $winners = $winner->findAll($criteria); $res = array(); foreach ($winners as $winner) { $res[] = $winner->attributes; } $topPhoto = Photo::model()->findByAttributes(array('weibo_id' => $winners[0]->mid)); if ($topPhoto) { $res[0]['detail'] = $topPhoto->attributes; } $this->responseJSON($res, "success"); }
public function actionIndex() { echo "================================================================================\n\r"; echo "ATMOSPHERA console command: Batch resizing of uploaded photos\n\r"; echo "================================================================================\n\r"; $fileform = new PhotoFileForm(); //get instance of model $fileform->setImageSize(); //set sizes from params-local $path = UrlHelper::getImageDir(); //get dir for upload $criteia = new CDbCriteria(); $countTotal = Photo::model()->count($criteia); echo "total count of photo: " . $countTotal . "\n\r"; echo "start process... please wait\n\r"; $offset = 0; //DebugBreak(); $step = floor($countTotal / 10); $criteia->limit = $step; $criteia->offset = $offset; $countTotal = 0; while (($count = count($aPhotos = Photo::model()->findAll($criteia))) > 0) { foreach ($aPhotos as $oPhoto) { $fileform->createImages($path, $oPhoto->filename, $oPhoto->thumb_filename); } $offset += $step; $criteia = new CDbCriteria(); $criteia->limit = $step; $criteia->offset = $offset; $countTotal += $count; echo "."; } echo "\n\r"; echo "total count of processed files: " . $countTotal . "\n\r"; }
private function loadPost($id, $slug) { $model = Photo::model()->is_publish()->findByAttributes(array('ID' => (int) $id, 'post_link' => $slug)); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function run() { $criteria = new CdbCriteria(); $criteria->limit = $this->data('limit'); $criteria->offset = $this->data('offset'); $model = Photo::model()->is_publish()->findAll($criteria); $this->layout($model); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Photo the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Photo::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionGetImages() { set_time_limit(0) or die('1'); $photos = Photo::model()->findAll(array('limit' => 3500, 'offset' => 10000)); foreach ($photos as $photo) { $this->downloadPhoto($photo->path); } }
/** * Retrieves a list of models based on the current search/filter conditions. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. */ public function getPhotoByAlbum($id) { // Warning: Please modify the following code to remove attributes that // should not be searched. $criteria = new CDbCriteria(); $criteria->condition = "album_id = '{$id}'"; $criteria->order = "id asc"; $model = Photo::model()->findAll($criteria); return $model; }
public function actionCustomer() { $model = new Order(); $errorMessage = null; if (isset($_GET['order_id']) && Order::model()->isValidateOrderId($_GET['order_id'])) { $model = $this->loadExistOrder($_GET['order_id']); $model->order_info = OrderState::model()->getStateZnByStateId($model->order_state_id) . $model->remark; $model->product_name = Product::model()->getProductNameByProductId($model->product_id); $model->order_photos = Photo::model()->findAllByAttributes(array('product_id' => $model->product_id)); } else { $model->unsetAttributes(); $errorMessage = Yii::t('order', 'Order is not exist!'); } $this->layout = false; $this->render('_customer', array('model' => $model, 'message' => $errorMessage)); }
public function actionPhotos() { if (!empty($_POST)) { if (isset($_POST['deletephotos'])) { $anketa = Anketa::model()->findByPk(Yii::app()->user->id); if (!$anketa) { throw new CException('Error user'); } if (isset($_POST['delete']) && is_array($_POST['delete'])) { foreach ($_POST['delete'] as $k => $v) { if ($k == $anketa->mainphoto) { $anketa->mainphoto = null; $anketa->saveAttributes(array('mainphoto')); } if ($model = Photo::model()->findByPk(array('id_user' => Yii::app()->user->id, 'id_photo' => $k))) { $model->delete(); } } Yii::app()->user->setFlash('profile', 'Информация обновлена'); } else { Yii::app()->user->setFlash('profile', 'Не выбраны фото для удаления'); } $this->refresh(); } else { if (isset($_POST['mainphoto'])) { $id = array_keys($_POST['mainphoto']); $id = $id[0]; $model = Anketa::model()->findByPk(Yii::app()->user->id); if (!$model) { throw new CException('Error user'); } $photo = Photo::model()->findByPk(array('id_photo' => $id, 'id_user' => $model->id)); if (!$photo) { throw new CException('Error photo'); } $model->mainphoto = $id; $model->saveAttributes(array('mainphoto')); Yii::app()->user->setFlash('profile', 'Основная фотография изменена'); $this->refresh(); } } } $models = Photo::model()->findAllByAttributes(array('id_user' => Yii::app()->user->id)); $user = Anketa::model()->findByPk(Yii::app()->user->id); $this->render('photos', compact('models', 'user')); }
public function actionInside() { if (isset($_GET['id'])) { $model = News::model()->findByPk($_GET['id']); $model_photo = Photo::model()->getPhotoByAlbum($_GET['id']); //print_r($model_photo); $this->render('detail', array('model' => $model, 'model_photo' => $model_photo)); } else { $news_criteria = new CDbCriteria(); $news_criteria->condition = "status = 1 AND news_type_id = 5"; $news_criteria->order = "create_date desc,news_id desc"; $news_total = News::model()->count($news_criteria); $pages = new CPagination($news_total); $pages->setPageSize(10); $pages->applyLimit($news_criteria); $news = News::model()->findAll($news_criteria); $this->render('news', array('news' => $news, 'pages' => $pages)); } }
public function actionDelete($id) { $service = Service::model()->findAll('contractor_id=' . $id); if ($service) { foreach ($service as $serv) { WrapServTransport::Del($serv->id); ServCulture::model()->deleteAllByAttributes(array('service_id' => $serv->id)); $food = ServFood::model()->findAll('service_id=' . $serv->id); if ($food) { foreach ($food as $mFood) { LinkFoodServ::model()->deleteAllByAttributes(array('serv_food_id' => $mFood->id)); } } ServFood::model()->deleteAllByAttributes(array('service_id' => $serv->id)); ServIntensiv::model()->deleteAllByAttributes(array('service_id' => $serv->id)); ServOther::model()->deleteAllByAttributes(array('service_id' => $serv->id)); $personal = ServPersonal::model()->findAll('service_id=' . $serv->id); if ($personal) { foreach ($personal as $mPers) { LinkPersonalLanguage::model()->deleteAllByAttributes(array('serv_personal_id' => $mPers->id)); } } ServPersonal::model()->deleteAllByAttributes(array('service_id' => $serv->id)); ServPlatform::model()->deleteAllByAttributes(array('service_id' => $serv->id)); ServProgram::model()->deleteAllByAttributes(array('service_id' => $serv->id)); ServTicket::model()->deleteAllByAttributes(array('service_id' => $serv->id)); $live = ServLive::model()->findAll('service_id=' . $serv->id); if ($live) { foreach ($live as $mLive) { ServLiveRoom::model()->deleteAllByAttributes(array('serv_live_id' => $mLive->id)); } } ServLive::model()->deleteAllByAttributes(array('service_id' => $serv->id)); Photo::model()->deleteAllByAttributes(array('service_id' => $serv->id)); } } Service::model()->deleteAllByAttributes(array('contractor_id' => $id)); Comment::model()->deleteAllByAttributes(array('contractor_id' => $id)); LinkCityContractor::model()->deleteAllByAttributes(array('contractor_id' => $id)); Contractor::model()->deleteByPk($id); echo "ok"; }
public function getImageSrc($imageSize = Photo::SIZE_MEDIUM) { if (($profile = $this->profile) !== null) { if (($photo = Photo::model()->findByPk($profile->photo_id)) !== null) { return ($src = $photo->getSrcAsSize($imageSize)) !== null ? $src : self::getDefaultImgSrc($imageSize); } } return self::getDefaultImgSrc($imageSize); }
function tearDown() { if ($this->photo_id) { $photo = Photo::model()->findByPk($this->photo_id)->delete(); } }
/** * 获取用户得到的所有照片 * */ public function actionGetUserAllPhoto() { // 参数检查 if (!isset($_REQUEST['user_id']) || !isset($_REQUEST['token']) || !isset($_REQUEST['type'])) { $this->_return('MSG_ERR_LESS_PARAM'); } $user_id = trim(Yii::app()->request->getParam('user_id')); $token = trim(Yii::app()->request->getParam('token')); $type = trim(Yii::app()->request->getParam('type')); $timestamp = trim(Yii::app()->request->getParam('timestamp')); if (!is_numeric($user_id)) { $this->_return('MSG_ERR_FAIL_PARAM'); } //验证token if (!Token::model()->verifyToken($user_id, $token, $GLOBALS['__APPID'])) { $this->_return('MSG_ERR_TOKEN'); } $timestamp = strtotime($timestamp); //用户不存在 返回错误 if ($user_id < 1) { $this->_return('MSG_ERR_NO_USER'); } $image = Photo::model()->getUserAllPhoto($user_id, $type, $timestamp); $this->_return('MSG_SUCCESS', $image); }
public function actionDelete($id) { Photo::model()->deleteAllByAttributes(array('service_id' => $id)); Service::model()->deleteByPk($id); echo "ok"; }
public function readMess($user_id, $mess_id) { $table_name = sprintf('user_message_%02s', dechex($user_id % 256)); $info = false; $res = ''; try { $con_message = Yii::app()->db_message; $info = $con_message->createCommand()->select('m_id, heroine_id, type, create_ts, msg_text, msg_type, msg_url, msg_id')->from($table_name)->where("m_id=:mess_id AND type = 0")->bindParam(':mess_id', $mess_id, PDO::PARAM_INT, 11)->queryRow(); if ($info) { //image 解锁图片 根据图片类型,解锁图片或推送图片 if ($info['msg_type'] == 1) { $photo_type = Photo::model()->selectPhotoType($info['msg_id']); $photo_type = $photo_type['type']; $photoParams = array('user_id' => $user_id, 'heroine_id' => $info['heroine_id'], 'photo_id' => $info['msg_id'], 'unlock_type' => 3, 'status' => 0, 'is_open' => 1, 'type' => $photo_type, 'timestamp' => time()); //插入解锁照片 Photo::model()->insertPhoto($user_id, $photoParams); //audio 预留 } elseif ($info['msg_type'] == 2) { //media 预留 } elseif ($info['msg_type'] == 3) { } } else { //没有此消息 return -1; } } catch (Exception $e) { error_log($e); //SQL错误 } return $res; }
<div class="form-group col-md-16"> <label class="control-label" for="service-photo">Фото</label> </div> <div class="clear-fix"></div> <br><br> <div class="photos col-md-36"> <?php $photos = Photo::model()->findAllByAttributes(array('service_id' => $serv->id)); foreach ($photos as $photo) { ?> <img src="<?php echo Yii::app()->getBaseUrl(true); ?> /upload/Service/<?php echo $serv->id; ?> /<?php echo $photo->src; ?> " width="200px"> <?php } ?> </div>
public function actionLoadInfrastructure() { $infr = []; $infr['title'] = Yii::t('static', 'static_Infraestructura_title'); $infr['description'] = Yii::t('static', 'static_Infraestructura_description'); $photos = []; foreach (Photo::model()->findAllByAttributes(array('service_id' => 11, 'status' => 'ACTIVE')) as $i => $photo) { $p = []; $p['source'] = $photo->source; array_push($photos, $p); } $infr['photos'] = $photos; echo json_encode($infr); }
public function actionPhotos($id = null) { if(isset($_GET['id'])) { $criteria = new CDbCriteria(); $criteria->condition = 'category_id = :category_id'; $criteria->params = array(':category_id'=>$id); $category = PhotoCategory::model()->findByPk($id); $category->views ++; $category->save(); $photos = Photo::model()->findAll($criteria); $relatedPhotos = PhotoCategory::model()->findAll(array('order'=>'date DESC', 'limit'=>4, 'condition'=>'id != :id', 'params'=>array(':id'=>$id))); $this->render('single_album', array('photos'=>$photos, 'category'=>$category, 'relatedPhotos'=>$relatedPhotos)); } else { $lastPhotos = PhotoCategory::model()->findAll(array('limit'=>4, 'order'=>'id DESC')); $data = new CActiveDataProvider('PhotoCategory', array( 'criteria'=>array( 'order'=>'id DESC', 'offset'=>4, ), 'sort'=>false, 'pagination'=>array( 'pageSize'=>10 ), ) ); $this->rightReclameId = 46; $this->render('albums', array('data'=>$data, 'lastPhotos'=>$lastPhotos)); } }
public function beforeBatchDelete($event) { $this->_deletedFiles = array(); $batchIds = $event->sender->getBatchIds(); foreach ($batchIds as $id) { $photo = Photo::model()->findByPk($id); $this->_deletedFiles[] = $photo->filename; $this->_deletedFiles[] = $photo->thumb_filename; $fileform = new PhotoFileForm(); $this->_deletedFiles[] = $fileform->rawDir . DIRECTORY_SEPARATOR . $photo->filename; foreach ($fileform->imageSizes as $imageSize) { $this->_deletedFiles[] = $imageSize['name'] . DIRECTORY_SEPARATOR . $photo->filename; } } }
public function actionGetPhoto() { //header_remove (); //var_dump(Yii::app()->user->isGuest);die(); //var_dump(Yii::app()->user); die(); if ($_SERVER['REMOTE_ADDR'] == '195.208.50.49') { // var_dump(Yii::app()->user); die(); } $file = $_SERVER['REQUEST_URI']; if (preg_match('#(\\d+)_(\\d+)#', $_SERVER['REQUEST_URI'], $matches)) { //504783_1 { $photo = Photo::model()->findByPk(array('id_user' => $matches[1], 'id_photo' => $matches[2])); if ($photo->intim && $photo->checkIntim()) { $file = Photo::PATH_INTIM; } } $file = $_SERVER['DOCUMENT_ROOT'] . $file; header('Content-type:image/jpeg'); readfile($file); exit; }
<?php $this->beginWidget('bootstrap.widgets.TbBox', array('title' => 'Total Publish Data')); $post = Post::model()->is_publish()->findAll(); $photo = Photo::model()->is_publish()->findAll(); $video = Video::model()->is_publish()->findAll(); $this->widget('ext.Hzl.google.HzlVisualizationChart', array('visualization' => 'PieChart', 'data' => array(array('Task', 'Total Publish Content'), array('Posts', count($post)), array('Photos', count($photo)), array('Videos', count($video))), 'options' => array('style' => array('width' => '100%', 'height' => '100%'), 'is3D' => true, 'title' => 'Total Publish Content'))); $this->endWidget(); ?> </div> <div class='span6'> <?php $this->beginWidget('bootstrap.widgets.TbBox', array('title' => 'Total Publish Data Pertahun')); $criteria = new CDbCriteria(); $criteria->group = 'year(post_created)'; $postAll = PostAll::model()->is_publish()->findAll($criteria); $data = array(array('Year', 'Post', 'Photos', 'Videos')); foreach ($postAll as $post) { $criteria = new CDbCriteria(); $criteria->condition = 'year(post_created)=' . Helper::getTime($post->post_created, 'Y'); $posts = Post::model()->is_publish()->findAll($criteria); $photo = Photo::model()->is_publish()->findAll($criteria); $video = Video::model()->is_publish()->findAll($criteria); $data[] = array(Helper::getTime($post->post_created, 'Y'), count($posts), count($photo), count($video)); } $this->widget('ext.Hzl.google.HzlVisualizationChart', array('visualization' => 'BarChart', 'data' => $data, 'options' => array('style' => array('width' => '100%', 'height' => '100%'), 'height' => 400, 'vAxis' => array('title' => 'year'), 'hAxis' => array('title' => 'Total Content'), 'curveType' => 'function', 'legend' => array('position' => 'top')))); $this->endWidget(); ?> </div> </div>
/** * 第一张封面照解锁 * 查询出女神 1级第一张封面照 */ public function insertGoddessCoverPhoto($heroine_id, $user_id, $level = 1) { try { $con_heroine = Yii::app()->db_heroine; $con_characters = Yii::app()->db_characters; $table_name = sprintf('photo_praise_%02s', dechex($user_id % 256)); //查询出此女神的第一张封面照 封面照类型1 $photo_data = $con_heroine->createCommand()->select('photo_id')->from('heroine_photo')->where('heroine_id=:heroine_id AND level=:level AND type=1')->bindParam(':heroine_id', $heroine_id, PDO::PARAM_INT, 11)->bindParam(':level', $level, PDO::PARAM_INT, 11)->queryRow(); if ($photo_data) { //查询用户是否有已经关注此女神的封面照 是否已经解锁 $user_photo_data = $con_characters->createCommand()->select('photo_id')->from($table_name)->where('user_id=:user_id AND photo_id=:photo_id ')->bindParam(':user_id', $user_id, PDO::PARAM_INT, 11)->bindParam(':photo_id', $photo_data['photo_id'], PDO::PARAM_INT, 11)->queryAll(); //没关注封面照 填入封面照 if ($user_photo_data == NULL) { $photoParams = array('user_id' => $user_id, 'heroine_id' => $heroine_id, 'photo_id' => $photo_data['photo_id'], 'unlock_type' => 2, 'status' => 0, 'is_open' => 0, 'timestamp' => time(), 'type' => 1); //插入解锁照片 Photo::model()->insertPhoto($user_id, $photoParams); // echo '插入照片成功'; // 日志 } else { //已经解锁 // echo '已经解锁'; } } else { //没有封面照 // echo '没有封面照'; } } catch (Exception $e) { error_log($e); } }
protected function beforeDelete() { Photo::model()->deleteAll('category_id = ' . $this->id); return parent::beforeDelete(); }
public function actionDeletephoto($id, $phid) { if (Yii::app()->request->isPostRequest) { // we only allow deletion via POST request $photo = Photo::model()->findByPk($id); $pname = $photo->name; @unlink($_SERVER['DOCUMENT_ROOT'] . '/userfiles/original/' . $pname); @unlink($_SERVER['DOCUMENT_ROOT'] . '/userfiles/large/' . $pname); @unlink($_SERVER['DOCUMENT_ROOT'] . '/userfiles/medium/' . $pname); @unlink($_SERVER['DOCUMENT_ROOT'] . '/userfiles/small/' . $pname); $photo->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if (!isset($_GET['ajax'])) { $this->redirect($this->createUrl('update', array('id' => $phid))); } } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } }
/** * 根据规则 抽一张图 * @param unknown $user_id * @param unknown $goddess_id * @param unknown $liking * @return number|multitype:number Ambigous <number, unknown> Ambigous <number, mixed, unknown> */ public function getGuess($user_id, $goddess_id, $liking) { $con_game = Yii::app()->db_game; $table_name = sprintf('guess_%02s', dechex($user_id % 256)); //根据女神ID 查询解锁照片数 总照片数 解锁照片ID $user_photos = Photo::model()->unlockPhotosIds($user_id, $goddess_id); if (count($user_photos) > 0) { $heroine_photoIds_temp = array(); for ($i = 1; $i <= 10; $i++) { $heroine_photoIds = Photo::model()->heroinePhotosIds($goddess_id, $i); $all_num = count($heroine_photoIds); $ids = Common::model()->array_dif($heroine_photoIds, $user_photos); if (count($ids) != 0) { $temp = $i; break; } } $unlock_num = count($ids); } else { $i = 0; $heroine_photoIds = Photo::model()->heroinePhotosIds($goddess_id, 1); $all_num = count($heroine_photoIds); $ids = $heroine_photoIds; $unlock_num = count($ids); } if (count($heroine_photoIds) == 0) { return array('err' => -6); } //判定好感等级, 不到等级 不能参加 猜牌 if ((int) $liking['level'] < (int) $i) { return array('err' => -3); } foreach ($ids as $k => $v) { $temp = $v; break; } $photo_id = (int) $temp['photo_id']; $photo_info = Photo::model()->photoInfo($photo_id); //查询这张照片已经猜图几次 每多一次 增加5% 几率; $guess_res = $con_game->createCommand()->select('count(*) as count')->from($table_name)->where('photo_id=:ID AND status=1 AND user_id=:USERID AND game_type = 0')->bindParam(':ID', $photo_id, PDO::PARAM_INT, 11)->bindParam(':USERID', $user_id, PDO::PARAM_INT, 11)->queryRow(); $add_rate = 0; if ($guess_res['count'] != 0) { $sel_guess_res = $con_game->createCommand()->select('*')->from($table_name)->where('photo_id=:ID AND status=0 AND card_type = 8 AND user_id=:USERID')->bindParam(':ID', $photo_id, PDO::PARAM_INT, 11)->bindParam(':USERID', $user_id, PDO::PARAM_INT, 11)->queryRow(); if ($sel_guess_res) { $sel_guess_res['unlock_num'] = $unlock_num; $sel_guess_res['all_num'] = $all_num; $sel_guess_res['url'] = $photo_info['url']; $sel_guess_res['thumb'] = $photo_info['url']; return array('err' => -5, 'result' => $sel_guess_res); } //查询是否猜牌是否5的倍数 如果是5次,查询是否已经擦涂过 if ($guess_res['count'] % 5 == 0) { $num = $guess_res['count'] / 5; $guess_res = $con_game->createCommand()->select('count(id) as count')->from($table_name)->where('photo_id=:ID AND status=1 AND card_type = 8 AND user_id=:USERID')->bindParam(':ID', $photo_id, PDO::PARAM_INT, 11)->bindParam(':USERID', $user_id, PDO::PARAM_INT, 11)->queryRow(); if ($num > $guess_res['count']) { $guess = array('image_id' => (int) $photo_id, 'unlock_num' => $unlock_num, 'all_num' => $all_num, 'url' => $photo_info['url'], 'thumb' => $photo_info['url'], 'type' => 3, 'vit' => 0, 'liking' => 0, 'gold' => 0, 'flowers' => 0); return array('err' => -4, 'result' => $guess); } } $add_rate = $guess_res['count'] % 5 * 5; } $liking = Liking::model()->getLikingRow($photo_info['level']); //按等级抽女神牌几率 $rate = $liking['rate'] + $add_rate; //剩余牌几率 $status_rate = 100 - (int) $rate; //0 空牌 1目标牌 2效果牌 $prize_arr = array('1' => $rate, '2' => $status_rate); $type = Common::model()->get_rand($prize_arr); $card_type = $type; $card_val = 0; $vit = 0; $liking = 0; $gold = 0; $flowers = 0; $i = rand(1, 2); //随机取效果牌 0无效牌 3体力 4好感 5获得金币 6盗走金币 7获得玫瑰花 $return_arr[0]['url'] = $photo_info['url']; $url_thumb = $photo_info['url']; if ($type == 1) { $return_arr[0]['url'] = $photo_info['url']; $return_arr[0]['type'] = 1; } $status_arr = Yii::app()->params['game_arr'][$GLOBALS['__APPID']]['status_card']; $r_1 = rand(1, 17); switch ($r_1) { case 1: case 2: $random_arr_1 = 3; break; case 3: case 4: case 5: $random_arr_1 = 4; break; case 6: case 7: case 8: $random_arr_1 = 5; break; case 9: case 10: case 11: $random_arr_1 = 6; break; case 12: case 13: case 14: $random_arr_1 = 7; break; case 15: case 16: case 17: $random_arr_1 = 2; break; } unset($status_arr[$random_arr_1]); $random_arr_2 = array_rand($status_arr, 1); $random[0] = $random_arr_1; $random[1] = $random_arr_2; $return_arr[1] = $this->getRandomCard($random[0]); $return_arr[2] = $this->getRandomCard($random[1]); if ($type == 2) { if ($random[0] == 2) { $type = 0; } $card_type = $random[0]; $card_val = $return_arr[1]['val']; $vit = $return_arr[1]['vit']; $liking = $return_arr[1]['liking']; $gold = $return_arr[1]['gold']; $flowers = $return_arr[1]['flowers']; $url = $return_arr[1]['url']; if ($i == 1) { $return_arr[0]['type'] = $return_arr[1]['type']; $return_arr[0]['url'] = $return_arr[1]['url']; $return_arr[1]['type'] = 1; $return_arr[1]['url'] = $photo_info['url']; } if ($i == 2) { $return_arr[0]['type'] = $return_arr[1]['type']; $return_arr[0]['url'] = $return_arr[1]['url']; $return_arr[1]['type'] = $return_arr[2]['type']; $return_arr[1]['url'] = $return_arr[2]['url']; $return_arr[2]['type'] = 1; $return_arr[2]['url'] = $photo_info['url']; } } unset($return_arr[1]['val']); unset($return_arr[1]['vit']); unset($return_arr[1]['liking']); unset($return_arr[1]['gold']); unset($return_arr[1]['flowers']); unset($return_arr[2]['val']); unset($return_arr[2]['vit']); unset($return_arr[2]['liking']); unset($return_arr[2]['gold']); unset($return_arr[2]['flowers']); // var_dump($return_arr);exit; if ($GLOBALS['__VERSION'] > '1.0') { $guess = array('cards' => $return_arr, 'image_id' => (int) $photo_id, 'thumb' => $url_thumb, 'unlock_num' => $unlock_num, 'all_num' => $all_num, 'type' => $type, 'card_type' => $card_type, 'val' => $card_val, 'vit' => $vit, 'liking' => $liking, 'gold' => $gold, 'flowers' => $flowers); } else { $url = $return_arr[0]['url']; $guess = array('image_id' => (int) $photo_id, 'url' => $url, 'thumb' => $url_thumb, 'unlock_num' => $unlock_num, 'all_num' => $all_num, 'type' => $type, 'card_type' => $card_type, 'val' => $card_val, 'vit' => $vit, 'liking' => $liking, 'gold' => $gold, 'flowers' => $flowers); } return $guess; }
</ul> <?php } ?> </li> <li><a href="/delivery/">Доставка</a></li> <li><a href="/contacts/">Контакты</a></li> </ul> </div> <div class="animation"> <ul id="pictures-demo"> <?php $criteria = new CDbCriteria(); $criteria->condition = "phid = 4 and view = 1"; $criteria->order = 'pos'; $photos = Photo::model()->findAll($criteria); foreach ($photos as $photo) { ?> <li><img src="/userfiles/original/<?php echo $photo->name; ?> " alt="<?php echo $photo->title; ?> "></li><?php } ?> </ul> </div> <div class="content"> <?php
public function fetchContents($contents) { foreach ($contents as $weibo) { if (isset($weibo['original_pic'])) { $oldPhoto = Photo::model()->findByAttributes(array('weibo_id' => $weibo['id'])); if ($oldPhoto) { continue; } // Fetch Image $filename = $this->fetchImage($weibo); if ($filename) { $urlJson = json_decode(file_get_contents("http://api.t.sina.com.cn/querymid.json?id=" . $weibo['id'])); $photo = new Photo(); $photo->weibo_id = $weibo['id']; $photo->url = $urlJson->mid; $photo->image = $filename; $photo->screen_name = $weibo['user']['screen_name']; $photo->sns_uid = $weibo['user']['id']; $photo->gender = $weibo['user']['gender']; $photo->location = $weibo['user']['location']; $photo->avatar = $weibo['user']['profile_image_url']; $photo->content = $weibo['text']; $photo->status = 0; $photo->datetime = time(); $photo->save(); } } } }
public function number() { $criteria = new CDbCriteria(); $criteria->condition = 'phid=:phid'; $criteria->params = array(':phid' => $this->id); return Photo::model()->count($criteria); }