Пример #1
0
 function testFileUtilsGetSize_1_Mo_File_with_spaces_and_simple_quote()
 {
     $file = dirname(__FILE__) . "/_fixtures/File '1 Mo";
     @copy(dirname(__FILE__) . '/_fixtures/File_1_Mo_sample', $file);
     $this->assertNotNull(file_utils_get_size($file));
     $this->assertTrue(file_utils_get_size($file) > 0);
     $this->assertTrue(file_utils_get_size($file) > 1000000);
     $this->assertTrue(file_utils_get_size($file) < 2000000);
     unlink($file);
 }
Пример #2
0
function frs_process_release_form($is_update, $request, $group_id, $title, $url)
{
    global $frspf, $frsrf, $frsff;
    $pm = ProjectManager::instance();
    //get and filter all inputs from $request
    $release = array();
    $res = $request->get('release');
    $vName = new Valid_String();
    $vPackage_id = new Valid_UInt();
    $vStatus_id = new Valid_UInt();
    if ($vName->validate($res['name']) && $vPackage_id->validate($res['package_id']) && $vStatus_id->validate($res['status_id'])) {
        $release['status_id'] = $res['status_id'];
        $release['name'] = $res['name'];
        $release['package_id'] = $res['package_id'];
    } else {
        $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('file_admin_editreleases', 'rel_update_failed'));
        $GLOBALS['Response']->redirect('/file/showfiles.php?group_id=' . $group_id);
    }
    $um = UserManager::instance();
    $user = $um->getCurrentUser();
    $vDate = new Valid_String();
    if ($vDate->validate($res['date'])) {
        $release['date'] = $res['date'];
    } else {
        $release['date'] = "";
    }
    $vRelease_notes = new Valid_Text();
    if ($vRelease_notes->validate($res['release_notes'])) {
        $release['release_notes'] = $res['release_notes'];
    } else {
        $release['release_notes'] = "";
    }
    $vChange_log = new Valid_Text();
    if ($vChange_log->validate($res['change_log'])) {
        $release['change_log'] = $res['change_log'];
    } else {
        $release['change_log'] = "";
    }
    if ($request->valid(new Valid_String('js'))) {
        $js = $request->get('js');
    } else {
        $js = "";
    }
    if ($request->validArray(new Valid_String('ftp_file'))) {
        $ftp_file = $request->get('ftp_file');
    } else {
        $ftp_file = array();
    }
    if ($request->validArray(new Valid_UInt('file_processor'))) {
        $file_processor = $request->get('file_processor');
    } else {
        $file_processor = array();
    }
    if ($request->validArray(new Valid_UInt('file_type'))) {
        $file_type = $request->get('file_type');
    } else {
        $file_type = array();
    }
    if ($request->validArray(new Valid_String('reference_md5'))) {
        $reference_md5 = $request->get('reference_md5');
    } else {
        $reference_md5 = array();
    }
    if ($request->validArray(new Valid_String('comment'))) {
        $comment = $request->get('comment');
    } else {
        $comment = array();
    }
    if ($request->validArray(new Valid_UInt('ftp_file_processor'))) {
        $ftp_file_processor = $request->get('ftp_file_processor');
    } else {
        $ftp_file_processor = array();
    }
    if ($request->validArray(new Valid_UInt('ftp_file_type'))) {
        $ftp_file_type = $request->get('ftp_file_type');
    } else {
        $ftp_file_type = array();
    }
    if ($request->validArray(new Valid_String('ftp_reference_md5'))) {
        $ftp_reference_md5 = $request->get('ftp_reference_md5');
    } else {
        $ftp_reference_md5 = array();
    }
    if ($request->valid(new Valid_String('release_news_subject'))) {
        $release_news_subject = $request->get('release_news_subject');
    } else {
        $release_news_subject = "";
    }
    if ($request->valid(new Valid_Text('release_news_details'))) {
        $release_news_details = $request->get('release_news_details');
    } else {
        $release_news_details = "";
    }
    if ($request->valid(new Valid_WhiteList('private_news', array(0, 1)))) {
        $private_news = $request->get('private_news');
    } else {
        $private_news = 0;
    }
    if ($request->validArray(new Valid_UInt('ugroups'))) {
        $ugroups = $request->get('ugroups');
    } else {
        $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('file_admin_editreleases', 'rel_update_failed'));
        $GLOBALS['Response']->redirect('/file/showfiles.php?group_id=' . $group_id);
    }
    if ($request->valid(new Valid_WhiteList('release_submit_news', array(0, 1)))) {
        $release_submit_news = (int) $request->get('release_submit_news');
    } else {
        $release_submit_news = 0;
    }
    if ($request->valid(new Valid_WhiteList('notification', array(0, 1)))) {
        $notification = $request->get('notification');
    } else {
        $notification = 0;
    }
    if ($is_update) {
        if ($request->validArray(new Valid_UInt('release_files_to_delete'))) {
            $release_files_to_delete = $request->get('release_files_to_delete');
        } else {
            $release_files_to_delete = array();
        }
        if ($request->validArray(new Valid_UInt('release_files'))) {
            $release_files = $request->get('release_files');
        } else {
            $release_files = array();
        }
        if ($request->validArray(new Valid_UInt('release_file_processor'))) {
            $release_file_processor = $request->get('release_file_processor');
        } else {
            $release_file_processor = array();
        }
        if ($request->validArray(new Valid_UInt('release_file_type'))) {
            $release_file_type = $request->get('release_file_type');
        } else {
            $release_file_type = array();
        }
        if ($request->validArray(new Valid_String('release_reference_md5'))) {
            $release_reference_md5 = $request->get('release_reference_md5');
        } else {
            $release_reference_md5 = array();
        }
        if ($request->validArray(new Valid_UInt('new_release_id'))) {
            $new_release_id = $request->get('new_release_id');
        } else {
            $new_release_id = array();
        }
        if ($request->validArray(new Valid_String('release_time'))) {
            $release_time = $request->get('release_time');
        } else {
            $release_time = array();
        }
        if ($request->validArray(new Valid_String('reference_md5'))) {
            $reference_md5 = $request->get('reference_md5');
        } else {
            $reference_md5 = array();
        }
        if ($request->validArray(new Valid_Text('release_comment'))) {
            $release_comment = $request->get('release_comment');
        } else {
            $release_comment = array();
        }
        if ($request->valid(new Valid_UInt('id'))) {
            $release['release_id'] = $request->get('id');
        } else {
            exit;
        }
    }
    $validator = new frsValidator();
    if ($is_update) {
        $valid = $validator->isValidForUpdate($release, $group_id);
    } else {
        $valid = $validator->isValidForCreation($release, $group_id);
    }
    if ($valid) {
        //uplaod release_notes and change_log if needed
        $data_uploaded = false;
        if (isset($_FILES['uploaded_change_log']) && !$_FILES['uploaded_change_log']['error']) {
            $code = addslashes(fread(fopen($_FILES['uploaded_change_log']['tmp_name'], 'r'), file_utils_get_size($_FILES['uploaded_change_log']['tmp_name'])));
            if (strlen($code) > 0 && strlen($code) < $GLOBALS['sys_max_size_upload']) {
                //size is fine
                $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('file_admin_editreleases', 'data_uploaded'));
                $data_uploaded = true;
                $release['change_log'] = $code;
            } else {
                //too big or small
                $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('file_admin_editreleases', 'length_err', $GLOBALS['sys_max_size_upload']));
            }
        }
        if (isset($_FILES['uploaded_release_notes']) && !$_FILES['uploaded_release_notes']['error']) {
            $code = addslashes(fread(fopen($_FILES['uploaded_release_notes']['tmp_name'], 'r'), file_utils_get_size($_FILES['uploaded_release_notes']['tmp_name'])));
            if (strlen($code) > 0 && strlen($code) < $GLOBALS['sys_max_size_upload']) {
                //size is fine
                if (!$data_uploaded) {
                    $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('file_admin_editreleases', 'data_uploaded'));
                }
                $release['release_notes'] = $code;
            } else {
                //too big or small
                $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('file_admin_editreleases', 'length_err', $GLOBALS['sys_max_size_upload']));
            }
        }
        if ($is_update) {
            // make sure that we don't change the date by error because of timezone reasons.
            // eg: release created in India (GMT +5:30) at 2004-06-03.
            // MLS in Los Angeles (GMT -8) changes the release notes
            // the release_date that we showed MLS is 2004-06-02.
            // with mktime(0,0,0,2,6,2004); we will change the unix time in the database
            // and the people in India will discover that their release has been created on 2004-06-02
            $rel =& $frsrf->getFRSReleaseFromDb($release['release_id']);
            if (format_date('Y-m-d', $rel->getReleaseDate()) == $release['date']) {
                // the date didn't change => don't update it
                $unix_release_time = $rel->getReleaseDate();
            } else {
                $date_list = split("-", $release['date'], 3);
                $unix_release_time = mktime(0, 0, 0, $date_list[1], $date_list[2], $date_list[0]);
            }
        } else {
            //parse the date
            $date_list = split("-", $release['date'], 3);
            $unix_release_time = mktime(0, 0, 0, $date_list[1], $date_list[2], $date_list[0]);
        }
        //now we create or update the release
        $array = array('release_date' => $unix_release_time, 'name' => $release['name'], 'status_id' => $release['status_id'], 'package_id' => $release['package_id'], 'notes' => $release['release_notes'], 'changes' => $release['change_log']);
        if ($is_update) {
            $array['release_id'] = $release['release_id'];
        }
        if ($is_update) {
            $res = $frsrf->update($array);
            if (!$res) {
                $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('file_admin_editreleases', 'rel_update_failed'));
                //insert failed - go back to definition screen
            } else {
                //release added - now show the detail page for this new release
                $release_id = $array['release_id'];
                $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('file_admin_editreleases', 'rel_updated', $release['name']));
            }
        } else {
            $res = $frsrf->create($array);
            if (!$res) {
                $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language'] > getText('file_admin_editreleases', 'add_rel_fail'));
                //insert failed - go back to definition screen
            } else {
                //release added - now show the detail page for this new release
                $release_id = $res;
                $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('file_admin_editreleases', 'rel_added'));
            }
        }
        if ($res) {
            // extract cross references
            $reference_manager =& ReferenceManager::instance();
            $reference_manager->extractCrossRef($release['release_notes'], $release_id, ReferenceManager::REFERENCE_NATURE_RELEASE, $group_id);
            $reference_manager->extractCrossRef($release['change_log'], $release_id, ReferenceManager::REFERENCE_NATURE_RELEASE, $group_id);
            //set the release permissions
            list($return_code, $feedbacks) = permission_process_selection_form($group_id, 'RELEASE_READ', $release_id, $ugroups);
            if (!$return_code) {
                $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('file_admin_editpackages', 'perm_update_err'));
                $GLOBALS['Response']->addFeedback('error', $feedbacks);
            }
            //submit news if requested
            if ($release_id && user_ismember($group_id, 'A') && $release_submit_news) {
                news_submit($group_id, $release_news_subject, $release_news_details, $private_news, 3);
            }
            // Send notification
            if ($notification) {
                $rel = $frsrf->getFRSReleaseFromDb($release_id);
                $count = $frsrf->emailNotification($rel);
                if ($count === false) {
                    $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'mail_failed', array($GLOBALS['sys_email_admin'])));
                } else {
                    if ($count > 0) {
                        $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('file_admin_editreleases', 'email_sent', $count));
                    }
                }
            }
            $group = $pm->getProject($group_id);
            $group_unix_name = $group->getUnixName(false);
            $project_files_dir = $GLOBALS['ftp_frs_dir_prefix'] . '/' . $group_unix_name;
            if ($is_update) {
                $files =& $rel->getFiles();
                //remove files
                foreach ($release_files_to_delete as $rel_file) {
                    $res =& $frsff->getFRSFileFromDb($rel_file);
                    $fname = $res->getFileName();
                    $res = $frsff->delete_file($group_id, $rel_file);
                    if ($res == 0) {
                        $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('file_admin_editreleases', 'f_not_yours', basename($fname)));
                    } else {
                        $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('file_admin_editreleases', 'file_deleted', basename($fname)));
                    }
                }
                //update files
                $index = 0;
                foreach ($release_files as $rel_file) {
                    if (!$release_files_to_delete || !in_array($rel_file, $release_files_to_delete)) {
                        $package_id = $release['package_id'];
                        $fname = $files[$index]->getFileName();
                        $list = split('/', $fname);
                        $fname = $list[sizeof($list) - 1];
                        if ($new_release_id[$index] != $release_id) {
                            //changing to a different release for this file
                            //see if the new release is valid for this project
                            $res2 = $frsrf->getFRSReleaseFromDb($new_release_id[$index], $group_id);
                            if (!$res2 || count($res2) < 1) {
                                //release not found for this project
                                $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('file_admin_editreleases', 'rel_not_yours', $fname));
                            } else {
                                $package_id = $res2->getPackageID();
                            }
                        }
                        if ($new_release_id[$index] == $release_id || $res2) {
                            if (!ereg("[0-9]{4}-[0-9]{2}-[0-9]{2}", $release_time[$index])) {
                                $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('file_admin_editreleases', 'data_not_parsed_file', $fname));
                            } else {
                                $res2 =& $frsff->getFRSFileFromDb($rel_file);
                                if (format_date('Y-m-d', $res2->getReleaseTime()) == $release_time[$index]) {
                                    $unix_release_time = $res2->getReleaseTime();
                                } else {
                                    $date_list = split("-", $release_time[$index], 3);
                                    $unix_release_time = mktime(0, 0, 0, $date_list[1], $date_list[2], $date_list[0]);
                                }
                                $array = array('release_id' => $new_release_id[$index], 'release_time' => $unix_release_time, 'type_id' => $release_file_type[$index], 'processor_id' => $release_file_processor[$index], 'file_id' => $rel_file, 'comment' => $release_comment[$index], 'filename' => 'p' . $package_id . '_r' . $new_release_id[$index] . '/' . $fname, 'filepath' => 'p' . $package_id . '_r' . $new_release_id[$index] . '/' . $fname . '_' . $unix_release_time);
                                if ($release_reference_md5[$index] && $release_reference_md5[$index] != '') {
                                    $array['reference_md5'] = $release_reference_md5[$index];
                                }
                                $res = $frsff->update($array);
                                if ($res) {
                                    $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('file_admin_editreleases', 'file_updated', $fname));
                                }
                            }
                        }
                    }
                    $index++;
                }
            }
            //add new files
            //files processing
            $http_files_list = array();
            $processor_type_list = array();
            $file_type_list = array();
            $http_files_processor_type_list = array();
            $ftp_files_processor_type_list = array();
            if (isset($js) && $js == 'no_js') {
                //if javascript is not allowed, there is maximum one file to upload
                // TODO : fix warnings due to array instead of string for "file_processor", "file_type" & "reference_md5"
                if ($ftp_file[0] != -1) {
                    $ftp_files_processor_type_list[] = array('name' => $ftp_file[0], 'processor' => $file_processor, 'type' => $file_type, 'reference_md5' => $reference_md5, 'comment' => $comment);
                } else {
                    if (trim($_FILES['file']['name'][0]) != '') {
                        $http_files_processor_type_list[] = array('error' => $_FILES['file']['error'][0], 'name' => stripslashes($_FILES['file']['name'][0]), 'tmp_name' => $_FILES['file']['tmp_name'][0], 'processor' => $file_processor, 'type' => $file_type, 'reference_md5' => $reference_md5, 'comment' => $comment);
                    }
                }
            } else {
                //get http files with the associated processor type and file type in allowed javascript case
                $nb_files = isset($_FILES['file']) ? count($_FILES['file']['name']) : 0;
                for ($i = 0; $i < $nb_files; $i++) {
                    if (trim($_FILES['file']['name'][$i]) != '') {
                        $http_files_processor_type_list[] = array('error' => $_FILES['file']['error'][$i], 'name' => stripslashes($_FILES['file']['name'][$i]), 'tmp_name' => $_FILES['file']['tmp_name'][$i], 'processor' => $file_processor[$i], 'type' => $file_type[$i], 'reference_md5' => $reference_md5[$i], 'comment' => $comment[$i]);
                    }
                }
                //remove hidden ftp_file input (if the user let the select boxe on --choose file)
                $tmp_file_list = array();
                $index = 0;
                foreach ($ftp_file as $file) {
                    if (trim($file) != '') {
                        $ftp_files_processor_type_list[] = array('name' => $file, 'processor' => $ftp_file_processor[$index], 'type' => $ftp_file_type[$index], 'reference_md5' => $ftp_reference_md5[$index]);
                        $index++;
                    }
                }
            }
            if (count($http_files_processor_type_list) > 0 || count($ftp_files_processor_type_list) > 0) {
                //see if this release belongs to this project
                $res1 =& $frsrf->getFRSReleaseFromDb($release_id, $group_id);
                if (!$res1 || count($res1) < 1) {
                    //release not found for this project
                    $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('file_admin_editreleases', 'rel_not_yours'));
                } else {
                    $now = time();
                    $addingFiles = false;
                    //iterate and add the http files to the frs_file table
                    foreach ($http_files_processor_type_list as $file) {
                        $filename = $file['name'];
                        if (isset($file['error'])) {
                            switch ($file['error']) {
                                case UPLOAD_ERR_OK:
                                    // all is OK
                                    break;
                                case UPLOAD_ERR_INI_SIZE:
                                case UPLOAD_ERR_FORM_SIZE:
                                    $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'error_upload_size', $file['error']));
                                    break;
                                case UPLOAD_ERR_PARTIAL:
                                    $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'error_upload_partial', $file['error']));
                                    break;
                                case UPLOAD_ERR_NO_FILE:
                                    $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'error_upload_nofile', $file['error']));
                                    break;
                                default:
                                    $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'error_upload_unknown', $file['error']));
                            }
                        }
                        if (is_uploaded_file($file['tmp_name'])) {
                            $uploaddir = $frsff->getSrcDir($request->getProject());
                            $uploadfile = $uploaddir . "/" . basename($filename);
                            if (!file_exists($uploaddir) || !is_writable($uploaddir) || !move_uploaded_file($file['tmp_name'], $uploadfile)) {
                                $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('file_admin_editreleases', 'not_add_file') . ": " . basename($filename));
                            } else {
                                $newFile = new FRSFile();
                                $newFile->setRelease($res1);
                                $newFile->setFileName($filename);
                                $newFile->setProcessorID($file['processor']);
                                $newFile->setTypeID($file['type']);
                                $newFile->setReferenceMd5($file['reference_md5']);
                                $newFile->setUserId($user->getId());
                                $newFile->setComment($file['comment']);
                                try {
                                    $frsff->createFile($newFile);
                                    $addingFiles = true;
                                } catch (Exception $e) {
                                    $GLOBALS['Response']->addFeedback('error', $e->getMessage());
                                }
                            }
                        } else {
                            $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('file_admin_editreleases', 'not_add_file') . ": " . basename($filename));
                        }
                    }
                    //iterate and add the ftp files to the frs_file table
                    foreach ($ftp_files_processor_type_list as $file) {
                        $filename = $file['name'];
                        $newFile = new FRSFile();
                        $newFile->setRelease($res1);
                        $newFile->setFileName($filename);
                        $newFile->setProcessorID($file['processor']);
                        $newFile->setTypeID($file['type']);
                        $newFile->setReferenceMd5($file['reference_md5']);
                        $newFile->setUserId($user->getId());
                        try {
                            $frsff->createFile($newFile, ~FRSFileFactory::COMPUTE_MD5);
                            $addingFiles = true;
                            $em = EventManager::instance();
                            $em->processEvent(Event::COMPUTE_MD5SUM, array('fileId' => $newFile->getFileID()));
                            $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('file_admin_editreleases', 'offline_md5', $filename));
                        } catch (Exception $e) {
                            $GLOBALS['Response']->addFeedback('error', $e->getMessage());
                        }
                    }
                }
                if ($addingFiles) {
                    $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('file_admin_editreleases', 'add_files'));
                }
            }
            //redirect to files
            $GLOBALS['Response']->redirect('/file/?group_id=' . $group_id);
        }
    } else {
        $GLOBALS['Response']->addFeedback('error', $validator->getErrors());
    }
    frs_display_release_form($is_update, $release, $group_id, $title, $url);
}
Пример #3
0
 /**
  * Check file upload validity
  *
  * @param  Array   One entry in $_FILES superarray (e.g. $_FILES['test'])
  * @return Boolean Is file upload valid or not.
  */
 function isValid($file)
 {
     $ok = false;
     if (is_array($file)) {
         switch ($file['error']) {
             case UPLOAD_ERR_OK:
                 // all is OK
                 $ok = true;
                 break;
             case UPLOAD_ERR_INI_SIZE:
             case UPLOAD_ERR_FORM_SIZE:
                 $this->error = $this->geti18nError('error_upload_size', $file['error']);
                 break;
             case UPLOAD_ERR_PARTIAL:
                 $this->error = $this->geti18nError('error_upload_partial', $file['error']);
                 break;
             case UPLOAD_ERR_NO_FILE:
                 $this->error = $this->geti18nError('error_upload_nofile', $file['error']);
                 break;
                 //case UPLOAD_ERR_NO_TMP_DIR: PHP 5.0.3
                 //case UPLOAD_ERR_CANT_WRITE: PHP 5.1.0
                 //case UPLOAD_ERR_EXTENSION: PHP 5.2.0
             //case UPLOAD_ERR_NO_TMP_DIR: PHP 5.0.3
             //case UPLOAD_ERR_CANT_WRITE: PHP 5.1.0
             //case UPLOAD_ERR_EXTENSION: PHP 5.2.0
             default:
                 $this->error = $this->geti18nError('error_upload_unknown', $file['error']);
         }
         if ($ok && $file['name'] == '') {
             $ok = false;
             $this->error = $this->geti18nError('error_upload');
         }
         if ($ok) {
             // Re-check filesize (do not trust uploaded MAX_FILE_SIZE)
             if (file_utils_get_size($file['tmp_name']) > $this->maxSize) {
                 $ok = false;
                 $this->error = $this->geti18nError('error_upload_size', 1);
             }
         }
     }
     return $ok;
 }
Пример #4
0
 /**
  * create a row in the table frs_file
  *
  * @return true or id(auto_increment) if there is no error
  */
 function create($file_name = null, $filepath = null, $release_id = null, $type_id = null, $processor_id = null, $release_time = null, $file_size = null, $reference_md5 = null, $post_date = null, $status = 'A')
 {
     $arg = array();
     $values = array();
     if ($file_name !== null) {
         $arg[] = 'filename';
         $values[] = $this->da->quoteSmart($file_name);
     }
     if ($filepath !== null) {
         $arg[] = 'filepath';
         $values[] = $this->da->quoteSmart($filepath);
     }
     if ($release_id !== null) {
         $arg[] = 'release_id';
         $values[] = $this->da->escapeInt($release_id);
     }
     if ($type_id !== null) {
         $arg[] = 'type_id';
         $values[] = $this->da->escapeInt($type_id);
     }
     if ($processor_id !== null) {
         $arg[] = 'processor_id';
         $values[] = $this->da->escapeInt($processor_id);
     }
     if ($reference_md5 !== null) {
         $arg[] = 'reference_md5';
         $values[] = $this->da->quoteSmart($reference_md5);
     }
     $arg[] = 'release_time';
     $values[] = $this->da->escapeInt(time());
     if ($file_size !== null) {
         $arg[] = 'file_size';
         $values[] = $this->da->escapeInt($file_size);
     } else {
         $arg[] = 'file_size';
         $values[] = file_utils_get_size($file_name);
     }
     $arg[] = 'post_date';
     $values[] = $this->da->escapeInt(time());
     $arg[] = 'status';
     $values[] = $status;
     $sql = 'INSERT INTO frs_file' . '(' . implode(', ', $arg) . ')' . ' VALUES (' . implode(', ', $values) . ')';
     return $this->_createAndReturnId($sql);
 }
Пример #5
0
 function getFileSize()
 {
     if ($this->file_size == null) {
         $file_location = $this->getFileLocation();
         // Use file_utils to provide a workaround for the 2 GB limitation
         $this->file_size = file_utils_get_size($file_location);
     }
     return $this->file_size;
 }