public static function get_upload_details($upload_id)
 {
     $upload_id = (int) $upload_id;
     if ($upload_id < 1) {
         throw new UploadsException('uploads_utils::get_upload_details - Invalid upload id: ' . $upload_id);
     }
     if (!is_array(self::$_upload_data_cache) || !isset(self::$_upload_data_cache[$upload_id])) {
         // not in cache.
         $db = cmsms()->GetDb();
         $query = 'SELECT * FROM ' . cms_db_prefix() . 'module_uploads WHERE upload_id = ?';
         $row = $db->GetRow($query, array($upload_id));
         if (!$row) {
             throw new UploadsException('uploads_utils::get_upload_details - Upload ' . $upload_id) . ' not found';
         }
         if (!is_array(self::$_upload_data_cache)) {
             self::$_upload_data_cache = array();
         }
         self::$_upload_data_cache[$row['upload_id']] = $row;
     }
     return self::$_upload_data_cache[$upload_id];
 }
 /**
  * A plugin to copy a file into the uploads module
  * and generate a timelimited URL to it
  *
  * @returns url or error message
  * @param src = (string,required) absolute server file specification 
  * @param category = (required) uploads category name or integer id
  * @param prefix = (boolean,optional) wether filenames should be prefixed - default false
  * @param email  = (string,optional) Tie the download url to the email address specified.
  * @param hours  = (int,optional)  number of hours the link will be valid for
  * @param downloads = (int,optional) max number of downloads allowed for this url
  */
 public static function create_tl_file($params, &$smarty)
 {
     $mod = cms_utils::get_module('Uploads');
     // set default values for variables
     $src = '';
     $email = '';
     $category = '';
     $prefix = TRUE;
     $hours = $mod->GetPreference('timelimited_hours', 0);
     $downloads = $mod->GetPreference('timelimited_downloads', 0);
     // get params
     if (isset($params['src'])) {
         $src = trim($params['src']);
     }
     if (isset($params['email'])) {
         $email = trim($params['email']);
     }
     if (isset($params['category'])) {
         $category = trim($params['category']);
     }
     if (isset($params['prefix'])) {
         $prefix = (int) $params['prefix'];
     }
     if (isset($params['hours'])) {
         $hours = (int) $params['hours'];
     }
     if (isset($params['downloads'])) {
         $downloads = (int) $params['downloads'];
     }
     // initial checks
     if (!$src) {
         echo 'ERROR in create_tl_file:  src parameter not specified';
         return;
     }
     if (!$category) {
         echo 'ERROR in create_tl_file:  no category specified';
         return;
     }
     $uploads = cms_utils::get_module('Uploads');
     if (!is_object($uploads)) {
         echo 'ERROR in create_tl_file:  Uploads module not found';
         return;
     }
     if (!file_exists($src)) {
         echo 'ERROR in create_tl_file:  file specified in src param not found';
         return;
     }
     if ($hours < 1 || $downloads < 1) {
         echo 'ERROR in create_tl_file:  Invalid hours or download limit';
     }
     try {
         // move the file into the uploads module
         $assistant = new uploads_uploadassistant($src, $category);
         $assistant->use_prefix($prefix);
         $upload_id = $assistant->handle_file();
         // need a time limited URL
         $urlkey = uploads_utils::create_timelimited_entry($upload_id, $email, $hours, $downloads);
         $url = uploads_utils::get_timelimited_url($urlkey, FALSE);
         // and we're done.
         if (isset($params['assign']) && $url) {
             $smarty->assign(trim($params['assign']), $url);
             return;
         }
         return $url;
     } catch (Exception $e) {
         echo $e->GetMessage();
     }
     // done.
 }
 public static function getFileDetails($file_id)
 {
     try {
         return uploads_utils::get_upload_details($file_id);
     } catch (Exception $e) {
         // nothing here.
     }
 }