コード例 #1
0
ファイル: main.php プロジェクト: hzhou9/coupon_deal
 public static function subscribe($id, $post)
 {
     global $db, $LANG;
     $post = array_map('trim', $post);
     if (!isset($post['email']) || !filter_var($post['email'], FILTER_VALIDATE_EMAIL)) {
         throw new \Exception($LANG['newsletter_usevalide']);
     } else {
         $stmt = $db->stmt_init();
         $stmt->prepare("INSERT INTO " . DB_TABLE_PREFIX . "newsletter (email, ipaddr, date) VALUES (?, ?, NOW())");
         $IP = \site\utils::getIP();
         $stmt->bind_param("ss", $post['email'], $IP);
         $execute = $stmt->execute();
         $stmt->close();
         if (!$execute) {
             throw new \Exception($LANG['newsletter_subscribed']);
         }
         if (\query\main::get_option('subscr_confirm_req')) {
             $session = md5(\site\utils::str_random(15));
             if (\user\mail_sessions::insert('subscription', array('email' => $post['email'], 'session' => $session)) && \site\mail::send($post['email'], $LANG['email_sub_title'] . ' - ' . \query\main::get_option('sitename'), array('template' => 'confirm_subscription'), array('confirmation_main_text' => $LANG['email_sub_maintext'], 'confirmation_button' => $LANG['email_sub_button'], 'link' => \site\utils::update_uri($GLOBALS['siteURL'] . 'verify.php', array('action' => 'subscribe', 'email' => $post['email'], 'token' => $session))))) {
                 return 1;
             } else {
                 // the email could not be sent, so delete him from the database
                 $stmt = $db->stmt_init();
                 $stmt->prepare("DELETE FROM " . DB_TABLE_PREFIX . "newsletter WHERE email = ?");
                 $stmt->bind_param("s", $post['email']);
                 $stmt->execute();
                 $stmt->close();
                 throw new \Exception($LANG['msg_error']);
             }
         } else {
             // auto-validate the subscription
             $stmt = $db->stmt_init();
             $stmt->prepare("UPDATE " . DB_TABLE_PREFIX . "newsletter SET econf = 1 WHERE email = ?");
             $stmt->bind_param("s", $post['email']);
             $stmt->execute();
             $stmt->close();
             if ($execute) {
                 return 2;
             } else {
                 throw new \Exception($LANG['msg_error']);
             }
         }
     }
 }
コード例 #2
0
ファイル: click.php プロジェクト: hzhou9/coupon_deal
if (isset($_GET['id']) && !\query\main::store_exists($_GET['id'])) {
    header('Location: ' . $GLOBALS['siteURL']);
    die;
}
// check if coupon exists. if not, redirect to your website
if (isset($_GET['coupon']) && !\query\main::item_exists($_GET['coupon'])) {
    header('Location: ' . $GLOBALS['siteURL']);
    die;
}
// check if product exists. if not, redirect to your website
if (isset($_GET['product']) && !\query\main::product_exists($_GET['product'])) {
    header('Location: ' . $GLOBALS['siteURL']);
    die;
}
include LBDIR . '/iptocountry/class.php';
$myIP = \site\utils::getIP();
$aIP = new IpToCountry();
$aIP->IP = $myIP;
$IPinfos = $aIP->infos();
//
$coupon = $product = 0;
if (isset($_GET['id'])) {
    $infos = \query\main::store_infos($_GET['id']);
    $store = $infos->ID;
    $url = $infos->url;
    $type = 'Store';
    $typeID = (int) $_GET['id'];
} else {
    if (isset($_GET['coupon'])) {
        $infos = \query\main::item_infos($_GET['coupon']);
        $store = $infos->storeID;