コード例 #1
0
ファイル: functions.php プロジェクト: our/net
function check_for_import_content()
{
    global $grid;
    if (!file_exists(GRID_DIR . '/import')) {
        return;
    }
    setup_user();
    $dh = opendir(GRID_DIR . '/import');
    $now = time();
    $expires = $now + 31536000;
    while ($filename = readdir($dh)) {
        if (substr($filename, 0, 1) == '.') {
            continue;
        }
        $message_id = generate_id();
        $file_id = generate_id();
        $created = $now;
        if (substr($filename, -5, 5) == '.html') {
            $html = file_get_contents(GRID_DIR . "/import/{$filename}");
            if (preg_match('#<title>(.+)</title>#', $html, $matches)) {
                list(, $content) = $matches;
            } else {
                $content = preg_replace('#\\.\\w+$#', '', $filename);
            }
            if (preg_match('#var meta = (.+?);#', $html, $matches)) {
                list(, $meta) = $matches;
                $meta = json_decode($meta);
                if (!empty($meta->date_published)) {
                    $date_published = strtotime($meta->date_published);
                    if (!empty($date_published)) {
                        $created = $date_published;
                    }
                }
            }
        } else {
            $content = preg_replace('#\\.\\w+$#', '', $filename);
        }
        $grid->db->insert('message', array('id' => $message_id, 'user_id' => $grid->user->id, 'content' => $content, 'parent_id' => 'c/library', 'server_id' => $grid->meta['server_id'], 'file_id' => $file_id, 'expires' => $expires, 'created' => $created, 'updated' => $now));
        $path = "../import/{$filename}";
        $grid->db->insert('file', array('id' => $file_id, 'user_id' => $grid->user->id, 'server_id' => $grid->meta['server_id'], 'name' => $filename, 'path' => $path, 'created' => $now, 'updated' => $now));
        attach_file($message_id, $file_id);
    }
}
コード例 #2
0
ファイル: staticsync.php プロジェクト: vachanda/ResourceSpace
include dirname(__FILE__) . "/../../include/db.php";
include dirname(__FILE__) . "/../../include/general.php";
include dirname(__FILE__) . "/../../include/resource_functions.php";
include dirname(__FILE__) . "/../../include/image_processing.php";
require "../../vendor/autoload.php";
use Aws\S3\S3Client;
$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) != 'cli') {
    exit("Command line execution only.");
}
if (isset($staticsync_userref)) {
    # If a user is specified, log them in.
    $userref = $staticsync_userref;
    $userdata = get_user($userref);
    setup_user($userdata);
}
ob_end_clean();
set_time_limit(60 * 60 * 40);
if ($argc == 2) {
    if (in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
        echo "To clear the lock after a failed run, ";
        echo "pass in '--clearlock', '-clearlock', '-c' or '--c'." . PHP_EOL;
        exit("Bye!");
    } else {
        if (in_array($argv[1], array('--clearlock', '-clearlock', '-c', '--c'))) {
            if (is_process_lock("staticsync")) {
                clear_process_lock("staticsync");
            }
        } else {
            exit("Unknown argv: " . $argv[1]);
コード例 #3
0
 }
 if (!$api) {
     $user_select_sql = "and u.session='{$session_hash}'";
 } else {
     $user_select_sql = "and u.username='******'";
 }
 if (isset($anonymous_login) && $username == $anonymous_login) {
     $user_select_sql = "and u.username='******'";
 }
 # Automatic anonymous login, do not require session hash.
 hook('provideusercredentials');
 $userdata = sql_query("select u.ref, u.username, g.permissions, g.fixed_theme, g.parent, u.usergroup, u.current_collection, u.last_active, timestampdiff(second,u.last_active,now()) idle_seconds,u.email, u.password, u.fullname, g.search_filter, g.edit_filter, g.ip_restrict ip_restrict_group, g.name groupname, u.ip_restrict ip_restrict_user, resource_defaults, u.password_last_change,g.config_options,g.request_mode, g.derestrict_filter, u.hidden_collections from user u,usergroup g where u.usergroup=g.ref {$user_select_sql} and u.approved=1 and (u.account_expires is null or u.account_expires='0000-00-00 00:00:00' or u.account_expires>now())");
 //print_r($userdata);
 if (count($userdata) > 0) {
     $valid = true;
     setup_user($userdata[0]);
     if ($password_expiry > 0 && !checkperm("p") && $allow_password_change && $pagename != "user_change_password" && $pagename != "index" && $pagename != "collections" && strlen(trim($userdata[0]["password_last_change"])) > 0) {
         # Redirect the user to the password change page if their password has expired.
         $last_password_change = time() - strtotime($userdata[0]["password_last_change"]);
         if ($last_password_change > $password_expiry * 60 * 60 * 24) {
             redirect("pages/user/user_change_password.php?expired=true");
         }
     }
     if (!isset($system_login) && strlen(trim($userdata[0]["last_active"])) > 0) {
         if ($userdata[0]["idle_seconds"] > $session_length * 60) {
             # Last active more than $session_length mins ago?
             $al = "";
             if (isset($anonymous_login)) {
                 $al = $anonymous_login;
             }
             if ($session_autologout && $username != $al) {