Example #1
0
function init_connection($glob)
{
    $glob['fd'] = xfsockopen($glob['host'], $glob['port']);
    if ($glob['fd']) {
        aff_client("FD-SOCKET OK");
    } else {
        aff_error_connect("Connection rate");
        init_connection($glob);
    }
    return $glob;
}
     $ctimes[$pid] = time();
 } else {
     pcntl_signal(SIGCHLD, SIG_IGN);
     pcntl_signal(SIGINT, 'task_sigint_handler');
     register_shutdown_function('task_shutdown');
     $my_pid = posix_getpid();
     $lock_filename = "update_daemon-{$my_pid}.lock";
     $lock_handle = make_lockfile($lock_filename);
     if (!$lock_handle) {
         die("error: Can't create lockfile ({$lock_filename}). " . "Maybe another daemon is already running.\n");
     }
     // ****** Updating RSS code *******
     // Only run in fork process.
     $start_timestamp = time();
     $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
     if (!init_connection($link)) {
         return;
     }
     // We disable stamp file, since it is of no use in a multiprocess update.
     // not really, tho for the time being -fox
     if (!make_stampfile('update_daemon.stamp')) {
         print "warning: unable to create stampfile";
     }
     // Call to the feed batch update function
     // or regenerate feedbrowser cache
     if (rand(0, 100) > 30) {
         update_daemon_common($link);
     } else {
         $count = update_feedbrowser_cache($link);
         _debug("Feedbrowser updated, {$count} feeds processed.");
         purge_orphans($link, true);
Example #3
0
<?php

error_reporting(E_ERROR | E_WARNING | E_PARSE);
header('Content-Type: text/html; charset=utf-8');
define('MOBILE_VERSION', true);
require_once "../config.php";
require_once "functions.php";
require_once "../functions.php";
require_once "../sessions.php";
require_once "../version.php";
require_once "../db-prefs.php";
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
init_connection($link);
login_sequence($link, true);
$feed_id = db_escape_string($_REQUEST["id"]);
$cat_id = db_escape_string($_REQUEST["cat"]);
$offset = (int) db_escape_string($_REQUEST["skip"]);
$search = db_escape_string($_REQUEST["search"]);
$is_cat = (bool) db_escape_string($_REQUEST["is_cat"]);
render_headlines_list($link, $feed_id, $cat_id, $offset, $search, $is_cat);
?>

Example #4
0
if ($api_tiki == 'pdo' && extension_loaded("pdo") && in_array('mysql', PDO::getAvailableDrivers())) {
    $dbInitializer = 'db/tiki-db-pdo.php';
}
require $dbInitializer;
init_connection(TikiDb::get());
if (isset($shadow_host, $shadow_user, $shadow_pass, $shadow_dbs)) {
    global $dbMaster, $dbSlave;
    // Set-up the replication
    $dbMaster = TikiDb::get();
    $host_tiki = $shadow_host;
    $user_tiki = $shadow_user;
    $pass_tiki = $shadow_pass;
    $dbs_tiki = $shadow_dbs;
    require $dbInitializer;
    $dbSlave = TikiDb::get();
    init_connection($dbSlave);
    require_once 'lib/core/TikiDb/MasterSlaveDispatch.php';
    $db = new TikiDb_MasterSlaveDispatch($dbMaster, $dbSlave);
    TikiDb::set($db);
}
unset($host_map, $db_tiki, $host_tiki, $user_tiki, $pass_tiki, $dbs_tiki, $shadow_user, $shadow_pass, $shadow_host, $shadow_dbs);
function init_connection($db)
{
    global $db_table_prefix, $common_users_table_prefix, $db_tiki;
    $db->setServerType($db_tiki);
    $db->setErrorHandler(new TikiDb_LegacyErrorHandler());
    if (isset($db_table_prefix)) {
        $db->setTablePrefix($db_table_prefix);
    }
    if (isset($common_users_table_prefix)) {
        $db->setUsersTablePrefix($common_users_table_prefix);