示例#1
0
function setup_default_config()
{
    global $config_values, $platform;
    function _default($a, $b)
    {
        global $config_values;
        if (!isset($config_values['Settings'][$a])) {
            $config_values['Settings'][$a] = $b;
        }
    }
    if (!isset($config_values['Settings'])) {
        $config_values['Settings'] = array();
    }
    // Sensible Defaults
    $basedir = get_base_dir();
    _default('Episode Only', '0');
    _default('Combine Feeds', '0');
    _default('Transmission Login', '');
    _default('Transmission Password', '');
    _default('Transmission Host', 'localhost');
    _default('Transmission Port', '9091');
    _default('Transmission URI', '/transmission/rpc');
    _default('Watch Dir', '');
    if ($platform == 'NMT') {
        _default('Download Dir', '/share/Download');
    } else {
        _default('Download Dir', '/mnt/Media/Downloads');
    }
    _default('Cache Dir', $basedir . "/rss_cache/");
    _default('TVDB Dir', $basedir . "/tvdb_cache/");
    _default('Save Torrents', "0");
    _default('Run Torrentwatch', "True");
    _default('Client', "Transmission");
    _default('Verify Episode', "1");
    _default('Only Newer', "1");
    _default('Download Proper', "1");
    _default('Default Feed All', "1");
    _default('Deep Directories', "0");
    _default('Require Episode Info', '0');
    _default('Disable Hide List', '0');
    _default('History', $basedir . "/rss_cache/rss_dl.history");
    _default('MatchStyle', "regexp");
    _default('Extension', "torrent");
    _default('verbosity', '0');
    _default('Default Seed Ratio', '-1');
    _default('Script', '');
    _default('Email Notifications', '');
    _default('SMTP Server', 'localhost');
    _default('TimeZone', 'UTC');
    _default('Sanitize Hidelist', '0');
}
示例#2
0
/**
 * @return   Smarty  Locally-usable Smarty instance.
 */
function get_smarty_instance()
{
    $s = new Smarty();
    $s->compile_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates', 'cache'));
    $s->cache_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates', 'cache'));
    $s->template_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates'));
    $s->config_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates'));
    $s->assign('domain', get_domain_name());
    $s->assign('base_dir', get_base_dir());
    $s->assign('base_href', get_base_href());
    $s->assign('constants', get_defined_constants());
    $s->assign('request', array('get' => $_GET));
    return $s;
}
示例#3
0
/**
 * @return   Smarty  Locally-usable Smarty instance.
 */
function get_smarty_instance($user)
{
    $s = new Smarty();
    $s->compile_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates', 'cache'));
    $s->cache_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates', 'cache'));
    $s->template_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates'));
    $s->config_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates'));
    $s->assign('domain', get_domain_name());
    $s->assign('base_dir', get_base_dir());
    $s->assign('base_href', get_base_href());
    $s->assign('constants', get_defined_constants());
    $s->assign('providers', get_map_providers());
    $s->assign('request', array('get' => $_GET, 'post' => $_POST, 'uri' => $_SERVER['REQUEST_URI'], 'query' => $_SERVER['QUERY_STRING'], 'authenticated' => isset($user), 'user' => $user));
    $s->register_modifier('nice_placename', 'nice_placename');
    $s->register_modifier('nice_domainname', 'nice_domainname');
    $s->register_modifier('nice_relativetime', 'nice_relativetime');
    $s->register_modifier('nice_datetime', 'nice_datetime');
    $s->register_modifier('nice_degree', 'nice_degree');
    $s->register_modifier('decode_utf8', 'decode_utf8');
    return $s;
}
示例#4
0
function &default_context($make_session)
{
    /*
        Argument is a boolean value that tells the function whether to make a
        session or not.
    */
    $db =& get_db_connection();
    /* change character set to utf8 */
    $db->query("SET NAMES utf8mb4");
    //$db->query("SET CHARACTER SET 'utf8'");
    $user = null;
    $type = get_preferred_type($_GET['type'] ? $_GET['type'] : $_SERVER['HTTP_ACCEPT']);
    if ($type == 'text/html' && $make_session) {
        // get the session user if there is one
        session_set_cookie_params(86400 * 31, get_base_dir(), null, false, true);
        session_start();
        $user = cookied_user($db);
    }
    // Smarty is created last because it needs $_SESSION populated
    $sm =& get_smarty_instance($user);
    $ctx = new Context($db, $sm, $user, $type);
    return $ctx;
}
function get_base_url()
{
    $href = get_server_url();
    $path = substr(get_base_dir(), strlen(get_server_dir()));
    $path = ltrim($path, '/');
    return sprintf('%s/%s', $href, $path);
}
示例#6
0
function local_get_post_baseurl($dirname)
{
    return 'http://' . get_domain_name() . get_base_dir() . '/files/' . trim($dirname, '/') . '/';
}
示例#7
0
<?php

require_once '../lib/lib.everything.php';
enforce_master_on_off_switch($_SERVER['HTTP_ACCEPT_LANGUAGE']);
$context = default_context(True);
/**** ... ****/
$context->db->query('START TRANSACTION');
$scan = add_scan($context->db, $context->user['id']);
flush_scans($context->db, 3600);
$context->db->query('COMMIT');
$dirname = "scans/{$scan['id']}";
$redirect = 'http://' . get_domain_name() . get_base_dir() . '/uploaded.php?scan=' . rawurlencode($scan['id']);
$s3post = AWS_ACCESS_KEY && AWS_SECRET_KEY && S3_BUCKET_ID ? s3_get_post_details(time() + 600, $dirname, $redirect) : null;
$localpost = AWS_ACCESS_KEY && AWS_SECRET_KEY && S3_BUCKET_ID ? null : local_get_post_details(time() + 600, $dirname, $redirect);
$context->sm->assign('s3post', $s3post);
$context->sm->assign('localpost', $localpost);
header("Content-Type: text/html; charset=UTF-8");
print $context->sm->fetch("upload.html.tpl");
示例#8
0
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '../lib');
require_once 'init.php';
require_once 'data.php';
$C = new Context(DB_DSN, GUARDIAN_API_KEY, FLICKR_API_KEY, $_COOKIE['visitor']);
$C->setCookie();
list($response_format, $response_mime_type) = parse_format($_GET['format'], 'html');
$woe_id = is_numeric($_GET['woe']) ? intval($_GET['woe']) : null;
$woe_ids = isset($_GET['woes']) ? intvals($_GET['woes']) : null;
$article_id = is_numeric($_GET['article']) ? intval($_GET['article']) : null;
$article_ids = isset($_GET['articles']) ? intvals($_GET['articles']) : null;
$count = is_numeric($_GET['count']) ? intval($_GET['count']) : null;
$offset = is_numeric($_GET['offset']) ? intval($_GET['offset']) : 0;
$js_callback = $response_mime_type == 'text/javascript' && $_GET['callback'] ? sanitize_js_callback($_GET['callback']) : null;
if ($woe_id && $article_id) {
    $url = new Net_URL('http://' . get_domain_name() . get_base_dir() . '/point.php');
    $url->addQueryString('article', $article_id);
    $url->addQueryString('woe', $woe_id);
    $url->addQueryString('format', $response_format);
    header('Location: ' . $url->getURL());
    exit;
} elseif (($article_ids || $woe_ids) && ($article_id || $woe_id)) {
    header('Content-Type: text/plain');
    die_with_code(400, "It's not possible to specify both singular and plural article/WOE ID's.\n");
} else {
    $points = get_points($C, compact('article_id', 'woe_id', 'article_ids', 'woe_ids', 'count', 'offset'));
    $total = get_points_total($C, compact('article_id', 'woe_id', 'article_ids', 'woe_ids'));
    $count = count($points);
}
$C->close();
header("Content-Type: {$response_mime_type}; charset=UTF-8");
示例#9
0
function scan_note_to_csv_row($note)
{
    preg_match('/^(\\w+)\\b/', $note['geometry'], $p);
    $row = array('type' => 'note ' . strtolower($p[1]), 'href' => '', 'created' => '"' . date('r', $note['created']) . '"', 'person_href' => '', 'geometry' => '"' . $note['geometry'] . '"', 'atlas_page_href' => '', 'snapshot_href' => 'http://' . get_domain_name() . get_base_dir() . '/snapshot.php?id=' . urlencode($note['scan_id']), 'note' => '"' . $note['note'] . '"');
    if ($scan['user_name']) {
        $row['person_href'] = 'http://' . get_domain_name() . get_base_dir() . '/snapshots.php?user='******'user_id']);
    }
    return join(',', array_values($row));
}
示例#10
0
<?php

require_once '../lib/lib.everything.php';
$context = default_context(True);
////
// Path
////
$mbtiles_filename = basename($_FILES['uploaded_mbtiles']['name']);
$target_mbtiles_folder = "mbtiles/";
$target_mbtiles_path = $target_mbtiles_folder . $mbtiles_filename;
////
// Content
////
$mbtiles_content_bytes = file_get_contents($_FILES['uploaded_mbtiles']['tmp_name']);
$mime_type = 'application/octet-stream';
// Post the file
post_file($target_mbtiles_path, $mbtiles_content_bytes, $mime_type);
$filename = explode('.', basename($_FILES['uploaded_mbtiles']['name']));
$slug = $filename[0];
$mbtiles_url = 'http://' . get_domain_name() . get_base_dir() . '/mbtiles.php/' . $slug . '/{Z}/{X}/{Y}.png';
$mbtiles = add_mbtiles($context->db, $context->user['id'], $mbtiles_url, $mbtiles_filename, 'files/' . $target_mbtiles_path);
$display_mbtiles_url = 'http://' . get_domain_name() . get_base_dir() . '/display_mbtiles.php?id=' . urlencode($mbtiles['id']) . '&filename=' . urlencode($slug);
header("Location: {$display_mbtiles_url}");
示例#11
0
function print_to_csv_row($print)
{
    $row = array('type' => 'atlas', 'href' => 'http://' . get_domain_name() . get_base_dir() . '/atlas.php?id=' . urlencode($print['id']), 'created' => '"' . date('r', $print['created']) . '"', 'person_href' => '', 'geometry' => '', 'atlas_page_href' => '', 'snapshot_href' => '', 'note' => '');
    if ($print['user_name']) {
        $row['person_href'] = 'http://' . get_domain_name() . get_base_dir() . '/atlases.php?user='******'user_id']);
    }
    $polys = array();
    foreach ($print['pages'] as $page) {
        $north = floatval($page['north']);
        $south = floatval($page['south']);
        $east = floatval($page['east']);
        $west = floatval($page['west']);
        $polys[] = sprintf('((%.6f %.6f,%.6f %.6f,%.6f %.6f,%.6f %.6f,%.6f %.6f))', $west, $south, $west, $north, $east, $north, $east, $south, $west, $south);
    }
    $row['geometry'] = sprintf('"MULTIPOLYGON(%s)"', join(', ', $polys));
    return join(',', array_values($row));
}
示例#12
0
文件: output.php 项目: quilime/mus
function get_url_string()
{
    return substr($_SERVER['SCRIPT_URL'], strlen(get_base_dir() . '/'));
}
示例#13
0
 function setCookie()
 {
     setcookie('visitor', $this->visitor_id, time() + 86400 * 30, get_base_dir(), get_domain_name());
 }
示例#14
0
$error = '';
if (isset($_POST['form_url'])) {
    if (empty($_POST['form_url'])) {
        $error = "Empty or missing form_url.";
    }
    if (empty($error)) {
        $added_form = add_form($context->db, $context->user['id']);
        $added_form['form_url'] = $_POST['form_url'];
        if (!empty($_POST['form_title'])) {
            $added_form['title'] = $_POST['form_title'];
        }
        set_form($context->db, $added_form);
        $message = array('action' => 'import form', 'url' => $_POST['form_url'], 'form_id' => $added_form['id']);
        // queue the task
        queue_task("tasks.parseForm", array("http://" . SERVER_NAME, API_PASSWORD), $message);
        $form_url = 'http://' . get_domain_name() . get_base_dir() . '/form.php?id=' . urlencode($added_form['id']);
        header("Location: {$form_url}");
        exit;
    }
}
if ($context->type == 'text/html') {
    if (!empty($error)) {
        $context->sm->assign('error', $error);
    }
    header("Content-Type: text/html; charset=UTF-8");
    print $context->sm->fetch("add-form.html.tpl");
} else {
    header('HTTP/1.1 400');
    $error = "Unknown type.";
    $context->sm->assign('error', $error);
    header("Content-Type: text/html; charset=UTF-8");
示例#15
0
            $error = 'Someone has already registered with that email address.';
            break;
        }
        $new_user = add_user($context->db);
        $new_user['name'] = $_POST['username'];
        $new_user['email'] = $_POST['email'];
        $new_user['password'] = $_POST['password1'];
        $registered_user = set_user($context->db, $new_user);
        if ($registered_user === false) {
            $error = 'User name exists.';
            break;
        }
        $hash = md5(rand(0, 1000));
        $q = 'UPDATE users SET hash=? WHERE name=?';
        $res = $context->db->query($q, $hash, $_POST['username']);
        login_user_by_id($context->db, $registered_user['id']);
        $to = $_POST['email'];
        $subject = 'Field Papers Verification';
        $url = sprintf('http://%s%s/verify.php?email=%s&hash=%s', get_domain_name(), get_base_dir(), urlencode($_POST['email']), urlencode($hash));
        $message = "Thanks for signing up for Field Papers!\n            \n            Please verify your account: {$url}\n            \n            ";
        $headers = 'From:noreply@fieldpapers.org' . "\r\n";
        mail($to, $subject, $message, $headers);
        // redirect
        header('Location: ' . $_POST['redirect']);
        break;
}
if (!empty($error)) {
    $context->sm->assign('error', $error);
}
header("Content-Type: text/html; charset=UTF-8");
print $context->sm->fetch("registration.html.tpl");
示例#16
0
            exit;
        }
        $latlon = array($latlonzoom[0], $latlonzoom[1]);
        $zoom = $latlonzoom[2];
    }
    $context->sm->assign('center', join(',', $latlon));
    $context->sm->assign('zoom', $zoom);
    $redirect_href = sprintf('http://%s%s/make-step2-geography.php?zoom=%s&lat=%s&lon=%s', get_domain_name(), get_base_dir(), $zoom, $latlon[0], $latlon[1]);
    header('HTTP/1.1 303');
    header("Location: {$redirect_href}");
}
if (isset($_GET) && !empty($_GET)) {
    if ($_GET['mbtiles_id']) {
        $mbtiles = get_mbtiles_by_id($context->db, $_GET['mbtiles_id']);
        $mbtiles_data = array("provider" => $mbtiles['url'], "uploaded_file" => $mbtiles['uploaded_file'], "center_x" => $mbtiles['center_x_coord'], "center_y" => $mbtiles['center_y_coord'], "zoom" => $mbtiles['center_zoom'], 'min_zoom' => $mbtiles['min_zoom'], 'max_zoom' => $mbtiles['max_zoom']);
        $context->sm->assign('mbtiles_data', $mbtiles_data);
    } elseif ($_GET['lat'] && $_GET['lon'] && $_GET['zoom']) {
        $center = array($_GET['lat'], $_GET['lon']);
        $zoom = $_GET['zoom'];
        $context->sm->assign('center', join(',', $center));
        $context->sm->assign('zoom', $zoom);
    } else {
        $redirect_href = sprintf('http://%s%s/make-step1-search.php?error=no_response', get_domain_name(), get_base_dir());
        header('HTTP/1.1 303');
        header("Location: {$redirect_href}");
        exit;
    }
}
$context->sm->assign('providers', get_map_providers());
header("Content-Type: text/html; charset=UTF-8");
print $context->sm->fetch("make-step2-geography.html.tpl");
示例#17
0
        $print = compose_from_geojson($context->db, $json_content);
    } else {
        $atlas_postvars = $_POST;
        if (!empty($_POST['form_url'])) {
            $added_form = add_form($context->db, $context->user['id']);
            $added_form['form_url'] = $_POST['form_url'];
            if (!empty($_POST['form_title'])) {
                $added_form['title'] = $_POST['form_title'];
            }
            set_form($context->db, $added_form);
            //
            // A new form was requested.
            // postvars will now have form_id in addition to form_url.
            //
            $atlas_postvars['form_id'] = $added_form['id'];
        }
        if ($clone_job && $clone_id) {
            $print = compose_clone($context->db, $atlas_postvars, $context->user['id'], $clone_id, false);
        } elseif ($refresh_job && $refresh_id) {
            $print = compose_clone($context->db, $atlas_postvars, $context->user['id'], $refresh_id, true);
        } else {
            $print = compose_from_postvars($context->db, $atlas_postvars, $context->user['id']);
        }
    }
    $context->db->query('COMMIT');
    if (is_null($print)) {
        die_with_code(400, "Missing... Something.");
    }
    $print_url = 'http://' . get_domain_name() . get_base_dir() . '/atlas.php?id=' . urlencode($print['id']);
    header("Location: {$print_url}");
}
示例#18
0
function check_files()
{
    global $config_values;
    $myuid = posix_getuid();
    $configDir = platform_getConfigDir() . '/';
    if (!is_writable($configDir)) {
        echo "<div id=\"errorDialog\" class=\"dialog_window\" style=\"display: block\">Please create the directory {$configDir} and make sure it's readable and writeable for the user running the webserver (uid: {$myuid}). </div>";
    }
    $cwd = getcwd();
    if (!(get_base_dir() . '/web' == $cwd)) {
        echo "<div id=\"errorDialog\" class=\"dialog_window\" style=\"display: block\">Please edit the config.php file and set the basedir to:<br /> \"{$cwd}\".<br />Then click your browsers refresh button.</div>";
        return;
    }
    $toCheck['cache_dir'] = $config_values['Settings']['Cache Dir'];
    if (strtolower($config_values['Settings']['Transmission Host']) == 'localhost' || $config_values['Settings']['Transmission Host'] == '127.0.0.1') {
        $toCheck['download_dir'] = $config_values['Settings']['Download Dir'];
    }
    $deepDir = $config_values['Settings']['Deep Directories'];
    $error = false;
    foreach ($toCheck as $key => $file) {
        if (!file_exists($file)) {
            $error .= "{$key}:&nbsp;<i>\"{$file}\"</i>&nbsp;&nbsp;does not exist <br />";
        }
        if (!$deepDir && $key == 'download_dir') {
            break;
        }
        if (!is_writable($file)) {
            $error .= "{$key}:&nbsp;<i>\"{$file}\"</i>&nbsp;&nbsp;is not writable for uid: {$myuid} <br />";
        }
        if (!is_readable($file)) {
            $error .= "{$key}:&nbsp;<i>\"{$file}\"</i>&nbsp;&nbsp;is not readable for uid: {$myuid} <br />";
        }
    }
    if ($error) {
        echo "<div id=\"errorDialog\" class=\"dialog_window\" style=\"display: block\">{$error}</div>";
    }
}
示例#19
0
<?php

require_once '../lib/lib.everything.php';
require_once '../lib/lib.qrcode.php';
enforce_master_on_off_switch($_SERVER['HTTP_ACCEPT_LANGUAGE']);
/**** ... ****/
$url = 'http://' . get_domain_name() . get_base_dir() . '/atlas.php?id=' . urlencode($_GET['print']);
$qrc = QRCode::getMinimumQRCode($url, QR_ERROR_CORRECT_LEVEL_Q);
$img = $qrc->createImage(16, 0);
header('Content-type: image/png');
header("X-Content: {$url}");
imagepng($img);
imagedestroy($img);
示例#20
0
    $attempted_upload = true;
    $acceptable_upload = preg_match('#^http://#', $url);
}
if ($attempted_upload && !$acceptable_upload) {
    die_with_code(400, 'Sorry, something about your file was bad');
}
if ($acceptable_upload && $scan && !$scan['decoded']) {
    queue_task("tasks.decodeScan", array("http://" . SERVER_NAME, API_PASSWORD), array("action" => "decode", "scan_id" => $scan["id"], "url" => $url));
    $context->db->query('START TRANSACTION');
    $scan = get_scan($context->db, $scan['id']);
    $parsed_url = parse_url($url);
    $scan['base_url'] = "http://{$parsed_url['host']}" . dirname($parsed_url['path']);
    $scan['progress'] = 0.1;
    // the first 10% is just getting the thing uploaded
    set_scan($context->db, $scan);
    $context->db->query('COMMIT');
}
if ($attempted_upload) {
    header('Location: http://' . get_domain_name() . get_base_dir() . '/snapshot.php?id=' . urlencode($scan['id']));
}
exit;
//
// Old form stuff down here.
//
if ($attempted_upload) {
    header('Location: http://' . get_domain_name() . get_base_dir() . '/uploaded.php?scan=' . urlencode($scan['id']));
}
$context->sm->assign('scan', $scan);
$context->sm->assign('language', $language);
header("Content-Type: text/html; charset=UTF-8");
print $context->sm->fetch("uploaded.html.tpl");