示例#1
0
 function init(&$sorted_target_drives, &$last_resort_sorted_target_drives)
 {
     // Shuffle or sort by available space (desc)
     if ($this->selection_algorithm == 'random') {
         kshuffle($sorted_target_drives);
         kshuffle($last_resort_sorted_target_drives);
     } else {
         if ($this->selection_algorithm == 'most_available_space') {
             arsort($sorted_target_drives);
             arsort($last_resort_sorted_target_drives);
         }
     }
     // Only keep directories that are in $this->directories
     $this->sorted_target_drives = array();
     foreach ($sorted_target_drives as $k => $v) {
         if (array_search($k, $this->directories) !== FALSE) {
             $this->sorted_target_drives[$k] = $v;
         }
     }
     $this->last_resort_sorted_target_drives = array();
     foreach ($last_resort_sorted_target_drives as $k => $v) {
         if (array_search($k, $this->directories) !== FALSE) {
             $this->last_resort_sorted_target_drives[$k] = $v;
         }
     }
 }
示例#2
0
文件: index.php 项目: yunsite/demila
$users = $usersClass->getAll(0, 0, $itemsClass->usersWhere);
abr('users', $users);
#推荐作品
$weeklyItems = $itemsClass->getAll(0, 10, " `status` = 'active' AND `weekly_to` >= '" . date('Y-m-d') . "' ", "`datetime` DESC");
abr('weeklyItems', $weeklyItems);
if ($itemsClass->foundRows > 10) {
    abr('haveWeekly', 'yes');
}
#加载分类
require_once ROOT_PATH . '/apps/categories/models/categories.class.php';
$categoriesClass = new categories();
$categories = $categoriesClass->getAll();
abr('categories', $categories);
#近期作品
$recentItems = $itemsClass->getAll(0, 40, " `status` = 'active' ", '`datetime` DESC');
kshuffle($recentItems);
abr('recentItems', $recentItems);
//免费作品
$freeItem = $itemsClass->getAll(0, 0, " `status` = 'active' AND `free_file` = 'true' ");
abr('freeItem', $freeItem);
#推荐作者
require_once ROOT_PATH . '/apps/users/models/users.class.php';
$usersClass = new users();
//获取用户信息及粉丝
$featuredAuthor = $usersClass->getAll(0, 0, " `status` = 'activate' AND `featured_author` = 'true' ", 'RAND()');
// if(is_array($featuredAuthor)) {
// 	//作者的一些作品
// 	$featuredItems = array();
//      foreach($featuredAuthor as $itear){
// 	    $featuredItems[$itear['user_id']] = $itemsClass->getAll(0, 2, " `status` = 'active' AND `user_id` = '".intval($itear['user_id'])."' ");
// 	}