Ejemplo n.º 1
0
function outputProcessBounce($message, $reset = 0)
{
    $infostring = "[" . date("D j M Y H:i", time()) . "] [" . getenv("REMOTE_HOST") . "] [" . getenv("REMOTE_ADDR") . "]";
    #print "$infostring $message<br/>\n";
    $message = preg_replace("/\n/", '', $message);
    ## contribution from http://forums.phplist.com/viewtopic.php?p=14648
    ## in languages with accented characters replace the HTML back
    //Replace the "&rsquo;" which is not replaced by html_decode
    $message = preg_replace("/&rsquo;/", "'", $message);
    //Decode HTML chars
    #$message = html_entity_decode($message,ENT_QUOTES,$_SESSION['adminlanguage']['charset']);
    $message = html_entity_decode($message, ENT_QUOTES, 'UTF-8');
    if ($GLOBALS["commandline"]) {
        cl_output($message);
    } else {
        if ($reset) {
            print '<script language="Javascript" type="text/javascript">
//        if (document.forms[0].name == "outputform") {
          document.outputform.output.value = "";
          document.outputform.output.value += "\\n";
//        }
      </script>' . "\n";
        }
        print '<script language="Javascript" type="text/javascript">
//      if (document.forms[0].name == "outputform") {
        document.outputform.output.value += "' . $message . '";
        document.outputform.output.value += "\\n";
//      } else
//        document.writeln("' . $message . '");
    </script>' . "\n";
    }
    flush();
}
Ejemplo n.º 2
0
        #  print "End of inclusion<br/>";
    } elseif (!empty($_GET['pi']) && isset($GLOBALS['plugins']) && is_array($GLOBALS['plugins']) && isset($GLOBALS['plugins'][$_GET['pi']]) && is_object($GLOBALS['plugins'][$_GET['pi']])) {
        $plugin = $GLOBALS["plugins"][$_GET["pi"]];
        $menu = $plugin->adminmenu();
        if (is_file($plugin->coderoot . $include)) {
            include $plugin->coderoot . $include;
        } elseif ($include == 'main.php' || $_GET['page'] == 'home') {
            print '<h3>' . $plugin->name . '</h3><ul>';
            foreach ($menu as $page => $desc) {
                print '<li>' . PageLink2($page, $desc) . '</li>';
            }
            print '</ul>';
        } elseif ($page != 'login') {
            print '<br/>' . "{$page} -&gt; " . s('Sorry this page was not found in the plugin') . '<br/>';
            #.' '.$plugin->coderoot.$include.'<br/>';
            cl_output("{$page} -> " . s('Sorry this page was not found in the plugin'));
            #. ' '.$plugin->coderoot . "$include");
        }
    } else {
        if ($GLOBALS["commandline"]) {
            clineError(s('Sorry, that module does not exist'));
            exit;
        }
        if (is_file('ui/' . $GLOBALS['ui'] . '/pages/' . $include)) {
            include 'ui/' . $GLOBALS['ui'] . '/pages/' . $include;
        } else {
            print "{$page} -&gt; " . $GLOBALS['I18N']->get('Sorry, not implemented yet');
        }
    }
} else {
    Error($GLOBALS['I18N']->get('Access Denied'));
Ejemplo n.º 3
0
$email = $date = $uid = '';
if (isset($cline['e'])) {
    $email = $cline['e'];
}
if (isset($cline['u'])) {
    $uid = $cline['u'];
}
if (isset($cline['d'])) {
    $date = $cline['d'];
}
$emailQ = Sql_Fetch_Row_Query(sprintf('select email from %s where uniqid = "%s" or email = "%s"  order by email desc', $GLOBALS['tables']['user'], sql_escape($uid), sql_escape($email)));
$emailDB = $emailQ[0];
if (empty($emailDB) && empty($email)) {
    cl_output('FAIL');
    exit;
}
if (isBlackListed($emailDB)) {
    ## do this anyway, just to be sure
    Sql_Query(sprintf('update %s set blacklisted = 1 where email = "%s"', $GLOBALS['tables']['user'], $emailDB));
    cl_output('OK');
    exit;
}
if (!empty($emailDB)) {
    ## do this immediately
    Sql_Query(sprintf('update %s set blacklisted = 1 where email = "%s"', $GLOBALS['tables']['user'], $emailDB));
    addEmailToBlackList($emailDB, 'blacklisted due to spam complaints', $date);
} else {
    addEmailToBlackList($email, 'blacklisted due to spam complaints', $date);
}
cl_output('OK ' . $emailDB);
exit;
Ejemplo n.º 4
0
function processQueueOutput($message, $logit = 1, $target = 'summary')
{
    global $report, $shadecount, $counters, $messageid;
    if (isset($counters['total_users_for_message ' . $messageid])) {
        $total = $counters['total_users_for_message ' . $messageid];
    } else {
        $total = 0;
    }
    if (!isset($shadecount)) {
        $shadecount = 0;
    }
    if (is_array($message)) {
        $tmp = '';
        foreach ($message as $key => $val) {
            $tmp .= $key . '=' . $val . '; ';
        }
        $message = $tmp;
    }
    if (!empty($GLOBALS['commandline'])) {
        cl_output(strip_tags($message) . ' [' . $GLOBALS['processqueue_timer']->interval(1) . '] (' . $GLOBALS['pagestats']['number_of_queries'] . ')');
        $infostring = '[' . date('D j M Y H:i', time()) . '] [CL]';
    } elseif ($GLOBALS['inRemoteCall']) {
        ## with a remote call we suppress output
        @ob_end_clean();
        $infostring = '';
        $message = '';
        @ob_start();
        return;
    } else {
        $infostring = '[' . date('D j M Y H:i', time()) . '] [' . $_SERVER['REMOTE_ADDR'] . ']';
        #print "$infostring $message<br/>\n";
        $lines = explode("\n", $message);
        foreach ($lines as $line) {
            $line = preg_replace('/"/', '\\"', $line);
            ## contribution in forums, http://forums.phplist.com/viewtopic.php?p=14648
            //Replace the "&rsquo;" which is not replaced by html_decode
            $line = preg_replace('/&rsquo;/', "'", $line);
            //Decode HTML chars
            $line = html_entity_decode($line, ENT_QUOTES, 'UTF-8');
            print "\n" . '<div class="output shade' . $shadecount . '">' . $line . '</div>';
            $line = str_replace("'", "\\'", $line);
            // #16880 - avoid JS error
            print '<script type="text/javascript">
      var parentJQuery = window.parent.jQuery;
      parentJQuery("#processqueue' . $target . '").append(\'<div class="output shade' . $shadecount . '">' . $line . '</div>\');
      parentJQuery("#processqueue' . $target . '").animate({scrollTop:100000}, "slow");
      </script>';
            $shadecount = !$shadecount;
            for ($i = 0; $i < 10000; ++$i) {
                print '  ';
                if ($i % 100 == 0) {
                    print "\n";
                }
            }
        }
        flush();
    }
    $report .= "\n{$infostring} {$message}";
    if ($logit) {
        logEvent($message);
    }
    flush();
}
Ejemplo n.º 5
0
function getPageLock($force = 0)
{
    global $tables;
    $thispage = $GLOBALS['page'];
    if ($thispage == 'pageaction') {
        $thispage = $_GET['action'];
    }
    $thispage = preg_replace('/\\W/', '', $thispage);
    #  cl_output('getting pagelock '.$thispage);
    #  ob_end_flush();
    if ($GLOBALS['commandline'] && $thispage == 'processqueue') {
        if (is_object($GLOBALS['MC'])) {
            ## multi-send requires a valid memcached setup
            $max = MAX_SENDPROCESSES;
        } else {
            $max = 1;
        }
    } else {
        $max = 1;
    }
    ## allow killing other processes
    if ($force) {
        Sql_query('delete from ' . $tables['sendprocess'] . ' where page = "' . sql_escape($thispage) . '"');
    }
    $running_req = Sql_query(sprintf('select now() - modified as age,id from %s where page = "%s" and alive order by started desc', $tables['sendprocess'], sql_escape($thispage)));
    $count = Sql_Num_Rows($running_req);
    $running_res = Sql_Fetch_Assoc($running_req);
    $waited = 0;
    # while ($running_res['age'] && $count >= $max) { # a process is already running
    while ($count >= $max) {
        # don't check age, as it may be 0
        #   cl_output('running process: '.$running_res['age'].' '.$max);
        if ($running_res['age'] > 600) {
            # some sql queries can take quite a while
            #cl_output($running_res['id'].' is old '.$running_res['age']);
            # process has been inactive for too long, kill it
            Sql_query("update {$tables['sendprocess']} set alive = 0 where id = " . $running_res['id']);
        } elseif ((int) $count >= (int) $max) {
            #   cl_output (sprintf($GLOBALS['I18N']->get('A process for this page is already running and it was still alive %s seconds ago'),$running_res['age']));
            output(s('A process for this page is already running and it was still alive %d seconds ago', $running_res['age']), 0);
            sleep(1);
            # to log the messages in the correct order
            if ($GLOBALS['commandline']) {
                cl_output(s('A process for this page is already running and it was still alive %d seconds ago', $running_res['age']), 0);
                cl_output($GLOBALS['I18N']->get('Running commandline, quitting. We\'ll find out what to do in the next run.'));
                exit;
            }
            output($GLOBALS['I18N']->get('Sleeping for 20 seconds, aborting will quit'), 0);
            flush();
            $abort = ignore_user_abort(0);
            sleep(20);
        }
        ++$waited;
        if ($waited > 10) {
            # we have waited 10 cycles, abort and quit script
            output($GLOBALS['I18N']->get('We have been waiting too long, I guess the other process is still going ok'), 0);
            return false;
        }
        $running_req = Sql_query('select now() - modified,id from ' . $tables['sendprocess'] . " where page = \"{$thispage}\" and alive order by started desc");
        $count = Sql_Num_Rows($running_req);
        $running_res = Sql_Fetch_row($running_req);
    }
    if (!empty($GLOBALS['commandline'])) {
        $processIdentifier = SENDPROCESS_SERVERNAME . ':' . getmypid();
    } else {
        $processIdentifier = $_SERVER['REMOTE_ADDR'];
    }
    $res = Sql_query('insert into ' . $tables['sendprocess'] . ' (started,page,alive,ipaddress) values(now(),"' . $thispage . '",1,"' . $processIdentifier . '")');
    $send_process_id = Sql_Insert_Id();
    $abort = ignore_user_abort(1);
    #  cl_output('Got pagelock '.$send_process_id );
    return $send_process_id;
}
Ejemplo n.º 6
0
     }
     if ($item['collate']) {
         $collation = $collation + $row['num'];
         $row['num'] = $collation;
     }
     if ($item['range'] != 'year') {
         $ls->addElement($row['year'] . ' ' . monthName($row['month']));
         $ls->addColumn($row['year'] . ' ' . monthName($row['month']), '#', $row['num']);
         $chartData[$row['year']][$row['month']] = $row['num'];
     } else {
         $ls->addElement($row['year']);
         $ls->addColumn($row['year'], '#', $row['num']);
         $chartData[$row['year']][''] = $row['num'];
     }
     if (!empty($row['year']) && !empty($row['month']) && !empty($row['num'])) {
         cl_output($item['name'] . '|' . $row['year'] . '|' . $row['month'] . '|' . $row['num']);
     }
 }
 unset($chartData['2000']);
 unset($chartData['2001']);
 unset($chartData['2002']);
 unset($chartData['2003']);
 unset($chartData['2004']);
 unset($chartData['2005']);
 unset($chartData['2006']);
 #unset($chartData['2007']);
 #unset($chartData['2008']);
 #unset($chartData['2009']);
 #unset($chartData['2011']);
 #var_dump($chartData);
 if (class_exists('gBarChart')) {
Ejemplo n.º 7
0
# It can be called from your phpserver: ~/lists/admin/?page=reindex
# PHP will skip indexes that are already created by name.
# WARNING: This can take a long time on large tables, there is no feedback
# and te session can be killed by your browser or server after a timeout.
# Just reload if you think nothing happens after 30 minutes or so.
@ob_end_flush();
include dirname(__FILE__) . '/structure.php';
print '<ul>';
foreach ($DBstruct as $table => $columns) {
    print '<li><h3>' . $table . '</h3><br/><ul>';
    cl_output($GLOBALS['I18N']->get('processing ') . $table);
    foreach ($columns as $column => $definition) {
        if (strpos($column, 'index') === 0) {
            printf('<li>' . $GLOBALS['I18N']->get('Adding index <b>%s</b> to %s</li>'), $definition[0], $table);
            cl_output(sprintf($GLOBALS['I18N']->get('Adding index <b>%s</b> to %s<br/>'), $definition[0], $table));
            flush();
            # ignore errors, which are most likely that the index already exists
            Sql_Query(sprintf('alter table %s add index %s', $table, $definition[0]), 1);
        } elseif (strpos($column, 'unique') === 0) {
            printf('<li>' . $GLOBALS['I18N']->get('Adding unique index <b>%s</b> to %s</li>'), $definition[0], $table);
            cl_output(sprintf($GLOBALS['I18N']->get('Adding unique index <b>%s</b> to %s<br/>'), $definition[0], $table));
            flush();
            # ignore errors, which are most likely that the index already exists
            ## hmm, mysql seems to create a new one each time
            ## that's when they're not "named" in the structure -> fix
            Sql_Query(sprintf('alter table %s add unique %s', $table, $definition[0]), 1);
        }
    }
    print '</ul></li>';
}
print '</ul>';
Ejemplo n.º 8
0
    exit;
}
$maxNextRun = 0;
$now = time();
foreach ($cronJobs as $cronJob) {
    $cronID = $cronJob['plugin'] . '|' . $cronJob['page'];
    $lastrun = getConfig(md5($cronID));
    if (empty($lastrun) || $now - $lastrun > $cronJob['frequency'] * 60) {
        cl_output('Need to run ' . $cronJob['plugin'] . ' - ' . $cronJob['page']);
        $cronJob['page'] = basename($cronJob['page'], '.php');
        if (isset($GLOBALS['plugins'][$cronJob['plugin']]) && is_file($GLOBALS['plugins'][$cronJob['plugin']]->coderoot . $cronJob['page'] . '.php')) {
            include_once $GLOBALS['plugins'][$cronJob['plugin']]->coderoot . $cronJob['page'] . '.php';
        } elseif (empty($cronJob['plugin']) && is_file(__DIR__ . '/' . $cronJob['page'] . '.php')) {
            include_once __DIR__ . '/' . $cronJob['page'] . '.php';
        }
        SaveConfig(md5($cronID), time(), 0);
    } else {
        $nextRun = $lastrun + $cronJob['frequency'] * 60 - $now;
        if ($nextRun > $maxNextRun) {
            $maxNextRun = $nextRun;
        }
        if (VERBOSE) {
            cl_output('Will run ' . $cronJob['plugin'] . ' - ' . $cronJob['page'] . ' in' . secs2time($nextRun));
        }
    }
}
## tell how soon we need to run again, so that the calling system can relax a bit
if ($maxNextRun > 0) {
    cl_output("DELAYUNTIL=" . (int) ($now + $maxNextRun));
}
#var_dump($cronJobs);
Ejemplo n.º 9
0
<?php

if (!defined('PHPLISTINIT')) {
    die;
}
if (empty($GLOBALS['commandline'])) {
    print $GLOBALS['I18N']->get('This page can only be called from the commandline');
    return;
}
ob_end_clean();
print ClineSignature();
ob_start();
$locale_root = dirname(__FILE__) . '/locale/';
$force = isset($cline['f']);
if (is_dir($locale_root)) {
    $dir = opendir($locale_root);
    while ($lan = readdir($dir)) {
        if (is_file($locale_root . '/' . $lan . '/phplist.po')) {
            cl_output($lan);
            $lastUpdate = getConfig('lastlanguageupdate-' . $lan);
            $thisUpdate = filemtime($locale_root . '/' . $lan . '/phplist.po');
            if ($force || $thisUpdate > $lastUpdate) {
                cl_output(s('Initialising language') . ' ' . $lan);
                $GLOBALS['I18N']->initFSTranslations($lan);
            } else {
                cl_output(s('Up to date'));
            }
        }
    }
}
 function canSend($messagedata, $userdata)
 {
     if (empty($messagedata["criteria_use"][1]) || $this->numcriterias <= 0) {
         return true;
     }
     // no criteria used
     if (!isset($GLOBALS['simpleattributeselect_criteriacache'][$messagedata['id']])) {
         $GLOBALS['simpleattributeselect_criteriacache'][$messagedata['id']] = array();
         $sql = $this->subscriberSelection($messagedata);
         if (!empty($sql)) {
             $req = Sql_Query($sql);
             while ($row = Sql_Fetch_Row($req)) {
                 $GLOBALS['simpleattributeselect_criteriacache'][$messagedata['id']][] = $row[0];
             }
         }
     }
     //ob_end_clean();
     //var_dump($GLOBALS['simpleattributeselect_criteriacache'][$messagedata['id']]);
     $cansend = sizeof($GLOBALS['simpleattributeselect_criteriacache'][$messagedata['id']]) && in_array($userdata['id'], $GLOBALS['simpleattributeselect_criteriacache'][$messagedata['id']]);
     if (VERBOSE) {
         if ($cansend) {
             cl_output('simpleattributeselect - CAN SEND ' . $userdata['id']);
         } else {
             cl_output('simpleattributeselect - CAN NOT SEND ' . $userdata['id']);
         }
     }
     return $cansend;
 }
Ejemplo n.º 11
0
            ## make sure to only change our own tables, in case we share with other applications
            if (in_array($row['TABLE_NAME'], array_values($GLOBALS['tables']))) {
                $dbcolumns[] = $row;
                $dbtables[$row['TABLE_NAME']] = $row['TABLE_NAME'];
            }
        }
        cl_output($GLOBALS['I18N']->get('Upgrading the database to use UTF-8, please wait'));
        foreach ($dbtables as $dbtable) {
            set_time_limit(600);
            print $GLOBALS['I18N']->get('Upgrading table ') . ' ' . $dbtable . '<br/>';
            flush();
            cl_output($GLOBALS['I18N']->get('Upgrading table ') . ' ' . $dbtable);
            Sql_Query(sprintf('alter table %s default charset utf8', $dbtable), 1);
        }
        foreach ($dbcolumns as $dbcolumn) {
            set_time_limit(600);
            print $GLOBALS['I18N']->get('Upgrading column ') . ' ' . $dbcolumn['COLUMN_NAME'] . '<br/>';
            flush();
            cl_output($GLOBALS['I18N']->get('Upgrading column ') . ' ' . $dbcolumn['COLUMN_NAME']);
            Sql_Query(sprintf('alter table %s change column %s %s %s character set utf8', $dbcolumn['TABLE_NAME'], $dbcolumn['COLUMN_NAME'], $dbcolumn['COLUMN_NAME'], $dbcolumn['COLUMN_TYPE']), 1);
        }
        cl_output($GLOBALS['I18N']->get('upgrade to UTF-8, done'));
        saveConfig('UTF8converted', date('Y-m-d H:i'), 0);
    } else {
        print s('Unable to determine the name of the database to convert');
    }
} else {
    print s('The DB was already converted to UTF-8 on') . ' ' . $isUTF8;
    cl_output(s('The DB was already converted to UTF-8 on') . ' ' . $isUTF8);
}
print '<br/>' . s('All Done');
Ejemplo n.º 12
0
$now = time();
foreach ($cronJobs as $cronJob) {
    $cronID = $cronJob['plugin'] . '|' . $cronJob['page'];
    $lastrun = getConfig(md5($cronID));
    if (empty($lastrun) || $now - $lastrun > $cronJob['frequency'] * 60) {
        cl_output('Need to run ' . $cronJob['plugin'] . ' - ' . $cronJob['page']);
        $cronJob['page'] = basename($cronJob['page'], '.php');
        $cmd_result = '';
        if (isset($GLOBALS['plugins'][$cronJob['plugin']]) && is_file($GLOBALS['plugins'][$cronJob['plugin']]->coderoot . $cronJob['page'] . '.php')) {
            cl_output('running php ' . $argv[0] . ' -c ' . $GLOBALS['configfile'] . ' -m ' . $cronJob['plugin'] . ' -p ' . $cronJob['page']);
            exec('php ' . $argv[0] . ' -c ' . $GLOBALS['configfile'] . ' -m ' . $cronJob['plugin'] . ' -p ' . $cronJob['page'], $cmd_result);
        } elseif (empty($cronJob['plugin']) && is_file(__DIR__ . '/' . $cronJob['page'] . '.php')) {
            cl_output('running php ' . $argv[0] . ' -c ' . $GLOBALS['configfile'] . ' -p ' . $cronJob['page']);
            exec('php ' . $argv[0] . ' -c ' . $GLOBALS['configfile'] . ' -p ' . $cronJob['page'], $cmd_result);
        }
        SaveConfig(md5($cronID), time(), 0);
    } else {
        $nextRun = $lastrun + $cronJob['frequency'] * 60 - $now;
        if ($nextRun > $maxNextRun) {
            $maxNextRun = $nextRun;
        }
        if (VERBOSE) {
            cl_output('Will run ' . $cronJob['plugin'] . ' - ' . $cronJob['page'] . ' in' . secs2time($nextRun));
        }
    }
}
## tell how soon we need to run again, so that the calling system can relax a bit
if ($maxNextRun > 0) {
    cl_output('DELAYUNTIL=' . (int) ($now + $maxNextRun));
}
#var_dump($cronJobs);
<?php

ob_end_clean();
## blacklist an email from commandline
if (!function_exists('cl_output')) {
    function cl_output($message)
    {
        @ob_end_clean();
        print strip_tags($message) . "\n";
        $infostring = '';
        ob_start();
    }
}
$email = $cline['e'];
$uid = $cline['u'];
if (!empty($uid) && empty($email)) {
    $emailreq = Sql_Fetch_Row_Query(sprintf('select email from %s where uniqid = "%s"', $GLOBALS['tables']['user'], $uid));
    $email = $emailreq[0];
}
if (empty($email)) {
    cl_output('No email');
    exit;
}
if (isBlackListed($email)) {
    cl_output('Already blacklisted');
    exit;
}
addEmailToBlackList($email, 'blacklisted due to spam complaints');
cl_output($email . ' blacklisted');
exit;
Ejemplo n.º 14
0
    output('creating tables');
    Sql_Query('drop table ' . $GLOBALS['tables']['linktrack_forward']);
    Sql_Query('drop table ' . $GLOBALS['tables']['linktrack_ml']);
    Sql_Query('drop table ' . $GLOBALS['tables']['linktrack_uml_click']);
    Sql_Create_Table($GLOBALS['tables']['linktrack_ml'], $DBstruct['linktrack_ml']);
    Sql_Create_Table($GLOBALS['tables']['linktrack_forward'], $DBstruct['linktrack_forward']);
    Sql_Create_Table($GLOBALS['tables']['linktrack_uml_click'], $DBstruct['linktrack_uml_click']);
    output(s('creating tables done'));
}
$process_id = getPageLock();
if (empty($process_id)) {
    return;
}
## only convert up to a week ago.
$lastweek = date('Y-m-d', time() - 24 * 7 * 3600);
cl_output(sprintf('select count(*) from %s lt, %s m where lt.messageid = m.id and m.entered < "%s"', $GLOBALS['tables']['linktrack'], $GLOBALS['tables']['message'], $lastweek));
$num = Sql_Fetch_Row_Query(sprintf('select count(*) from %s lt, %s m where lt.messageid = m.id and m.entered < "%s"', $GLOBALS['tables']['linktrack'], $GLOBALS['tables']['message'], $lastweek));
output(s('%d entries still to convert', $num[0]) . '<br/>');
$c = 0;
$req = Sql_Query(sprintf('select lt.* from %s lt, %s m where lt.messageid = m.id and m.entered < "%s" limit %d', $GLOBALS['tables']['linktrack'], $GLOBALS['tables']['message'], $lastweek, $limit));
$total = Sql_Affected_Rows();
if ($total) {
    output(s('converting data') . '<br/>');
}
while ($row = Sql_Fetch_Array($req)) {
    if (checkLock($process_id)) {
        keepLock($process_id);
    } else {
        output(s('processing cancelled'));
        break;
    }
Ejemplo n.º 15
0
     #    echo "$errormessage<br/>";
 }
 // OK, the message has been saved, now check to see if we need to send a test message
 if ($sendtest) {
     $sendtestresult = '<br/>';
     if (empty($_SESSION['lasttestsent'])) {
         $_SESSION['lasttestsent'] = 0;
     }
     $sendtestAllowed = true;
     ## check with plugins that sending a test is allowed
     reset($GLOBALS['plugins']);
     while ($sendtestAllowed && ($plugin = current($GLOBALS['plugins']))) {
         $sendtestAllowed = $plugin->sendTestAllowed($messagedata);
         if (!$sendtestAllowed) {
             if (VERBOSE) {
                 cl_output('Sending test blocked by plugin ' . $plugin->name);
             }
         }
         next($GLOBALS['plugins']);
     }
     $delay = time() - $_SESSION['lasttestsent'];
     if ($delay < SENDTEST_THROTTLE) {
         foreach ($GLOBALS['plugins'] as $plname => $plugin) {
             $plugin->processError('Send test throttled on ' . $delay);
         }
         $sendtestresult .= s('You can send a test mail once every %d seconds', SENDTEST_THROTTLE) . '<br/>';
         $emailaddresses = array();
     } elseif (!$sendtestAllowed) {
         $sendtestresult .= s('Sending test mails is currently not available') . '<br/>';
         $emailaddresses = array();
     } else {
Ejemplo n.º 16
0
function getPageLock($force = 0)
{
    global $tables;
    $thispage = $GLOBALS["page"];
    if ($thispage == 'pageaction') {
        $thispage = $_GET['action'];
    }
    #  cl_output('getting pagelock '.$thispage);
    #  ob_end_flush();
    if ($GLOBALS["commandline"] && $thispage == 'processqueue') {
        if (is_object($GLOBALS['MC'])) {
            ## multi-send requires a valid memcached setup
            $max = MAX_SENDPROCESSES;
        } else {
            $max = 1;
        }
    } else {
        $max = 1;
    }
    ## allow killing other processes
    if ($force) {
        Sql_Query_Params("delete from " . $tables['sendprocess'] . " where page = ?", array($thispage));
    }
    $query = ' select current_timestamp - modified as age, id' . ' from ' . $tables['sendprocess'] . ' where page = ?' . ' and alive > 0' . ' order by age desc';
    $running_req = Sql_Query_Params($query, array($thispage));
    $running_res = Sql_Fetch_Assoc($running_req);
    $count = Sql_Num_Rows($running_req);
    if (VERBOSE) {
        cl_output($count . ' out of ' . $max . ' active processes');
    }
    $waited = 0;
    # while ($running_res['age'] && $count >= $max) { # a process is already running
    while ($count >= $max) {
        # don't check age, as it may be 0
        #   cl_output('running process: '.$running_res['age'].' '.$max);
        if ($running_res['age'] > 600) {
            # some sql queries can take quite a while
            #cl_output($running_res['id'].' is old '.$running_res['age']);
            # process has been inactive for too long, kill it
            Sql_query("update {$tables["sendprocess"]} set alive = 0 where id = " . $running_res['id']);
        } elseif ((int) $count >= (int) $max) {
            #   cl_output (sprintf($GLOBALS['I18N']->get('A process for this page is already running and it was still alive %s seconds ago'),$running_res['age']));
            output(sprintf($GLOBALS['I18N']->get('A process for this page is already running and it was still alive %s seconds ago'), $running_res['age']), 0);
            sleep(1);
            # to log the messages in the correct order
            if ($GLOBALS["commandline"]) {
                cl_output($GLOBALS['I18N']->get('Running commandline, quitting. We\'ll find out what to do in the next run.'));
                exit;
            }
            output($GLOBALS['I18N']->get('Sleeping for 20 seconds, aborting will quit'), 0);
            flush();
            $abort = ignore_user_abort(0);
            sleep(20);
        }
        $waited++;
        if ($waited > 10) {
            # we have waited 10 cycles, abort and quit script
            output($GLOBALS['I18N']->get('We have been waiting too long, I guess the other process is still going ok'), 0);
            return false;
        }
        $query = ' select current_timestamp - modified as age, id' . ' from ' . $tables['sendprocess'] . ' where page = ?' . ' and alive > 0' . ' order by age desc';
        $running_req = Sql_Query_Params($query, array($thispage));
        $running_res = Sql_Fetch_Assoc($running_req);
        $count = Sql_Num_Rows($running_req);
    }
    $query = ' insert into ' . $tables['sendprocess'] . '    (started, page, alive, ipaddress)' . ' values' . '    (current_timestamp, ?, 1, ?)';
    if (!empty($GLOBALS['commandline'])) {
        $processIdentifier = SENDPROCESS_SERVERNAME . ':' . getmypid();
    } else {
        $processIdentifier = $_SERVER['REMOTE_ADDR'];
    }
    $res = Sql_Query_Params($query, array($thispage, $processIdentifier));
    $send_process_id = Sql_Insert_Id($tables['sendprocess'], 'id');
    $abort = ignore_user_abort(1);
    #  cl_output('Got pagelock '.$send_process_id );
    return $send_process_id;
}
Ejemplo n.º 17
0
    if (!$haserror) {
        $tls->collapse();
        $ls->addColumn($table, "ok", $GLOBALS["img_tick"]);
    } else {
        $pass = false;
        $ls->addColumn($table, "ok", $GLOBALS["img_cross"]);
    }
    if (!empty($indexes)) {
        $ls->addColumn($table, "index", $indexes);
    }
    if (!empty($uniques)) {
        $ls->addColumn($table, "unique", $uniques);
    }
    if (!empty($category)) {
        $ls->addColumn($table, "category", $category);
    }
    if (!empty($tls)) {
        $ls->addColumn($table, "check", $tls->display());
    }
    /*
      if (!empty($createlink)) {
        $ls->addColumn($table,"create",'<div> Table is missing <a href="'.$createlink.'" class="ajaxable">Create</a></div>');
      }
    */
}
print $ls->display();
if ($pass) {
    cl_output('PASS');
} else {
    cl_output('FAIL');
}
Ejemplo n.º 18
0
    return;
}
print ClineSignature();
$cronJobs = array();
foreach ($GLOBALS['plugins'] as $pluginname => $plugin) {
    $pluginJobs = $plugin->cronJobs();
    foreach ($pluginJobs as $job) {
        $cronJobs[] = array('plugin' => $pluginname, 'page' => $job['page'], 'frequency' => $job['frequency']);
    }
}
$now = time();
foreach ($cronJobs as $cronJob) {
    $cronID = $cronJob['plugin'] . '|' . $cronJob['page'];
    $lastrun = getConfig(md5($cronID));
    if (empty($lastrun) || $now - $lastrun > $cronJob['frequency'] * 60) {
        cl_output('Need to run ' . $cronJob['plugin'] . ' - ' . $cronJob['page']);
        $cronJob['page'] = basename($cronJob['page'], '.php');
        if (isset($GLOBALS['plugins'][$cronJob['plugin']]) && is_file($GLOBALS['plugins'][$cronJob['plugin']]->coderoot . $cronJob['page'] . '.php')) {
            include_once $GLOBALS['plugins'][$cronJob['plugin']]->coderoot . $cronJob['page'] . '.php';
        } elseif (empty($cronJob['plugin']) && is_file(__DIR__ . '/' . $cronJob['page'] . '.php')) {
            include_once __DIR__ . '/' . $cronJob['page'] . '.php';
        }
        SaveConfig(md5($cronID), time(), 0);
    } else {
        if (VERBOSE) {
            $nextRun = $lastrun + $cronJob['frequency'] * 60 - $now;
            cl_output('Will run ' . $cronJob['plugin'] . ' - ' . $cronJob['page'] . ' in' . secs2time($nextRun));
        }
    }
}
#var_dump($cronJobs);