Category Archives: Shopping Carts

Shop-Script FREE PHP shopping cart software

Shop-Script FREE PHP shopping cart software is lite PHP shopping cart solution which is available for free download. Shop-Script FREE will help you instantly create a search engine friendly online store and start accepting online orders and payments for these orders by PayPal. Shop-Script FREE.

 

<?php
/*****************************************************************************
*                                                                           *
* Shop-Script FREE                                                          *
* Copyright (c) 2005 WebAsyst LLC. All rights reserved.                     *
*                                                                           *
****************************************************************************/



//ADMIN :: products managment

ini_set("display_errors", "1");

include("./cfg/connect.inc.php");
include("./includes/database/mysql.php");
include("./cfg/category_functions.php");
include("./cfg/general.inc.php");

//connect 2 database
db_connect(DB_HOST,DB_USER,DB_PASS) or die (db_error());
db_select_db(DB_NAME) or die (db_error());

session_start();
include("./checklogin.php");
if (!isset($_SESSION["log"]) || strcmp($_SESSION["log"],ADMIN_LOGIN)) //unauthorized
{
die ("You are not authorized to view this page");
}

//get currency ISO 3 code
$currency_iso_3 = (defined('CONF_CURRENCY_ISO3')) ? CONF_CURRENCY_ISO3 : "USD" ;

//current language
include("./cfg/language_list.php");
if (!isset($_SESSION["current_language"]) ||
$_SESSION["current_language"] < 0 || $_SESSION["current_language"] > count($lang_list))
$_SESSION["current_language"] = 0; //set default language

if (isset($lang_list[$_SESSION["current_language"]]) &amp;&amp; file_exists("./languages/".$lang_list[$_SESSION["current_language"]]->filename))
include("./languages/".$lang_list[$_SESSION["current_language"]]->filename); //include current language file
else
{
die("<font color=red><b>ERROR: Couldn't find language file!</b></font>");
}

if (!isset($_GET["productID"])) $_GET["productID"] = 0;

if (isset($_POST["save_product"])) //save item to the database
{

if (!isset($_POST["price"]) || !$_POST["price"] || $_POST["price"] < 0)
$_POST["price"] = 0; //price can not be negative

if (!isset($_POST["name"]) || trim($_POST["name"])=="") $_POST["name"] = "not defined";

$instock = (isset($_POST["in_stock"])) ? 1 : 0;

if ($_POST["save_product"]) { //if $_POST["save_product"] != 0 then update item

//delete old product photos if they're being replaced
$q = db_query("SELECT picture, big_picture, thumbnail FROM ".PRODUCTS_TABLE." WHERE productID='".$_POST["save_product"]."'") or die (db_error());
$row = db_fetch_row($q);

//generating query

$s = "UPDATE ".PRODUCTS_TABLE." SET categoryID='".$_POST["categoryID"]."', name='".$_POST["name"]."', Price='".$_POST["price"]."', description='".$_POST["description"]."', in_stock=".$instock.", customers_rating='".$_POST["rating"]."', brief_description='".$_POST["brief_description"]."', list_price='".$_POST["list_price"]."', product_code='".$_POST["product_code"]."'";

$s1 = "";

//old pictures?
if (isset($_FILES["picture"]) &amp;&amp; $_FILES["picture"]["name"])
{
//delete old picture
if ($row[0] &amp;&amp; file_exists("./products_pictures/".$row[0]))
unlink("./products_pictures/".$row[0]);
}
if (isset($_FILES["big_picture"]) &amp;&amp; $_FILES["big_picture"]["name"])
{
//delete old picture
if ($row[1] &amp;&amp; file_exists("./products_pictures/".$row[1]))
unlink("./products_pictures/".$row[1]);
}
if (isset($_FILES["thumbnail"]) &amp;&amp; $_FILES["thumbnail"]["name"])
{
//delete old picture
if ($row[2] &amp;&amp; file_exists("./products_pictures/".$row[2]))
unlink("./products_pictures/".$row[2]);
}

$pid = $_POST["save_product"];

}
else
{
//add new product
db_query("INSERT INTO ".PRODUCTS_TABLE." (categoryID, name, description, customers_rating, Price, in_stock, customer_votes, items_sold, enabled, brief_description, list_price, product_code, picture, thumbnail, big_picture) VALUES ('".$_POST["categoryID"]."','".$_POST["name"]."','".$_POST["description"]."', 0, '".$_POST["price"]."', ".$instock.", 0, 0, 1, '".$_POST["brief_description"]."', '".$_POST["list_price"]."', '".$_POST["product_code"]."','','','');") or die (db_error());
$pid = db_insert_id();

$dont_update = 1; //don't update product

$s  = "";
$s1 = "UPDATE ".PRODUCTS_TABLE." SET categoryID=categoryID";
}

//add pictures?
//regular photo
if (isset($_FILES["picture"]) &amp;&amp; $_FILES["picture"]["name"] &amp;&amp; preg_match('/\.(jpg|jpeg|gif|jpe|pcx|bmp)$/i', $_FILES["picture"]["name"])) //upload
{
$_FILES["picture"]["name"] = str_replace(" ","_",$_FILES["picture"]["name"]);
$r = move_uploaded_file($_FILES["picture"]["tmp_name"], "./products_pictures/".$_FILES["picture"]["name"]);
if (!$r) //failed 2 upload
{
echo "<center><font color=red>".ERROR_FAILED_TO_UPLOAD_FILE."</font>\n<br><br>\n";
echo "<a href=\"javascript:window.close();\">".CLOSE_BUTTON."</a></center></body>\n</html>";
exit;
}

SetRightsToUploadedFile( "./products_pictures/".$_FILES["picture"]["name"] );

$s .= ", picture='".$_FILES["picture"]["name"]."'";
$s1.= ", picture='".$_FILES["picture"]["name"]."'";
}
//enlarged photo
if (isset($_FILES["big_picture"]) &amp;&amp; $_FILES["big_picture"]["name"] &amp;&amp; preg_match('/\.(jpg|jpeg|gif|jpe|pcx|bmp)$/i', $_FILES["big_picture"]["name"]))
{
$_FILES["big_picture"]["name"] = str_replace(" ","_",$_FILES["big_picture"]["name"]);
$r = move_uploaded_file($_FILES["big_picture"]["tmp_name"], "./products_pictures/".$_FILES["big_picture"]["name"]);
if (!$r) //failed 2 upload
{
echo "<center><font color=red>".ERROR_FAILED_TO_UPLOAD_FILE."</font>\n<br><br>\n";
echo "<a href=\"javascript:window.close();\">".CLOSE_BUTTON."</a></center></body>\n</html>";
exit;
}

SetRightsToUploadedFile( "./products_pictures/".$_FILES["big_picture"]["name"] );

$s .= ", big_picture='".$_FILES["big_picture"]["name"]."'";
$s1.= ", big_picture='".$_FILES["big_picture"]["name"]."'";
}
//thumbnail
if (isset($_FILES["thumbnail"]) &amp;&amp; $_FILES["thumbnail"]["name"] &amp;&amp; preg_match('/\.(jpg|jpeg|gif|jpe|pcx|bmp)$/i', $_FILES["thumbnail"]["name"]))
{
$_FILES["thumbnail"]["name"] = str_replace(" ","_",$_FILES["thumbnail"]["name"]);
$r = move_uploaded_file($_FILES["thumbnail"]["tmp_name"], "./products_pictures/".$_FILES["thumbnail"]["name"]);
if (!$r) //failed 2 upload
{
echo "<center><font color=red>".ERROR_FAILED_TO_UPLOAD_FILE."</font>\n<br><br>\n";
echo "<a href=\"javascript:window.close();\">".CLOSE_BUTTON."</a></center></body>\n</html>";
exit;
}

SetRightsToUploadedFile( "./products_pictures/".$_FILES["thumbnail"]["name"] );

$s .= ", thumbnail='".$_FILES["thumbnail"]["name"]."'";
$s1.= ", thumbnail='".$_FILES["thumbnail"]["name"]."'";
}

if (!isset($dont_update)) //update product info
{
$s .= " WHERE productID='".$_POST["save_product"]."'";
db_query($s) or die (db_error());
$productID = $_POST["save_product"];
}
else //don't update (insert query is already completed)
{
$s1.= " WHERE productID=$pid";
db_query($s1) or die (db_error());
$productID = $pid;
}

update_products_Count_Value_For_Categories(0);

//close window
echo "<script>\n";
echo "window.opener.location.reload();\n";
echo "window.close();\n";
echo "</script>\n</body>\n</html>";
exit;
}
else //get product from db
{
if ($_GET["productID"])
{

$q = db_query("SELECT categoryID, name, description, customers_rating, Price, picture, in_stock, thumbnail, big_picture, brief_description, list_price, product_code FROM ".PRODUCTS_TABLE." WHERE productID='".$_GET["productID"]."'") or die (db_error());
$row = db_fetch_row($q);
if (!$row) //product wasn't found
{
echo "<center><font color=red>".ERROR_CANT_FIND_REQUIRED_PAGE."</font>\n<br><br>\n";
echo "<a href=\"javascript:window.close();\">".CLOSE_BUTTON."</a></center></body>\n</html>";
exit;
}

if (isset($_GET["picture_remove"])) //delete items picture from server if requested
{
if ($_GET["picture_remove"] &amp;&amp; file_exists("./products_pictures/".$row[$_GET["picture_remove"]]))
unlink("./products_pictures/".$row[$_GET["picture_remove"]]);
$picture = "none";
}

if (isset($_GET["delete"])) //delete product
{
//at first photos...
if ($row[5] != "none" &amp;&amp; $row[5] != "" &amp;&amp; file_exists("./products_pictures/".$row[5]))
unlink("./products_pictures/".$row[5]);
if ($row[7] != "none" &amp;&amp; $row[7] != "" &amp;&amp; file_exists("./products_pictures/".$row[7]))
unlink("./products_pictures/".$row[7]);
if ($row[8] != "none" &amp;&amp; $row[8] != "" &amp;&amp; file_exists("./products_pictures/".$row[8]))
unlink("./products_pictures/".$row[8]);

$q = db_query("DELETE FROM ".PRODUCTS_TABLE." WHERE productID='".$_GET["productID"]."'") or die (db_error());

//close window
echo "<script>\n";
echo "window.opener.location.reload();\n";
echo "window.close();\n";
echo "</script>\n</body>\n</html>";
exit;
}

$title = $row[1];

}
else //creating new item
{
$title = ADMIN_PRODUCT_NEW;
$cat = isset($_GET["categoryID"]) ? $_GET["categoryID"] : 0;
$row = array($cat,"","","",0,"",1,"","","",0,"");
}
}



?>

<html>

<head>
<link rel=STYLESHEET href="images/backend/style-backend.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo DEFAULT_CHARSET;?>">
<title><?php echo ADMIN_PRODUCT_TITLE;?></title>
<script>
function confirmDelete(question, where)
{
temp = window.confirm(question);
if (temp) //delete
{
window.location=where;
}
}
function open_window(link,w,h) //opens new window
{
var win = "width="+w+",height="+h+",menubar=no,location=no,resizable=yes,scrollbars=yes";
wishWin = window.open(link,'wishWin',win);
}
</script>
</head>

<body bgcolor=#FFFFE2>
<center>
<p>
<b><?php echo $title; ?></b>

<form enctype="multipart/form-data" action="products.php" method=post>

<table width=100% border=0 cellpadding=3 cellspacing=0>

<tr>
<td align=right><?php echo ADMIN_CATEGORY_PARENT;?></td>
<td>
<select name="categoryID">
<option value="0"><?php echo ADMIN_CATEGORY_ROOT;?></option>
<?php
//show categories select element
$cats = fillTheCList(0,0);
for ($i=0; $i<count($cats); $i++)
{
echo "<option value=\"".$cats[$i][0]."\"";
if ($row[0] == $cats[$i][0]) //select category
echo " selected";
echo ">";
for ($j=0;$j<$cats[$i][5];$j++) echo "&amp;nbsp;&amp;nbsp;";
echo $cats[$i][1];
echo "</option>";
}
?>
</select>
</td>
</tr>

<tr>
<td align=right><?php echo ADMIN_PRODUCT_NAME;?></td>
<td><input type="text" name="name" value="<?php echo str_replace("\"","&amp;quot;",$row[1]); ?>"></td>
</tr>

<tr>
<td align=right><?php echo ADMIN_PRODUCT_CODE;?></td>
<td><input type="text" name="product_code" value="<?php echo str_replace("\"","&amp;quot;",$row[11]); ?>"></td>
</tr>

<?php    if ($_GET["productID"]) { ?>
<tr>
<td align=right><?php echo ADMIN_PRODUCT_RATING;?>:</td>
<td><input type=text name="rating" value="<?php echo str_replace("\"","&amp;quot;",$row[3]); ?>"></b></td>
</tr>

<?php }; ?>

<tr>
<td align=right><?php echo ADMIN_PRODUCT_PRICE;?>, <?php echo $currency_iso_3; ?><br>(<?php echo STRING_NUMBER_ONLY;?>):</td>
<td><input type="text" name="price" value=<?php echo $row[4]; ?>></td>
</tr>

<tr>
<td align=right><?php echo ADMIN_PRODUCT_LISTPRICE;?>, <?php echo $currency_iso_3; ?><br>(<?php echo STRING_NUMBER_ONLY;?>):</td>
<td><input type="text" name="list_price" value=<?php echo $row[10]; ?>></td>
</tr>

<?php
if ($row[6]<0) $is = 0;
else $is = $row[6];

?>
<tr>
<td align=right><?php echo ADMIN_PRODUCT_INSTOCK;?>:</td>
<td><input type="checkbox" name="in_stock"<?php if ($is > 0) echo " checked"; ?>></td>
</tr>


<tr><td>&amp;nbsp;</td></tr>

<tr>
<td align=right><?php echo ADMIN_PRODUCT_PICTURE;?></td>
<td><input type="file" name="picture"></td>
<tr><td></td><td>
<?php
if ($row[5]!="" &amp;&amp; file_exists("./products_pictures/".$row[5]))
{
echo "<a href=\"products_pictures/".$row[5]."\">$row[5]</a>\n";
echo "<br><a href=\"javascript:confirmDelete('".QUESTION_DELETE_PICTURE."','products.php?productID=".$_GET["productID"]."&amp;picture_remove=5');\">".DELETE_BUTTON."</a>\n";
}
else echo "<font color=brown>".ADMIN_PICTURE_NOT_UPLOADED."</font>";
?>
</td>
</tr>
<tr>
<td align=right><?php echo ADMIN_PRODUCT_THUMBNAIL;?></td>
<td><input type="file" name="thumbnail"></td>
<tr><td></td><td>
<?php
if ($row[7]!="" &amp;&amp; file_exists("./products_pictures/".$row[7]))
{
echo "<a href=\"products_pictures/".$row[7]."\">$row[7]</a>\n";
echo "<br><a href=\"javascript:confirmDelete('".QUESTION_DELETE_PICTURE."','products.php?productID=".$_GET["productID"]."&amp;picture_remove=7');\">".DELETE_BUTTON."</a>\n";
}
else echo "<font color=brown>".ADMIN_PICTURE_NOT_UPLOADED."</font>";
?>
</td>
</tr>
<tr>
<td align=right><?php echo ADMIN_PRODUCT_BIGPICTURE;?></td>
<td valign=top><input type="file" name="big_picture"></td>
<tr><td></td><td valign=top>
<?php
if ($row[8] &amp;&amp; file_exists("./products_pictures/".$row[8]))
{
echo "<a href=\"products_pictures/".$row[8]."\">$row[8]</a>\n";
echo "<br><a href=\"javascript:confirmDelete('".QUESTION_DELETE_PICTURE."','products.php?productID=".$_GET["productID"]."&amp;picture_remove=8');\">".DELETE_BUTTON."</a>\n";
}
else echo "<font color=brown>".ADMIN_PICTURE_NOT_UPLOADED."</font>";
?>
</td>
</tr>


<tr>
<td align=right><?php echo ADMIN_PRODUCT_DESC;?><br>(HTML):</td>
<td><textarea name="description" rows=15 cols=40><?php echo str_replace("<","&amp;lt;",$row[2]); ?></textarea></td>
</tr>

<tr>
<td align=right><?php echo ADMIN_PRODUCT_BRIEF_DESC;?><br>(HTML):</td>
<td><textarea name="brief_description" rows=7 cols=40><?php echo str_replace("<","&amp;lt;",$row[9]); ?></textarea></td>
</tr>

</table>


<p><center>
<input type="submit" value="<?php echo SAVE_BUTTON;?>" width=5>
<input type="hidden" name="save_product" value=<?php echo $_GET["productID"]; ?>>
<input type="button" value="<?php echo CANCEL_BUTTON;?>" onClick="window.close();">
<?php    if ($_GET["productID"]) echo "<input type=button value=\"".DELETE_BUTTON."\" onClick=\"confirmDelete('".QUESTION_DELETE_CONFIRMATION."','products.php?productID=".$_GET["productID"]."&amp;delete=1');\">"; ?>
</center></p>
</form>


</center>
</body>

</html>

&amp;nbsp;

 

 

PrestaShop is a professional-grade for php scripts

PrestaShop is a professional-grade e-commerce shopping cart software that you can download, install, and use for free. Features: Front End – Special deals (price reductions, gift vouchers) – Featured products on homepage – Top sellers on homepage – New items on homepage – ‘Free shipping’ offers.

 

/*
========================================================================
TEMPLATE.CSS
========================================================================
*/


/* --- Body - control position #container, allows centering of site -- */
body {
text-align: center;
background-color: white;
}

#container {
display: block;
background-image: url(../templateimages/back_fade.png);
background-position: top left;
background-repeat: repeat-x;
margin: 0 auto;
}

/* Contains rest of HTML */
#centrecontainer {
width: 780px;
text-align: left;
margin: 0 auto;
min-height: 100%;
}


/* --- Header section ------------------------------------------------ */
#header {
height: 70px;
margin: 0px;

}

#header #title {
height: 70px;
margin: 0px 10px 0px 10px;
}

/* Top links */
#header2 .links {
margin: 0px 10px 0px 10px;
padding: 5px 0px 5px 0px;
font-size: 7.5pt;
}


#header2 .links li {
list-style: none;
display: inline;
margin: 0px;
padding: 0px;
}

#header2 .links a:link, #header2 .links a:visited
{
position: relative;
text-decoration: none;
color: white;
font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif;
font-weight: bold;
margin: 0px 12px 5px 0px;
}


#header2 .links a:hover
{
position: relative;
text-decoration: none;
color: black;
font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif;
font-weight: bold;
}

#header2 .links2 {
margin: 0px 10px 0px 10px;
padding: 2px 0px 2px 0px;
}

#header2 .links2 li {
list-style: none;
display: inline;
margin: 0px;
padding: 0px;
}

#header2 .links2 a:link, #header2 .links2 a:visited
{
margin: 0px 10px 0px 0px;
text-decoration: none;
color: white;
font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif;
font-size: 7.5pt;
font-weight: normal;
}


#header2 .links2 a:hover
{
color: black;
text-decoration: underline;
}


/* --- Entire page body section - everything below the header -------- */
#pagebody {
padding: 10px 10px 0px 10px;
margin: 0px 0px 0px 0px;
}

/* Left hand section of page body (if you have one!) */
#left {
width: 168px;
margin: 0px;
float: left;
}

/* Dynamic page content section of page body */
#pagecontent {
width: 560px;
float: left;
padding: 0;
}

#pagecontent_pad {
padding: 10px 5px 5px 0px;
}

/* Right hand section of page body */
#right {
width: 168px;
margin: 0px;
float: right;
margin-top: 0px;
padding-top: 0px;
}

/* --- Footer -------------------------------------------------------- */
#footer {
padding-top: 20px;
clear: both;
text-align: left;

}

/* Footer nav links */
#footer .links {
margin: 0px;
}

#footer .links li {
list-style: none;
display: inline;
}

#footer .links a {
font-size: 7pt;
padding: 2px;
margin-left: 3px;
margin-right: 3px;
}

/* T&amp;Cs text */
#terms {
background-image: url(../templateimages/back_fade3.png);
background-position: top left;
background-repeat: no-repeat;
margin-top: 4px;
padding-top: 10px;
margin-bottom: 12px;
font-size: 7pt;
color: #999999;
}


/* --- language, currency menu and search box ------------------------ */
#languagemenu form select, #currencymenu form select, #prodtypemenuform select {
width: 168px;
margin: 0;
padding: 0;
}

#searchbox input {
width: 148px;
}

#searchbox #searchbutton {
width: 10px;
text-align: right;
margin: 0;
padding: 0;
}

/* --- Template items ------------------------------------------------ */
#left_pad {
padding: 0px 5px 0px 8px;
}

#left h2 {
margin: 10px 0px 5px 0px;
font-weight: bold;
}

/* search and mailinglist forms */
#quicksearch form {
display: block;
}

#left input.submit {
height: 22px;
width: 30px;
}

#left input.text {
width: 95px;
}

#mailinglist label#email {
display: block;
margin: 0px 0px 2px 0px;
}

#mailinglist label#htmlemail {
display: block;
margin: 2px 0px 2px 0px;
}

#right h2 {
margin: 10px 0px 5px 0px;
font-weight: bold;
}

&amp;nbsp;

Shopping cart designed to provide a powerful base for php

CactuShop is an ASP (Active Server Pages) shopping cart designed to provide a powerful base for e-commerce web sites hosted on Microsoft Windows web servers. Main Features: W3C Standards Compliant CactuShop’s default template and the code created by all front end pages is designed to adhere to the W3C’s recommended XHTML specification. The placement and appearance of almost every page element can be controlled thanks to the extensive CSS implementation. CactuShop’s skinning system means graphic designers can work on the look and feel without touching any ASP files.

 

var blnComma = false;

function goInStock(id) {
var outOfStock = document.getElementById('outofstockline' + id);
var inStock = document.getElementById('addtobasketline' + id);
var outOfStockMessage = document.getElementById('outofstockmessage' + id);
outOfStock.style.display = 'none';
outOfStock.style.visibility = 'hidden';
outOfStockMessage.style.display = 'none';
outOfStockMessage.style.visibility = 'hidden';
inStock.style.display = '';
inStock.style.visibility = 'visible';

}

function goOutOfStock(id) {
var outOfStock = document.getElementById('outofstockline' + id);
var inStock = document.getElementById('addtobasketline' + id);
var outOfStockMessage = document.getElementById('outofstockmessage' + id);
inStock.style.display = 'none';
inStock.style.visibility = 'hidden';
outOfStockMessage.style.display = '';
outOfStockMessage.style.visibility = 'visible';
outOfStock.style.display = '';
outOfStock.style.visibility = 'visible';
}

function ExtractNum(stringNum)
{
//We're doing string functions to make sure that we're getting the price after "(+" of each option labels
stringNo = stringNum.slice(stringNum.lastIndexOf("(+"),stringNum.length);

var blnIsNegative = false;

if (stringNo.length < 2) {
//It didn't find "(+" so it must be "(-"
stringNo = stringNum.slice(stringNum.lastIndexOf("(-"),stringNum.length);
blnIsNegative = true;
}
if (stringNum.lastIndexOf("(+") == -1 &amp;&amp; stringNum.lastIndexOf("(-") == -1) {stringNo = 0;}
var parsedNo = "";
for(var n=0; n<stringNo.length; n++)
{
var i = stringNo.substring(n,n+1);
if(i=="1"||i=="2"||i=="3"||i=="4"||i=="5"||i=="6"||i=="7"||i=="8"||i=="9"||i=="0"||i==".")
parsedNo += i;
if(i==","){
blnComma = true;
parsedNo += "."; }
}

if (parsedNo.length > 0)
{
if (blnIsNegative)
{return '-' + parsedNo;}
else
{return parsedNo;}
}
else {return 0;}
}

function checkStock(id,outOfStockItems) {
// Build up out options selections
var txtPrice = document.getElementById('txtPrice' + id);
var origPrice = document.getElementById('origPrice' + id);
var txtPriceEx = document.getElementById('txtPriceEx' +id);
var numFixedPlaces = document.getElementById('numFixedPlaces' +id);
var selections = new Array();
var selectionCount = 0;
var numOptionsTotal = 0;

var strPrice = "s" + origPrice.value;
if (strPrice.indexOf(",") > 0) {blnComma = true;}

for (i=0;i<document.getElementById('options' + id).elements.length;i++) {
var element = document.getElementById('options' + id).elements[i];
if(element.name.substring(0,6)=='OPT_ID') {
switch(element.type)
{
case 'checkbox':
// is this checkbox selected?
if(element.checked == true) {
// use this ID
selections[selectionCount]=element.value;
selectionCount++;

// find all labels
var labels = document.getElementsByTagName('label');
// loop through all label elements
for (var m = 0; m < labels.length; m++) {
var label = labels[m];
var labelFor = label.htmlFor;
if (labelFor == element.id) {
numOptionsTotal = numOptionsTotal + parseFloat(ExtractNum(label.innerHTML));
}
}
} else {
// otherwise we have to get out the nocheckvalue
var nocheck = document.getElementById('options' + id).elements['NOCHECK_' + element.name]
selections[selectionCount]=nocheck.value;
selectionCount++;
}
break;

case 'radio':
if(element.checked == true) {
selections[selectionCount]=element.value;
selectionCount++;
// find all labels
var labels = document.getElementsByTagName('label');
// loop through all label elements
for (var m = 0; m < labels.length; m++) {
var label = labels[m];
var labelFor = label.htmlFor;
if (labelFor == element.id) {
numOptionsTotal = numOptionsTotal + parseFloat(ExtractNum(label.innerHTML));
}
}
}
break;

case 'select-one':
var Index = element.selectedIndex;
selections[selectionCount]=element.value;
selectionCount++;
numOptionsTotal = numOptionsTotal + parseFloat(ExtractNum(element.options[Index].text));
break;

default:
break;

}

}

}
txtPrice.value=( parseFloat(origPrice.value.replace(',','.')) +  parseFloat(numOptionsTotal)).toFixed(numFixedPlaces.value);
if (txtPriceEx != null){
var numTax = document.getElementById('numTax' + id);
txtPriceEx.value = (txtPrice.value.replace(',','.') * numTax.value).toFixed(numFixedPlaces.value);
}
if (blnComma) {
txtPrice.value= txtPrice.value.replace('.',',');
if (txtPriceEx != null) {txtPriceEx.value = txtPriceEx.value.replace('.',',');}
}
selections = (selections.sort());
var selection = selections.join('-');
var isOutOfStock = false;

// Does this combination exist in out outofstock array?
for(i=0; i<outOfStockItems.length; i++) {
if(outOfStockItems[i]==selection) {
isOutOfStock = true;
break;
}
}

if(isOutOfStock) {
goOutOfStock(id);
} else {
goInStock(id);
}
}

&amp;nbsp;

PHP Scripts for Dolphin is a smart community builder

Dolphin is a smart community builder.  It is the universal web community script written in PHP and MySQL. - Blog (photo upload, user can create different categories, permissions, comments) ,- The ability to sort member menu and groups on member menu,- The ability to approve “x” number of profiles simultaneously,- Cash profile info ,- General folder for all pics
- Smiles Pack ,- French, German, Russian, Dutch, Spanish Languages ,- Default integration of Ray Web Multimedia Software free version ,- Optional integration of phpBB, vBulletin ,- Optional integration of Barracuda Traffic Development Software ,- Speed Dating Module ,- Registration Security Images ,- Email member profile ,- On-fly photos auto scaling ,- Profile of the week and profile of the month ,- “Links”, “FAQ”, “About us”, “Contact us”, “Privacy”, “Terms of use”, “Services” pages ,- Affiliate system with commissions tracking routine and security tool.

 

<?php
/*
Copyright (C) 2006 Google Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/


/* This uses SAX parser to convert XML data into PHP associative arrays
* When invoking the constructor with the input data, strip out the first XML line
*
* Member field Description:
* $params: This stores the XML data. The attributes and contents of XML tags
* can be accessed as follows
*
* <addresses>
*  <anonymous-address id="123"> <test>data 1 </test>
*  </anonymous-address>
*  <anonymous-address id="456"> <test>data 2 </test>
*  </anonymous-address>
* </addresses>
*
* print_r($this->params) will return
Array
(
[addresses] => Array
(
[anonymous-address] => Array
(
[0] => Array
(
[id] => 123
[test] => Array
(
[VALUE] => data 1
)

)

[1] => Array
(
[id] => 456
[test] => Array
(
[VALUE] => data 2
)

)

)

)

)
* XmlParser returns an empty params array if it encounters
* any error during parsing
*/

class XmlParser {

var $params= array(); //Stores the object representation of XML data
var $root;
var $global_index = -1;

/* Constructor for the class
* Takes in XML data as input( do not include the <xml> tag
*/

function XmlParser($input) {
$xmlp = xml_parser_create();
xml_parse_into_struct($xmlp, $input, $vals, $index);
xml_parser_free($xmlp);
$this->root = strtolower($vals[0]['tag']);
$this->params = $this->UpdateRecursive($vals);
}

/* Returns true if a given variable represents an associative array */
function is_associative_array( $var ) {
return is_array( $var ) &amp;&amp; !is_numeric( implode( '', array_keys( $var ) ) );
}

/* Converts the output of SAX parser into a PHP associative array similar to the
* DOM parser output
*/

function UpdateRecursive($vals) {
$this->global_index++;
//Reached end of array
if($this->global_index >= count($vals))
return;
$params = array();
$tag = strtolower($vals[$this->global_index]['tag']);
$value = trim(@$vals[$this->global_index]['value']);
$type = $vals[$this->global_index]['type'];

//Add attributes
if(isset($vals[$this->global_index]['attributes'])) {
foreach($vals[$this->global_index]['attributes'] as $key=>$val) {
$key = strtolower($key);
$params[$tag][$key] = $val;
}
}

if($type == 'open') {
$new_arr = array();

//Read all elements at the next levels and add to an array
while($vals[$this->global_index]['type'] != 'close' &amp;&amp;
$this->global_index < count($vals)) {
$arr = $this->UpdateRecursive($vals);
if(count($arr) > 0) {
$new_arr[] = $arr;
}
}
$this->global_index++;
foreach($new_arr as $arr) {
foreach($arr as $key=>$val) {
if(isset($params[$tag][$key])) {
//If this key already exists
if($this->is_associative_array($params[$tag][$key])) {
//If this is an associative array and not an indexed array
// remove exisiting value and convert to an indexed array
$val_key = $params[$tag][$key];
array_splice($params[$tag][$key], 0);
$params[$tag][$key][0] =  $val_key;
$params[$tag][$key][] =  $val;
} else {
$params[$tag][$key][] =  $val;
}
} else {
$params[$tag][$key] =  $val;
}
}
}
}
else if ($type ==  'complete') {
if($value != '')
$params[$tag]['VALUE'] = $value;
}
else
$params = array();
return $params;
}

/* Returns the root of the XML data */
function GetRoot() {
return $this->root;
}

/* Returns the array representing the XML data */
function GetData() {
return $this->params;
}
}
?>

&amp;nbsp;

 

 

PHP Scripts for UC Google Checkout

Once they make a purchase, you can use Checkout to charge their credit cards, process their orders, and receive payment in your bank account.Ubercart provides Google Checkout as an alternate method of receiving and processing orders from your customers. Orders that are made using Google Checkout may still have payments and shipping processed through the Ubercart interface.This module has passed the certification process for both Checkout API and Order Processing API integration, providing the best link possible between your customer checkout and order administration processes in Ubercart with your Google Checkout account.

 

<?php
/*
Copyright (C) 2006 Google Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/


/*
* Class used to generate XML data
* Based on sample code available at http://simon.incutio.com/code/php/XmlWriter.class.php.txt
*/


class XmlBuilder {
var $xml;
var $indent;
var $stack = array();

function XmlBuilder($indent = '  ') {
$this->indent = $indent;
$this->xml = '<?xml version="1.0" encoding="utf-8"?>'."\n";
}

function _indent() {
for ($i = 0, $j = count($this->stack); $i < $j; $i++) {
$this->xml .= $this->indent;
}
}

//Used when an element has sub-elements
// This function adds an open tag to the output
function Push($element, $attributes = array()) {
$this->_indent();
$this->xml .= '<'.$element;
foreach ($attributes as $key => $value) {
$this->xml .= ' '.$key.'="'.htmlentities($value).'"';
}
$this->xml .= ">\n";
$this->stack[] = $element;
}

//Used when an element has no subelements.
//Data within the open and close tags are provided with the
//contents variable
function Element($element, $content, $attributes = array()) {
$this->_indent();
$this->xml .= '<'.$element;
foreach ($attributes as $key => $value) {
$this->xml .= ' '.$key.'="'.htmlentities($value).'"';
}
$this->xml .= '>'.htmlentities($content).'</'.$element.'>'."\n";
}

function EmptyElement($element, $attributes = array()) {
$this->_indent();
$this->xml .= '<'.$element;
foreach ($attributes as $key => $value) {
$this->xml .= ' '.$key.'="'.htmlentities($value).'"';
}
$this->xml .= " />\n";
}

//Used to close an open tag
function Pop($pop_element) {
$element = array_pop($this->stack);
$this->_indent();
if($element !== $pop_element)
die('XML Error: Tag Mismatch when trying to close "'. $pop_element. '"');
else
$this->xml .= "</$element>\n";
}

function GetXML() {
if(count($this->stack) != 0)
die ('XML Error: No matching closing tag found for " '. array_pop($this->stack). '"');
else
return $this->xml;
}
}
?>

&amp;nbsp;

Simple & Free Ajax-PHP Shopping Cart: jCart

jCart is a very simple & free shopping cart script that is built with PHP & jQuery.It offers a base Ajaxed basket interface that can be improved further by implementing the checkout pages.The script is unobtrusive, generates valid XHTML & design of it can be customized easily via CSS.jCart‘s inputs are validated on the server-side for a better security.

 

<?php
/*****************************************************************************
*                                                                           *
* Shop-Script FREE                                                          *
* Copyright (c) 2005 WebAsyst LLC. All rights reserved.                     *
*                                                                           *
****************************************************************************/


//core file

ini_set("display_errors", "1");

// -------------------------INITIALIZATION-----------------------------//

//make sure that URL does not contain something like index.php/?parameter1=1&amp;... //

//include core files
include("./cfg/connect.inc.php");
include("./includes/database/mysql.php");
include("./cfg/general.inc.php");
include("./cfg/appearence.inc.php");
include("./cfg/functions.php");
include("./cfg/category_functions.php");
include("./cfg/language_list.php");

session_start();

ini_set("display_errors", "1");

//init Smarty
require 'smarty/smarty.class.php';
$smarty = new Smarty; //core smarty object
$smarty_mail = new Smarty; //for e-mails

//select a new language?
if (isset($_POST["new_language"]))
{
$_SESSION["current_language"] = $_POST["new_language"];
}

//current language session variable
if (!isset($_SESSION["current_language"]) ||
$_SESSION["current_language"] < 0 || $_SESSION["current_language"] > count($lang_list))
$_SESSION["current_language"] = 0; //set default language
//include a language file
if (isset($lang_list[$_SESSION["current_language"]]) &amp;&amp; file_exists("./languages/".$lang_list[$_SESSION["current_language"]]->filename))
include("./languages/".$lang_list[$_SESSION["current_language"]]->filename); //include current language file
else
{
die("<font color=red><b>ERROR: Couldn't find language file!</b></font>");
}

//connect to the database
db_connect(DB_HOST,DB_USER,DB_PASS) or die (db_error());
db_select_db(DB_NAME) or die (db_error());

//get currency ISO 3 code
$currency_iso_3 = (defined('CONF_CURRENCY_ISO3')) ? CONF_CURRENCY_ISO3 : "USD" ;
$smarty->assign("currency_iso_3", $currency_iso_3);

//load all categories to array $cats to avoid multiple DB queries (frequently used in future - but not always!)
$cats = array();
$i=0;
$q = db_query("SELECT categoryID, name, parent, products_count, description, picture FROM ".CATEGORIES_TABLE." where categoryID<>0 ORDER BY name") or die (db_error());
while ($row = db_fetch_row($q))
{
$cats[$i++] = $row;
}

//set $categoryID
if (isset($_GET["categoryID"]) || isset($_POST["categoryID"]))
$categoryID = isset($_GET["categoryID"]) ? $_GET["categoryID"] : $_POST["categoryID"];
else $categoryID = 0;

$categoryID = (int)$categoryID;

//$productID
if (!isset($_GET["productID"]))
{
if (isset($_POST["productID"]))
{
$productID = (int)$_POST["productID"];
}
}
else
{
$productID = (int)$_GET["productID"];
}

//and different vars...
if (isset($_GET["register"]) || isset($_POST["register"]))
$register = isset($_GET["register"]) ? $_GET["register"] : $_POST["register"];
if (isset($_GET["update_details"]) || isset($_POST["update_details"]))
$update_details = isset($_GET["update_details"]) ? $_GET["update_details"] : $_POST["update_details"];
if (isset($_GET["order"]) || isset($_POST["order"]))
$order = isset($_GET["order"]) ? $_GET["order"] : $_POST["order"];
if (isset($_GET["check_order"]) || isset($_POST["check_order"]))
$check_order = isset($_GET["check_order"]) ? $_GET["check_order"] : $_POST["check_order"];
if (isset($_GET["proceed_ordering"]) || isset($_POST["proceed_ordering"]))
$proceed_ordering = isset($_GET["proceed_ordering"]) ? $_GET["proceed_ordering"] : $_POST["proceed_ordering"];

if (!isset($_SESSION["vote_completed"])) $_SESSION["vote_completed"] = array();

//checking for proper $offset init
$offset = isset($_GET["offset"]) ? $_GET["offset"] : 0;
if ($offset<0 || $offset % CONF_PRODUCTS_PER_PAGE) $offset = 0;




// -------------SET SMARTY VARS AND INCLUDE SOURCE FILES------------//

if (isset($productID)) //to rollout categories navigation table
{
$q = db_query("SELECT categoryID FROM ".PRODUCTS_TABLE." WHERE productID='$productID'") or die (db_error());
$r = db_fetch_row($q);
if ($r) $categoryID = $r[0];
}

//set Smarty include files dir
$smarty->template_dir = $lang_list[$_SESSION["current_language"]]->template_path;
$smarty_mail->template_dir = $lang_list[$_SESSION["current_language"]]->template_path."/mail";

//assign core Smarty variables

$smarty->assign("lang_list", $lang_list);
$smarty->assign("lang_list_count", count($lang_list));

if (isset($_SESSION["current_language"])) $smarty->assign("current_language", $_SESSION["current_language"]);
// - following vars are used as hidden in the customer survey form
$smarty->assign("categoryID", $categoryID);
if (isset($productID)) $smarty->assign("productID", $productID);
if (isset($_GET["currency"])) $smarty->assign("currency", $_GET["currency"]);
if (isset($_GET["user_details"])) $smarty->assign("user_details", $_GET["user_details"]);
if (isset($_GET["aux_page"])) $smarty->assign("aux_page", $_GET["aux_page"]);
if (isset($_GET["show_price"])) $smarty->assign("show_price", $_GET["show_price"]);
if (isset($_GET["adv_search"])) $smarty->assign("adv_search", $_GET["adv_search"]);
if (isset($_GET["searchstring"])) $smarty->assign("searchstring", $_GET["searchstring"]);
if (isset($register)) $smarty->assign("register", $register);
if (isset($order)) $smarty->assign("order", $order);
if (isset($check_order)) $smarty->assign("check_order", $check_order);

//set defualt main_content template to homepage
$smarty->assign("main_content_template", "home.tpl.html");
// includes all .php files from includes/ dir
$includes_dir = opendir("./includes");
while ( ($inc_file = readdir($includes_dir)) != false )
if (strstr($inc_file,".php"))
{
include("./includes/$inc_file");
}

// output:

//security warnings!
if (file_exists("./install.php"))
{
echo "<center>".WARNING_DELETE_INSTALL_PHP."</center>";
}
if (file_exists("./forgot_password.php"))
{
echo "<center>".WARNING_DELETE_FORGOTPW_PHP."</center>";
}

if (!is_writable("./products_pictures") || !is_writable("./templates_c"))
{
echo "<center>".WARNING_WRONG_CHMOD."</center>";
}

//show administrative mode link if logged in as administrator
include("./checklogin.php");
if (isset($_SESSION["log"]) &amp;&amp; isset($_SESSION["pass"]))
echo "<br><center><a href=\"admin.php\"><font color=red>".ADMINISTRATE_LINK."</font></a></center><p>";

//show Smarty output
$smarty->display($lang_list[$_SESSION["current_language"]]->template_path."index.tpl.html");

?>

&amp;nbsp;

Shop-Script FREE PHP shopping cart software

Shop-Script FREE PHP shopping cart software is lite PHP shopping cart solution which is available for free download. Shop-Script FREE will help you instantly create a search engine friendly online store and start accepting online orders and payments for these orders by PayPal. Shop-Script FREE is written in PHP with the use of MySQL. Works on PHP 4 and PHP 5. General features: Fully open source code (PHP); MySQL database driven; Very fast; Uses Smarty template engine; Design is separate from PHP scripts and is pretty easy to customize; Works exactly the same in all major browsers – Internet Explorer, Firefox, Opera, Safari; Multilingual interface “wrapper” – all interface elements which are not stored in the database can be easily translated into any language; Unlimited number of products; Hierarchical product category tree (unlimited category nesting); Basic product description tools – upload product image, edit description in HTML (WYSIWYG editor is not included), price, customer rating; Structured presentation of products in storefront effectively indexed by search engines; Product search by name; Shopping cart (session based); Simplest one-step checkout; Orders are stored in the database; Order notifications by email.

 

<?php
/*****************************************************************************
*                                                                           *
* Shop-Script FREE                                                          *
* Copyright (c) 2005 WebAsyst LLC. All rights reserved.                     *
*                                                                           *
****************************************************************************/


ini_set("display_errors", "1");

//main admin module

function add_department($admin_dpt)
//adds new $admin_dpt to department list
{
global $admin_departments;

$i = 0;
while ($i<count($admin_departments) &amp;&amp; $admin_departments[$i]["sort_order"] < $admin_dpt["sort_order"]) $i++;
for ($j=count($admin_departments)-1; $j>=$i; $j--)
$admin_departments[$j+1] = $admin_departments[$j];
$admin_departments[$i] = $admin_dpt;
}

function __escape_string($_Data)
{
return str_replace("'", "\'", str_replace('\', '\\\', stripslashes($_Data)));
}

include("./cfg/connect.inc.php");
include("./includes/database/mysql.php");
include("./cfg/general.inc.php");
include("./cfg/appearence.inc.php");
include("./cfg/functions.php");
include("./cfg/category_functions.php");
include("./cfg/language_list.php");

session_start();

//authorized login check
include("./checklogin.php");
if (!isset($_SESSION["log"]) || !isset($_SESSION["pass"])) //unauthorized
{
//show authorization form
header("Location: access_admin.php");
die("<script>window.location='
access_admin.php';</script>");
}

define('
WORKING_THROUGH_ADMIN_SCRIPT', true); //for security purposes

//logout?
if (isset($_GET["logout"])) //logout
{
//show authorization form
$_SESSION["log"] = "";
$_SESSION["pass"] = "";
unset($_SESSION["log"]);
unset($_SESSION["pass"]);
die("<script>window.location='
access_admin.php';</script>");
}

//init Smarty
require '
smarty/smarty.class.php';
$smarty = new Smarty; //core smarty object
$smarty_mail = new Smarty; //for e-mails

if (!isset($_SESSION["current_language"]) ||
$_SESSION["current_language"] < 0 || $_SESSION["current_language"] > count($lang_list))
$_SESSION["current_language"] = 0; //set default language

if (isset($lang_list[$_SESSION["current_language"]]) &amp;&amp; file_exists("./languages/".$lang_list[$_SESSION["current_language"]]->filename))
include("./languages/".$lang_list[$_SESSION["current_language"]]->filename); //include current language file
else
{
die("<font color=red><b>ERROR: Couldn'
t find language file!</b></font>");
}


//connect to database
db_connect(DB_HOST,DB_USER,DB_PASS) or die (db_error());
db_select_db(DB_NAME) or die (db_error());

//set Smarty include files dir
$smarty->template_dir = $lang_list[$_SESSION["
current_language"]]->template_path."/admin";
$smarty_mail->template_dir = $lang_list[$_SESSION["
current_language"]]->template_path."/mail";

//get currency ISO 3 code
$currency_iso_3 = (defined('CONF_CURRENCY_ISO3')) ? CONF_CURRENCY_ISO3 : "
USD" ;
$smarty->assign("
currency_iso_3", $currency_iso_3);

// several functions

function mark_as_selected($a,$b) //required for excel import
//returns "
selected" if $a == $b
{
return !strcmp($a,$b) ? "
selected" : "";

} //mark_as_selected


function get_NOTempty_elements_count($arr) //required for excel import
//gets how many NOT NULL (not empty strings) elements are there in the $arr
{
$n = 0;
for ($i=0;$i<count($arr);$i++)
if (trim($arr[$i]) != "
") $n++;
return $n;
} //get_NOTempty_elements_count


//end of functions definition

//define department and subdepartment
if (!isset($_GET["
dpt"]))
{
$dpt = isset($_POST["
dpt"]) ? $_POST["dpt"] : "";
}
else $dpt = $_GET["
dpt"];
if (!isset($_GET["
sub"]))
{
if (isset($_POST["
sub"])) $sub = $_POST["sub"];
}
else $sub = $_GET["
sub"];

//define smarty template
$smarty->assign("
admin_main_content_template", "default.tpl.html");
$smarty->assign("
current_dpt", $dpt);

//get new orders count
$q = db_query("
select count(*) from ".ORDERS_TABLE) or die (db_error());
$n = db_fetch_row($q);
$smarty->assign("
new_orders_count", $n[0]);

$admin_departments = array();

// includes all .php files from includes/ dir
$includes_dir = opendir("
./includes/admin");
$file_count = 0;
while ( ($inc_file = readdir($includes_dir)) != false )
if (strstr($inc_file,"
.php"))
{
include("
./includes/admin/$inc_file");
$file_count++;
}

if (isset($sub)) $smarty->assign("
current_sub", $sub);

$smarty->assign("
admin_departments", $admin_departments);
$smarty->assign("
admin_departments_count", $file_count);

//show Smarty output
$smarty->display($lang_list[$_SESSION["
current_language"]]->template_path."admin/index.tpl.html");

?>


&amp;nbsp;

PHP PayPal shopping cart script

This free PHP PayPal shopping cart script can display an unlimited number of products from a Microsoft Excel spreadsheet. Just export your Microsoft Excel product spreadsheet as a delimited text file (tab) and your Paypal shopping cart can be ready in minutes.

 

<"e;php

/**************************************************************

Free PHP PayPal shopping cart script

download the latest version from:
http://www.perl-studio.com/paypal/free
Copyright Notice
Copyright (c) 1996-2002 AyerSoft/Perl-Studio. All rights reserved.

#    Created on Sunday, September 15, 2002  using
#    Perl Studio by AyerSoft copyright(C) 2002
###################################################
#    You are free to customize this script as you wish, but do not
#    redistribute without written permission from AyerSoft.
#    DISCLAIMER
#    The information and code provided is provided 'as is' without
#    warranty of any kind, either express or implied. In no event
#    shall the AyerSoft Company be liable for any damages whatsoever
#    including direct, indirect, incidental, consequential, loss of
#    business profits or special damages, even if the author has been
#    advised  of the possibility of such damages.
#    DO NOT USE THIS SCRIPT UNLESS YOU CAN FULLY AGREE WITH THIS
#    DISCLAIMER.
#####################################################

This PHP PayPal shopping cart script can display an unlimited number
of products from a Microsoft Excel spreadsheet. Just export your
Microsoft Excel product spreadsheet as a delimited text file (tab)
and your Paypal shopping cart can be ready in minutes

Implementation:

Enter the details of each item you wish to sell into your
Microsoft Excel product spreadsheet.

Export your Microsoft Excel product spreadsheet as a delimited
text file (tab) saved as products.txt.

Edit the PayPal business name (email address) in the PHP PayPal
shopping cart scripts, to reflect the PayPal email address that
you receive the PayPal payments at.

Upload the PHP PayPal shopping cart scripts to a FTP directory
on your WebSite.

Upload the products.txt to the same FTP directory the PHP PayPal
shopping cart scripts are in. Code SYNOPSIS:

The PHP PayPal shopping cart script reads in the delimited text file
and writes the HTML add to cart buttons for each product in the delimited text file.
All the PayPal add to cart buttons code is automatically generated.
The PayPal view cart button code is also automatically generated. Microsoft Excel product spreadsheet Implementation:

Three required columns/fields
item_number
item_name
item_amount
The item_number field is an ID, SKU or tracking number for your item.
The item_name field is the name of the item or service you wish to sell.
The item_amount field is the price of the item you wish to sell.

*/

// start user configuration
//=============================================================

/* Quick install:
edit the $business_email variable
upload the script and products.txt to the same FTP directory
*/

/* $products_path: path to Microsoft Excel tab delimited text
file with fields item_number, item_name, item_amount on each line.
*/

$products_path = "
products.txt";

// PayPal business name (email address)

$business_email = "
paypal@no-spam.com";

/* optional user configuration */
/***************************************************************/

// back ground color for products table

$bgcolor="
#ffffff";

// type of delimiter used in products delimited text file

$delimiter = "\t";

/* $image_url = Add Your Logo
Customize the look of your PayPal payment pages by adding your logo. This
image, which must be 150 by 50 pixels in size, will appear in the upper left
hand corner of the page when your customer presses your Shopping Cart
button.
*/


$image_url = "https://www.paypal.com/images/logo-xclick.gif";

/* $return_url = Successful Payment URL
Enter the URL where you would like to send your customers after they have
completed payment. Once your customer has completed their payment, they will
see a payment confirmation page. From this page, they will press the
'Continue' button and return to the Successful Payment URL you have
specified. If you do not enter a Successful Payment URL, customers who click
this link will be taken to a PayPal web page.
*/


$return_url = "http://$HTTP_HOST";

/* $cancel_return = Cancel Payment URL
Enter the URL where you would like to send your customers if they cancel
their payment at any point in the Shopping Cart payment flow. If you do
not enter a Cancel Payment URL, customers who click this link will be taken
to a PayPal web page.
*/


$cancel_return = "http://$HTTP_HOST";

/*
Enter the currency symbols PayPal uses to designate US dollars
or Euros or Pounds Sterlings. Enter a backslash before the $ symbol.

US: $
Euros:  �
Pounds Sterling: �
Canadian Dollar (C$)
Japanese Yen (�)

*/


$m_symbol = "$";

/*
The currency of the payment is U.S.Dollars: USD
The currency of the payment is British Pounds Sterling: GBP
The currency of the payment is Euros: EUR
The currency of the payment is Canadian Dollar: CAD
The currency of the payment is Yen: JPY
*/


$currency_code = "USD";

//=============================================================
// end user configurationsite_header('Our Products');/* load products.txt.  */
$fp = fopen($products_path, "r");
$file_contents = fread($fp, filesize($products_path));
fclose($fp);
// Place each line in the products file into an array
$line = explode("\n", $file_contents);
$i = 0;
/* urlencode the PayPal business email address */
$email = urlencode($business_email);

/* loop through the array of products and display the HTML add to cart buttons */
while($i <= sizeof($line)) {
/* split the line with delimiter used in the file */
list ($item_number,$item_name,$item_amount) = split($delimiter, $line[$i],3);
if($item_amount > 0){
$number = urlencode($item_number);
$item_name = str_replace("\"", " ", $item_name);
$name_value = $item_name;
/* remove characters that migh cause problems with the javascript functions */
$name_value = preg_replace("/[\,\;\`\'\|\*\~\^\[\]\{\}\$\"]/", " ", $name_value);
$name_value = preg_replace("/^\s+|\s+$/", "", $name_value);
$name = urlencode($name_value);
$amount = urlencode($item_amount);
$url = "https://www.paypal.com/cart/add=1&amp;business=$email&amp;item_number=$number&amp;item_name=$name&amp;amount=$amount¤cy_code=$currency_code&amp;bn=AyerSoft.PerlStudio";
$url .= "&amp;return=$return_url&amp;cancel_return=$cancel_return&amp;image_url=$image_url";

/* create the code for the add to cart buttons for each product */
$html_row=<<<HTML_ROW

<tr>
<td>$item_number</td><td>$item_name</td><td>$m_symbol$item_amount</td>
<td>
<a href="javascript:onclick=window.paypalwinOpen('$url');"><img src="http://images.paypal.com/images/x-click-but22.gif" border="0"></a>
</td></tr>

HTML
_ROW;
/* display the code for the add to cart buttons for each product */
echo $html_row;
}
$i++;
}

site_footer();
exit;

/* site header and footer functions */
/* read in a html header file or print out a HTML header section */
//************************************************************************************
function site_header($title) {
global $DOCUMENT_ROOT,$bgcolor;

$file = $DOCUMENT_ROOT .'/header.html';
if (!(is_readable($file))){
$file = "header.html";
}$header=<<<HEADER
<HTML>
<HEAD>
<TITLE>$title</TITLE>

<script language="JavaScript">
<!--

var pixels_width = window.screen.width;
var pixels_height = window.screen.height;

var nWidth= "600";
var nHeight="400";

if(pixels_width < 740){
nWidth = "540";
}
if(pixels_height < 540){
nHeight = "350";
}

var optionString = "scrollbars,location,resizable,status,";
optionString += "height=" + nHeight + ",width=" + nWidth;
optionString += ",screenX=10,screenY=10,top=10,left=10";

var cartWindow = null;

function paypalwinOpen(url){
if (!cartWindow || cartWindow.closed) {
cartWindow = window.open(url,"cart",optionString);
} else {
// window already exists, so bring it forward
cartWindow.location.href=url;
cartWindow.focus();
}

}

// -->
</script>

<style type="text/css">
.cartTD    {font-size: 11px; font-family: verdana,helvetica,arial,sans-serif;}
</style>

</HEAD>

HEADER
;    echo $header;
if ((is_readable($file))){
include($file);
}
echo "\n<table width=550 bgcolor=\"$bgcolor\" cellspacing=0 cellpadding=0 border=1>\n";


}
/* read in a html footer file or print out a HTML footer section */
//************************************************************************************
function site_footer() {
global $DOCUMENT_ROOT,$email;

$file = $DOCUMENT_ROOT .'/footer.html';
if (!(is_readable($file))){
$file = "footer.html";
}

$cart_url = "https://www.paypal.com/cart/display=1&amp;business=$email";

$footer=<<<FOOTER

</table>
<p align=center>
<a href="javascript:onclick=window.paypalwinOpen('$cart_url');"><img src="https://www.paypal.com/images/view_cart_02.gif" border="0"></a>
</p>

FOOTER
;

echo $footer;

if ((is_readable($file))){
include($file);
}
else{
echo "\n


</body>
</HTML>\n"
;
}

}
//************************************************************************************

"e;>

&amp;nbsp;

ApPHP Shopping Cart is a PHP/MySQL for php

ApPHP Shopping Cart is a PHP/MySQL open-source e-commerce system. It is a fully customizable shopping cart, specially designed for web. ApPHP Shopping Cart allows visitors to collect items in a virtual shopping cart over multiple product web pages without losing the items ordered.The script provides all necessary features including multi-currency and multi-language support. Visitors may view the contents of their shopping cart at any time and may add or delete items as needed. The program automatically calculates the subtotal, shipping charges, and total price. When a visitor decides to checkout, the order information is collected in database a receipt is sent to the shopper.Supports unlimited number of products and categories. Orders Management allows customer to view their orders and manage them. Powerful Administrator Control Panel. Administrators and customers management. Includes modules: News, Gallery, Contacts Us, Comments, CMS for pages with WYSIWYG etc. Many other features.

 

#! /usr/local/bin/php -n
<?php

/*
+----------------------------------------------------------------------+
| PHP Version 5                                                        |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2006 The PHP Group                                |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license,      |
| that is bundled with this package in the file LICENSE, and is        |
| available through the world-wide-web at the following url:           |
| http://www.php.net/license/3_01.txt                                  |
| If you did not receive a copy of the PHP license and are unable to   |
| obtain it through the world-wide-web, please send a note to          |
| license@php.net so we can mail you a copy immediately.               |
+----------------------------------------------------------------------+
| Authors: Marcus Boerger <helly@php.net>                              |
+----------------------------------------------------------------------+
*/


/* This script lists extension-, class- and method names that contain any
underscores. It omits magic names (e.g. anything that starts with two
underscores but no more).
*/


$cnt_modules = 0;
$cnt_classes = 0;
$cnt_methods = 0;
$err = 0;

$classes = array_merge(get_declared_classes(), get_declared_interfaces());

$extensions = array();

foreach(get_loaded_extensions() as $ext) {
$cnt_modules++;
if (strpos($ext, "_") !== false) {
$err++;
$extensions[$ext] = array();
}
}

$cnt_classes = count($classes);

foreach($classes as $c) {
if (strpos($c, "_") !== false) {
$err++;
$ref = new ReflectionClass($c);
if (!($ext = $ref->getExtensionName())) {;
$ext = $ref->isInternal() ? "<internal>" : "<user>";
}
if (!array_key_exists($ext, $extensions)) {
$extensions[$ext] = array();
}
$extensions[$ext][$c] = array();
foreach(get_class_methods($c) as $method) {
$cnt_methods++;
if (strpos(substr($method, substr($method, 0, 2) != "__"  ? 0 : 2), "_") !== false) {
$err++;
$extensions[$ext][$c][] = $method;
}
}
}
else
{
$cnt_methods += count(get_class_methods($c));
}
}

$cnt = $cnt_modules + $cnt_classes + $cnt_methods;

printf("\n");
printf("Modules: %5d\n", $cnt_modules);
printf("Classes: %5d\n", $cnt_classes);
printf("Methods: %5d\n", $cnt_methods);
printf("\n");
printf("Names:   %5d\n", $cnt);
printf("Errors:  %5d (%.1f%%)\n", $err, round($err * 100 / $cnt, 1));
printf("\n");

ksort($extensions);
foreach($extensions as $ext => &amp;$classes) {
echo "Extension: $ext\n";
ksort($classes);
foreach($classes as $classname => &amp;$methods) {
echo "  Class: $classname\n";
ksort($methods);
foreach($methods as $method) {
echo "    Method: $method\n";
}
}
}

printf("\n");

?>

&amp;nbsp;

PHP Script: Simple PHP Shopping Cart

The simple PHP shopping cart is the easiest way to add e-commerce to your website. Display products on any HTML or PHP page. Easily style the checkout process to match your website, and process payments through,or Direct. Try the online demo to see just how easy it is to make a new product.

 

<?php


$usage = <<<USAGE

Usage
: php find_tested.php [path_to_test_files] ([extension])

Outputs test coverage information for functions and methods in csv format.
Supplying an optional extension name outputs only information for functions and methods from that extension.

Output format:
Extension, Class Name, Method/Function Name, Test Status, Test Files

A test status of "verify" for a method means that there is at least one other method of the same name, so test coverage must be verified manually.

USAGE;


/* method record fields */
define("CLASS_NAME", "CLASS_NAME");
define("METHOD_NAME", "METHOD_NAME");
define("EXTENSION_NAME", "EXTENSION_NAME");
define("IS_DUPLICATE", "IS_DUPLICATE");
define("IS_TESTED", "IS_TESTED");
define("TESTS", "TESTS");


// process command line args
$num_params = $argc;
if ($num_params < 2 || $num_params > 3) {
die($usage);
}

$extension_test_path = $argv[1];

if ($num_params == 3) {
$extension_name = $argv[2];

// check extension exists
$extensions = get_loaded_extensions();
if (!in_array($extension_name, $extensions)) {
echo "Error: extension $extension_name is not loaded. Loaded extensions:\n";
foreach($extensions as $extension) {
echo "$extension\n";
}
die();
}
} else {
$extension_name = false;
}


$method_info = populate_method_info();

if ($extension_name != false) {
// get only the methods from the extension we are querying
$extension_method_info = array();
foreach($method_info as $method_record) {
if (strcasecmp($extension_name, $method_record[EXTENSION_NAME]) == 0) {
$extension_method_info[] = $method_record;
}
}
} else {
$extension_method_info = $method_info;
}

get_phpt_files($extension_test_path, $count, $phpt_files);

$extension_method_info = mark_methods_as_tested($extension_method_info, $phpt_files);


foreach($extension_method_info as $record) {
echo $record[EXTENSION_NAME] . ",";
echo $record[CLASS_NAME] . ",";
echo $record[METHOD_NAME] . ",";
echo $record[IS_TESTED] . ",";
echo $record[TESTS] . "\n";
}

/**
* Marks the "tested" status of methods in $method_info according
* to whether they are tested in $phpt_files
*/

function mark_methods_as_tested($method_info, $phpt_files) {

foreach($phpt_files as $phpt_file) {
$tested_functions = extract_tests($phpt_file);

foreach($tested_functions as $tested_function) {

// go through method info array marking this funtion as tested
foreach($method_info as &amp;$current_method_record) {
if (strcasecmp($tested_function, $current_method_record[METHOD_NAME]) == 0) {
// matched the method name
if ($current_method_record[IS_DUPLICATE] == true) {
// we cannot be sure which class this method corresponds to,
// so mark method as needing to be verified
$current_method_record[IS_TESTED] = "verify";
} else {
$current_method_record[IS_TESTED] = "yes";
}
$current_method_record[TESTS] .= $phpt_file . "; ";
}
}
}
}
return $method_info;
}

/**
* returns an array containing a record for each defined method.
*/

function populate_method_info() {

$method_info = array();

// get functions
$all_functions = get_defined_functions();
$internal_functions = $all_functions["internal"];

foreach ($internal_functions as $function) {
// populate new method record
$function_record = array();
$function_record[CLASS_NAME] = "Function";
$function_record[METHOD_NAME] = $function;
$function_record[IS_TESTED] = "no";
$function_record[TESTS] = "";
$function_record[IS_DUPLICATE] = false;

// record the extension that the function belongs to
$reflectionFunction = new ReflectionFunction($function);
$extension = $reflectionFunction->getExtension();
if ($extension != null) {
$function_record[EXTENSION_NAME] = $extension->getName();
} else {
$function_record[EXTENSION_NAME] = "";
}
// insert new method record into info array
$method_info[] = $function_record;
}

// get methods
$all_classes = get_declared_classes();
foreach ($all_classes as $class) {
$reflectionClass = new ReflectionClass($class);
$methods = $reflectionClass->getMethods();
foreach ($methods as $method) {
// populate new method record
$new_method_record = array();
$new_method_record[CLASS_NAME] = $reflectionClass->getName();
$new_method_record[METHOD_NAME] = $method->getName();
$new_method_record[IS_TESTED] = "no";
$new_method_record[TESTS] = "";

$extension = $reflectionClass->getExtension();
if ($extension != null) {
$new_method_record[EXTENSION_NAME] = $extension->getName();
} else {
$new_method_record[EXTENSION_NAME] = "";
}

// check for duplicate method names
$new_method_record[IS_DUPLICATE] = false;
foreach ($method_info as &amp;$current_record) {
if (strcmp($current_record[METHOD_NAME], $new_method_record[METHOD_NAME]) == 0) {
$new_method_record[IS_DUPLICATE] = true;
$current_record[IS_DUPLICATE] = true;
}
}
// insert new method record into info array
$method_info[] = $new_method_record;
}
}

return $method_info;
}

function get_phpt_files($dir, &amp;$phpt_file_count, &amp;$all_phpt)
{
$thisdir = dir($dir.'/'); //include the trailing slash
while(($file = $thisdir->read()) !== false) {
if ($file != '.' &amp;&amp; $file != '..') {
$path = $thisdir->path.$file;
if(is_dir($path) == true) {
get_phpt_files($path , $phpt_file_count , $all_phpt);
} else {
if (preg_match("/\w+\.phpt$/", $file)) {
$all_phpt[$phpt_file_count] = $path;
$phpt_file_count++;
}
}
}
}
}

function  extract_tests($file) {
$code = file_get_contents($file);

if (!preg_match('/--FILE--\s*(.*)\s*--(EXPECTF|EXPECTREGEX|EXPECT)?--/is', $code, $r)) {
//        print "Unable to get code in ".$file."\n";
return array();
}

$tokens = token_get_all($r[1]);
$functions = array_filter($tokens, 'filter_functions');
$functions = array_map( 'map_token_value',$functions);
$functions = array_unique($functions);

return $functions;
}

function filter_functions($x) {
return $x[0] == 307;
}

function map_token_value($x) {
return $x[1];
}


?>



&amp;nbsp;