当前位置: 首页>>代码示例>>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;未经允许,请勿转载。