Beispiel #1
0
            $EmailMessage = str_replace("%SITE_NAME%", JB_SITE_NAME, $EmailMessage);
            $EmailMessage = str_replace("%SITE_LOGO_URL%", JB_SITE_LOGO_URL, $EmailMessage);
            $EmailMessage = str_replace("%RESUME_ALERTS%", $resume_alert_list_text, $EmailMessage);
            $EmailMessage = str_replace("%RESUME_ALERT%", '', $EmailMessage);
            // for compatibility with older version
            $EmailMessage = str_replace("%KEYWORDS_LINE%", $resume_alert_list_text, $EmailMessage);
            // deprecated, use %RESUME_ALERTS% instead
            $EmailMessage = str_replace("%EMPLOYER_LINK%", $_clink, $EmailMessage);
            $text_message = html_entity_decode($EmailMessage);
            $text_message = strip_tags($text_message);
            // send the sucker...
            if ($DO_SEND == "YES") {
                // mark as sent
                $now = gmdate("Y-m-d H:i:s");
                $sql = "UPDATE `employers` SET `alert_last_run`='{$now}' WHERE `ID`='" . jb_escape_sql($user_row['ID']) . "'";
                JB_mysql_query($sql) or die(mysql_error() . $sql);
                if (JB_mysql_affected_rows() > 0) {
                    // place on the queue
                    JB_queue_mail($to_address, $to_name, $e_row['EmailFromAddress'], $e_row['EmailFromName'], $subject, $text_message, $html_message, $e_row['EmailID']);
                }
            }
        }
        // end IF $msg_body
    }
    // if valid email
}
// close while loop
if ($_REQUEST['from_admin'] && strpos($_SERVER['PHP_SELF'], 'admin') !== false) {
    echo "The execution of the 'admin/resumealerts.php' script completed. You may check the <a href='email_queue.php'>outgoing mail queue</a>";
    $DO_SEND = "YES";
}
Beispiel #2
0
function JB_do_house_keeping()
{
    global $jb_mysql_link;
    if (defined('NO_HOUSE_KEEPING')) {
        return;
    }
    $unix_time = time();
    // get the time of last run housekeep
    $sql = "SELECT * FROM `jb_variables` where `key` = 'LAST_HOUSEKEEP_RUN' ";
    if (!($result = JB_mysql_query($sql))) {
        return false;
    }
    $t_row = @mysql_fetch_array($result, MYSQL_ASSOC);
    // Poor man's lock
    //$sql = "LOCK TABLES `jb_variables` WRITE";
    //JB_mysql_query($sql)
    $sql = "UPDATE `jb_variables` SET `val`='YES' WHERE `key`='HOUSEKEEP_RUNNING' AND `val`='NO' ";
    $result = @JB_mysql_query($sql) or $DB_ERROR = mysql_error();
    if (JB_mysql_affected_rows() == 0) {
        // it is running in another proccess
        // make sure it cannot be locked for more than 30 secs
        // This is in case the proccess fails inside the lock
        // and does not release it.
        if ($unix_time > $t_row['val'] + 30) {
            // 30
            // release the lock
            $sql = "UPDATE `jb_variables` SET `val`='NO' WHERE `key`='HOUSEKEEP_RUNNING' ";
            $result = @JB_mysql_query($sql) or $DB_ERROR = mysql_error();
            // update timestamp
            $sql = "REPLACE INTO jb_variables (`key`, `val`) VALUES ('LAST_HOUSEKEEP_RUN', '{$unix_time}')  ";
            $result = @JB_mysql_query($sql) or $DB_ERROR = mysql_error();
        }
        return;
        // this function is already executing in another process.
    }
    ///////////////////////////////////////////////////////////
    // Start Critical Section - is only executed in one process at at time
    ///////////////////////////////////////////////////////////
    JB_save_session();
    // update sessions on every request
    JBPLUG_do_callback('house_keeping_critical_section', $A = false);
    // added in 3.6.1
    if ($unix_time > $t_row['val'] + 60) {
        // did 1 minute elapse since last run? 60
        // do stuff here -
        JBPLUG_do_callback('do_house_keeping', $A = false);
        // added in 3.5.0
        JB_update_all_sessions();
        // update timestamp
        $sql = "REPLACE INTO jb_variables (`key`, `val`) VALUES ('LAST_HOUSEKEEP_RUN', '{$unix_time}')  ";
        $result = @JB_mysql_query($sql) or $DB_ERROR = mysql_error();
        if (!defined('NO_HOUSE_KEEPING') && JB_CRON_EMULATION_ENABLED == 'YES') {
            set_time_limit(40);
            JB_do_cron_job();
        }
    }
    // release the poor man's lock
    $sql = "UPDATE `jb_variables` SET `val`='NO' WHERE `key`='HOUSEKEEP_RUNNING' ";
    JB_mysql_query($sql) or die(mysql_error());
    /////////////////////////////////////////////////////////////////
    // End Critical Section
}
function JB_increment_views_tally($id)
{
    $sql = " UPDATE employers SET views_quota_tally=views_quota_tally+1 WHERE views_quota > 0 AND ID='" . jb_escape_sql($id) . "' AND views_quota_tally < views_quota ";
    $result = jb_mysql_query($sql);
    return JB_mysql_affected_rows();
}
Beispiel #4
0
		<tr><td><font color="#ffffff">
		Confirm Delete - Purge all applications that are older than </font><input size="3" type="" name="purge_days" value="<?php 
        echo jb_escape_html($_REQUEST['purge_days']);
        ?>
"><font color="#ffffff"> days.  </font> <input name="purge2" type="submit" value="OK"><br>
		<i>You may purge the old applications to gain more space on your account.</i>
		</td></tr>
		</table>
		</form>
		<?php 
    }
    if ($_REQUEST['purge2'] != '') {
        $now = gmdate("Y-m-d H:i:s");
        $sql = "DELETE from applications where DATE_SUB('{$now}', INTERVAL '" . jb_escape_sql($_REQUEST['purge_days']) . "' DAY) > app_date ";
        $result = JB_mysql_query($sql) or die(mysql_error());
        $JBMarkup->ok_msg(JB_mysql_affected_rows() . " application(s) deleted from the system");
    }
    $offset = (int) $_REQUEST['offset'];
    $records_per_page = 4;
    $sql = "SELECT * FROM applications ORDER BY `app_date` DESC LIMIT {$offset}, {$records_per_page} ";
    $result = JB_mysql_query($sql) or die(mysql_error());
    $count = array_pop(mysql_fetch_row(jb_mysql_query("SELECT count(*) FROM applications ")));
    if (mysql_num_rows($result) > 0) {
        $result = JB_mysql_query($sql) or die(mysql_error());
        $nav = JB_nav_pages_struct($result, $q_string, $count, $records_per_page);
        $LINKS = 10;
        $ALM->nav_pages_start();
        JB_render_nav_pages($nav, $LINKS, $q_string, $show_emp, $cat);
        $ALM->nav_pages_end();
        $row['formatted_date'] = JB_get_formatted_date($row['app_date']);
        $ALM->open_form('form1');
Beispiel #5
0
function JB_process_mail_queue($send_count = 1)
{
    $now = gmdate("Y-m-d H:i:s");
    $unix_time = time();
    global $jb_mysql_link;
    // get the time of last run
    $sql = "SELECT * FROM `jb_variables` where `key` = 'LAST_MAIL_QUEUE_RUN' ";
    $result = @JB_mysql_query($sql) or $DB_ERROR = mysql_error();
    $t_row = @mysql_fetch_array($result, MYSQL_ASSOC);
    if ($DB_ERROR != '') {
        return $DB_ERROR;
    }
    // Poor man's lock (making sure that this function is a Singleton)
    $sql = "UPDATE `jb_variables` SET `val`='YES' WHERE `key`='MAIL_QUEUE_RUNNING' AND `val`='NO' ";
    $result = JB_mysql_query($sql) or $DB_ERROR = mysql_error();
    if (JB_mysql_affected_rows() == 0) {
        // make sure it cannot be locked for more than 30 secs
        // This is in case the proccess fails inside the lock
        // and does not release it.
        if ($unix_time > $t_row['val'] + 30) {
            // release the lock
            $sql = "UPDATE `jb_variables` SET `val`='NO' WHERE `key`='MAIL_QUEUE_RUNNING' ";
            $result = @JB_mysql_query($sql) or $DB_ERROR = mysql_error();
            // update timestamp
            $sql = "REPLACE INTO jb_variables (`key`, `val`) VALUES ('LAST_MAIL_QUEUE_RUN', '{$unix_time}')  ";
            $result = @JB_mysql_query($sql) or $DB_ERROR = mysql_error();
        }
        return;
        // this function is already executing in another process.
    }
    ///////////////////////////////////////////////////////////
    // Start Critical Section - is only executed in one process at at time
    ///////////////////////////////////////////////////////////
    if ($unix_time > $t_row['val'] + 5) {
        // did 5 seconds elapse since last run?
        if (JB_EMAIL_POP_BEFORE_SMTP == 'YES') {
            JB_do_pop_before_smtp();
        }
        if (func_num_args() > 1) {
            $mail_id = func_get_arg(1);
            $and_mail_id = " AND mail_id=" . jb_escape_sql($mail_id) . " ";
        }
        $JB_EMAILS_MAX_RETRY = (int) JB_EMAILS_MAX_RETRY;
        if ($JB_EMAILS_MAX_RETRY == '') {
            $JB_EMAILS_MAX_RETRY = 5;
        }
        $JB_EMAILS_ERROR_WAIT = (int) JB_EMAILS_ERROR_WAIT;
        if ($JB_EMAILS_ERROR_WAIT == '') {
            $JB_EMAILS_ERROR_WAIT = 10;
        }
        $JB_EMAILS_PER_BATCH = (int) JB_EMAILS_PER_BATCH;
        if (!$JB_EMAILS_PER_BATCH) {
            $JB_EMAILS_PER_BATCH = 5;
        }
        // The following query is using index composite1
        // ALTER TABLE mail_queue ADD INDEX `composite1` (`status`, `retry_count`)
        // We need to double the $JB_EMAILS_PER_BATCH for the LIMIT
        // This is because not all mails fetched by the query are sent
        // since emails with status='queued' and 0 > retry_count <= x need to
        // wait for $JB_EMAILS_ERROR_WAIT seconds
        //
        if ($JB_EMAILS_MAX_RETRY > 0) {
            $retry_count = " AND retry_count <= " . jb_escape_sql($JB_EMAILS_MAX_RETRY);
        }
        $sql = "SELECT * from mail_queue where (status='queued' OR status='error')  {$retry_count}  {$and_mail_id}  LIMIT " . $JB_EMAILS_PER_BATCH * 2 . " ";
        $result = JB_mysql_query($sql) or JB_q_mail_error(mysql_error() . $sql);
        while (($row = mysql_fetch_array($result, MYSQL_ASSOC)) && $send_count > 0) {
            $time_stamp = strtotime($row['date_stamp'] . " GMT");
            $now = strtotime(gmdate("Y-m-d H:i:s"));
            $wait = $JB_EMAILS_ERROR_WAIT * 60;
            if ($now - $wait > $time_stamp && $row['status'] == 'error' || $row['status'] == 'queued') {
                $send_count--;
                $error = JB_send_email($row);
            }
        }
        // delete old stuff
        if (JB_EMAILS_DAYS_KEEP == 'JB_EMAILS_DAYS_KEEP') {
            define(JB_EMAILS_DAYS_KEEP, '0');
        }
        if (JB_EMAILS_DAYS_KEEP > 0) {
            $now = gmdate("Y-m-d H:i:s");
            $sql = "SELECT mail_id, att1_name, att2_name, att3_name from mail_queue where status='sent' AND DATE_SUB('{$now}',INTERVAL " . JB_EMAILS_DAYS_KEEP . " DAY) >= date_stamp  ";
            $result = JB_mysql_query($sql) or die(mysql_error());
            while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                if ($row['att1_name'] != '' && file_exists($row['att1_name'])) {
                    unlink($row['att1_name']);
                }
                if ($row['att2_name'] != '' && file_exists($row['att2_name'])) {
                    unlink($row['att2_name']);
                }
                if ($row['att3_name'] != '' && file_exists($row['att3_name'])) {
                    unlink($row['att3_name']);
                }
                $sql = "DELETE FROM mail_queue where mail_id='" . jb_escape_sql($row['mail_id']) . "' ";
                JB_mysql_query($sql) or die(mysql_error());
            }
        }
        // update timestamp
        $unix_time = time();
        $sql = "REPLACE INTO jb_variables (`key`, `val`) VALUES ('LAST_MAIL_QUEUE_RUN', '{$unix_time}')  ";
        $result = @JB_mysql_query($sql) or $DB_ERROR = mysql_error();
    }
    // release the poor man's lock
    $sql = "UPDATE `jb_variables` SET `val`='NO' WHERE `key`='MAIL_QUEUE_RUNNING' ";
    @JB_mysql_query($sql) or die(mysql_error());
}
function JB_pend_membership_invoice($invoice_id, $payment_method, $pending_reason)
{
    $invoice_row = JB_get_membership_invoice_row($invoice_id);
    if ($invoice_row['status'] == 'Confirmed') {
        $sql = "UPDATE `membership_invoices` set status='Pending', payment_method='" . jb_escape_sql($payment_method) . "', reason='" . jb_escape_sql($pending_reason) . "' WHERE invoice_id='" . jb_escape_sql($invoice_id) . "' ";
        JB_mysql_query($sql) or JB_pp_mail_error(mysql_error());
    }
    if (JB_mysql_affected_rows() > 0) {
        $invoice_row['status'] = 'Pending';
        $invoice_row['payment_method'] = $payment_method;
        $invoice_row['reason'] = $pending_reason;
    }
    return $invoice_row;
}
 function save()
 {
     $sql = "UPDATE xml_import_feeds SET `feed_metadata`='" . jb_escape_sql(serialize($this)) . "' WHERE feed_id='" . jb_escape_sql($this->feed_id) . "' ";
     //echo $sql;
     jb_mysql_query($sql);
     return JB_mysql_affected_rows();
 }
Beispiel #8
0
    } else {
        // count each failed attampt.
        // print a 'Good Bye' message on 3rd unsucessful attempt
        // and record the time
        $sql = "UPDATE jb_variables SET `val`=`val`+1 WHERE `key`='ADMIN_PASS_FAILED' ";
        JB_mysql_query($sql);
        if (JB_mysql_affected_rows() == 0) {
            $sql = "REPLACE into jb_variables (`key`, `val`) VALUES ('ADMIN_PASS_FAILED', '1') ";
            JB_mysql_query($sql);
        }
        $retries++;
        if ($retries > 2) {
            echo "Good Bye.";
            $sql = "UPDATE jb_variables SET `val`='" . time() . "' WHERE `key`='ADMIN_PASS_FAILED_TIME' ";
            JB_mysql_query($sql);
            if (JB_mysql_affected_rows() == 0) {
                $sql = "REPLACE into jb_variables (`key`, `val`) VALUES ('ADMIN_PASS_FAILED_TIME', '" . time() . "') ";
                JB_mysql_query($sql);
            }
            die;
        }
    }
}
if (!function_exists('JB_escape_html_local')) {
    function JB_escape_html_local($str)
    {
        $trans = array("<" => '&lt;', ">" => '&gt;', '"' => '&quot;', '(' => '&#40;', ')' => '&#41;', '&' => '&amp;');
        return strtr($str, $trans);
    }
}
if ($_SESSION['ADMIN'] == '') {