Beispiel #1
0
}
$marked_files_id_string = implode(',', $marked_files_id);
// We must compute up to this point, what this user has downloaded before and compare it then later with the defined user limitations
// Important: Please note, that we can check it only for registered users. By visitors it is not really useful, then we have here only a changeable IP.
$total_consumed = JDHelper::getUserLimits($user_rules, $marked_files_id);
// When $total_consumed['limits_info'] has a value, we must check whether this user may download the selected files
// If so, then the result is: TRUE - otherwise: the limitations message
// Has $total_consumed['limits_info'] not any value, it exists not any limitations for this user
if ($total_consumed['limits_info']) {
    $may_download = JDHelper::checkUserDownloadLimits($user_rules, $total_consumed, $sum_selected_files, $sum_selected_volume, $marked_files_id);
} else {
    $may_download = true;
}
// check whether user has enough points from alphauserpoints (when used and installed)
if ($may_download === true && $jlistConfig['use.alphauserpoints']) {
    $aup_result = JDHelper::checkUserPoints($sum_aup_points, $marked_files_id);
    if ($aup_result['may_download'] === true) {
        $may_download = true;
    } else {
        $may_download = $aup_result['points_info'];
    }
}
// write data in session
if ($may_download === true) {
    if ($user_random_id) {
        JDHelper::writeSessionEncoded($user_random_id, 'jd_random_id');
        JDHelper::writeSessionEncoded($marked_files_id_string, 'jd_list');
        JDHelper::writeSessionClear('jd_fileid');
    } else {
        // single file download
        if ($fileid) {
 /**
  * Check whether a user may download a file within his limitations
  * 
  * @param mixed $cat_id
  * @param mixed $file_id
  * @param mixed $files_list
  * @param mixed $user_rules
  * @param mixed $sum_selected_files
  * @param mixed $sum_selected_volume
  */
 public static function checkDirectDownloadLimits($cat_id, $file_id, $marked_files_id, $user_rules, $sum_selected_files, $sum_selected_volume)
 {
     global $jlistConfig;
     // we need the filed id when not used checkboxes
     if (!$marked_files_id) {
         $marked_files_id = array($file_id);
     }
     $marked_files_id_string = implode(',', $marked_files_id);
     // We must compute up to this point, what this user has downloaded before and compare it then later with the defined user limitations
     // Important: Please note, that we can check it only for registered users. By visitors it is not really useful, then we have here only a changeable IP.
     $total_consumed = JDHelper::getUserLimits($user_rules, $marked_files_id);
     // When $total_consumed['limits_info'] has a value, we must check whether this user may download the selected files
     // If so, then the result is: TRUE - otherwise: the limitations message
     // Has $total_consumed['limits_info'] not any value, it exists not any limitations for this user
     if ($total_consumed['limits_info']) {
         $may_download = JDHelper::checkUserDownloadLimits($user_rules, $total_consumed, $sum_selected_files, $sum_selected_volume, $marked_files_id);
     } else {
         $may_download = true;
     }
     // check whether user has enough points from alphauserpoints (when used and installed)
     if ($may_download === true && $jlistConfig['use.alphauserpoints']) {
         $aup_result = JDHelper::checkUserPoints($sum_aup_points, $marked_files_id);
         if ($aup_result['may_download'] === true) {
             $may_download = true;
         } else {
             $may_download = $aup_result['points_info'];
         }
     }
     // write data in session
     if ($may_download === true) {
         if ($user_random_id) {
             JDHelper::writeSessionEncoded($user_random_id, 'jd_random_id');
             JDHelper::writeSessionEncoded($marked_files_id_string, 'jd_list');
             JDHelper::writeSessionClear('jd_fileid');
         } else {
             // single file download
             if ($file_id) {
                 JDHelper::writeSessionEncoded($file_id, 'jd_fileid');
             } else {
                 JDHelper::writeSessionEncoded($marked_files_id[0], 'jd_fileid');
             }
             JDHelper::writeSessionClear('jd_random_id');
             JDHelper::writeSessionClear('jd_list');
         }
         JDHelper::writeSessionEncoded($cat_id, 'jd_catid');
         return true;
     } else {
         return $may_download;
     }
 }