<div class="row-fluid"> <div class="span6"> <?php include "../databaseInfo.php"; include 'form_submission.php'; if (!isset($_POST["submit"]) && !isset($_POST["g-recaptcha-response"]) && !isset($_POST["name"]) && !isset($_POST["email"]) && !isset($_POST["message"])) { displayForm(); } if (isset($_POST["submit"]) && !isset($_POST["g-recaptcha-response"]) && (!isset($_POST["name"]) && !isset($_POST["email"]) && !isset($_POST["message"]))) { echo "Please fill out all fields"; displayForm(); } elseif (isset($_POST["submit"]) && isset($_POST["g-recaptcha-response"]) && isset($_POST["name"]) && isset($_POST["email"]) && isset($_POST["message"])) { if (isValid($_POST["g-recaptcha-response"])) { if (submitEmail($_POST["name"], $_POST["email"], $_POST["message"])) { echo '<div class="alert alert-dismissible alert-success"> <button type="button" class="close" data-dismiss="alert">×</button> Message sent successfully </div>'; displayForm(); } else { echo '<div class="alert alert-dismissible alert-danger"> <button type="button" class="close" data-dismiss="alert">×</button> There has been a problem with submission. Please try again. </div>'; displayForm(); } } else { echo '<div class="alert alert-dismissible alert-danger"> <button type="button" class="close" data-dismiss="alert">×</button>
function guru_cronjobs() { $jnow = JFactory::getDate(); $date_today = $jnow->toSql(); $date_today_int = strtotime($date_today); $db = JFactory::getDBO(); $sql = "select last_check_date from #__guru_config where id=1"; $db->setQuery($sql); $db->query(); $last_check_date = $db->loadResult(); $int_last_check = strtotime($last_check_date); $day_last_check = date('d', $int_last_check); $day_today = date('d'); if ($day_today != $day_last_check) { $sql = "select * from #__guru_buy_courses"; $db->setQuery($sql); $db->query(); $all_courses = $db->loadAssocList(); $all_plans = getPlanExpiration(); if (isset($all_courses) && count($all_courses) > 0) { $guru_configs = getConfigs(); foreach ($all_courses as $course_key => $course_value) { $date_today_int = strtotime($date_today); $course_id = $course_value["course_id"]; $plan_id = intval($course_value["plan_id"]); $emails_for_course = getCourseEmails($course_id); //----------------------New Lesson Email------------------------------------ if (isset($emails_for_course) && count($emails_for_course) > 0) { foreach ($emails_for_course as $email_key => $email_value) { if ($email_value["term"] == "12") { $sql = "select DATE_FORMAT(p.start_release, '%Y-%m-%d') as start_release, p.course_type, p.lesson_release, p.lessons_show from #__guru_program p WHERE p.id=" . intval($course_id); $db->setQuery($sql); $db->query(); $coursetype_details = $db->loadAssocList(); if ($coursetype_details[0]["course_type"] == 1) { $start_relase_date = strtotime($coursetype_details[0]["start_release"]); $buy_date = strtotime($course_value["buy_date"]); $buy_date = date("Y-m-d", $buy_date); $buy_date = strtotime($buy_date); $next_release_date = $buy_date; $jnow = JFactory::getDate(); $my_today_date = $jnow->toSql(); $my_today_date = strtotime($my_today_date); $my_today_date = date("Y-m-d", $my_today_date); $my_today_date = strtotime($my_today_date); $release_count = 1; while ($next_release_date < $my_today_date) { if ($coursetype_details[0]["lesson_release"] == 1) { $next_release_date = strtotime('+1 day', $next_release_date); } elseif ($coursetype_details[0]["lesson_release"] == 2) { $next_release_date = strtotime('+1 week', $next_release_date); } elseif ($coursetype_details[0]["lesson_release"] == 3) { $next_release_date = strtotime('+1 month', $next_release_date); } else { break; } $release_count++; } $last_check_date = strtotime($last_check_date); if ($next_release_date > $last_check_date) { submitEmail2($email_value, $course_id, $course_value, @$order_expiration, $all_plans[$plan_id]["name"], $guru_configs, $release_count); } } } } //---------------------------------------------------------- if (isset($emails_for_course) && count($emails_for_course) > 0 && $course_value["email_send"] == 0) { if ($all_plans[$plan_id]["term"] != "0") { $order_expiration = strtotime($course_value["expired_date"]); $order_expiration_string = date("Y-m-d", $order_expiration); $order_expiration = strtotime($order_expiration_string); $date_totay_string = date("Y-m-d", $date_today_int); $date_today_int = strtotime($date_totay_string); foreach ($emails_for_course as $email_key => $email_value) { $alert_date = ""; if ($email_value["term"] == "0" && $date_today_int >= $order_expiration) { $order_expiration = date("Y-m-d H:i:s", $order_expiration); submitEmail($email_value, $course_id, $course_value, $order_expiration, $all_plans[$plan_id]["name"], $guru_configs); } elseif ($email_value["term"] != "0" && ($email_value["term"] >= 1 && $email_value["term"] <= 5)) { $alert_date = strtotime(getRealTerm($email_value["term"]) . " days", $order_expiration); } elseif ($email_value["term"] != "0" && ($email_value["term"] >= 6 && $email_value["term"] <= 10)) { $alert_date = strtotime(getRealTerm($email_value["term"]) . " days", $order_expiration); } if (trim($alert_date) != "") { $alert_date_string = date("Y-m-d H:i:s", $alert_date); $alert_date = strtotime($alert_date_string); } if (isset($alert_date) && trim($alert_date) != "" && $date_today_int >= $alert_date) { $order_expiration = date("Y-m-d H:i:s", $order_expiration); submitEmail($email_value, $course_id, $course_value, $order_expiration, $all_plans[$plan_id]["name"], $guru_configs); } } } $sql = "update #__guru_buy_courses set email_send = 1 where userid=" . intval($course_value["userid"]) . " and course_id = " . intval($course_id); $db->setQuery($sql); $db->query(); } //if sometime expire this course } //if we have emails for send } //foreach order //set today date to not check emails on this day $sql = "update #__guru_config set last_check_date='" . $date_today . "'"; $db->setQuery($sql); $db->query(); } //if we have courses } //if today not search }