function opwUpdateWhosOnline() { global $db; if (isset($_SESSION['user_id'])) { $wo_user_id =& $_SESSION['user_id']; $wo_full_name = $_SESSION['firstname'] . ' ' . $_SESSION['lastname']; } else { $wo_user_id = ''; $wo_full_name = 'Guest'; } $wo_session_id = owpSessionID(); $wo_ip_address = $_SERVER['REMOTE_ADDR']; $wo_last_page_url = addslashes($_SERVER['REQUEST_URI']); $current_time = time(); $xx_mins_ago = $current_time - 900; $owpDBTable = owpDBGetTables(); // remove entries that have expired $db->Execute("DELETE FROM " . $owpDBTable['whos_online'] . " WHERE time_last_click < '" . $xx_mins_ago . "'"); $sql = "SELECT count(*) as total \n FROM " . $owpDBTable['whos_online'] . " \n WHERE session_id = '" . $wo_session_id . "'"; $owp_user_query = $db->Execute($sql); $owp_user = $owp_user_query->fields; if ($owp_user['total'] > 0) { $db->Execute("UPDATE " . $owpDBTable['whos_online'] . " \n \t SET user_id = " . $db->qstr($wo_user_id) . ",\n \t full_name = " . $db->qstr($wo_full_name) . ",\n \t ip_address = " . $db->qstr($wo_ip_address) . ", \t \n \t time_last_click = " . $db->qstr($current_time) . ",\n \t last_page_url = " . $db->qstr($wo_last_page_url) . "\n WHERE session_id = '" . $wo_session_id . "'"); } else { $sql = "INSERT INTO " . $owpDBTable['whos_online'] . " \n (user_id,\n full_name, \n session_id, \n ip_address,\n time_entry,\n time_last_click,\n last_page_url) \n VALUES (" . $db->qstr($wo_user_id) . ',' . $db->qstr($wo_full_name) . ',' . $db->qstr($wo_session_id) . ',' . $db->qstr($wo_ip_address) . ',' . $db->qstr($current_time) . ',' . $db->qstr($current_time) . ',' . $db->qstr($wo_last_page_url) . ")"; $db->Execute($sql); } }
function send($newsletter_id) { global $db; $owpDBTable = owpDBGetTables(); $send_mail = new phpmailer(); $send_mail->From = OWP_EMAIL_ADDRESS; $send_mail->FromName = OWP_NAME; $send_mail->Subject = $this->title; $sql = "SELECT admin_gender, admin_firstname, admin_lastname,\n admin_email_address \n FROM " . $owpDBTable['administrators'] . " \n WHERE admin_newsletter = '1'"; $mail_values = $db->Execute($sql); while ($mail = $mail_values->fields) { $send_mail->Body = $this->content; $send_mail->AddAddress($mail['admin_email_address'], $mail['admin_firstname'] . ' ' . $mail['admin_lastname']); $send_mail->Send(); // Clear all addresses and attachments for next loop $send_mail->ClearAddresses(); $send_mail->ClearAttachments(); $mail_values->MoveNext(); } $today = date("Y-m-d H:i:s"); $db->Execute("UPDATE " . $owpDBTable['newsletters'] . " \n SET date_sent = " . $db->DBTimeStamp($today) . ",\n status = '1' \n WHERE newsletters_id = '" . owpDBInput($newsletter_id) . "'"); }
function owpGetCountryZones($country_id) { global $db; $owpDBTable = owpDBGetTables(); $zones_array = array(); $zones_query = $db->Execute("select zone_id, zone_name from " . $owpDBTable['zones'] . " where zone_country_id = '" . $country_id . "' order by zone_name"); while ($zones = $zones_query->fields) { $zones_array[] = array('id' => $zones['zone_id'], 'text' => $zones['zone_name']); $zones_query->MoveNext(); } return $zones_array; }