$address = $_POST['address']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $country = $_POST['country']; $ship_name = $_POST['ship_name']; $ship_address = $_POST['ship_address']; $ship_city = $_POST['ship_city']; $ship_state = $_POST['ship_state']; $ship_zip = $_POST['ship_zip']; $ship_country = $_POST['ship_country']; do_html_header('结算'); do_html_top(); if (is_array($_SESSION['cart'])) { if ($name && $address && $city && $state && $zip && $country) { $userid = find_userid($_SESSION['valid_user']); if ($order_info = insert_order($_POST, $userid)) { display_cart($_SESSION['cart'], false, 1, 1); display_card_form($order_info); } else { echo "订单写入数据库失败"; } } else { echo "用户信息填写不完整"; display_button('checkout.php', '返回'); } } else { echo "您还没有添加商品到购物车"; display_button('index.php', '返回首页'); } do_html_footer();
if ($i == 1) { $destination = "archive/{$list}/{$mailid}/index.html"; } else { $destination = "archive/{$list}/{$mailid}/" . $HTTP_POST_FILES['userfile']['name'][$i]; $query = "insert into images values ({$mailid}, \n '" . $HTTP_POST_FILES['userfile']['name'][$i] . "',\n '" . $HTTP_POST_FILES['userfile']['type'][$i] . "')"; $result = mysql_query($query); } } //if we are using PHP version >= 4.03 if (!is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'][$i])) { // possible file upload attack detected echo 'Something funny happening with ' . $HTTP_POST_FILES['userfile']['name'] . ', not uploading.'; do_html_footer(); exit; } move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'][$i], $destination); /* // if version <= 4.02 copy ($userfile[$i], $destination); unlink($userfile[$i]); */ $i++; } display_preview_button($list, $mailid, 'preview-html'); display_preview_button($list, $mailid, 'preview-text'); display_button('send', "&id={$mailid}"); echo '<br /><br /><br /><br /><br />'; do_html_footer(); ?>
function do_html_header($title) { if (@(!$_SESSION['items'])) { $_SESSION['items'] = '0'; } if (@(!$_SESSION['total_price'])) { $_SESSION['total_price'] = '0.00'; } ?> <html> <head> <title><?php echo $title; ?> </title> </head> <body> <table> <tr> <td><img src="logo.png"></td> <td>Total books: <?php echo $_SESSION['items']; ?> <br/> Total price: <?php echo $_SESSION['total_price']; ?> </td> <td> <?php if (isset($_SESSION['admin_user'])) { display_button("logout.php", "log-out", "Log Out"); } else { display_button("show_cart.php", "show-cart", "Show Cart"); } ?> </td> </tr> </table> <h1><?php echo $title; ?> </h1> <?php }
<?php include 'book_sc_fns.php'; // The shopping cart needs sessions, so start one session_start(); $catid = $HTTP_GET_VARS['catid']; $name = get_category_name($catid); do_html_header($name); // get the book info out from db $book_array = get_books($catid); display_books($book_array); // if logged in as admin, show add, delete book links if (isset($HTTP_SESSION_VARS['admin_user'])) { display_button('index.php', 'continue', 'Continue Shopping'); display_button('admin.php', 'admin-menu', 'Admin Menu'); display_button("edit_category_form.php?catid={$catid}", 'edit-category', 'Edit Category'); } else { display_button('index.php', 'continue-shopping', 'Continue Shopping'); } do_html_footer();
function display_toolbar($button, $extra_parameters = '') { // draw on of our toolbars global $table_width; echo "<table width=\"" . $table_width . "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n <tr>\n <td bgcolor=\"#ccccc\" align=\"center\">"; for ($i = 0; $i < 5; $i++) { if ($button[$i]) { display_button($button[$i], $extra_parameters); } else { display_spacer(); } } echo "</td>\n </tr>\n </table>"; }
<?php // The shopping cart needs sessions, so start one //session_start(); do_html_header('Checkout'); if (isset($_SESSION['cart']) && array_count_values($_SESSION['cart'])) { display_cart($_SESSION['cart'], false, 0); display_checkout_form(); } else { echo '<p>There are no items in your cart</p>'; } display_button(base_url("index.php") . '/cart/show_cart', 'continue-shopping', 'Continue Shopping');
<?php include 'book_sc_fns.php'; // The shopping cart needs sessions, so start one session_start(); do_html_header('Checkout'); $card_type = $HTTP_POST_VARS['card_type']; $card_number = $HTTP_POST_VARS['card_number']; $card_month = $HTTP_POST_VARS['card_month']; $card_year = $HTTP_POST_VARS['card_year']; $card_name = $HTTP_POST_VARS['card_name']; if ($HTTP_SESSION_VARS['cart'] && $card_type && $card_number && $card_month && $card_year && $card_name) { //display cart, not allowing changes and without pictures display_cart($HTTP_SESSION_VARS['cart'], false, 0); display_shipping(calculate_shipping_cost()); if (process_card($HTTP_POST_VARS)) { //empty shopping cart session_destroy(); echo 'Thankyou for shopping with us. Your order has been placed.'; display_button('index.php', 'continue-shopping', 'Continue Shopping'); } else { echo 'Could not process your card. '; echo 'Please contact the card issuer or try again.'; display_button('purchase.php', 'back', 'Back'); } } else { echo 'You did not fill in all the fields, please try again.<hr />'; display_button('purchase.php', 'back', 'Back'); } do_html_footer();
function send($mailid, $admin_user, $emailAddr) { if (!check_admin_user($admin_user)) { return false; } if (!($info = load_mail_info($mailid))) { echo "Cannot load list information for message {$mailid}"; return false; } $subject = $info['subject']; //$CI->email->subject($subject); $listid = $info['listid']; $status = $info['status']; $sent = $info['sent']; $from_name = 'Trimart'; $from_address = '*****@*****.**'; //$CI->email->from($from_address,$from_name); $query = "select email from sub_lists where listid =" . $listid; $conn = db_connect(); $result = $conn->query($query); if (!$result) { echo "No result"; return false; } else { if ($result->num_rows == 0) { echo "There is nobody subscribed to list number {$listid}"; return false; } } $mail = new PHPMailer(); $mail->IsSMTP(); // we are going to use SMTP $mail->SMTPAuth = true; // enabled SMTP authentication $mail->SMTPSecure = "ssl"; // prefix for secure protocol to connect to the server $mail->Host = "smtp.gmail.com"; //"";192.168.20.202 // setting GMail as our SMTP server $mail->Port = 465; //;8089 // SMTP port to connect to GMail $mail->Username = "******"; //"andre.campbell#mcalbds"; // user email address $mail->Password = "******"; //"AC#220991"; // password in GMail // read in the text version of the newsletter $textfilename = APPPATH . "archive\\" . $listid . "\\" . $mailid . "\\text.txt"; if (file_exists($textfilename)) { $tfp = fopen($textfilename, "r"); $text = fread($tfp, filesize($textfilename)); fclose($tfp); } // read in the HTML version of the newsletter $htmlfilename = APPPATH . "archive\\" . $listid . "\\" . $mailid . "\\index.html"; if (file_exists($htmlfilename)) { $hfp = fopen($htmlfilename, "r"); $html = fread($hfp, filesize($htmlfilename)); fclose($hfp); } // get the list of images that relate to this message $query = "select path, mimetype from images where mailid = {$mailid}"; $result = $conn->query($query); if (!$result) { echo '<p>Unable to get image list from database.</p>'; return false; } $num = $result->num_rows; for ($i = 0; $i < $num; $i++) { //load each image from disk $row = $result->fetch_array(); $imgfilename = APPPATH . "archive\\{$listid}\\{$mailid}\\" . $row[0]; $imgtype = $row[1]; // add each image to the object //$message->addHTMLImage($imgfilename, $imgtype, $imgfilename, true); $mail->AddEmbeddedImage($imgfilename); // some attached files //$mail->AddAttachment("images/phpmailer_mini.gif"); // as many as you want } // create message body //$body = $message->get(); // create message headers $from = '"' . get_real_name($admin_user) . '" <' . $admin_user . '>'; $hdrarray = array('From' => $from, 'Subject' => $subject); //$hdrs = $message->headers($hdrarray); if ($status == 'STORED') { $mail->isHTML(true); $mail->Subject = $subjectf; $mail->AddAddress($_POST['emailAddr'], $admin_user); $sent = FALSE; // send the HTML message to the administrator //$sender->send($admin_user, $hdrs, $body); if ($html) { $mail->Body = $html; if (!$mail->Send()) { echo "Error sending html version: " . $mail->ErrorInfo; } } else { $sent = TRUE; } if ($sent) { echo "Mail sent to {$admin_user} with email address " . $_POST['emailAddr']; // mark newsletter as tested $query = "update mail set status = 'TESTED' where mailid = {$mailid}"; $result = $conn->query($query); echo '<p>Press send again to send mail to whole list.<center>'; display_button('send', "&id={$mailid}"); echo '</center></p>'; } //$mail->ClearAddresses(); } else { if ($status == 'TESTED') { $count = 0; $subscribers = get_subscribers($_GET['id']); $CI =& get_instance(); $row = $CI->trimart->get_login_credentials($user, $password); // for each subscriber /*for($i = 0; $i < count($subscribers); $i++) { $mail->AddAddress(subscriber[$i][0],$CI->trimart->get_real_name(subscriber[$i][0])); }*/ $mail->AddAddress('jamalbutcher2@gmail', 'YOU'); $mail->send(); $query = "update mail set status = 'SENT', sent = now() \n where mailid = {$mailid}"; $result = $conn->query($query); echo "<p>A total of {$count} messages were sent.</p>"; } else { if ($status == 'SENT') { echo '<p>This mail has already been sent.</p>'; } } } }
function display_toolbar($button, $extra_parameters = '') { // draw on of our toolbars global $table_width; echo "<table width = {$table_width} cellpadding = 0 cellspacing = 0 border = 0>"; echo '<tr>'; echo '<td bgcolor = "#cccccc" align = center>'; for ($i = 0; $i < 5; $i++) { if ($button[$i]) { display_button($button[$i], $extra_parameters); } else { display_spacer(); } } echo '</td>'; echo '</tr>'; echo '</table>'; }
<?php include 'book_sc_fns.php'; // The shopping cart needs sessions, so start one session_start(); do_html_header('Welcome to Book-O-Rama'); echo '<p>Please choose a category:</p>'; // get categories out of database $cat_array = get_categories(); // display as links to cat pages display_categories($cat_array); // if logged in as admin, show add, delete, edit cat links if (isset($_SESSION['admin_user'])) { display_button('admin.php', 'admin-menu', 'Admin Menu'); } do_html_footer();
function display_toolbar($buttons) { foreach ($buttons as $item) { display_button($item); } }
$_SESSION['cart'][$isbn] = $_POST[$isbn]; } } $_SESSION['total_price'] = calculate_price($_SESSION['cart']); $_SESSION['items'] = calculate_items($_SESSION['cart']); } do_html_header('Your shopping cart'); if (isset($_SESSION['cart']) && array_count_values($_SESSION['cart'])) { display_cart($_SESSION['cart']); } else { echo '<p>There are no items in your cart</p>'; echo '<hr />'; } $target = 'index'; // if we have just added an item to the cart, continue shopping in that category if ($new) { $details = get_book_details($new); if ($details['catid']) { $target = 'show_cat?catid=' . $details['catid']; } } display_button($target, 'continue-shopping', 'Continue Shopping'); // use this if SSL is set up // $path = $_SERVER['PHP_SELF']; // $server = $_SERVER['SERVER_NAME']; // $path = str_replace('show_cart.php', '', $path); // display_button('https://'.$server.$path.'checkout.php', // 'go-to-checkout', 'Go To Checkout'); // if no SSL use below code display_button('checkout', 'go-to-checkout', 'Go To Checkout');
<?php //include our function set include 'book_sc_fns.php'; // The shopping cart needs sessions, so start one session_start(); do_html_header('Checkout'); if ($HTTP_SESSION_VARS['cart'] && array_count_values($HTTP_SESSION_VARS['cart'])) { display_cart($HTTP_SESSION_VARS['cart'], false, 0); display_checkout_form(); } else { echo '<p>There are no items in your cart</p>'; } display_button('show_cart.php', 'continue-shopping', 'Continue Shopping'); do_html_footer();
<?php //if(!isset($_SESSION)){ session_start(); // } require_once "book_f.php"; if ($_SESSION['cart']) { display_cart($_SESSION['cart'], false, 0); display_checkout_form(); } else { echo "<p> Không có giỏ hàng </p>"; } display_button("index.php?dk=show_cart", "continue-shopping", "Continue Shopping"); function display_checkout_form() { ?> <style> .tb_checkout input{width: 85%; border: 1px solid #330; padding: 5px; margin: 5px 0px; font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#333; } .tb_checkout input:hover{ border: 2px solid #C30; background-color:#F9C; }
} $_SESSION['total_price'] = calculate_price($_SESSION['cart']); $_SESSION['items'] = calculate_items($_SESSION['cart']); } if (isset($_POST['save'])) { foreach ($_SESSION['cart'] as $isbn => $qty) { if ($_POST[$isbn] == '0') { unset($_SESSION['cart'][$isbn]); } else { $_SESSION['cart'][$isbn] = $_POST[$isbn]; } } $_SESSION['total_price'] = calculate_price($_SESSION['cart']); $_SESSION['items'] = calculate_items($_SESSION['cart']); } do_html_header("Your cart"); if ($_SESSION['cart'] && array_count_values($_SESSION['cart'])) { display_cart($_SESSION['cart']); } else { echo "<p>Your cart is empty</p><hr />"; } $target = "index.php"; if ($new) { $details = get_book_details($new); if ($details['catid']) { $target = "show_cat.php?catid=" . $details['catid']; } } display_button($target, "continue-shopping", "Continue shopping"); display_button("checkout.php", "go-to-checkout", "Checkout"); do_html_footer();
$month = $_POST['month']; $year = $_POST['year']; $name = $_POST['name']; do_html_header('支付'); do_html_top(); if ($_POST['submit'] && $_SESSION['cart'] && $_POST['order_info_userid'] && $_POST['order_info_orderid'] && $_POST['type'] && $_POST['number'] && $_POST['secure_number'] && $_POST['month'] && $_POST['year'] && $_POST['name']) { display_cart($_SESSION['cart'], false, 1, 1); if (query_order_pay($order_info_orderid) == PAYED) { echo "您的订单已经支付成功,无需再次支付。您的订单号:" . $order_info_orderid; } if (query_order_pay($order_info_orderid) == UNPAYED) { if (process_card()) { change_order_status($order_info_orderid); $date = date("Y-m-d H:i:s"); echo "您的订单支付成功。支付时间:" . $date . "。您的订单号:" . $order_info_orderid; unset($_SESSION['cart']); unset($_SESSION['total_price']); unset($_SESSION['items']); } else { echo "您的信用卡有误。"; } } else { echo "错误2<br>"; echo query_order_pay($order_info_orderid); } } else { echo "支付信息请填完整"; print_r($_POST); display_button('purchase.php', '支付'); } do_html_footer();
$_SESSION['items'] = 0; $_SESSION['total_price'] = 0.0; } if (isset($_SESSION['cart'][$new])) { $_SESSION['cart'][$new]++; } else { $_SESSION['cart'][$new] = 1; } $_SESSION['total_price'] = calculate_price($_SESSION['cart']); $_SESSION['items'] = calculate_items($_SESSION['cart']); } if ($_POST['submit']) { foreach ($_SESSION['cart'] as $isbn => $qty) { if ($_POST[$isbn] == '0') { unset($_SESSION['cart'][$isbn]); } else { $_SESSION['cart'][$isbn] = $_POST[$isbn]; } } $_SESSION['total_price'] = calculate_price($_SESSION['cart']); $_SESSION['items'] = calculate_items($_SESSION['cart']); } do_html_header("购物车"); do_html_top(); if ($_SESSION['cart'] && array_count_values($_SESSION['cart'])) { display_cart($_SESSION['cart'], true); display_button('checkout.php', '结算'); } else { echo "还没有商品添加到购物车"; } do_html_footer();
<?php include 'book_sc_fns.php'; session_start(); $isbn = $_GET['isbn']; $book = get_book_details($isbn); do_html_header($book['title']); display_book_details($book); $target = "index.php"; if ($book['catid']) { $target = "show_cat.php?catid=" . $book['catid']; } if (check_admin_user()) { display_button("edit_book_form.php?isbn=" . $isbn, "edit-item", "Edit element"); display_button("admin.php", "admin-menu", "Administration menu"); display_button($target, "continue", "Continue"); } else { display_button("show_cart.php?new=" . $isbn, "add-to-cart", "Add " . $book['title'] . " to my shopping cart"); display_button($target, "continue-shopping", "Continue shopping"); } do_html_footer();
function send($mailid, $admin_user) { if (!check_admin_user($admin_user)) { return false; } if (!($info = load_mail_info($mailid))) { echo "Cannot load list information for message {$mailid}"; return false; } $subject = $info[0]; $listid = $info[1]; $status = $info[2]; $sent = $info[3]; $from_name = 'Pyramid MLM'; $from_address = 'return@address'; $query = "select email from sub_lists where listid = {$listid}"; $result = mysql_query($query); if (!$result) { echo $query; return false; } else { if (mysql_num_rows($result) == 0) { echo "There is nobody subscribed to list number {$listid}"; return false; } else { // include PEAR mail classes include 'Mail.php'; include 'Mail/mime.php'; // instantiate MIME class and pass it the carriage return/line feed // character used on this system $message = new Mail_mime("\r\n"); // read in the text version of the newsletter $textfilename = "archive/{$listid}/{$mailid}/text.txt"; $tfp = fopen($textfilename, "r"); $text = fread($tfp, filesize($textfilename)); fclose($tfp); // read in the HTML version of the newsletter $htmlfilename = "archive/{$listid}/{$mailid}/index.html"; $hfp = fopen($htmlfilename, "r"); $html = fread($hfp, filesize($htmlfilename)); fclose($hfp); // add HTML and text to the mimemail object $message->setTXTBody($text); $message->setHTMLBody($html); // get the list of images that relate to this message $query = "select path, mimetype from images where mailid = {$mailid}"; if (db_connect()) { $result = mysql_query($query); if (!$result) { echo '<p>Unable to get image list from database.'; return false; } $num = mysql_numrows($result); for ($i = 0; $i < $num; $i++) { //load each image from disk $imgfilename = "archive/{$listid}/{$mailid}/" . mysql_result($result, $i, 0); $imgtype = mysql_result($result, $i, 1); // add each image to the object $message->addHTMLImage($imgfilename, $imgtype, $imgfilename, true); } } // create message body $body = $message->get(); // create message headers $from = '"' . get_real_name($admin_user) . '" <' . $admin_user . '>'; $hdrarray = array('From' => $from, 'Subject' => $subject); $hdrs = $message->headers($hdrarray); // create the actual sending object $sender =& Mail::factory('mail'); if ($status == 'STORED') { // send the HTML message to the administrator $sender->send($admin_user, $hdrs, $body); // send the plain text version of the message to administrator mail($admin_user, $subject, $text, 'From: "' . get_real_name($admin_user) . '" <' . $admin_user . ">"); echo "Mail sent to {$admin_user}"; // mark newsletter as tested $query = "update mail set status = 'TESTED' where mailid = {$mailid}"; if (db_connect()) { $result = mysql_query($query); } echo '<p>Press send again to send mail to whole list.<center>'; display_button('send', "&id={$mailid}"); echo '</center>'; } else { if ($status == 'TESTED') { //send to whole list $query = "select subscribers.realname, sub_lists.email, \r\n subscribers.mimetype \r\n from sub_lists, subscribers \r\n where listid = {$listid} and \r\n sub_lists.email = subscribers.email"; if (!db_connect()) { return false; } $result = mysql_query($query); if (!$result) { echo '<p>Error getting subscriber list'; } $count = 0; // for each subscriber while ($subscriber = mysql_fetch_row($result)) { if ($subscriber[2] == 'H') { //send HTML version to people who want it $sender->send($subscriber[1], $hdrs, $body); } else { //send text version to people who don't want HTML mail mail($subscriber[1], $subject, $text, 'From: "' . get_real_name($admin_user) . '" <' . $admin_user . ">"); } $count++; } $query = "update mail set status = 'SENT', sent = now() \r\n where mailid = {$mailid}"; if (db_connect()) { $result = mysql_query($query); } echo "<p>A total of {$count} messages were sent."; } else { if ($status == 'SENT') { echo '<p>This mail has already been sent.'; } } } } } }
} else { $_SESSION['cart'][$isbn] = $_POST[$isbn]; } // Cập nhật số lượng mới } $_SESSION['total_price'] = calculate_price($_SESSION['cart']); $_SESSION['items'] = calculate_items($_SESSION['cart']); } ?> <?php /*echo "<pre>"; // print_r($_SESSION); echo "</pre>";*/ // Tiếp bài học 19.11.2015 if ($_SESSION['cart']) { display_cart($_SESSION['cart']); } else { echo "<p>Giỏ hàng rỗng</p>"; echo "<hr>"; } $url = "index.php?dk=loaisach"; if ($new) { $detail = get_book_details($new); if ($detail[catid]) { $url = "index.php?dk=show_cart&catid={$detail['catid']}"; } } display_button($url, 'continue-shopping', 'Continue Shopping'); display_button('index.php?dk=checkout', 'go-to-checkout', 'Go-To-Checkout');
<?php require 'book_sc_fns.php'; session_start(); do_html_header("Final settlement"); $name = $_POST['name']; $address = $_POST['address']; $city = $_POST['city']; $zip = $_POST['zip']; $country = $_POST['country']; if ($_SESSION['cart'] && $name && $address && $city && $zip && $country) { if (insert_order($_POST) != false) { display_cart($_SESSION['cart'], false, 0); display_shipping(calculate_shipping_cost()); display_card_form($name); display_button("show_cart.php", "continue-shopping", 'Continue shopping'); } else { echo "Can\\'t save data. Please, try again later."; display_button("checkout.php", "back", "Back"); } } else { echo "You didn\\'t fill in all fields. Please, try again.<hr />"; display_button("checkout.php", "back", "Back"); } do_html_footer();
function display_toolbar($button, $extra_parameters = '') { // draw our toolbar // there are up to five buttons per row and up to three rows // these numbers are completely arbitary and depend on the // images size and acceptable screen width global $table_width; echo "<table width=\"" . $table_width . "\"\n cellpadding=\"0\" cellspacing=\"0\" border=\"0\">"; for ($i = 0; $i < 3; $i++) { if (@$button[$i * 5]) { echo "<tr>\n <td bgcolor=\"#cccccc\">"; for ($j = 0; $j < 5; $j++) { echo "<td bgcolor=\"#cccccc\">"; if (@$button[$i * 5 + $j]) { display_button($button[$i * 5 + $j], $extra_parameters); } else { display_spacer(); } echo "</td>"; } echo "</tr>"; } } echo "</table>"; }
<?php require 'book_sc_fns.php'; session_start(); do_html_header("Welcome to BUKVOFIL shop!"); echo '<p>Please, choose your category:</p>'; $cat_array = get_categories(); display_categories($cat_array); if (isset($_SESSION['admin_user'])) { display_button("admin.php", "admin_menu", "Administration menu"); } do_html_footer();
<?php include 'book_sc_fns.php'; // The shopping cart needs sessions, so start one session_start(); $isbn = $_GET['isbn']; // get this book out of database $book = get_book_details($isbn); do_html_header($book['title']); display_book_details($book); // set url for "continue button" $target = 'index.php'; if ($book['catid']) { $target = 'show_cat.php?catid=' . $book['catid']; } // if logged in as admin, show edit book links if (check_admin_user()) { display_button("edit_book_form.php?isbn={$isbn}", 'edit-item', 'Edit Item'); display_button('admin.php', 'admin-menu', 'Admin Menu'); display_button($target, 'continue', 'Continue'); } else { display_button("show_cart.php?new={$isbn}", 'add-to-cart', 'Add ' . $book['title'] . ' To My Shopping Cart'); display_button($target, 'continue-shopping', 'Continue Shopping'); } do_html_footer();
<?php include 'book_sc_fns.php'; // The shopping cart needs sessions, so start one session_start(); do_html_header("Checkout"); // create short variable names $name = $_POST['name']; $address = $_POST['address']; $city = $_POST['city']; $zip = $_POST['zip']; $country = $_POST['country']; // if filled out if ($_SESSION['cart'] && $name && $address && $city && $zip && $country) { // able to insert into database if (insert_order($_POST) != false) { //display cart, not allowing changes and without pictures display_cart($_SESSION['cart'], false, 0); display_shipping(calculate_shipping_cost()); //get credit card details display_card_form($name); display_button('show_cart.php', 'continue-shopping', 'Continue Shopping'); } else { echo 'Could not store data, please try again.'; display_button('checkout.php', 'back', 'Back'); } } else { echo 'You did not fill in all the fields, please try again.<hr />'; display_button('checkout.php', 'back', 'Back'); } do_html_footer();
function do_html_header($title = '') { // print an HTML header // declare the session variables we want access to inside the function global $HTTP_SESSION_VARS; if (!$HTTP_SESSION_VARS['items']) { $HTTP_SESSION_VARS['items'] = '0'; } if (!$HTTP_SESSION_VARS['total_price']) { $HTTP_SESSION_VARS['total_price'] = '0.00'; } ?> <html> <head> <title><?php echo $title; ?> </title> <style> h2 { font-family: Arial, Helvetica, sans-serif; font-size: 22px; color = red; margin = 6px } body { font-family: Arial, Helvetica, sans-serif; font-size: 13px } li, td { font-family: Arial, Helvetica, sans-serif; font-size: 13px } hr { color: #FF0000; width=70%; text-align=center} a { color: #000000 } </style> </head> <body> <table width=100% border=0 cellspacing = 0 bgcolor=#cccccc> <tr> <td rowspan = 2> <a href = "index.php"><img src="images/Book-O-Rama.gif" alt="Bookorama" border=0 align=left valign=bottom height = 55 width = 325></a> </td> <td align = right valign = bottom> <?php if (isset($HTTP_SESSION_VARS['admin_user'])) { echo ' '; } else { echo 'Total Items = ' . $HTTP_SESSION_VARS['items']; } ?> </td> <td align = right rowspan = 2 width = 135> <?php if (isset($HTTP_SESSION_VARS['admin_user'])) { display_button('logout.php', 'log-out', 'Log Out'); } else { display_button('show_cart.php', 'view-cart', 'View Your Shopping Cart'); } ?> </tr> <tr> <td align = right valign = top> <?php if (isset($HTTP_SESSION_VARS['admin_user'])) { echo ' '; } else { echo 'Total Price = $' . number_format($HTTP_SESSION_VARS['total_price'], 2); } ?> </td> </tr> </table> <?php if ($title) { do_html_heading($title); } }
<?php require_once 'functions.php'; session_start(); $isbn = $_GET['isbn']; $book = get_book_details($isbn); do_html_header($book['title']); do_html_top(); display_book_details($book); $target = "show_cart.php?new=" . $isbn; display_button($target, '加入购物车'); do_html_footer();
if (mysql_num_rows($kq) > 0) { echo "<table width=100% border=0>"; // Lấy từng dòng mỗi cuốn sách dùng vòng while "Lên thuộc lệnh này dùng nhiều" while ($row = mysql_fetch_array($kq)) { $url = "index.php?dk=show_book&isbn={$row['isbn']}"; echo "<tr>"; echo "<td>"; // "isbn" Kiềm tra 'id' sách if (@file_exists("images/{$row['isbn']}.jpg")) { $title = "<img src='images/{$row['isbn']}.jpg' width=100 height=120 border=0>"; do_html_url($url, $title); } else { echo " "; } echo "</td>"; echo "<td>"; $title = $row[title] . "by" . $row[author]; do_html_url($url, $title); echo "</td>"; echo "</tr>"; } echo "</table>"; echo "<hr>"; } if (isset($_SESSION['admin_user'])) { display_button("index.php?dk=loaisach", "continue", "Continue Shopping"); display_button("index.php?dk=admin", "admin-menu", "Admin Menu"); display_button("index.php?dk=edit_category_form&catid={$catid}", "edit-category", "Edit Category"); } else { display_button("index.php?dk=loaisach", "continue-shopping", "Continue Shopping"); }
function send($mailid, $admin_user, $emailAddr) { $CI =& get_instance(); $CI->load->library('email'); /*$config['protocol'] = "smtp"; $config['smtp_host'] = "ssl://smtp.gmail.com"; //$config['smpt_timeout'] = '5'; //$config['smtp_user'] = "******"; //$config['smtp_pass'] = "******"; $config['smtp_port'] = 465;//"8089"; $config['charset'] = 'iso-8859-1'; $config['mailtype'] = "text"; $config['newline'] = "\r\n"; //$config['validation'] = TRUE;*/ //$config['protocol'] = 'smtp'; //$config['smtp_host'] = 'aspmx.l.google.com'; //change this //$config['smtp_port'] = '25'; //$config['smtp_user'] = '******'; //change this //$config['smtp_pass'] = '******'; //change this //$config['mailtype'] = 'text'; //$config['charset'] = 'iso-8859-1'; //$config['wordwrap'] = TRUE; //$config['newline'] = "\r\n"; //$CI->email->initialize($config); /*$CI->email->from('jamalbutcher@gmail', 'sender name'); $CI->email->to('jamalbutcher@gmail'); //$CI->email->cc('*****@*****.**'); $CI->email->subject('Your Subject'); $CI->email->message('Your Message'); //$CI->email->attach('/path/to/file1.png'); // attach file //$CI->email->attach('/path/to/file2.pdf'); if ($CI->email->send()) echo "Mail Sent!"; else echo "There is error in sending mail!";*/ ini_set('SMTP', 'smtp.gmail.com'); //192.168.20.202 ini_set('smtp_port', 25); //25 ini_set('sendmail_from', 'jamalbutcher@gmail'); //ini_set('smtp_user','jamalbutcher@gmail'); //ini_set('smptp_pass','P4m266a-mlx'); //ini_set('SMTP', '192.168.20.202'); // //ini_set('smtp_port', 8089); //25 if (!check_admin_user($admin_user)) { return false; } if (!($info = load_mail_info($mailid))) { echo "Cannot load list information for message {$mailid}"; return false; } $subject = $info['subject']; $CI->email->subject($subject); $listid = $info['listid']; $status = $info['status']; $sent = $info['sent']; $from_name = 'Trimart'; $from_address = '*****@*****.**'; $CI->email->from($from_address, $from_name); $query = "select email from sub_lists where listid =" . $listid; $conn = db_connect(); $result = $conn->query($query); if (!$result) { echo "No result"; return false; } else { if ($result->num_rows == 0) { echo "There is nobody subscribed to list number {$listid}"; return false; } } // include PEAR mail classes //include('Mail.php'); //include('Mail/Mime.php'); // instantiate MIME class and pass it the carriage return/line feed // character used on this system //$message = new Mail_mime("\r\n"); // read in the text version of the newsletter $textfilename = APPPATH . "archive\\" . $listid . "\\" . $mailid . "\\text.txt"; //$tfp = fopen($textfilename, "r"); //$text = fread($tfp, filesize($textfilename)); //fclose($tfp); // read in the HTML version of the newsletter $htmlfilename = APPPATH . "archive\\" . $listid . "\\" . $mailid . "\\index.html"; //$hfp = fopen($htmlfilename, "r"); //$html = fread($hfp, filesize($htmlfilename)); //fclose($hfp); // add HTML and text to the mimuser object //$message->setTXTBody($text); //$message->setHTMLBody($html); // get the list of images that relate to this message $query = "select path, mimetype from images where mailid = {$mailid}"; $result = $conn->query($query); if (!$result) { echo '<p>Unable to get image list from database.</p>'; return false; } $num = $result->num_rows; for ($i = 0; $i < $num; $i++) { //load each image from disk $row = $result->fetch_array(); $imgfilename = APPPATH . "archive\\{$listid}\\{$mailid}\\" . $row[0]; //var_dump($imgfilename); $imgtype = $row[1]; // add each image to the object //$message->addHTMLImage($imgfilename, $imgtype, $imgfilename, true); $CI->email->attach($imgfilename); } // create message body //$body = $message->get(); // create message headers $from = '"' . get_real_name($admin_user) . '" <' . $admin_user . '>'; $hdrarray = array('From' => $from, 'Subject' => $subject); //$hdrs = $message->headers($hdrarray); // create the actual sending object //$sender =& Mail::factory('mail'); if ($status == 'STORED') { // send the HTML message to the administrator //$sender->send($admin_user, $hdrs, $body); // send the plain text version of the message to administrator //mail($_POST['emailAddr'], $subject, $text, 'From: "'.$admin_user.'" <'.$admin_user.">"); //var_dump($_POST['emailAddr']); if (mail($_POST['emailAddr'], $subject, 'Hello')) { echo "<p>Success you genius</p>"; } $CI->email->to($_POST['emailAddr']); //var_dump($_POST['emailAddr']); if (mail($_POST['emailAddr'], $subject, 'Hello', $from_address)) { echo "Mail sent to {$admin_user} with email address " . $_POST['emailAddr']; // mark newsletter as tested $query = "update mail set status = 'TESTED' where mailid = {$mailid}"; $result = $conn->query($query); echo '<p>Press send again to send mail to whole list.<center>'; display_button('send', "&id={$mailid}"); echo '</center></p>'; } /*else { echo $CI->email->print_debugger(); }*/ } else { if ($status == 'TESTED') { //send to whole list $query = "select subscribers.realname, sub_lists.email, \n subscribers.mimetype \n from sub_lists, subscribers \n where listid = {$listid} and \n sub_lists.email = subscribers.email"; $result = $conn->query($query); if (!$result) { echo '<p>Error getting subscriber list</p>'; } $count = 0; // for each subscriber while ($subscriber = $result->fetch_row()) { if ($subscriber[2] == 'H') { //send HTML version to people who want it //$sender->send($subscriber[1], $hdrs, $body); $CI->email->send(); } else { //send text version to people who don't want HTML mail /*mail($subscriber[1], $subject, $text, 'From: "'.get_real_name($admin_user).'" <'.$admin_user.">");*/ $CI->email->to($subscriber[1]); $CI->email->send(); } $count++; } $query = "update mail set status = 'SENT', sent = now() \n where mailid = {$mailid}"; $result = $conn->query($query); echo "<p>A total of {$count} messages were sent.</p>"; } else { if ($status == 'SENT') { echo '<p>This mail has already been sent.</p>'; } } } }
<?php include 'book_sc_fns.php'; // The shopping cart needs sessions, so start one session_start(); do_html_header("Welcome to Book-O-Rama"); echo "<p>Please choose a category:</p>"; // get categories out of database $cat_array = get_categories(); // display as links to cat pages display_categories($cat_array); // if logged in as admin, show add, delete, edit cat links if (isset($_SESSION['admin_user'])) { display_button("admin.php", "admin-menu", "Admin Menu"); } do_html_footer();