Exemple #1
0
        if ($weekday == 0) {
            $weekday = 7;
        }
        if ($weekday == $rUser['watchmail_day']) {
            $nextmail = date($sDateformat, mktime($rUser['watchmail_hour'], 0, 0, date('n'), date('j') + 7, date('Y')));
        } elseif ($weekday > $rUser['watchmail_day']) {
            $nextmail = date($sDateformat, mktime($rUser['watchmail_hour'], 0, 0, date('n'), date('j') - $weekday + $rUser['watchmail_day'] + 7, date('Y')));
        } else {
            $nextmail = date($sDateformat, mktime($rUser['watchmail_hour'], 0, 0, date('n'), date('j') + 6 - $rUser['watchmail_day'], date('Y')));
        }
    }
    sql("UPDATE user SET watchmail_nextmail='&1' WHERE user_id='&2'", $nextmail, $rUser['user_id']);
}
mysql_free_result($rsUsers);
/* end send out everything that has to be sent */
CleanupAndExit($watchpid);
function process_owner_log($user_id, $log_id)
{
    global $dblink, $logowner_text;
    //	echo "process_owner_log($user_id, $log_id)\n";
    $rsLog = sql("SELECT cache_logs.cache_id cache_id, cache_logs.text text, cache_logs.text_html text_html, cache_logs.date logdate, user.username username, caches.name cachename FROM `cache_logs`, `user`, `caches` WHERE (cache_logs.user_id = user.user_id) AND (cache_logs.cache_id = caches.cache_id) AND (cache_logs.id ='&1')", $log_id);
    $rLog = sql_fetch_array($rsLog);
    mysql_free_result($rsLog);
    $watchtext = $logowner_text;
    $logtext = $rLog['text'];
    if ($rLog['text_html'] != 0) {
        $logtext = html_entity_decode($logtext, ENT_COMPAT, 'UTF-8');
        $h2t =& new html2text($logtext);
        $logtext = $h2t->get_text();
        /*
        		$logtext = html_entity_decode($logtext, ENT_COMPAT, 'UTF-8');
Exemple #2
0
$sDateformat = 'Y-m-d H:i:s';
/* end with some constants */
/* begin db connect */
db_connect();
if ($dblink === false) {
    echo 'Unable to connect to database';
    exit;
}
/* end db connect */
$rsNotify = sql("\tSELECT  `notify_waiting`.`id`, `notify_waiting`.`cache_id`, `notify_waiting`.`type`,\n\t\t\t\t`user`.`username`,\n\t\t\t\t`user2`.`email`, `user2`.`username` as `recpname`, `user2`.`latitude` as `lat1`, `user2`.`longitude` as `lon1`, `user2`.`user_id` as `recid`,\n\t\t\t\t`caches`.`name` as `cachename`, `caches`.`date_hidden`, `caches`.`latitude` as `lat2`, `caches`.`longitude` as `lon2`, `caches`.`wp_oc`,\n\t\t\t\t`cache_type`.`de` as `cachetype`,\n\t\t\t\t`cache_size`.`de` as `cachesize`\n\t\t\tFROM `notify_waiting`, `caches`, `user`, `user` `user2`, `cache_type`, `cache_size`, `cache_status`\n\t\t\tWHERE `notify_waiting`.`cache_id`=`caches`.`cache_id`\n\t\t\t  AND `notify_waiting`.`user_id`=`user2`.`user_id`\n\t\t\t  AND `caches`.`user_id`=`user`.`user_id`\n\t\t\t  AND `caches`.`type`=`cache_type`.`id`\n\t\t\t  AND `caches`.`status`=`cache_status`.`id`\n\t\t\t  AND `caches`.`size`=`cache_size`.`id`\n\t\t\t  AND `cache_status`.`allow_user_view`=1");
while ($rNotify = sql_fetch_array($rsNotify)) {
    sql("DELETE FROM `notify_waiting` WHERE `id` ='&1'", $rNotify['id']);
    process_new_cache($rNotify);
}
mysql_free_result($rsNotify);
CleanupAndExit($notifypid);
/* end send out everything that has to be sent */
function process_new_cache($notify)
{
    global $notify_text, $mailfrom, $mailsubject, $debug, $debug_mailto, $rootpath;
    //echo "process_new_cache(".$notify['id'].")\n";
    $fehler = false;
    // mail-template lesen
    switch ($notify['type']) {
        case notify_new_cache:
            // Type: new cache
            $mailbody = read_file($rootpath . 'util/notification/notify_newcache.email');
            break;
        default:
            $fehler = true;
            break;
 ****************************************************************************/
//prepare the templates and include all neccessary
$rootpath = '../../';
$pidfile = '/var/www/www.opencaching.de/html/cache/search.pid';
// chdir to proper directory (needed for cronjobs)
chdir(substr(realpath($_SERVER['PHP_SELF']), 0, strrpos(realpath($_SERVER['PHP_SELF']), '/')));
require_once $rootpath . 'lib/clicompatbase.inc.php';
require_once $rootpath . 'lib/ftsearch.inc.php';
// use posix pid-files to lock process
if (!CreatePidFile($pidfile)) {
    CleanupAndExit($pidfile, "Another instance is running!");
    exit;
}
db_connect();
ftsearch_refresh();
CleanupAndExit($pidfile);
//
// checks if other instance is running, creates pid-file for locking
//
function CreatePidFile($PidFile)
{
    if (!CheckDaemon($PidFile)) {
        return false;
    }
    if (file_exists($PidFile)) {
        echo "Error: Pidfile (" . $PidFile . ") already present at " . __FILE__ . ":" . __LINE__ . "!\n";
        return false;
    } else {
        if ($pidfile = @fopen($PidFile, "w")) {
            fputs($pidfile, posix_getpid());
            fclose($pidfile);