Example #1
0
             $record = new Grid_Record($table, get_object_vars($object));
             $record->save(true);
             if ($table == 'file') {
                 $now = time();
                 $file_sync_upload = new Grid_Record('file_sync_upload', array('id' => $object->id, 'created' => $now));
                 $file_sync_upload->save(true);
             }
         }
     }
     $now = time();
     $last_updated = json_decode($grid->meta['last_updated']);
     $servers = json_decode($params['servers']);
     foreach ($servers as $server_id) {
         $last_updated->{$server_id} = $now;
     }
     save_meta(array('last_updated' => json_encode($last_updated)));
 } else {
     if (!empty($params['download'])) {
         $id = $params['download'];
         $offset = (int) $params['offset'];
         $file = $grid->db->record('file', $id);
         $path = GRID_DIR . "/public/uploads/{$file->path}";
         $binary_data = file_get_contents($path);
         $base64_data = base64_encode($binary_data);
         $data_chunk = substr($base64_data, $offset, $file_chunk_size);
         $complete = $offset + $file_chunk_size >= strlen($base64_data);
         $response = (object) array('revision' => REVISION, 'id' => $id, 'data' => $data_chunk, 'complete' => $complete);
         header('Content-Type: application/json');
         echo json_encode($response);
     } else {
         if (!empty($params['files'])) {
Example #2
0
if (empty($_SESSION['is_admin'])) {
    die('You must login as an admin user.');
}
$storage_path = '/';
if (!empty($grid->meta['storage_path'])) {
    $storage_path = $grid->meta['storage_path'];
}
$old_storage_path = $storage_path;
if (!empty($_POST['storage_path'])) {
    $storage_path = $_POST['storage_path'];
    if ($storage_path == $old_storage_path) {
        die('Storage path unchanged!');
    }
    $grid->log("Setting storage path to {$storage_path}");
    save_meta(array('storage_path' => $storage_path));
    if ($storage_path == '/') {
        $storage_path = '';
    }
    if (!file_exists("{$storage_path}/occupy.here/data/incoming")) {
        exec("mkdir -p {$storage_path}/occupy.here/data/incoming", $result);
    }
    if (!file_exists("{$storage_path}/occupy.here/public/uploads")) {
        exec("mkdir -p {$storage_path}/occupy.here/public/uploads", $result);
    }
    if (is_link('/occupy.here/data/incoming')) {
        unlink('/occupy.here/data/incoming');
    } else {
        rename('/occupy.here/data/incoming', '/occupy.here/data/incoming.bak');
    }
    if ($storage_path == '') {
Example #3
0
function check_for_expired_content()
{
    global $grid;
    $now = time();
    if (empty($grid->meta['last_expired_check']) || $now - $grid->meta['last_expired_check'] > 60) {
        $grid->db->delete('message', 'expires < ?', array($now));
        $grid->db->delete('file', 'expires < ?', array($now));
        save_meta(array('last_expired_check' => $now));
    }
}
Example #4
0
<?php

if (!empty($_SESSION['is_admin']) && !empty($_POST['default_path']) && preg_match('#^(/[a-zA-Z0-9-/]+)+$#', $_POST['default_path'])) {
    save_meta(array('default_path' => $_POST['default_path']));
}
$hostname = HOSTNAME;
header("Location: http://{$hostname}/admin");