Exemple #1
0
/**
 *
 * @copyright  2010-2015 izend.org
 * @version    4
 * @link       http://www.izend.org
 */
function rssfeed($lang)
{
    global $rss_thread;
    $itemlist = array();
    if ($rss_thread) {
        $sqllang = db_sql_arg($lang, false);
        $tabthreadnode = db_prefix_table('thread_node');
        $tabnode = db_prefix_table('node');
        $tabnodelocale = db_prefix_table('node_locale');
        $tabnodecontent = db_prefix_table('node_content');
        $tabcontenttext = db_prefix_table('content_text');
        $where = "tn.thread_id={$rss_thread} AND tn.ignored=FALSE";
        $sql = "SELECT nl.name AS node_name, nl.title AS node_title, UNIX_TIMESTAMP(n.created) AS node_created, ct.text AS content_text FROM {$tabthreadnode} tn JOIN {$tabnode} n ON n.node_id=tn.node_id JOIN {$tabnodelocale} nl ON nl.node_id=tn.node_id AND nl.locale={$sqllang} LEFT JOIN {$tabnodecontent} nc ON nc.node_id=n.node_id AND nc.content_type='text' AND nc.ignored=FALSE LEFT JOIN {$tabcontenttext} ct ON ct.content_id=nc.content_id AND ct.locale=nl.locale WHERE {$where} ORDER BY tn.number";
        $r = db_query($sql);
        if ($r) {
            foreach ($r as $node) {
                extract($node);
                $title = $node_title;
                $uri = false;
                // $lang . '/' . $node_name;
                $created = $node_created;
                $description = strip_tags($content_text);
                $itemlist[] = compact('title', 'uri', 'created', 'description');
            }
        }
    }
    $description = translate('description', $lang);
    $output = view('rssfeed', false, compact('lang', 'description', 'itemlist'));
    return $output;
}
Exemple #2
0
function track($request_uri = false, $track_agent = false)
{
    global $track_log, $track_db;
    global $track_agent_blacklist;
    if (!($track_log or $track_db)) {
        return true;
    }
    if (!$request_uri) {
        $request_uri = request_uri();
    }
    if (!$request_uri) {
        return false;
    }
    $user_agent = false;
    if ($track_agent or $track_agent_blacklist) {
        $user_agent = user_agent();
        if (!validate_user_agent($user_agent)) {
            $user_agent = false;
        }
        if ($user_agent and $track_agent_blacklist) {
            $reg = '/' . implode('|', $track_agent_blacklist) . '/i';
            if (preg_match($reg, $user_agent)) {
                return true;
            }
        }
    }
    $r = true;
    if ($track_log) {
        require_once 'log.php';
        $logmsg = $request_uri;
        if ($user_agent) {
            $logmsg .= "\t" . $user_agent;
        }
        $r = write_log($track_log === true ? 'track.log' : $track_log, $logmsg);
        if (!$r) {
            return false;
        }
    }
    if ($track_db) {
        $ip_address = client_ip_address();
        if (!validate_ip_address($ip_address)) {
            return false;
        }
        $sqlipaddress = db_sql_arg($ip_address, false);
        $sqlrequesturi = db_sql_arg($request_uri, true);
        $sqluseragent = db_sql_arg($user_agent, true, true);
        $tabtrack = db_prefix_table($track_db === true ? 'track' : $track_db);
        $sql = "INSERT INTO {$tabtrack} (ip_address, request_uri, user_agent) VALUES (INET_ATON({$sqlipaddress}), {$sqlrequesturi}, {$sqluseragent})";
        $r = db_insert($sql);
        if (!$r) {
            return false;
        }
    }
    return true;
}
Exemple #3
0
function registry_delete($name)
{
    $sqlname = db_sql_arg($name, false);
    $tabregistry = db_prefix_table('registry');
    $sql = "DELETE FROM {$tabregistry} WHERE name={$sqlname}";
    $r = db_delete($sql);
    if ($r === false) {
        return false;
    }
    return true;
}
Exemple #4
0
function download($lang, $arglist = false)
{
    $node_id = $download_name = false;
    if (is_array($arglist)) {
        if (isset($arglist[0])) {
            $node_id = $arglist[0];
        }
        if (isset($arglist[1])) {
            $download_name = $arglist[1];
        }
    }
    if (!$node_id) {
        return run('error/badrequest', $lang);
    }
    if (!$download_name) {
        return run('error/badrequest', $lang);
    }
    $sqllang = db_sql_arg($lang, false);
    $sqlname = db_sql_arg($download_name, true);
    $tabnodecontent = db_prefix_table('node_content');
    $tabcontentdownload = db_prefix_table('content_download');
    $sql = "SELECT cd.path FROM {$tabnodecontent} nc JOIN {$tabcontentdownload} cd ON nc.content_type='download' AND cd.content_id=nc.content_id AND cd.locale={$sqllang} WHERE nc.node_id={$node_id} AND cd.name={$sqlname}";
    $r = db_query($sql);
    if (!$r) {
        return run('error/notfound', $lang);
    }
    $path = $r[0]['path'];
    $filepath = ROOT_DIR . DIRECTORY_SEPARATOR . $path;
    if (!file_exists($filepath)) {
        return run('error/internalerror', $lang);
    }
    $filename = $download_name;
    $filesize = filesize($filepath);
    $filetype = file_mime_type($filepath);
    if (!$filetype) {
        $filetype = 'application/octet-stream';
    }
    header('HTTP/1.1 200 OK');
    // make sure status code is OK in case URL pointed to a file not found like an image
    header('Content-Description: File Transfer');
    header("Content-Type: {$filetype}");
    header("Content-Disposition: attachment; filename={$filename}");
    header("Content-Length: {$filesize}");
    readfile($filepath);
    return false;
}
Exemple #5
0
<?php

/**
 *
 * @copyright  2014 izend.org
 * @version    1
 * @link       http://www.izend.org
 */
require_once 'pdo.php';
$db_url = $scheme . '://test:test@localhost/test';
$db_prefix = 'test_';
$db_debug = true;
db_connect($db_url);
$msecs = microtime(true);
$rss_thread = 1;
$lang = 'fr';
$sqllang = db_sql_arg($lang, false);
$tabthreadnode = db_prefix_table('thread_node');
$tabnode = db_prefix_table('node');
$tabnodelocale = db_prefix_table('node_locale');
$tabnodecontent = db_prefix_table('node_content');
$tabcontenttext = db_prefix_table('content_text');
$where = "tn.thread_id={$rss_thread} AND tn.ignored=FALSE";
$sql = "SELECT nl.name AS node_name, nl.title AS node_title, UNIX_TIMESTAMP(n.created) AS node_created, ct.text AS content_text FROM {$tabthreadnode} tn JOIN {$tabnode} n ON n.node_id=tn.node_id JOIN {$tabnodelocale} nl ON nl.node_id=tn.node_id AND nl.locale={$sqllang} LEFT JOIN {$tabnodecontent} nc ON nc.node_id=n.node_id AND nc.content_type='text' AND nc.ignored=FALSE LEFT JOIN {$tabcontenttext} ct ON ct.content_id=nc.content_id AND ct.locale=nl.locale WHERE {$where} ORDER BY tn.number";
$r = db_query($sql);
dump($r);
echo sprintf('%.4f', microtime(true) - $msecs), PHP_EOL;
Exemple #6
0
set_include_path(get_include_path() . PATH_SEPARATOR . ROOT_DIR . DIRECTORY_SEPARATOR . 'library');
set_include_path(get_include_path() . PATH_SEPARATOR . ROOT_DIR . DIRECTORY_SEPARATOR . 'includes');
require_once 'dump.php';
@(include 'db.inc');
$db_debug = false;
$br = php_sapi_name() == 'cli' ? '' : '</br>';
if (isset($db_url) && $db_url == 'mysql://*****:*****@localhost/databasename') {
    $db_url = false;
}
if (!$db_url) {
    echo 'db_url?', $br, PHP_EOL;
    exit(1);
}
require_once 'pdo.php';
db_connect($db_url);
require 'models/cloud.inc';
$tabthread = db_prefix_table('thread');
$sql = "SELECT thread_id FROM {$tabthread}";
$r = db_query($sql);
if ($r) {
    $tabtagindex = db_prefix_table('tag_index');
    db_exec("TRUNCATE TABLE {$tabtagindex}");
    $tabtag = db_prefix_table('tag');
    db_exec("TRUNCATE TABLE {$tabtag}");
    foreach ($r as $t) {
        $thread_id = $t['thread_id'];
        echo $thread_id, $br, PHP_EOL;
        //		cloud_delete($thread_id);
        cloud_create($thread_id);
    }
}
Exemple #7
0
 *
 * @copyright  2012-2015 izend.org
 * @version    3
 * @link       http://www.izend.org
 */
define('ROOT_DIR', dirname(__FILE__));
set_include_path(get_include_path() . PATH_SEPARATOR . ROOT_DIR . DIRECTORY_SEPARATOR . 'library');
set_include_path(get_include_path() . PATH_SEPARATOR . ROOT_DIR . DIRECTORY_SEPARATOR . 'includes');
require_once 'dump.php';
@(include 'db.inc');
$db_debug = false;
$br = php_sapi_name() == 'cli' ? '' : '</br>';
if (isset($db_url) && $db_url == 'mysql://*****:*****@localhost/databasename') {
    $db_url = false;
}
if (!$db_url) {
    echo 'db_url?', $br, PHP_EOL;
    exit(1);
}
require_once 'pdo.php';
db_connect($db_url);
require 'models/user.inc';
$tabuser = db_prefix_table('user');
$sql = "SELECT name FROM {$tabuser} WHERE name IS NOT NULL";
$r = db_query($sql);
if ($r) {
    foreach ($r as $u) {
        $name = $u['name'];
        user_create_avatar($name);
    }
}