Code 1page FlatFile Ecom

https://cmxads.com/one-page-ecommerce-cms.php

Mahalo

SIGNATURE:
Clifford "RAY" Hackett www.rayis.me RESUME: www.rayis.me/resume

I founded www.adapt.org in 1980 it now has over 50 million members.
$500 of material=World’s fastest hydrofoil sailboat. http://sunrun.biz

On Mon, Jun 17, 2019 at 5:54 PM Ray Hackett <3659745> wrote:

1: <?php
2: session_start();
3: $starttime = microtime();
4: $startarray = explode(" ", $starttime);
5: $starttime = $startarray[1] + $startarray[0];
6: $self = $_SERVER['PHP_SELF'];
7: $PAYMENT_GATEWAY=$self;]
8: //data file
9: $fl=’cart-data.txt’;
10: //add to cart action
11: $page_name=’one-page-ecommerce-cart-cms.php’;
12: //set file product fields array
13: $fields=array(
14: ‘id’,
15: ‘product_code’,
16: ‘product_name’,
17: ‘product_desc’,
18: ‘product_img’,
19: ‘price’,
20: ‘weight’,
21: ‘catalog’,
22: ‘catid’,
23: );
24:
25: $taxout=”;
26: $shipout=”;
27: //gateway and other form variables
28: $tax_rate=’6′;
29: $taxstate=’WV’;
30: $currency=’USD’;
31: //base handling added to ship percentage
32: $handling=’5′;
33: $ship_rate=’10’;
34: //$price=’amount’;
35: //$name=’item_name’;
36: //$num=’item_num’;
37: //$desc=’item_desc’;
38:
39: function flock_utf8_contents($filename){
40: $return = FALSE;
41: if(file_exists($filename) and is_readable($filename)){
42: if($handle = @fopen($filename, ‘r’)){
43: while(!$return){
44: if(flock($handle, LOCK_SH)){
45: if($return = file_get_contents($filename)){
46: flock($handle, LOCK_UN);
47: }}}fclose($handle);}}
48: return mb_convert_encoding($return, ‘UTF-8’,
49: mb_detect_encoding($return, ‘UTF-8, ISO-8859-1’, true));}
50:
51:
52:
53: $str=flock_utf8_contents($fl);
54:
55: function parse_file() {
56: global $str;
57: global $fields;
58: $res=array();
59: $lines=array();
60: $output = array();
61: $output = explode("\n", $str);
62: $output=array_filter($output);
63: $output=array_map(‘trim’, $output);
64: foreach ($output as $key=>$data) {
65: $lines = explode(‘;’, $data);
66: $res[]=array_combine($fields,$lines);
67: }
68: return $res;
69: }
70:
71: $current_url = base64_encode("http://".$_SERVER[object 4].$_SERVER['REQUEST_URI']);
72:
73: $res=parse_file();
74:
75: function find($string, $array){
76: foreach ($array as $key => $value) {
77: unset ($array[$key]);
78: if (in_array($string, $value)) {
79: $array[$key] = $value;}}
80: return $array;}
81:
82: ?>
83: <!doctype html>
84: <html lang="en">
85: <head>
86: <meta charset="utf-8">
87: <title>php simple ecommerce cms with shopping cart just one page of code remarkable and free <?php echo $title;?></title>
88: <meta name="description" content="Free php flatfile database ecommerce and shopping cart script. A complete ecommerce shop and cart all on just one page of code. Easy to set up checkout form to post to google paypal or your gateway. Can modify for you as well. Another great cmxtendable script from handicapped george.">
89: <meta name="robots" content="index">
90: <style type="text/css">
91: body, html {
92: margin-top:10px;
93: font-size:14px;
94: height:100%;
95: min-height:100%;
96: font-family: Tahoma, Arial;
97: background:#E0E0E0;
98: background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFFFFF), to(#E0E0E0 ));*/
99: background: -moz-linear-gradient(top, #FFFFFF 0%, #E0E0E0 100%);*/
100: background: -o-linear-gradient(top, #FFFFFF 0%, #E0E0E0 100%);*/
101: background: linear-gradient(top, #FFFFFF 0%, #E0E0E0 100%);*/
102: }
103: #wrapper {
104: padding:20px;
105: width:750px;
106: margin: auto;
107: min-height:100%;
108: background-color: #ffffff;
109: border: 2px solid #333;
110: /* curved border radius */
111: -moz-border-radius:20px;
112: -webkit-border-radius:20px;
113: -o-border-radius:20px;
114: border-radius:20px;
115: }
116: .box{
117: display: none;
118: width: 100%;
119: }
120:
121: a:hover + .box,.box:hover{
122: display: block;
123: position: relative;
124: z-index: 100;
125: }
126: </style>
127:
128: </head>
129:
130: <body>
131:

132:

133:

134:

135:

138:

Shopping

136: Flatfile Ecommerce CMXtendable Shopping Cart all in just one page of code.
137:

139:
140:

141: <br>
142:

143: $val) {
147:
148: echo ‘

‘;
149: echo “”;
150: echo ‘

‘;
151: echo ‘

‘.$val[“product_name”].’

‘;
152: echo ‘

‘.$val[“product_desc”].’

‘;
153: echo ‘

Price ‘.$currency.$val[“price”].’ Add To Cart

‘;
154: //echo ‘<input type="text" name="product_qty" value="1" />’;
155: echo ‘</div>’;
156: echo ‘<input type="hidden" name="product_code" value="’.$val["product_code"].’">’;
157: echo ‘<input type="hidden" name="type" value="add" />’;
158: echo ‘<input type="hidden" name="return_url" value="’.$current_url.’">’;
159: echo ‘</form>’;
160: echo ‘</div>’;
161: }
162:
163: ?>
164:
165: </div>
166:
167:

168: Shopping Cart

‘;
173: $total = 0;
174: echo “”;
175: echo ‘

    ‘;
    176: $cart_items = 0;
    177:
    178: foreach ($_SESSION[“products”] as $cart_itm)
    179: {
    180: $product_code = $cart_itm[“code”];
    181: $res=parse_file();
    182: for($i=0; $i$rs) {
    187:
    188: echo ‘

  • ‘;
    189: if(empty($cart_itm['qty'])){
    190: $cart_itm['qty']=’1’;
    191: }
    192: echo ‘

    ‘;
    193: echo ‘‘.$rs['product_name'].’ (Item # :’.$rs['product_code'].’) ‘;
    194: echo ‘

    Qty : ‘.$cart_itm['qty'].’

    ‘;
    195: echo ‘

    ‘.$rs['product_desc'].’

    ‘;
    196: echo ‘

    ‘.$currency.$rs['price'].’

    ‘;
    197: echo ‘</div>’;
    198: echo ‘<span style="background:crimson;padding-right:5px;padding-left:5px;text-align:center;"><a style="text-decoration:none;font-weight:bold;color:white;text-align:center;" href="’.$page_name.’?removep=’.$cart_itm["code"].’&return_url=’.$current_url.’">&times; Delete</a></span>’;
    199: echo ‘</li>’;
    200: $subtotal = ($cart_itm['price']*$cart_itm['qty']);
    201: $total = ($total + $subtotal);
    202: echo ‘<input type="hidden" name="item_name['.$cart_items.']" value="’.$rs['product_name'].’" />’;
    203: echo ‘<input type="hidden" name="item_code['.$cart_items.']" value="’.$rs['product_code'].’" />’;
    204: echo ‘<input type="hidden" name="item_desc['.$cart_items.']" value="’.$rs['product_desc'].’" />’;
    205: echo ‘<input type="hidden" name="item_qty['.$cart_items.']" value="’.$cart_itm["qty"].’" />’;
    206:
    207: $cart_items ++;
    208:
    209: }}
    210: echo ‘</ul>’;
    211: echo ‘<span class="check-out-txt">’;
    212: if($tax_rate){
    213: $tax = $total * $tax_rate / 100;
    214: $tax=substr($tax,0,-1);
    215: $total=$total+$tax;
    216: $taxout= "$taxstate tax: $tax_rate% $tax";
    217: }
    218: if($ship_rate){
    219: $shipping = $total * $ship_rate / 100;
    220: $shipping =$shipping+ $handling;
    221: $shipout= ‘shipping ‘.$currency.number_format($shipping,2);
    222: $total=$total+$tax+$shipping;
    223: }
    224: echo ‘<strong>’.$shipout.'<br>Total. : ‘.$currency.number_format($total,2).’ – ‘.$taxout.'</strong>’;
    225: echo ‘</span>’;
    226: if($subtotal>=0){
    227: echo ‘<br><br><input type="submit" name="type" value="Begin Checkout">’;
    228: }
    229: echo ‘</form>’;
    230: }else{
    231: echo ‘<strong>Cart is empty add something.</strong>’;
    232: }
    233: ?>
    234: </div>
    235: <?php
    236: if(isset($_GET["emptycart"]) && $_GET["emptycart"]==1){
    237: $return_url = base64_decode($_GET["return_url"]);
    238: session_destroy();
    239: // header(‘Location:’.$return_url);
    240: echo "<meta http-equiv=\"Refresh\" content=\"0;URL=$return_url\">";
    241: }
    242:
    243: if(isset($_POST["type"]) && $_POST["type"]==’add’){
    244:
    245: $product_code = filter_var($_POST["product_code"], FILTER_SANITIZE_STRING);
    246: $product_qty = filter_var($_POST["product_qty"], FILTER_SANITIZE_NUMBER_INT);
    247: $return_url = base64_decode($_POST["return_url"]); //return url
    248:
    249: if($product_qty > 10){
    250: die("

    Maximum quantity of 10 reached.

    ");
    251: }
    252:
    253: $res=parse_file();
    254: for($i=0; $i<count($res); $i++){
    255: $results = find ($product_code, $res);
    256: }
    257: if ($results) {
    258: foreach ($results as $key=>$rs) {
    259: $new_product = array(array(‘name’=>$rs['product_name'], ‘code’=>$rs['product_code'], ‘qty’=>$cart_itm["qty"], ‘price’=>$rs['price']));
    260:
    261: if(isset($_SESSION["products"])){
    262: $found = false;
    263: foreach ($_SESSION["products"] as $cart_itm){
    264: if($cart_itm["code"] == $product_code){
    265: $product[] = array(‘name’=>$cart_itm["name"], ‘code’=>$cart_itm["code"], ‘qty’=>$product_qty, ‘price’=>$cart_itm["price"]);
    266: $found = true;
    267: }else{
    268: $product[] = array(‘name’=>$cart_itm["name"], ‘code’=>$cart_itm["code"], ‘qty’=>$cart_itm["qty"], ‘price’=>$cart_itm["price"]);
    269: }
    270: }
    271: if($found == false) {
    272: $_SESSION["products"] = array_merge($product, $new_product);
    273: }else{
    274: $_SESSION["products"] = $product;
    275: }
    276: }else{
    277: $_SESSION["products"] = $new_product;
    278: }
    279: }
    280: }
    281: // header(‘Location:’.$return_url);
    282: echo "<meta http-equiv=\"Refresh\" content=\"0;URL=$return_url\">";
    283: }
    284: if(isset($_GET["removep"]) && isset($_GET["return_url"]) && isset($_SESSION["products"])){
    285: $product_code = $_GET["removep"]; //get the product code to remove
    286: $return_url = base64_decode($_GET["return_url"]); //get return url
    287:
    288: foreach ($_SESSION["products"] as $cart_itm){
    289: if($cart_itm["code"]!=$product_code){
    290: $product[] = array(‘name’=>$cart_itm["name"], ‘code’=>$cart_itm["code"], ‘qty’=>$cart_itm["qty"], ‘price’=>$cart_itm["price"]);
    291: }
    292: $_SESSION["products"] = $product;
    293: }
    294: // header(‘Location:’.$return_url);
    295: echo "<meta http-equiv=\"Refresh\" content=\"0;URL=$return_url\">";
    296: }
    297:
    298: echo "

    ";
    299: $endtime = microtime();
    300: $endarray = explode(" ", $endtime);
    301: $endtime = $endarray[1] + $endarray[0];
    302: $totaltime = $endtime – $starttime;
    303: $totaltime = round($totaltime,4);
    304: echo "


    This search took $totaltime seconds to complete.”;
    305:
    306: function convert($size)
    307: {
    308: $unit=array(‘b’,’kb’,’mb’,’gb’,’tb’,’pb’);
    309: return @round($size/pow(1024,($i=floor(log($size,1024)))),2).’ ‘.$unit[$i];
    310: }
    311:
    312: echo ‘ Memory usage ‘ . convert(memory_get_usage(true)) . ‘

    ‘; // 123 kb
    313:
    314:
    315: echo ‘</div>’;
    316: echo ‘<p style="width:100%;text-align:center;"><a href="http://www.cmxads.com/one-page-ecommerce-cms.php">Cmxads.com One Page Ecommerce CMS Php Script</a></p>’;
    317: echo ‘</body>’;
    318: echo ‘</html>’;
    319: ?>

    End

Leave a comment