當前位置: 首頁>>代碼示例>>PHP>>正文


PHP file::loadById方法代碼示例

本文整理匯總了PHP中file::loadById方法的典型用法代碼示例。如果您正苦於以下問題:PHP file::loadById方法的具體用法?PHP file::loadById怎麽用?PHP file::loadById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在file的用法示例。


在下文中一共展示了file::loadById方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: deleteRedundantFiles

function deleteRedundantFiles()
{
    // check for any files to delete
    $nextCheck = trim(SITE_CONFIG_NEXT_CHECK_FOR_FILE_REMOVALS);
    if (strlen($nextCheck) == 0) {
        $nextCheck = time();
    }
    // dont run the check if we're not due to yet
    if ($nextCheck > time()) {
        return false;
    }
    // connect db
    $db = Database::getDatabase(true);
    // file removal periods
    $fileRemovalFreeAcc = trim(SITE_CONFIG_FREE_USER_UPLOAD_REMOVAL_DAYS);
    $fileRemovalPaidAcc = trim(SITE_CONFIG_PREMIUM_USER_UPLOAD_REMOVAL_DAYS);
    // set a maximum of 5 years otherwise we hit unix timestamp calculation issues
    if ($fileRemovalFreeAcc > 1825) {
        $fileRemovalFreeAcc = 1825;
    }
    if ($fileRemovalPaidAcc > 1825) {
        $fileRemovalPaidAcc = 1825;
    }
    // free/non-accounts
    if ((int) $fileRemovalFreeAcc != 0) {
        $sQL = 'SELECT file.id ';
        $sQL .= 'FROM file LEFT JOIN users ';
        $sQL .= 'ON file.userId = users.id ';
        $sQL .= 'WHERE file.statusId = 1 AND ';
        $sQL .= 'UNIX_TIMESTAMP(file.uploadedDate) < ' . strtotime('-' . $fileRemovalFreeAcc . ' days') . ' AND ';
        $sQL .= '(UNIX_TIMESTAMP(file.lastAccessed) < ' . strtotime('-' . $fileRemovalFreeAcc . ' days') . ' OR file.lastAccessed IS NULL) ';
        $sQL .= 'AND (file.userId IS NULL OR users.level = \'free user\');';
        $rows = $db->getRows($sQL);
        if (is_array($rows)) {
            foreach ($rows as $row) {
                // load file object
                $file = file::loadById($row['id']);
                if ($file) {
                    // remove file
                    $file->removeBySystem();
                }
            }
        }
    }
    // paid accounts
    if ((int) $fileRemovalPaidAcc != 0) {
        $sQL = 'SELECT file.id ';
        $sQL .= 'FROM file LEFT JOIN users ';
        $sQL .= 'ON file.userId = users.id ';
        $sQL .= 'WHERE file.statusId = 1 AND ';
        $sQL .= 'UNIX_TIMESTAMP(file.uploadedDate) < ' . strtotime('-' . $fileRemovalPaidAcc . ' days') . ' AND ';
        $sQL .= '(UNIX_TIMESTAMP(file.lastAccessed) < ' . strtotime('-' . $fileRemovalPaidAcc . ' days') . ' OR file.lastAccessed IS NULL) ';
        $sQL .= 'AND (users.level = \'admin\' OR users.level = \'paid user\');';
        $rows = $db->getRows($sQL);
        if (is_array($rows)) {
            foreach ($rows as $row) {
                // load file object
                $file = file::loadById($row['id']);
                if ($file) {
                    // remove file
                    $file->removeBySystem();
                }
            }
        }
    }
    // update db for next check. Run file check again in 1 hour.
    $nextCheck = time() + 60 * 60;
    $db->query('UPDATE site_config SET config_value = :newValue WHERE config_key = \'next_check_for_file_removals\'', array('newValue' => $nextCheck));
}
開發者ID:farzam65,項目名稱:YetiShare-File-Hosting-Script-Free,代碼行數:69,代碼來源:functions.inc.php

示例2: die

<?php

require_once 'ajax_auth.inc.php';
$db = Database::getDatabase();
$id = (int) $_REQUEST['id'];
$statusId = (int) $_REQUEST['statusId'];
// check for removal
if ($statusId == 3) {
    // load file
    $file = file::loadById($id);
    if (!$file) {
        die("0");
    }
    // remove
    $file->removeBySystem();
}
$db->query('UPDATE file SET statusId = :statusId WHERE id = :id', array('statusId' => $statusId, 'id' => $id));
if ($db->affectedRows() == 1) {
    die("1");
}
die("0");
開發者ID:farzam65,項目名稱:YetiShare-File-Hosting-Script-Free,代碼行數:21,代碼來源:updateFileState.ajax.php

示例3: redirect

<?php

/* setup includes */
require_once 'includes/master.inc.php';
/* require login */
$Auth->requireUser('login.php');
/* load file */
if (isset($_REQUEST['u'])) {
    $file = file::loadById($_REQUEST['u']);
    if (!$file) {
        // failed lookup of file
        redirect('http://' . _CONFIG_SITE_FULL_URL . '/account_home.' . SITE_CONFIG_PAGE_EXTENSION);
    }
    // check current user has permission to edit file
    if ($file->userId != $Auth->id) {
        redirect('http://' . _CONFIG_SITE_FULL_URL . '/account_home.' . SITE_CONFIG_PAGE_EXTENSION);
    }
} else {
    redirect('http://' . _CONFIG_SITE_FULL_URL . '/account_home.' . SITE_CONFIG_PAGE_EXTENSION);
}
/* setup page */
define("PAGE_NAME", t("edit_page_name", "Edit"));
define("PAGE_DESCRIPTION", t("edit_meta_description", "Edit existing item"));
define("PAGE_KEYWORDS", t("edit_meta_keywords", "edit, existing, item"));
/* handle submission */
if ((int) $_REQUEST['submitme']) {
    // validation
    $filename = trim($_REQUEST['filename']);
    $reset_stats = (int) trim($_REQUEST['reset_stats']);
    $folder = (int) trim($_REQUEST['folder']);
    if (!strlen($filename)) {
開發者ID:farzam65,項目名稱:YetiShare-File-Hosting-Script-Free,代碼行數:31,代碼來源:account_edit_item.php


注:本文中的file::loadById方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。