public function run()
 {
     $controller = $this->getController();
     $this->_setting = $controller->_setting;
     $this->_stylePath = $controller->_stylePath;
     $this->_static_public = $controller->_static_public;
     //SEO
     $controller->_seoTitle = Yii::t('common', 'User Center') . ' - ' . Yii::t('common', 'Collect Manage') . ' - ' . $this->_setting['site_name'];
     //加载css,js
     Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/user.css");
     Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js");
     //收藏列表
     $collect_mod = new Collect();
     $uid = Yii::app()->user->id;
     $criteria = new CDbCriteria();
     $criteria->condition = 't.user_id=' . $uid;
     $criteria->order = 't.id DESC';
     //分页
     $count = $collect_mod->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 15;
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $datalist = $collect_mod->findAll($criteria);
     $controller->render('my_collect', array('datalist' => $datalist, 'pages' => $pages));
 }
function parse_element($type, $confObj)
{
    $elementlist = array();
    if ("step" == $type) {
        $objlist = $confObj["steps"];
    } elseif ("collect" == $type) {
        $objlist = $confObj["collects"];
    }
    foreach ($objlist as $obj) {
        if ("step" == $type) {
            $element = new Step();
        } elseif ("collect" == $type) {
            $element = new Collect();
        }
        $element->setName($obj[$type . ".name"]);
        $element->setCmd($obj[$type . ".cmd"]);
        $element->setDesc($obj[$type . ".desc"]);
        if (array_key_exists($type . ".hostname", $obj)) {
            $element->setHostName($obj[$type . ".hostname"]);
        }
        if (array_key_exists($type . ".cmd.sep", $obj)) {
            $element->setCmdSep($obj[$type . ".cmd.sep"]);
        }
        if (array_key_exists($type . ".ignore_fail", $obj)) {
            $element->setIgnoreFail($obj[$type . ".ignore_fail"]);
        }
        array_push($elementlist, $element);
    }
    return $elementlist;
}
Example #3
0
 protected function renderCollection()
 {
     //show items which are included in this collection
     $albumsOfCollection = Collect::albumsOfCollection();
     //if user is editor or admin, we will show all items
     //to permit to include its in collection
     if ($this->levelAccess) {
         //get all items which aren't already in this collection
         $albumsNotInCollection = Collect::albumsNotInCollection();
         //there are some items not in collection and some in collection
         if ($albumsOfCollection && $albumsNotInCollection) {
             $arrAllAlbums = array_merge($albumsOfCollection, $albumsNotInCollection);
         }
         if ($albumsOfCollection && !$albumsNotInCollection) {
             $arrAllAlbums = $albumsOfCollection;
         }
         if (!$albumsOfCollection && $albumsNotInCollection) {
             $arrAllAlbums = $albumsNotInCollection;
         }
         if (!$albumsOfCollection && !$albumsNotInCollection) {
             $arrAllAlbums = array();
         }
         if ($arrAllAlbums) {
             $arrItems = array();
             foreach ($arrAllAlbums as $item) {
                 $arrItems[] = $this->render('editorShop/itemCollectionShop', array('item' => $item), true);
             }
             $this->render('editorShop/viewSortableCollectionShop', array('arrItems' => $arrItems));
         } else {
             echo $this->tr('noAlbumExists');
         }
     } else {
         $this->render('shop/_viewCollectionShop', array('items' => $albumsOfCollection));
     }
 }
 /**
  * 判断一个用户是否跟随者
  * @param unknown_type $userId
  */
 public function isCollector($userId)
 {
     $owner = $this->getOwner();
     //if(!$owner->entityId) return false;
     $collect = Collect::model()->findByAttributes(array('userId' => $userId, 'collectableEntityId' => $owner->entityId));
     if (!$collect) {
         return false;
     }
     return true;
 }
Example #5
0
 public function run()
 {
     $controller = $this->getController();
     $this->_setting = $controller->_setting;
     $this->_stylePath = $controller->_stylePath;
     $this->_static_public = $controller->_static_public;
     //SEO
     $controller->_seoTitle = Yii::t('common', 'User Center') . ' - ' . Yii::t('common', 'Collect Manage') . ' - ' . $this->_setting['site_name'];
     //收藏列表
     $collect_mod = new Collect();
     $uid = Yii::app()->user->id;
     $criteria = new CDbCriteria();
     $criteria->addColumnCondition(array('t.user_id' => $uid));
     $criteria->order = 't.id DESC';
     //分页
     $count = $collect_mod->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 15;
     $pages->applyLimit($criteria);
     $datalist = $collect_mod->findAll($criteria);
     $controller->render('my_collect', array('datalist' => $datalist, 'pages' => $pages));
 }
 public function run()
 {
     $controller = $this->getController();
     $op = Yii::app()->request->getParam('op');
     $ids = Yii::app()->request->getParam('id');
     $uid = Yii::app()->user->id;
     $res = false;
     //操作状态
     $count = true;
     //是否需要统计
     $count_field = '';
     //统计数据的字段名
     $action = '';
     //要返回的action名
     if (!$uid) {
         $message = Yii::t('common', 'You Need Login');
     } else {
         if (!$ids) {
             $message = Yii::t('common', 'Operation Failed');
         } else {
             switch ($op) {
                 case 'collect':
                     $collect_mod = new Collect();
                     //检测是否是自己收藏的
                     foreach ((array) $ids as $k => $id) {
                         $tmp = $collect_mod->findByPk($id);
                         if ($tmp->user_id != $uid) {
                             unset($ids[$k]);
                         } else {
                             $content[] = $collect_mod->findByPk($id);
                         }
                     }
                     $collect_mod->deleteByPk($ids);
                     $res = true;
                     $count_field = 'favorite_count';
                     $action = 'mycollect';
                     break;
                 case 'attention':
                     $attention_mod = new Attention();
                     //检测是否是自己关注的
                     foreach ((array) $ids as $k => $id) {
                         $tmp = $attention_mod->findByPk($id);
                         if ($tmp->user_id != $uid) {
                             unset($ids[$k]);
                         } else {
                             $content[] = $attention_mod->findByPk($id);
                         }
                     }
                     $attention_mod->deleteByPk($ids);
                     $res = true;
                     $count_field = 'attention_count';
                     $action = 'myattention';
                     break;
                 case 'friend':
                     $friend_mod = new Friend();
                     //检测是否是自己的好友
                     foreach ((array) $ids as $k => $id) {
                         $tmp = $friend_mod->findByPk($id);
                         if ($tmp->uid1 != $uid && $tmp->uid2 != $uid) {
                             unset($ids[$k]);
                         }
                     }
                     $friend_mod->deleteByPk($ids);
                     $res = true;
                     $count = false;
                     $action = 'myfriends';
                     break;
                 default:
                     break;
             }
             if ($res) {
                 $message = Yii::t('common', 'Cancel Success');
                 if ($count && $content) {
                     //减少统计数据
                     $model_type = new ModelType();
                     foreach ($content as $c) {
                         $type = $model_type->findByPk($c->type);
                         $type_name = ucfirst($type->type_key);
                         if ($type_name && $c && $count_field) {
                             $content_mod = new $type_name();
                             $cur_post = $content_mod->findByPk($c->cid);
                             if ($cur_post->{$count_field} > 0) {
                                 $content_mod->updateCounters(array($count_field => -1), 'id=:id', array('id' => $c->cid));
                             }
                         }
                     }
                 }
             } else {
                 $message = Yii::t('common', 'Operation Failed');
             }
         }
     }
     //用setFlash提示信息(类似alert)
     $controller->layout = false;
     Yii::app()->user->setFlash($res ? 'success' : 'error', $message);
     $controller->redirect($controller->createUrl('user/' . $action));
 }
Example #7
0
 /**
  * ajax操作 (收藏、关注)
  * 
  */
 public function actionAjax()
 {
     $uid = Yii::app()->user->id;
     $ret = array();
     if (!$uid) {
         $ret = array('state' => 'error', 'message' => Yii::t('common', 'You Need Login'));
     } else {
         $act = $this->_request->getParam('act');
         $postid = $this->_request->getParam('id');
         $post = Post::model()->findByPk($postid);
         $type_id = $this->_type_ids['post'];
         if (!$post) {
             $ret = array('state' => 'error', 'message' => Yii::t('common', 'Collect Failed'));
         } else {
             $attention_mod = new Attention();
             $collect_mod = new Collect();
             switch ($act) {
                 case 'attention':
                     //判断是否已经关注了
                     $exist_attention = $attention_mod->find('user_id=:uid AND cid=:cid AND type=:type_id', array(':uid' => $uid, ':cid' => $postid, ':type_id' => $type_id));
                     if ($exist_attention) {
                         $ret = array('state' => 'error', 'message' => Yii::t('common', 'You Have Attented it'));
                     } else {
                         //关注
                         $attention_mod->cid = $postid;
                         $attention_mod->title = $post->title;
                         $attention_mod->user_id = $uid;
                         $attention_mod->url = $this->_request->hostinfo . $this->createUrl('post/view', array('id' => $postid));
                         $attention_mod->type = $type_id;
                         $attention_mod->create_time = time();
                         if ($attention_mod->save()) {
                             $post->updateCounters(array('attention_count' => 1), 'id=:id', array('id' => $postid));
                             $ret = array('state' => 'success', 'message' => Yii::t('common', 'Attent Success'), 'count' => $post->attention_count + 1);
                         } else {
                             $ret = array('state' => 'error', 'message' => Yii::t('common', 'Attent Failed'));
                         }
                     }
                     break;
                 case 'collect':
                     //判断是否已经收藏
                     $exist_collect = $collect_mod->find('user_id=:uid AND cid=:cid AND type=:type_id', array(':uid' => $uid, ':cid' => $postid, ':type_id' => $type_id));
                     if ($exist_collect) {
                         $ret = array('state' => 'error', 'message' => Yii::t('common', 'You Have Collected it'));
                     } else {
                         //收藏
                         $collect_mod->cid = $postid;
                         $collect_mod->title = $post->title;
                         $collect_mod->user_id = $uid;
                         $collect_mod->url = $this->_request->hostinfo . $this->createUrl('post/view', array('id' => $postid));
                         $collect_mod->type = $type_id;
                         $collect_mod->create_time = time();
                         if ($collect_mod->save()) {
                             $post->updateCounters(array('favorite_count' => 1), 'id=:id', array('id' => $postid));
                             $ret = array('state' => 'success', 'message' => Yii::t('common', 'Collect Success'), 'count' => $post->favorite_count + 1);
                         } else {
                             $ret = array('state' => 'error', 'message' => Yii::t('common', 'Collect Failed'));
                         }
                     }
                     break;
                 default:
                     $ret = array('state' => 'error', 'message' => Yii::t('common', 'Operation Failed'));
                     break;
             }
         }
     }
     exit(CJSON::encode($ret));
 }
Example #8
0
 function parse()
 {
     $fp = fopen($this->filePath, "r") or die("Couldnot open file");
     $confObj = array("var" => "", "check" => "", "step" => "", "collect" => "");
     $type = "";
     $num = 0;
     while (!feof($fp)) {
         $line = trim(fgets($fp, 1024));
         $head = substr($line, 0, 1);
         $elementArray = explode('.', $line, 2);
         $element = $elementArray[0];
         switch ($head) {
             case "\$":
                 $confObj["var"] .= $line . '\\nline_split';
                 break;
             case "{":
                 if ($type == "") {
                     $confObj["step"] .= '\\nmodule_split';
                     $confObj["check"] .= '\\nmodule_split';
                     $confObj["collect"] .= '\\nmodule_split';
                 } else {
                     if (array_key_exists($type, $confObj)) {
                         $confObj[$type] .= $line . '\\nline_split';
                         $num = $num + 1;
                     }
                 }
                 break;
             case "}":
                 if ($num == 0) {
                     $confObj["step"] .= '\\nline_split';
                     $confObj["check"] .= '\\nline_split';
                     $confObj["collect"] .= '\\nline_split';
                     $type = "";
                 } else {
                     if ($num > 0) {
                         $num = $num - 1;
                         $confObj[$type] .= $line . '\\nline_split';
                     }
                 }
                 break;
             case "#":
                 if (array_key_exists($type, $confObj)) {
                     $confObj[$type] .= $line . '\\nline_split';
                 }
                 break;
             default:
                 if (array_key_exists($type, $confObj)) {
                     $confObj[$type] .= $line . '\\nline_split';
                 } else {
                     if (array_key_exists($element, $confObj)) {
                         $confObj[$element] .= $line . '\\nline_split';
                         $type = $element;
                     }
                 }
                 break;
         }
     }
     fclose($fp);
     $this->varibles = Varible::parseList($confObj["var"]);
     $this->checks = Check::parseList($confObj["check"], "check");
     $this->steps = Step::parseList($confObj["step"], "step");
     //echo $confObj["step"];
     $this->collects = Collect::parseList($confObj["collect"], "collect");
 }
Example #9
0
 public function actionDelAllCollection()
 {
     if (!empty($this->_account['userId'])) {
         $myCollection = Collect::model()->find('user_id=:user_id', array(':user_id' => $this->_account['userId']));
         if ($myCollection->delete()) {
             echo CJSON::encode(array('status' => 200, 'msg' => '删除成功'));
         } else {
             echo CJSON::encode(array('status' => 500, 'msg' => '删除失败'));
         }
     } else {
         echo CJSON::encode(array('status' => 404, 'msg' => '无权访问!'));
     }
 }
Example #10
0
/**
 * 专辑采集,只采集ID
 * 包括专辑ID和歌手ID
 * 此采集较慢,因为有些歌手的专辑较多,请求百度专辑接口的次数较多
 * 最好每次只采 100 位歌手的专辑
 */
if (!defined('APP_PATH')) {
    exit("Access is denied.");
}
require_once APP_PATH . 'util/db.php';
require_once APP_PATH . 'util/Collect.class.php';
$collect_size = 100;
// 采集数量
$con = get_con();
$collect = new Collect();
// manual_collect表示手动再次采集该歌手的专辑,比如想要更新歌手的新专辑就可以设置该字段为1
// 如果想重新采集某歌手的专辑设置manual_collect为1并设置shield_collect为0
$result = mysql_query("select id from {DBPREFIX}artist where (manual_collect=1 or id not in (select distinct artist_id from {DBPREFIX}album)) and shield_collect=0 order by manual_collect desc limit {$collect_size}", $con);
$artistIdArr = array();
while (!!($row = mysql_fetch_array($result))) {
    $artistIdArr[] = $row['id'];
}
// print_r($artistIdArr);die;
if (!empty($artistIdArr)) {
    $albumArr = $collect->albumList($artistIdArr);
    // print_r($albumArr);die;
    if (!empty($albumArr)) {
        foreach ($artistIdArr as $artistId) {
            $data['artist_id'] = $artistId;
            //  有些歌手没有专辑只有歌曲,把没有专辑的歌手的shield_collect设为1,防止下次还采集它。如果想再采集该歌手设置manual_collect为1。
Example #11
0
 function parse()
 {
     $fp = fopen($this->filePath, "r") or die("Couldnot open file");
     $varListStr = "";
     $checkListStr = "";
     $stepListStr = "";
     $collectListStr = "";
     while (!feof($fp)) {
         $line = trim(fgets($fp, 1024));
         $flag = substr($line, 0, 1);
         $elementArray = explode('.', $line, 2);
         $element = $elementArray[0];
         switch ($flag) {
             case "\$":
                 $varListStr .= $line . '\\n';
                 break;
             case "{":
                 $stepListStr .= $line . '\\nflag';
                 $checkListStr .= $line . '\\nflag';
                 $collectListStr .= $line . '\\nflag';
                 break;
             case "}":
                 $stepListStr .= $line . '\\n';
                 $checkListStr .= $line . '\\n';
                 $collectListStr .= $line . '\\n';
                 break;
             case "#":
                 break;
             default:
                 switch ($element) {
                     case "step":
                         $stepListStr .= $line . '\\n';
                         break;
                     case "check":
                         $checkListStr .= $line . '\\n';
                         break;
                     case "collect":
                         $collectListStr .= $line . '\\n';
                         break;
                     default:
                         break;
                 }
                 break;
         }
     }
     fclose($fp);
     //echo "</br></br>".$varListStr."</br></br>";
     //echo $checkListStr."</br></br>";
     //echo $stepListStr."</br></br>";
     //echo $collectListStr."</br></br>";
     $this->varibles = Varible::parseList($varListStr);
     $this->checks = Check::parseList($checkListStr, "check");
     $this->steps = Step::parseList($stepListStr, "step");
     $this->collects = Collect::parseList($collectListStr, "collect");
 }
Example #12
0
            $listed++;
            $ind++;
            if ($ind === (int) $itemsOnLine || $listed === $existentsItems) {
                echo '</div>';
                $ind = 0;
            }
        }
    } else {
        echo $this->tr('noAlbum');
    }
    ?>
	<?php 
    if ($this->conf->showCollectionTags) {
        ?>
		<div class="tagsAlbum">
			<div class="tags">
				<?php 
        echo CHtml::label($this->tr('tagsLabel'), false, array('class' => 'tagsLabel')) . ': ';
        ?>
				<?php 
        echo $this->conf->combinedAlbumsTags ? Collect::combineAlbumsTagOfCollection() : $this->collection->tags;
        ?>
			</div>
		</div>
	<?php 
    }
    ?>
</div>
<?php 
    $this->endCache();
}
Example #13
0
 public function getDesigner()
 {
     try {
         $strCyid = isset($_GET['cyid']) ? $_GET['cyid'] : '';
         if (empty($strCyid)) {
             return get_rsp_result(false, 'cyid is empty');
         }
         $sql = Collect::getSelectDesignerSql($strCyid);
         global $g_arr_db_config;
         $dbConfig = $g_arr_db_config['designer'];
         $rows = $this->_getDb($dbConfig)->getRecords($sql);
         if ($rows === false) {
             Log::write('CollectTask::getDesigner():getRecords() failed, SQL:' . $sql, 'log');
             return get_rsp_result(false, 'get designer error');
         }
         $arrDesigner = array();
         foreach ($rows as $row) {
             $designer = new DesignerProtocol();
             $designer->setProtocol($row);
             $arrDesigner[] = $designer;
         }
         return json_encode(array('result' => true, 'designer' => $arrDesigner));
     } catch (Exception $e) {
         Log::write('CollectTask::getDesigner() excepton error:' . $e->getMessage(), 'log');
         $result = get_rsp_result(false, 'get designer exception');
         return $result;
     }
 }
Example #14
0
/**
 * 专辑信息采集
 * 包括专辑名称、封面、发行时间、流派、发行公司、歌曲列表
 * 此采集较慢,因为要下载歌手头像到本地
 * 最好每次只采 300 张专辑的信息
 */
if (!defined('APP_PATH')) {
    exit("Access is denied.");
}
require_once APP_PATH . 'util/db.php';
require_once APP_PATH . 'util/Collect.class.php';
$collect_size = 300;
// 采集数量
$con = get_con();
$collect = new Collect();
$result = mysql_query("select album_id from {DBPREFIX}album where album_title='' or album_title is null limit {$collect_size}", $con);
$albumIdArr = array();
while (!!($row = mysql_fetch_array($result))) {
    $albumIdArr[] = $row['album_id'];
}
if (!empty($albumIdArr)) {
    $albumInfoArr = $collect->albumInfo($albumIdArr, COVERSAVEPATH, COVERRELATIVEPATH);
    if (!empty($albumInfoArr)) {
        foreach ($albumInfoArr as $album) {
            $data['album_id'] = $album['album_id'];
            $data['album_title'] = $album['album_title'];
            $data['album_cover'] = $album['album_cover'];
            $data['time'] = $album['time'];
            $data['styles'] = $album['styles'];
            $data['company'] = $album['company'];
<?php

/**
 * 歌手列表采集,只采集ID
 * 包括歌手ID、字母编号、地区编号、类型
 * 一次采集全部歌手
 */
if (!defined('APP_PATH')) {
    exit("Access is denied.");
}
require_once APP_PATH . 'util/db.php';
require_once APP_PATH . 'util/Collect.class.php';
$con = get_con();
$collect = new Collect();
//$artistAreaCodeArr = array('cn', 'western', 'kr', 'jp');
$artistAreaCodeArr = array('cn');
//$artistTypeArr = array('male', 'female', 'group');
$artistTypeArr = array('male');
//$indexLetterArr = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'other');
$indexLetterArr = array('A');
$artistArr = $collect->artistList($artistAreaCodeArr, $artistTypeArr, $indexLetterArr);
if (!empty($artistArr)) {
    foreach ($artistArr as $artist) {
        $data['id'] = $artist['id'];
        $data['index_letter'] = $artist['index_letter'];
        $data['area_code'] = $artist['area_code'];
        $data['type'] = $artist['type'];
        $result = mysql_query("select id from " . DBPREFIX . "artist where id={$data['id']}", $con);
        if (!($row = mysql_fetch_array($result))) {
            // 数据库不存在该歌手 -> insert
            $sql = "insert into\n                                " . DBPREFIX . "artist\n                               (id,\n                                index_letter,\n                                area_code,\n                                type)\n                        values\n                               ({$data['id']},\n                                '{$data['index_letter']}',\n                                '{$data['area_code']}',\n                                '{$data['type']}')";
Example #16
0
 /**
  * 处理ajax收藏操作
  * 
  */
 private function _opCollection()
 {
     $uid = Yii::app()->user->id;
     if (!$uid) {
         $ret = array('state' => 'error', 'message' => Yii::t('common', 'You Need Login'));
         return $ret;
     }
     $postid = Yii::app()->request->getParam('id');
     $post = Post::model()->findByPk($postid);
     if (!$post) {
         $ret = array('state' => 'error', 'message' => Yii::t('common', 'Collect Failed'));
         return $ret;
     }
     $collect_mod = new Collect();
     //判断是否已经收藏
     $exist_collect = $collect_mod->find('user_id=:uid AND cid=:cid AND type=:type_id', array(':uid' => $uid, ':cid' => $postid, ':type_id' => $type_id));
     if ($exist_collect) {
         $ret = array('state' => 'error', 'message' => Yii::t('common', 'You Have Collected it'));
     } else {
         //收藏
         $collect_mod->cid = $postid;
         $collect_mod->title = $post->title;
         $collect_mod->user_id = $uid;
         $collect_mod->url = Yii::app()->request->hostinfo . $this->controller->createUrl('post/view', array('id' => $postid));
         $collect_mod->type = $type_id;
         $collect_mod->create_time = time();
         if ($collect_mod->save()) {
             $post->updateCounters(array('favorite_count' => 1), 'id=:id', array('id' => $postid));
             $ret = array('state' => 'success', 'message' => Yii::t('common', 'Collect Success'), 'count' => $post->favorite_count + 1);
         } else {
             $ret = array('state' => 'error', 'message' => Yii::t('common', 'Collect Failed'));
         }
     }
     return $ret;
 }
Example #17
0
 public function actionCollection()
 {
     $id = Yii::app()->request->getPost('id');
     if (!empty($this->_account['userId'])) {
         $collect_model = Collect::model()->find('user_id=:user_id', array(':user_id' => $this->_account['userId']));
         if (!empty($collect_model)) {
             $collection = $collect_model->collection;
             $collection = explode(',', $collection);
             if (in_array($id, $collection)) {
                 echo CJSON::encode(array('status' => 500, 'msg' => '您已收藏过该房源'));
             } else {
                 array_push($collection, $id);
                 $collection = implode(',', $collection);
                 $collect_model->collection = $collection;
                 if ($collect_model->save()) {
                     echo CJSON::encode(array('status' => 200, 'msg' => '收藏成功'));
                 } else {
                     echo CJSON::encode(array('status' => 500, 'msg' => '收藏失败'));
                 }
             }
         } else {
             $collection = array();
             array_push($collection, $id);
             $collection = implode(',', $collection);
             $collect_model = new Collect();
             $collect_model->user_id = $this->_account['userId'];
             $collect_model->collection = $collection;
             if ($collect_model->save()) {
                 echo CJSON::encode(array('status' => 200, 'msg' => '收藏成功'));
             } else {
                 echo CJSON::encode(array('status' => 500, 'msg' => '收藏失败'));
             }
         }
     } else {
         echo CJSON::encode(array('status' => 404, 'msg' => '您还未登录,请先登录'));
     }
 }
/**
 * 歌手资料采集
 * 包括歌手姓名、头像、生日、地区
 * 此采集较慢,因为要下载歌手头像到本地
 * 最好每次只采 500 位歌手的资料
 */
if (!defined('APP_PATH')) {
    exit("Access is denied.");
}
require_once APP_PATH . 'util/db.php';
require_once APP_PATH . 'util/Collect.class.php';
$collect_size = 500;
// 采集数量
$con = get_con();
$collect = new Collect();
$result = mysql_query("select id from {DBPREFIX}artist where name='' or name is null limit {$collect_size}", $con);
$artistIdArr = array();
while (!!($row = mysql_fetch_array($result))) {
    $artistIdArr[] = $row['id'];
}
if (!empty($artistIdArr)) {
    $artistInfoArr = $collect->artistInfo($artistIdArr, AVATARSAVEPATH, AVATARRELATIVEPATH);
    if (!empty($artistInfoArr)) {
        foreach ($artistInfoArr as $artist) {
            $data['id'] = $artist['id'];
            $data['name'] = $artist['name'];
            $data['avatar'] = $artist['avatar'];
            $data['area'] = $artist['area'];
            $data['birth'] = $artist['birth'];
            $sql = "update\n                           " . DBPREFIX . "artist\n                       set\n                            name = '{$data['name']}',\n                            avatar = '{$data['avatar']}',\n                            area = '{$data['area']}',\n                            birth = '{$data['birth']}'\n                     where\n                            id = {$data['id']}";
Example #19
0
 private function renderPage()
 {
     $this->displayPageTitle();
     //if is collection check if isn't shop and go to adequate rutine, which will detect level access and will render according with this
     if ($this->collection) {
         !$this->isShop ? Collect::renderCollection() : shop::renderCollection();
     } else {
         if (!$this->levelAccess) {
             if ($this->emptyContent()) {
                 return;
             }
             $this->conf->itemsOnPaginate ? $this->paginateGallery() : $this->fullGallery();
         }
     }
     //if not simple visitor, we add cpanel for editor
     if ($this->levelAccess) {
         count($this->imgsOrder) ? $this->fullGallery() : $this->emptyContent();
         $this->renderEditorPanel();
     }
 }