function doadexpirations() { global $wpdb, $nameofsite; $notify_admin = get_awpcp_option('notifyofadexpired'); $notify_expiring = get_awpcp_option('notifyofadexpiring'); // disable the ads or delete the ads? // 1 = disable, 0 = delete $disable_ads = get_awpcp_option('autoexpiredisabledelete'); // allow users to use %s placeholder for the website name in the subject line $subject = get_awpcp_option('adexpiredsubjectline'); $subject = sprintf($subject, $nameofsite); $bodybase = get_awpcp_option('adexpiredbodymessage'); $admin_sender_email = awpcp_admin_sender_email_address(); $admin_recipient_email = awpcp_admin_recipient_email_address(); $ads = AWPCP_Ad::find("ad_enddate <= NOW() AND disabled != 1 AND payment_status != 'Unpaid' AND verified = 1"); foreach ($ads as $ad) { $ad->disable(); if ($notify_expiring == false && $notify_admin == false) { continue; } $adtitle = get_adtitle($ad->ad_id); $adstartdate = date("D M j Y G:i:s", strtotime(get_adstartdate($ad->ad_id))); $body = $bodybase; $body .= "\n\n"; $body .= __("Listing Details", "AWPCP"); $body .= "\n\n"; $body .= __("Ad Title:", "AWPCP"); $body .= " {$adtitle}"; $body .= "\n\n"; $body .= __("Posted:", "AWPCP"); $body .= " {$adstartdate}"; $body .= "\n\n"; $body .= __("Renew your ad by visiting:", "AWPCP"); $body .= " " . urldecode(awpcp_get_renew_ad_url($ad->ad_id)); $body .= "\n\n"; if ($notify_expiring) { $user_email = get_adposteremail($ad->ad_id); if (!empty($user_email)) { awpcp_process_mail($admin_sender_email, $user_email, $subject, $body, $nameofsite, $admin_recipient_email); } } if ($notify_admin) { awpcp_process_mail($admin_sender_email, $admin_recipient_email, $subject, $body, $nameofsite, $admin_recipient_email); } } }
protected function process_contact_form() { global $nameofsite; $ad = $this->get_ad(); $form = array_merge($this->get_posted_data(), array('ad_id' => $ad->ad_id)); $errors = array(); if (!$this->validate_posted_data($form, $errors)) { return $this->contact_form($form, $errors); } $ad_title = $ad->get_title(); $ad_url = url_showad($ad->ad_id); $sender_name = stripslashes($form['awpcp_sender_name']); $sender_email = stripslashes($form['awpcp_sender_email']); $message = awpcp_strip_html_tags(stripslashes($form['awpcp_contact_message'])); if (get_awpcp_option('usesenderemailinsteadofadmin')) { $sender = awpcp_strip_html_tags($sender_name); $from = $sender_email; } else { $sender = $nameofsite; $from = awpcp_admin_sender_email_address(); } /* send email to admin */ if (get_awpcp_option('notify-admin-about-contact-message')) { $subject = __('Notification about a response regarding Ad: %s', 'AWPCP'); $subject = sprintf($subject, $ad_title); ob_start(); include AWPCP_DIR . '/frontend/templates/email-reply-to-ad-admin.tpl.php'; $admin_body = ob_get_contents(); ob_end_clean(); $admin_email = awpcp_admin_recipient_email_address(); $result = awpcp_process_mail($from, $admin_email, $subject, $admin_body, $sender, $sender_email); } $subject = sprintf("%s %s: %s", get_awpcp_option('contactformsubjectline'), _x('regarding', 'reply email', 'AWPCP'), $ad_title); ob_start(); include AWPCP_DIR . '/frontend/templates/email-reply-to-ad-user.tpl.php'; $body = ob_get_contents(); ob_end_clean(); $sendtoemail = get_adposteremail($ad->ad_id); $result = awpcp_process_mail($from, $sendtoemail, trim($subject), $body, $sender, $sender_email); if ($result) { $message = __("Your message has been sent.", "AWPCP"); return $this->render('content', awpcp_print_message($message)); } else { $this->messages[] = __("There was a problem encountered during the attempt to send your message. Please try again and if the problem persists, please contact the system administrator.", "AWPCP"); return $this->contact_form($form, $errors); } }
function deletead($adid, $adkey, $editemail, $force = false, &$errors = array()) { $output = ''; $awpcppage = get_currentpagename(); $awpcppagename = sanitize_title($awpcppage, $post_ID = ''); $isadmin = checkifisadmin() || $force; if (get_awpcp_option('onlyadmincanplaceads') && $isadmin != 1) { $message = __("You do not have permission to perform the function you are trying to perform. Access to this page has been denied", "AWPCP"); $errors[] = $message; } else { global $wpdb, $nameofsite; $tbl_ads = $wpdb->prefix . "awpcp_ads"; $tbl_ad_photos = $wpdb->prefix . "awpcp_adphotos"; $savedemail = get_adposteremail($adid); if ($isadmin == 1 || strcasecmp($editemail, $savedemail) == 0) { $ad = AWPCP_Ad::find_by_id($adid); if ($ad && $ad->delete()) { if ($isadmin == 1 && is_admin()) { $message = __("The Ad has been deleted", "AWPCP"); return $message; } else { $message = __("Your Ad details and any photos you have uploaded have been deleted from the system", "AWPCP"); $errors[] = $message; } } else { if ($ad === null) { $errors[] = __("The specified Ad doesn't exists.", 'AWPCP'); } else { $errors[] = __("There was an error trying to delete the Ad. The Ad was not deleted.", 'AWPCP'); } } } else { $message = __("Problem encountered. Cannot complete request", "AWPCP"); $errors[] = $message; } } $output .= "<div id=\"classiwrapper\">"; $output .= awpcp_menu_items(); $output .= "<p>"; $output .= $message; $output .= "</p>"; $output .= "</div>"; return $output; }