code stringlengths 1 2.01M | repo_name stringlengths 3 62 | path stringlengths 1 267 | language stringclasses 231 values | license stringclasses 13 values | size int64 1 2.01M |
|---|---|---|---|---|---|
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
include_once("UserGroup.php"); //--> User Group
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$objUserGroup = new UserGroup($objSession->getLanguage(), $uid); //--> User Group
$error_message = '';
$name = '';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_POST['Submit'])){
$name = $_POST['name'];
if(!empty($name)){
$isReturn = $objUserGroup->add($arrOperate, $name);
if($isReturn)
$error_message = 'add group successfully.';
else
$error_message = 'add group fail.';
}else{
$error_message = 'The user group name should\'t be empty.';
}
}
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = CACHE_SYS_DIR;
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('backurl',$backurl);
$smarty->assign('error_message', $error_message);
$smarty->assign('name', $name);
$smarty->display('listUserGroup_Add.htm');
?>
| 123gohelmetsv2 | trunk/admin/system/listUserGroup_Add.php | PHP | asf20 | 1,347 |
<?php
include_once("../configs/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Index.php"); //--> Index
$objIndex = new Index(DEFAULT_LAN, 0); //--> Index
$objIndex->createBookIndex('id, name FROM books', 'index_book');
$objIndex->createBookIndex('id, name FROM audio', 'index_audio');
$objIndex->createBookIndex('id, name FROM vedio', 'index_vedio');
$objIndex->createBookIndex('id, name FROM pic', 'index_pic');
$objIndex->createBookIndex('id, title FROM info', 'index_joke', ' and classid in(16,17,18,47,48,49)');
$objIndex->createBookIndex('id, title FROM info', 'index_news', ' and classid in(5,62,63,64)');
?> | 123gohelmetsv2 | trunk/admin/system/createIndex.php | PHP | asf20 | 692 |
<?php
include_once("../configure/admin.config.inc.php");//--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Users.php"); //--> User
include_once("Operation.php"); //--> Operation
include_once("UserGroup.php"); //--> Menu group class
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation instance
$objUserGroup = new UserGroup($objSession->getLanguage(), $objSession->getUserID()); //--> Menu group instance
$objUser = new Users($uid); //--> user
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_GET['id']) && !empty($_GET['id'])){
$id = $_GET['id'];
if($gid == $id){
$error_message = 'invalid delete user group.';
}else if(count($objUser->lists($arrOperate, " WHERE groupid=$id", 1, 1, '')) > 0) {
$error_message = "can't delete the user group, because that have user above the user group.";
}else{
$isReturn = $objUserGroup->delete($arrOperate, $id);
if($isReturn)
$error_message = 'delete group successfully.';
else
$error_message = 'delete group fail.';
}
}
echo "<script language='javascript'>";
echo "alert(\"$error_message\");";
echo "location.href=\"".$_SERVER['HTTP_REFERER']."\";";
echo "</script>";
//$backurl = $_SERVER['HTTP_REFERER'];
//header("Location: $backurl");
?>
| 123gohelmetsv2 | trunk/admin/system/listUserGroup_Delete.php | PHP | asf20 | 1,407 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
include_once("UserGroup.php"); //--> User Group
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$objUserGroup = new UserGroup($objSession->getLanguage(), $uid); //--> User Group
$error_message = '';
$strMenuGroupName = '';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(count($arrOperate) > 0){
$strQuery = $_SERVER["REQUEST_URI"];
$arrUrlInfo = pathinfo($strQuery);
$selfFileName = $arrUrlInfo['filename'];
$arrOperateAllInfo = $objOperate->listFromCustom($arrOperate, " WHERE id in (".implode(",", $arrOperate).")");
$i = 0;
foreach($arrOperateAllInfo as $key => $value){
$strFileName = $selfFileName."_".$value['name'].".php";
if(file_exists($strFileName)){
$arrOperateInfo[$i]['name'] = $value['name'];
$arrOperateInfo[$i]['viewName'] = $value['name'];
$i++;
}
}
}
$arrUserGroupList = $objUserGroup->lists($arrOperate, " WHERE id > $gid", $page, DISPLAY_DATA_SIZE, '');
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = CACHE_SYS_DIR;
$smarty->assign('error_message', $error_message);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('selfFileName', $selfFileName);
$smarty->assign('arrOperateInfo', $arrOperateInfo);
$smarty->assign('arrUserGroupList', $arrUserGroupList);
$smarty->assign('arrMenuList', $arrMenuList);
$smarty->assign('PAGE_BAR', $objUserGroup->pagenav);
$smarty->display('listUserGroup.htm');
?>
| 123gohelmetsv2 | trunk/admin/system/listUserGroup.php | PHP | asf20 | 1,868 |
<?php
include_once("../configure/admin.config.inc.php");//--> admin global var
include_once("account.inc.php"); //--> account var
include_once("db.inc.php"); //--> db global var
include_once("Operation.php"); //--> Operation
include_once("Users.php"); //--> Users
include_once("Account.php"); //--> Account
include_once("AccountLog.php"); //--> AccountLog
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation instance
$objUsers = new Users($uid); //--> Users
$objAccount = new Account($uid); //--> Account
$objAccountLog = new AccountLog($uid); //--> AccountLog
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_GET['id']) && !empty($_GET['id'])){
$id = $_GET['id'];
$isReturn = $objUsers->editStatus($arrOperate, $id, "normal");
if($isReturn){
$error_message = 'Live successfully.';
//$amount = $objAccountLog->fetchSumCounting($arrOperate, SOURCE_USER, $id);
//echo 'a='.$amount;
$amount = $objAccountLog->isExistOperate($arrOperate, $id, SOURCE_USER, $id, SOURCE_TYPE_ADD);
if($amount <= 0)
$objAccount->addAccounting($arrOperate, DEFAULT_LAN, $uid, $id, DEFAULT_USER_ADD_BALANCE, SOURCE_USER, $id, SOURCE_TYPE_ADD, $_SERVER['REMOTE_ADDR']);
}else
$error_message = 'Live failure.';
}
echo "<script language='javascript'>";
echo "alert(\"$error_message\");";
echo "location.href=\"".$_SERVER['HTTP_REFERER']."\";";
echo "</script>";
//$backurl = $_SERVER['HTTP_REFERER'];
//header("Location: $backurl");
?>
| 123gohelmetsv2 | trunk/admin/system/listUser_Live.php | PHP | asf20 | 1,620 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$error_message = '';
$strMenuGroupName = '';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(count($arrOperate) > 0){
$strQuery = $_SERVER["REQUEST_URI"];
$arrUrlInfo = pathinfo($strQuery);
$selfFileName = $arrUrlInfo['filename'];
$arrOperateAllInfo = $objOperate->listFromCustom($arrOperate, " WHERE id in (".implode(",", $arrOperate).")");
$i = 0;
foreach($arrOperateAllInfo as $key => $value){
$strFileName = $selfFileName."_".$value['name'].".php";
if(file_exists($strFileName)){
$arrOperateInfo[$i]['name'] = $value['name'];
$arrOperateInfo[$i]['viewName'] = $value['name'];
$i++;
}
}
}
$arrDataList = $objOperate->lists($arrOperate, "", $page, DISPLAY_DATA_SIZE, '');
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = CACHE_SYS_DIR;
$smarty->assign('error_message', $error_message);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('selfFileName', $selfFileName);
$smarty->assign('arrOperateInfo', $arrOperateInfo);
$smarty->assign('arrDataList', $arrDataList);
$smarty->assign('arrMenuList', $arrMenuList);
$smarty->assign('PAGE_BAR', $objMenu->pagenav);
$smarty->display('listOperation.htm');
?>
| 123gohelmetsv2 | trunk/admin/system/listOperation.php | PHP | asf20 | 1,693 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation instance
$error_message = '';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(!empty($id)){
$arrInfo = $objOperate->getFromID($arrOperate, $id);
$name = $arrInfo['name'];
}
if(isset($_POST['Submit'])){
$name = $_POST['name'];
if(empty($name)){
$error_message = 'The operation name should\'t be empty.';
}
if(empty($error_message)){
$isReturn = $objOperate->edit($arrOperate, $id, $name);
if($isReturn)
$error_message = 'edit successfully.';
else
$error_message = 'edit failure.';
}
}
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = CACHE_SYS_DIR;
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('id', $id);
$smarty->assign('backurl',$backurl);
$smarty->assign('error_message', $error_message);
$smarty->assign('name', $name);
$smarty->display('listOperation_Edit.htm');
?>
| 123gohelmetsv2 | trunk/admin/system/listOperation_Edit.php | PHP | asf20 | 1,357 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
include_once("PromotionImpl.php"); //--> Special
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$oPromoImpl = new PromotionImpl(DB_TAG_SYSTEM, $uid); //--> Manufacturer
$error_message = '';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(count($arrOperate) > 0){
$strQuery = $_SERVER["REQUEST_URI"];
$arrUrlInfo = pathinfo($strQuery);
$selfFileName = $arrUrlInfo['filename'];
$arrOperateAllInfo = $objOperate->listFromCustom($arrOperate, " WHERE id in (".implode(",", $arrOperate).") AND name != 'Add'");
$i = 0;
foreach($arrOperateAllInfo as $key => $value){
$strFileName = $selfFileName."_".$value['name'].".php";
if(file_exists($strFileName)){
$arrOperateInfo[$i]['name'] = $value['name'];
$arrOperateInfo[$i]['viewName'] = $value['name'];
$i++;
}
}
}
$arrDataList = $oPromoImpl->lists($arrOperate, $LANGEUAGE_ID, ' ORDER BY s.id desc', $page, DISPLAY_DATA_SIZE, '');
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_SYS_DIR;
$smarty->assign('error_message', $error_message);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('selfFileName', $selfFileName);
$smarty->assign('arrOperateInfo', $arrOperateInfo);
$smarty->assign('arrDataList', $arrDataList);
$smarty->assign('PAGE_BAR', $oPromoImpl->pagenav);
$smarty->display('listPromotion.htm');
?>
| 123gohelmetsv2 | trunk/admin/promotion/listPromotion.php | PHP | asf20 | 1,807 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
include_once("PromotionImpl.php"); //--> Special
include_once("Product.php"); //--> Product
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$objPromoImpl = new PromotionImpl(DB_TAG_SYSTEM, $uid); //--> Special
$oProduct = new Product(DB_TAG_SYSTEM, $uid); //--> Product
$error_message = '';
$productID = '';
$descript = '';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(!empty($id)){
$arrData = $objPromoImpl->getById($arrOperate, $id);
$productID = $arrData['productID'];
$descript = $arrData['descript'];
}
if(isset($_POST['Submit'])){
$id = $_POST['id'];
$productID = $_POST['productID'];
$descript = $_POST['descript'];
if(empty($productID)){
$error_message = 'The product ID should\'t be empty.';
}else if(empty($descript)){
$error_message = 'The promotion description should\'t be empty.';
}
if(empty($error_message)){
$isReturnOrg = $objPromoImpl->edit($arrOperate, $id, $productID, $descript);
if($isReturnOrg)
$error_message = 'edit successfully.';
else{
$error_message = 'edit failure1.';
}
}
}
/*--------- get product list ---------------------*/
$arrProducts = array();
$where = ' AND p.status in ("normal", "hot")';
$order = 'ORDER BY pd.name';
$arrDataList = $oProduct->lists($arrOperate, $LANGEUAGE_ID, $where, $order, 0, 10000, '');
foreach($arrDataList as $arrRow){
$arrProducts[$arrRow['id']] = $arrRow['name'] . " ($CURRENCY" . ($arrRow['price'] / 100) . ')';
}
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_SYS_DIR;
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('id', $id);
$smarty->assign('error_message', $error_message);
$smarty->assign('backurl',$backurl);
$smarty->assign('arrProducts', $arrProducts);
$smarty->assign('descript', $descript);
$smarty->assign('productID', $productID);
$smarty->display('listPromotion_Edit.htm');
?>
| 123gohelmetsv2 | trunk/admin/promotion/listPromotion_Edit.php | PHP | asf20 | 2,347 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
include_once("PromotionImpl.php"); //--> Special
include_once("Product.php"); //--> Product
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$objPromoImpl = new PromotionImpl(DB_TAG_SYSTEM, $uid); //--> Special
$oProduct = new Product(DB_TAG_SYSTEM, $uid); //--> Product
$error_message = '';
$productID = '';
$descript = '';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_POST['Submit'])){
$productID = $_POST['productID'];
$descript = $_POST['descript'];
if(empty($productID)){
$error_message = 'The product ID should\'t be empty.';
}else if(empty($descript)){
$error_message = 'The Promotion desction should\'t be empty.';
}else{
$isReturnOrg = $objPromoImpl->add($arrOperate, $productID, $descript);
if($isReturnOrg)
$error_message = 'add successfully.';
else{
$error_message = 'add failure.';
}
}
}
$arrProducts = array();
$where = ' AND p.status in ("normal", "hot")';
$order = 'ORDER BY pd.name';
$arrDataList = $oProduct->lists($arrOperate, $LANGEUAGE_ID, $where, $order, 0, 10000, '');
foreach($arrDataList as $arrRow){
$arrProducts[$arrRow['id']] = $arrRow['name'] . " ($CURRENCY" . ($arrRow['price'] / 100) . ')';
}
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_SYS_DIR;
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('error_message', $error_message);
$smarty->assign('backurl',$backurl);
$smarty->assign('arrProducts', $arrProducts);
$smarty->assign('descript', $descript);
$smarty->assign('productID', $productID);
$smarty->display('listPromotion_Add.htm');
?>
| 123gohelmetsv2 | trunk/admin/promotion/listPromotion_Add.php | PHP | asf20 | 2,051 |
<?php
include_once("../configure/admin.config.inc.php");//--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Operation.php"); //--> Operation
include_once("PromotionImpl.php"); //--> Special
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation instance
$objPromoImpl = new PromotionImpl(DB_TAG_SYSTEM, $uid); //--> Special
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_GET['id']) && !empty($_GET['id'])){
$id = $_GET['id'];
$isReturn = $objPromoImpl->delete($arrOperate, $id);
if($isReturn)
$error_message = 'delete successfully.';
else
$error_message = 'delete failure.';
}
echo "<script language='javascript'>";
echo "alert(\"$error_message\");";
echo "location.href=\"".$_SERVER['HTTP_REFERER']."\";";
echo "</script>";
//$backurl = $_SERVER['HTTP_REFERER'];
//header("Location: $backurl");
?>
| 123gohelmetsv2 | trunk/admin/promotion/listPromotion_Delete.php | PHP | asf20 | 999 |
<?php
include_once("../configure/admin.config.inc.php");//--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Operation.php"); //--> Operation
include_once("Customer.php"); //--> Customer
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation instance
$objCustomer = new Customer(DB_TAG_SYSTEM, $uid); //--> Manufacturer
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_GET['id']) && !empty($_GET['id'])){
$id = $_GET['id'];
$isReturn = $objCustomer->delete($arrOperate, $id);
if($isReturn)
$error_message = 'delete successfully.';
else
$error_message = 'delete failure.';
}
echo "<script language='javascript'>";
echo "alert(\"$error_message\");";
echo "location.href=\"".$_SERVER['HTTP_REFERER']."\";";
echo "</script>";
//$backurl = $_SERVER['HTTP_REFERER'];
//header("Location: $backurl");
?>
| 123gohelmetsv2 | trunk/admin/customer/listCustomer_Delete.php | PHP | asf20 | 991 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Customer.php"); //--> Customer
include_once("Operation.php"); //--> Operation
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation(); //--> Operation
$objCustomer = new Customer(DB_TAG_SYSTEM, $uid); //--> Customer
$error_message = '';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
$arrInfo = $objCustomer->getFromID($arrOperate, $id);
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = CACHE_SYS_DIR;
$smarty->assign('error_message', $error_message);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('backurl',$backurl);
$smarty->assign('arrInfo', $arrInfo);
$smarty->display('listCustomer_View.htm');
?>
| 123gohelmetsv2 | trunk/admin/customer/listCustomer_View.php | PHP | asf20 | 1,035 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
include_once("Customer.php"); //--> Customer
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$oCustomer = new Customer(DB_TAG_SYSTEM, $uid); //--> Customer
$error_message = '';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(count($arrOperate) > 0){
$strQuery = $_SERVER["REQUEST_URI"];
$arrUrlInfo = pathinfo($strQuery);
$selfFileName = $arrUrlInfo['filename'];
$arrOperateAllInfo = $objOperate->listFromCustom($arrOperate, " WHERE id in (".implode(",", $arrOperate).") AND name != 'Add'");
$i = 0;
foreach($arrOperateAllInfo as $key => $value){
$strFileName = $selfFileName."_".$value['name'].".php";
if(file_exists($strFileName)){
$arrOperateInfo[$i]['name'] = $value['name'];
$arrOperateInfo[$i]['viewName'] = $value['name'];
$i++;
}
}
}
if(isset($_GET['keyword']) && !empty($_GET['keyword'])){
$keyword = $_GET['keyword'];
$searchType = $_GET['searchType'];
if(empty($keyword)){
$error_message = 'The keyword should\'t be empty.';
}else{
if($searchType == 'id'){
if(is_numeric($keyword))
$where = " WHERE id = $keyword";
else
$error_message = 'The keyword should\'t be product ID.';
}else if($searchType == 'name'){
$where = " WHERE firstname like '%$keyword%'";
}else if($searchType == 'email'){
$where = " WHERE email like '%$keyword%'";
}else{
$where = " WHERE firstname like '%$keyword%'";
}
}
}
$where .= " ORDER BY id DESC";
$arrDataList = $oCustomer->lists($arrOperate, $where, $page, DISPLAY_DATA_SIZE, '');
$arrSearchType = array('id' => 'Number', 'name' => 'firstname', 'email' => 'Email');
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_SYS_DIR;
$smarty->assign('error_message', $error_message);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('selfFileName', $selfFileName);
$smarty->assign('arrOperateInfo', $arrOperateInfo);
$smarty->assign('arrDataList', $arrDataList);
$smarty->assign('arrSearchType', $arrSearchType);
$smarty->assign('searchTypeS', $searchType);
$smarty->assign('keyword', $keyword);
$smarty->assign('PAGE_BAR', $oCustomer->pagenav);
$smarty->display('listCustomer.htm');
?>
| 123gohelmetsv2 | trunk/admin/customer/listCustomer.php | PHP | asf20 | 2,618 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
include_once("Customer.php"); //--> Customer
include_once("Country.php"); //--> Country
include_once("AddressBook.php"); //--> AddressBook
include_once("Validation.php"); //--> Validation
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$objCustomer = new Customer(DB_TAG_SYSTEM, $uid); //--> Customer
$objCountry = new Country($uid); //--> Country
$objAddressBook = new AddressBook($uid); //--> AddressBook
$objValidation = new Validation($uid); //--> Validation
$error_message = '';
$gender = '';
$firstname = '';
$lastname = '';
$email = '';
$oldemail = '';
$telephone = '';
$fax = '';
$zoneid = 1;
$countryid = 223;
$company = '';
$postcode = '';
$state = '';
$city = '';
$street = '';
$newsletter = 'unsubscribed';
$address_id = 0;
$password = '';
$arrAddressBook = array();
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(!empty($id)){
$arrData = $objCustomer->getFromID($arrOperate, $id);
$firstname = $arrData['firstname'];
$lastname = $arrData['lastname'];
$oldemail = $arrData['email'];
$email = $arrData['email'];
$address_id = $arrData['default_address_id'];
$telephone = $arrData['telephone'];
$fax = $arrData['fax'];
$newsletter = $arrData['newsletter'];
$password = $arrData['password'];
if($address_id > 0){
$arrAddressBook = $objAddressBook->getByID($arrOperate, $address_id);
$countryid = $arrAddressBook['countryid'];
$company = $arrAddressBook['company'];
$postcode = $arrAddressBook['postcode'];
$state = $arrAddressBook['state'];
$city = $arrAddressBook['city'];
$street = $arrAddressBook['street'];
}
}
if(isset($_POST['Submit'])){
$id = $_POST['id'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$fax = $_POST['fax'];
$countryid = $_POST['countryid'];
$company = $_POST['company'];
$postcode = $_POST['postcode'];
$state = $_POST['state'];
$city = $_POST['city'];
$street = $_POST['street'];
$newsletter = $_POST['newsletter'];
if(empty($firstname))
$error_message = 'The first name should\'t be empty.';
else if(empty($lastname)){
$error_message = 'The first name should\'t be empty.';
}else if(empty($email)){
$error_message = 'The email should\'t be empty.';
}else if(!$objValidation->isEmail($email)){
$error_message = 'The email format invalid.';
}else if($objCustomer->IsExistEmail($email) && $email != $oldemail){
$error_message = 'the email be existed.';
}
if(empty($error_message)){
if($address_id > 0)
$objAddressBook->edit($address_id, $id, $gender, $company, $firstname, $lastname, $street, $suburb, $postcode, $city, $state, $countryid, $zoneid);
$isReturnOrg = $objCustomer->edit($arrOperate, $id, $gender, $firstname, $lastname, $email, $address_id, $telephone, $fax, $newsletter, $password);
if($isReturnOrg)
$error_message = 'edit successfully.';
else{
$error_message = 'edit failure.';
}
}
}
$arrCountries = $objCountry->getGroupList();
$arrNewsletter = array('subscribed' => 'Subscribed', 'unsubscribed' => 'Unsubscribed');
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_SYS_DIR;
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('id', $id);
$smarty->assign('error_message', $error_message);
$smarty->assign('backurl',$backurl);
$smarty->assign('firstname', $firstname);
$smarty->assign('lastname', $lastname);
$smarty->assign('email', $email);
$smarty->assign('countryid', $countryid);
$smarty->assign('arrCountries', $arrCountries);
$smarty->assign('newsletter', $newsletter);
$smarty->assign('arrNewsletter', $arrNewsletter);
$smarty->assign('telephone', $telephone);
$smarty->assign('fax', $fax);
$smarty->assign('company', $company);
$smarty->assign('postcode', $postcode);
$smarty->assign('state', $state);
$smarty->assign('city', $city);
$smarty->assign('street', $street);
$smarty->display('listCustomer_Edit.htm');
?>
| 123gohelmetsv2 | trunk/admin/customer/listCustomer_Edit.php | PHP | asf20 | 4,499 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation class
include_once("MenuGroup.php"); //--> Menu group class
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation instance
$objMenuGroup = new MenuGroup($objSession->getLanguage(), $uid); //--> Menu group instance
$selfFileName = '';
$error_message = '';
$strMenuGroupName = '';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(count($arrOperate) > 0){
$strQuery = $_SERVER["REQUEST_URI"];
$arrUrlInfo = pathinfo($strQuery);
$selfFileName = $arrUrlInfo['filename'];
$arrOperateAllInfo = $objOperate->listFromCustom($arrOperate, " WHERE id in (".implode(",", $arrOperate).")");
$i = 0;
foreach($arrOperateAllInfo as $key => $value){
$strFileName = $selfFileName."_".$value['name'].".php";
if(file_exists($strFileName)){
$arrOperateInfo[$i]['name'] = $value['name'];
$arrOperateInfo[$i]['viewName'] = $value['name'];
$i++;
}
}
}
$arrMenuGroupList = $objMenuGroup->lists($arrOperate, " WHERE id > $gid ORDER BY status, orders", $page, DISPLAY_DATA_SIZE, '');
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = CACHE_SYS_DIR;
$smarty->assign('error_message', $error_message);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('selfFileName', $selfFileName);
$smarty->assign('arrOperateInfo', $arrOperateInfo);
$smarty->assign('arrMenuGroupList', $arrMenuGroupList);
$smarty->assign('arrMenuList', $arrMenuList);
$smarty->assign('PAGE_BAR', $objMenu->pagenav);
$smarty->display('listMenuGroup.htm');
?>
| 123gohelmetsv2 | trunk/admin/menu/listMenuGroup.php | PHP | asf20 | 1,966 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
include_once("MenuGroup.php"); //--> Menu group class
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation instance
$objMenuGroup = new MenuGroup($objSession->getLanguage(), $uid); //--> Menu group instance
$error_message = '';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(!empty($id)){
$arrGroupInfo = $objMenuGroup->getFromID($arrOperate, $id);
$strOrders = $arrGroupInfo['orders'];
$strMenuGroupName = $arrGroupInfo['name'];
}
if(isset($_POST['Submit'])){
$strOrders = $_POST['orders'];
$strMenuGroupName = $_POST['menuGroupName'];
if(empty($strMenuGroupName)){
$error_message = 'The menu group name should\'t be empty.';
}
if(empty($error_message)){
$isReturn = $objMenuGroup->edit($arrOperate, $id, $strOrders, $strMenuGroupName);
if($isReturn)
$error_message = 'edit group successfully.';
else
$error_message = 'edit group fail.';
}
}
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = CACHE_SYS_DIR;
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('id', $id);
$smarty->assign('backurl',$backurl);
$smarty->assign('error_message', $error_message);
$smarty->assign('orders', $strOrders);
$smarty->assign('menuGroupName', $strMenuGroupName);
$smarty->display('listMenuGroup_Edit.htm');
?>
| 123gohelmetsv2 | trunk/admin/menu/listMenuGroup_Edit.php | PHP | asf20 | 1,773 |
<?php
include_once("../configure/admin.config.inc.php");//--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
include_once("Menu.php"); //--> Menu
include_once("MenuGroup.php"); //--> MenuGroup
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$objMenu = new Menu($objSession->getLanguage(), $uid); //--> Menu
$objMenuGroup = new MenuGroup($objSession->getLanguage(), $uid); //--> MenuGroup
$error_message = '';
$strMenuName = '';
$strMenuUrl = '';
$strMenuRemark = '';
$strGroupID = '';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_POST['Submit'])){
$strGroupID = $_POST['groupid'];
$strOrders = $_POST['orders'];
$strMenuName = $_POST['menuName'];
$strMenuUrl = $_POST['menuUrl'];
$strMenuRemark = $_POST['menuRemark'];
if(empty($strGroupID))
$error_message = 'The menu group ID should\'t be empty.';
else if(empty($strMenuName))
$error_message = 'The menu name should\'t be empty.';
else if(empty($strMenuUrl)){
$error_message = 'The menu url should\'t be empty.';
}else{
$isReturn = $objMenu->add($arrOperate, $strGroupID, $strOrders, $strMenuName, $strMenuUrl, $strMenuRemark);
if($isReturn)
$error_message = 'add successfully.';
else
$error_message = 'add failure.';
}
}
$arrMenuGroup = array();
$arrMenuGroupList = $objMenuGroup->lists($arrOperate, '', 1, 100, '');
if(is_array($arrMenuGroupList)){
foreach ($arrMenuGroupList as $value){
if($objSession->getLanguage() == "zh-CN"){
$arrMenuGroup[$value['id']] = $value['namecn'];
}else
$arrMenuGroup[$value['id']] = $value['name'];
}
}
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = CACHE_SYS_DIR;
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('backurl',$backurl);
$smarty->assign('error_message', $error_message);
$smarty->assign('arrMenuGroup', $arrMenuGroup);
$smarty->assign('groupidS', $strGroupID);
$smarty->assign('orders', $strOrders);
$smarty->assign('menuName', $strMenuName);
$smarty->assign('menuUrl', $strMenuUrl);
$smarty->assign('menuRemark', $strMenuRemark);
$smarty->display('listMenu_Add.htm');
?>
| 123gohelmetsv2 | trunk/admin/menu/listMenu_Add.php | PHP | asf20 | 2,501 |
<?php
include_once("../configure/admin.config.inc.php");//--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Operation.php"); //--> Operation
include_once("Menu.php"); //--> Menu
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation instance
$objMenu = new Menu($objSession->getLanguage(), $uid); //--> Menu
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_GET['id']) && !empty($_GET['id'])){
$id = $_GET['id'];
$isReturn = $objMenu->delete($arrOperate, $id);
if($isReturn)
$error_message = 'delete successfully.';
else
$error_message = 'delete fail.';
}
echo "<script language='javascript'>";
echo "alert(\"$error_message\");";
echo "location.href=\"".$_SERVER['HTTP_REFERER']."\";";
echo "</script>";
//$backurl = $_SERVER['HTTP_REFERER'];
//header("Location: $backurl");
?>
| 123gohelmetsv2 | trunk/admin/menu/listMenu_Delete.php | PHP | asf20 | 968 |
<?php
include_once("../configure/admin.config.inc.php");//--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
include_once("Menu.php"); //--> Menu
include_once("MenuGroup.php"); //--> MenuGroup
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$objMenu = new Menu($objSession->getLanguage(), $uid); //--> Menu
$objMenuGroup = new MenuGroup($objSession->getLanguage(), $uid); //--> MenuGroup
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
$error_message = '';
$strMenuName = '';
$strMenuNameCN = '';
$strMenuUrl = '';
$strMenuRemark = '';
$strGroupID = '';
$arrMenuInfo = $objMenu->getFromID($arrOperate, $id);
if(is_array($arrMenuInfo)){
$strMenuName = $arrMenuInfo['name'];
$strOrders = $arrMenuInfo['orders'];
$strMenuUrl = $arrMenuInfo['url'];
$strMenuRemark = $arrMenuInfo['remark'];
$strGroupID = $arrMenuInfo['groupid'];
}
if(isset($_POST['Submit'])){
$strGroupID = $_POST['groupid'];
$strOrders = $_POST['orders'];
$strMenuName = $_POST['name'];
$strMenuUrl = $_POST['menuUrl'];
$strMenuRemark = $_POST['menuRemark'];
if(empty($strGroupID))
$error_message = 'The menu group ID should\'t be empty.';
else if(empty($strMenuName))
$error_message = 'The menu name should\'t be empty.';
else if(empty($strMenuUrl)){
$error_message = 'The menu url should\'t be empty.';
}else{
$isReturn = $objMenu->edit($arrOperate, $id, $strGroupID, $strOrders, $strMenuName, $strMenuUrl, $strMenuRemark);
if($isReturn)
$error_message = 'edit successfully.';
else
$error_message = 'edit failure.';
}
}
$arrMenuGroup = array();
$arrMenuGroupList = $objMenuGroup->lists($arrOperate, '', 1, 100, '');
if(is_array($arrMenuGroupList)){
foreach ($arrMenuGroupList as $value){
if($objSession->getLanguage() == "zh-CN"){
$arrMenuGroup[$value['id']] = $value['namecn'];
}else
$arrMenuGroup[$value['id']] = $value['name'];
}
}
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = CACHE_SYS_DIR;
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('id', $id);
$smarty->assign('backurl',$backurl);
$smarty->assign('error_message', $error_message);
$smarty->assign('arrMenuGroup', $arrMenuGroup);
$smarty->assign('groupidS', $strGroupID);
$smarty->assign('orders', $strOrders);
$smarty->assign('name', $strMenuName);
$smarty->assign('menuUrl', $strMenuUrl);
$smarty->assign('menuRemark', $strMenuRemark);
$smarty->display('listMenu_Edit.htm');
?>
| 123gohelmetsv2 | trunk/admin/menu/listMenu_Edit.php | PHP | asf20 | 2,846 |
<?php
include_once("../configure/admin.config.inc.php");//--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
include_once("MenuGroup.php"); //--> Menu group class
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation instance
$objMenuGroup = new MenuGroup($objSession->getLanguage(), $uid); //--> Menu group instance
$error_message = '';
$strMenuGroupName = '';
$strMenuGroupNameCN = '';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_POST['Submit'])){
$strOrders = $_POST['orders'];
$strMenuGroupName = $_POST['menuGroupName'];
if(!empty($strMenuGroupName)){
$isReturn = $objMenuGroup->add($arrOperate, $strOrders, $strMenuGroupName);
if($isReturn)
$error_message = 'add menu group successfully.';
else
$error_message = 'add menu group fail.';
}else{
$error_message = 'The menu group name should\'t be empty.';
}
}
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = CACHE_SYS_DIR;
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('backurl',$backurl);
$smarty->assign('error_message', $error_message);
$smarty->assign('orders', $strOrders);
$smarty->assign('menuGroupName', $strMenuGroupName);
$smarty->display('listMenuGroup_add.htm');
?>
| 123gohelmetsv2 | trunk/admin/menu/listMenuGroup_Add.php | PHP | asf20 | 1,600 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
include_once("Menu.php"); //--> Menu
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$objMenu = new Menu($objSession->getLanguage(), $uid); //--> Menu
$error_message = '';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(count($arrOperate) > 0){
$strQuery = $_SERVER["REQUEST_URI"];
$arrUrlInfo = pathinfo($strQuery);
$selfFileName = $arrUrlInfo['filename'];
$arrOperateAllInfo = $objOperate->listFromCustom($arrOperate, " WHERE id in (".implode(",", $arrOperate).") AND name != 'Add'");
$i = 0;
foreach($arrOperateAllInfo as $key => $value){
$strFileName = $selfFileName."_".$value['name'].".php";
if(file_exists($strFileName)){
$arrOperateInfo[$i]['name'] = $value['name'];
$arrOperateInfo[$i]['viewName'] = $value['name'];
$i++;
}
}
}
$arrDataList = $objMenu->lists($arrOperate, " ORDER BY orders", $page, DISPLAY_DATA_SIZE, '');
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = CACHE_SYS_DIR;
$smarty->assign('error_message', $error_message);
$smarty->assign('backurl',$backurl);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('selfFileName', $selfFileName);
$smarty->assign('arrOperateInfo', $arrOperateInfo);
$smarty->assign('arrMenuList', $arrDataList);
$smarty->assign('PAGE_BAR', $objMenu->pagenav);
$smarty->display('listMenu.htm');
?>
| 123gohelmetsv2 | trunk/admin/menu/listMenu.php | PHP | asf20 | 1,820 |
<?php
include_once("../configure/admin.config.inc.php");//--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Operation.php"); //--> Operation
include_once("MenuGroup.php"); //--> Menu group class
include_once("Menu.php"); //--> Menu class
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation instance
$objMenuGroup = new MenuGroup($objSession->getLanguage(), $uid); //--> Menu group instance
$objMenu = new Menu($objSession->getLanguage(), $uid); //--> Menu instance
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_GET['id']) && !empty($_GET['id'])){
$id = $_GET['id'];
if($gid == $id){
$error_message = 'invalid delete menu group.';
}else if(count($objMenu->lists($arrOperate, " WHERE groupid=$id", 1, 1, '')) > 0) {
$error_message = "can't delete the user group, because that have user above the user group.";
}else{
$isReturn = $objMenuGroup->delete($arrOperate, $id);
if($isReturn)
$error_message = 'delete group successfully.';
else
$error_message = 'delete group fail.';
}
}
echo "<script language='javascript'>";
echo "alert(\"$error_message\");";
echo "location.href=\"".$_SERVER['HTTP_REFERER']."\";";
echo "</script>";
//$backurl = $_SERVER['HTTP_REFERER'];
//header("Location: $backurl");
?>
| 123gohelmetsv2 | trunk/admin/menu/listMenuGroup_Delete.php | PHP | asf20 | 1,424 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Authority.php"); //--> Authority
include_once("Operation.php"); //--> Operation
include_once("UserGroup.php"); //--> User Group
require_once("controlHeader.php"); //--> system control header
$objAuth = new Authority($objSession->getLanguage(), $uid); //--> Authority
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$objUserGroup = new UserGroup($objSession->getLanguage(), $uid); //--> User Group
if(isset($_POST['groupid']) && !empty($_POST['groupid'])){
$groupid = $_POST['groupid'];
}else {
$groupid = 0;
}
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
$error_message = '';
if(isset($_POST['Submit'])){
$arrOperation = $_POST['arrOperation'];
$groupid = $_POST['groupid'];
if(is_array($arrOperation)){
$arrOperateCache = array();
foreach ($arrOperation as $value){
$arrCache = explode('_', $value);//-- 0: menuid, 1: operate id
$arrOperateCache[$arrCache[0]][] = $arrCache[1];
}
$isReturn = $objAuth->addGroupAuthTransaction($arrOperate, $groupid, $arrOperateCache);
if($isReturn)
$error_message = 'add successfully.';
else
$error_message = 'add failure.';
}
}
$arrOperateList = $objOperate->listOperation();
$arrPermissionList = $objAuth->listGroupPermission($groupid);
if(is_array($arrPermissionList)){
foreach ($arrPermissionList as $key => $arrPer){
$arrOperate = explode(',', $arrPer['operate']);
$arrOperateCache = array();
foreach ($arrOperateList['id'] as $keyid => $arrID){
$arrOperateCache[$keyid] = $arrPer['mid'] . '_' . $arrID;
}
foreach ($arrOperate as $keyid1 => $arrID1){
$arrOperate[$keyid1] = $arrPer['authMenuID'] . '_' . $arrID1;
}
$arrPermissionList[$key]['arrOperationID'] = $arrOperateCache;
$arrPermissionList[$key]['arrOperationName'] = $arrOperateList['name'];
$arrPermissionList[$key]['arrOperationS'] = $arrOperate;
}
}
$arrGroupID = $objUserGroup->arrGetGroupList($gid);
/*----- out html -----*/
$smarty = new Smarty(); //-- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = CACHE_SYS_DIR;
$smarty->assign('error_message', $error_message);
$smarty->assign('arrGroupID', $arrGroupID);
$smarty->assign('groupid', $groupid);
$smarty->assign('arrPermissionList', $arrPermissionList);
$smarty->display('GroupPermission.htm');
?>
| 123gohelmetsv2 | trunk/admin/menu/GroupPermission.php | PHP | asf20 | 2,602 |
BODY {
MARGIN: 0px
}
BODY {
FONT-SIZE: 11px; COLOR: #000000; FONT-FAMILY: Arial
}
P {
FONT-SIZE: 11px; COLOR: #000000; FONT-FAMILY: Arial
}
TD {
FONT-SIZE: 11px; COLOR: #000000; FONT-FAMILY: Arial
}
TH {
FONT-SIZE: 11px; COLOR: #000000; FONT-FAMILY: Arial
}
TEXTAREA {
BORDER-RIGHT: #4c77b6 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #4c77b6 1px solid; PADDING-LEFT: 2px; FONT-SIZE: 11px; BACKGROUND: #fff; PADDING-BOTTOM: 2px; MARGIN: 5px; VERTICAL-ALIGN: middle; BORDER-LEFT: #4c77b6 1px solid; COLOR: #000; PADDING-TOP: 2px; BORDER-BOTTOM: #4c77b6 1px solid; FONT-FAMILY: verdana, helvetica, sans-serif
}
SELECT {
BORDER-RIGHT: #4c77b6 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #4c77b6 1px solid; PADDING-LEFT: 2px; FONT-SIZE: 11px; BACKGROUND: #fff; PADDING-BOTTOM: 2px; MARGIN: 5px; VERTICAL-ALIGN: middle; BORDER-LEFT: #4c77b6 1px solid; COLOR: #000; PADDING-TOP: 2px; BORDER-BOTTOM: #4c77b6 1px solid; FONT-FAMILY: verdana, helvetica, sans-serif
}
A:link {
COLOR: #000000; TEXT-DECORATION: none;
}
A:active {
COLOR: #ffb220; TEXT-DECORATION: underline
}
A:visited {
COLOR: #000000; TEXT-DECORATION: none
}
A:hover {
COLOR: #ffb220; TEXT-DECORATION: underline
}
A:link {
COLOR: #657e7e; TEXT-DECORATION: none
}
A:active {
COLOR: #d2691e; TEXT-DECORATION: underline
}
A:visited {
COLOR: #657e7e; TEXT-DECORATION: none
}
A:hover {
COLOR: #d2691e; TEXT-DECORATION: underline
}
.white {
COLOR: #ffffff
}
.red {
FONT-WEIGHT: bold; FONT-SIZE: 13px; COLOR: #ff0000
}
.orange {
FONT-WEIGHT: bold; COLOR: #ffb220
}
.submenu {
COLOR: #657e7e
}
.mainfont {
FONT-WEIGHT: bold; FONT-SIZE: 13px; COLOR: #657e7e
}
.buttonhead {
FONT-SIZE: 11px; FONT-FAMILY: Arial
}
.textarea {
FONT-SIZE: 11px; FONT-FAMILY: Arial
}
.error {
COLOR: #ff0000
}
.bar {
LINE-HEIGHT: 22px; BACKGROUND-COLOR: #c7d3d3; TEXT-ALIGN: center
}
.menulistbar {
BACKGROUND-COLOR: #657e7e
}
.tablebg {
BACKGROUND-COLOR: #c7d3d3
}
.bg {
BACKGROUND-COLOR: #fafafa
}
.block {
BACKGROUND-COLOR: #ffffff
}
.zebrawhite {
LINE-HEIGHT: 22px; BACKGROUND-COLOR: #f5f5f5; TEXT-ALIGN: center
}
.zebranotwhite {
LINE-HEIGHT: 22px; BACKGROUND-COLOR: #e9eded; TEXT-ALIGN: center
}
.yellow {
LINE-HEIGHT: 22px; BACKGROUND-COLOR: #f5f5dc; TEXT-ALIGN: center
}
.border {
FONT-WEIGHT: bold; FONT-SIZE: 10px; COLOR: #93aaaa
}
.header {
FONT-WEIGHT: bold; FONT-SIZE: 10px; COLOR: #7b9595; TEXT-ALIGN: center
}
.subheader {
FONT-WEIGHT: bold; FONT-SIZE: 14px; COLOR: #657e7e; FONT-FAMILY: Arial
}
.maintext {
FONT-WEIGHT: bold; FONT-SIZE: 10px
}
.zebraspec {
BACKGROUND-COLOR: #999999
}
.imagestatus {
FONT-SIZE: 10px
}
.present {
COLOR: #0000ff
}
.absent {
COLOR: #8b0000
}
.comment {
FONT-SIZE: 10px
}
.StatTableHead {
FONT-WEIGHT: bold; FONT-SIZE: 12px; COLOR: #000000; BACKGROUND-COLOR: #6495ed; TEXT-ALIGN: center
}
.ctlbutton {
FONT-SIZE: 13px; FONT-FAMILY: Arial
}
.selectTitle {
font-family: Tahoma, Verdana, Arial;
font-size: 10pt;
font-weight: bold;
}
.select {
font-family: Tahoma, Verdana, Arial;
font-size: 8pt;
}
.title {
font-size: 11pt;
font-weight: bolder;
}
.borderedtable {
border: solid #7F9EE2 1px;
}
.columnheader_r {
font-family: Tahoma, Verdana, Arial;
font-size: 8.5pt;
font-weight: bold;
color: #FFFFFF;
background-color: #6478D7;
}
.rowodd {
font-family: Tahoma, Verdana, Arial;
font-size: 8.5pt;
font-weight: normal;
color: #000000;
background-color: #E2E4E7
}
.roweven {
font-family: Tahoma, Verdana, Arial;
font-size: 8.5pt;
font-weight: normal;
color: #000000;
background-color: #F7F7F7
}
.totalrowodd {
font-family: Tahoma, Verdana, Arial;
font-size: 8.5pt;
font-weight: bold;
color: #000000;
background-color: #E2E4E7
}
.totalroweven {
font-family: Tahoma, Verdana, Arial;
font-size: 8.5pt;
font-weight: bold;
color: #000000;
background-color: #F7F7F7
}
.td{
FONT-SIZE: 11px; COLOR: #000000; FONT-FAMILY: Arial
}
.tr{
FONT-SIZE: 11px; COLOR: #000000; FONT-FAMILY: Arial
}
.filterHide{display:none;}
.filterShow{display:block;}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: none;
}
.copyright
{
font-family: Arial, Helvetica, sans-serif;
color: #868585;
font-size: 9px;
}
.error_message
{
font-weight: bolder;
color: #FF0D25;
}
.submitbutton
{
font-family: Verdana;
font-size: 12px;
color: #000000;
background-image: url(../images/submitbg.gif);
height: 21px;
width: 80px;
background-attachment: scroll;
background-repeat: repeat-x;
background-position: center center;
border: 1px solid #A3AA90;
margin: auto;
padding: 0px;
CURSOR: hand;
COLOR: black;
FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#ffffff, EndColorStr=#cecfde);
}
.btn {
BORDER-RIGHT: #7b9ebd 1px solid;
PADDING-RIGHT: 2px;
BORDER-TOP: #7b9ebd 1px solid;
PADDING-LEFT: 2px;
FONT-SIZE: 12px;
FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#ffffff, EndColorStr=#cecfde);
BORDER-LEFT: #7b9ebd 1px solid;
CURSOR: hand;
COLOR: black;
PADDING-TOP: 2px;
BORDER-BOTTOM: #7b9ebd 1px solid;
height: 21px;
width: 80px;
}
.oldPrice { text-decoration: line-through; }
.pageHeading { font-family: Verdana, Arial, sans-serif; font-size: 18px; color: #727272; font-weight: bold; }
.pageFrom {
font-family: Verdana, Arial, sans-serif;
font-size: 12px;
color: #000000;
height: 21px;
}
.main { font-family: Verdana, Arial, sans-serif; font-size: 12px; }
.invoiceTitle{border:1px solid #000000;}
.invoiceTitleLeftTop{border-left:1px solid #000000; border-top:1px solid #000000;}
.invoiceTitleLeftTopRight{border-left:1px solid #000000; border-top:1px solid #000000;border-right:1px solid #000000;}
.invoiceTitleLeftTopBottom{border-left:1px solid #000000; border-top:1px solid #000000; border-bottom:1px solid #000000;}
.invoiceTitleLeftRightBottom{border-left:1px solid #000000; border-right:1px solid #000000; border-bottom:1px solid #000000;}
.invoiceTitleLeftBottom{border-left:1px solid #000000; border-bottom:1px solid #000000;} | 123gohelmetsv2 | trunk/admin/css/style.css | CSS | asf20 | 6,345 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Authority
require_once("controlHeader.php"); //--> system control header
include_once("InfoClass.php"); //--> info class
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$objInfoClass = new InfoClass(DB_TAG_SYSTEM, $uid); //--> Info Class
$error_message = '';
$strName = '';
$strParentid = '';
$strIsLeaf = 'no';
$sorts = -1;
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_POST['Submit'])){
$strParentid = $_POST['parentid'];
$strName = $_POST['name'];
$strIsLeaf = $_POST['isLeaf'];
$sorts = $_POST['sorts'];
$summary = $_POST['summary'];
if($strParentid == "")
$error_message = 'The UP to level class should\'t be empty.';
else if(empty($strName))
$error_message = 'The class name should\'t be empty.';
else{
$isReturn = $objInfoClass->add($arrOperate, $strName, $strParentid, $sorts, $strIsLeaf, $summary);
if($isReturn)
$error_message = 'add successfully.';
else
$error_message = 'add failure.';
}
}
$arrParentid = array('0' => "root");
$arrIsLeaf = array('yes' => 'Yes', 'no' => 'No');
$arrTmpStack = array();
$arrLevelStack = array();
$i = 0;
array_push($arrTmpStack,'0');
while(sizeof($arrTmpStack) > 0){
$strtmp = array_pop($arrTmpStack);
$i = array_pop($arrLevelStack);
if($strtmp > 0){
$arrback = $objInfoClass->getFromID($arrOperate, $strtmp);
if(is_array($arrback)){
$tmp = '';
for($j = 0; $j < $i; $j++){
$tmp.=' ';
}
$arrParentid[$arrback['id']] = $tmp.$arrback['name'];
}
}
$mixBack = $objInfoClass->listFromCustom($arrOperate, " WHERE parentid='$strtmp'");
if(is_array($mixBack)){
$i++;
foreach($mixBack as $value){
array_push($arrTmpStack,$value['id']);
array_push($arrLevelStack,$i);
}
}
}
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_SYS_DIR;
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('backurl',$backurl);
$smarty->assign('error_message', $error_message);
$smarty->assign('arrIsLeaf', $arrIsLeaf);
$smarty->assign('isLeafS', $strIsLeaf);
$smarty->assign('sorts', $sorts);
$smarty->assign('arrParentid', $arrParentid);
$smarty->assign('parentidS', $strParentid);
$smarty->assign('name', $strName);
$smarty->assign('summary', $summary);
$smarty->display('listInfoClass_Add.htm');
?>
| 123gohelmetsv2 | trunk/admin/info/listInfoClass_Add.php | PHP | asf20 | 2,761 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
include_once("InfoClass.php"); //--> Info Class
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$objInfoClass = new InfoClass(DB_TAG_SYSTEM, $uid); //--> Info Class
$error_message = '';
if(isset($_GET['page']))
$page = $_GET['page'];
else
$page = 1;
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(count($arrOperate) > 0){
$strQuery = $_SERVER["REQUEST_URI"];
$arrUrlInfo = pathinfo($strQuery);
$selfFileName = $arrUrlInfo['filename'];
$arrOperateAllInfo = $objOperate->listFromCustom($arrOperate, " WHERE id in (".implode(",", $arrOperate).") AND name != 'Add'");
$i = 0;
foreach($arrOperateAllInfo as $key => $value){
$strFileName = $selfFileName."_".$value['name'].".php";
if(file_exists($strFileName)){
$arrOperateInfo[$i]['name'] = $value['name'];
$arrOperateInfo[$i]['viewName'] = $value['name'];
$i++;
}
}
}
$arrDataList = array();
$arrTmpStack = array();
$arrLevelStack = array();
$i = 0;
$k = 0;
$iDisCount = DISPLAY_DATA_SIZE;
array_push($arrTmpStack,'0');
while(sizeof($arrTmpStack) > 0){
$strtmp = array_pop($arrTmpStack);
$i = array_pop($arrLevelStack);
if($strtmp > 0){
$arrback = $objInfoClass->getFromID($arrOperate, $strtmp);
if(is_array($arrback)){
$tmp = '';
for($j = 1; $j < $i; $j++){
$tmp.=' ';
}
$status = '';
$iStart = ($page - 1) * $iDisCount;
$iEnd = $iStart + $iDisCount;
if($k >= $iStart && $k < $iEnd)
$arrDataList[] = array("id" => $arrback['id'], "sorts" => $arrback['sorts'], "isLeaf" => $arrback['isLeaf'], "name" => $tmp.$arrback['name'], "level" => $i);
$k++;
if($k >= $iEnd)
break;
}
}
$mixBack = $objInfoClass->listFromCustom($arrOperate, " WHERE parentid='$strtmp' ORDER BY sorts DESC");
if(is_array($mixBack)){
$i++;
foreach($mixBack as $value){
array_push($arrTmpStack,$value['id']);
array_push($arrLevelStack,$i);
}
}
}
$objInfoClass->mutilPager($objInfoClass->getCount(), $page, $iDisCount, '');
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_SYS_DIR;
$smarty->assign('error_message', $error_message);
$smarty->assign('backurl',$backurl);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('selfFileName', $selfFileName);
$smarty->assign('arrOperateInfo', $arrOperateInfo);
$smarty->assign('arrDataList', $arrDataList);
$smarty->assign('PAGE_BAR', $objInfoClass->pagenav);
$smarty->display('listInfoClass.htm');
?>
| 123gohelmetsv2 | trunk/admin/info/listInfoClass.php | PHP | asf20 | 2,987 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
require_once("controlHeader.php"); //--> system control header
include_once("InfoClass.php"); //--> Info Class
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$objInfoClass = new InfoClass(DB_TAG_SYSTEM, $uid); //--> Info Class
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
$error_message = '';
$summary = '';
$sorts = -1;
$arrInfoClass = $objInfoClass->getFromID($arrOperate, $id);
if(is_array($arrInfoClass)){
$strName = $arrInfoClass['name'];
$strParentid = $arrInfoClass['parentid'];
$strIsLeaf = $arrInfoClass['isLeaf'];
$sorts = $arrInfoClass['sorts'];
$summary = $arrInfoClass['summary'];
}
if(isset($_POST['Submit'])){
$strParentid = $_POST['parentid'];
$strName = $_POST['name'];
$strIsLeaf = $_POST['isLeaf'];
$sorts = $_POST['sorts'];
$summary = $_POST['summary'];
if($strParentid == "")
$error_message = 'The UP to level class should\'t be empty.';
else if(empty($strName))
$error_message = 'The class name should\'t be empty.';
else{
$isReturn = $objInfoClass->edit($arrOperate, $id, $strName, $strParentid, $sorts, $strIsLeaf, $summary);
if($isReturn)
$error_message = 'edit successfully.';
else
$error_message = 'edit failure.';
}
}
$arrParentid = array('0' => "root");
$arrIsLeaf = array('yes' => 'Yes', 'no' => 'No');
$arrTmpStack = array();
$arrLevelStack = array();
$i = 0;
array_push($arrTmpStack,'0');
while(sizeof($arrTmpStack) > 0){
$strtmp = array_pop($arrTmpStack);
$i = array_pop($arrLevelStack);
if($strtmp > 0){
$arrback = $objInfoClass->getFromID($arrOperate, $strtmp);
if(is_array($arrback)){
$tmp = '';
for($j = 0; $j < $i; $j++){
$tmp.=' ';
}
$arrParentid[$arrback['id']] = $tmp.$arrback['name'];
}
}
$mixBack = $objInfoClass->listFromCustom($arrOperate, " WHERE parentid='$strtmp'");
if(is_array($mixBack)){
$i++;
foreach($mixBack as $value){
array_push($arrTmpStack,$value['id']);
array_push($arrLevelStack,$i);
}
}
}
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_SYS_DIR;
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('id', $id);
$smarty->assign('backurl',$backurl);
$smarty->assign('error_message', $error_message);
$smarty->assign('arrIsLeaf', $arrIsLeaf);
$smarty->assign('isLeafS', $strIsLeaf);
$smarty->assign('sorts', $sorts);
$smarty->assign('arrParentid', $arrParentid);
$smarty->assign('parentidS', $strParentid);
$smarty->assign('name', $strName);
$smarty->assign('summary', $summary);
$smarty->display('listInfoClass_Edit.htm');
?>
| 123gohelmetsv2 | trunk/admin/info/listInfoClass_Edit.php | PHP | asf20 | 2,960 |
<?php
include_once("../configure/admin.config.inc.php");//--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Operation.php"); //--> Operation
include_once("InfoClass.php"); //--> Menu
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation instance
$objInfoClass = new InfoClass(DB_TAG_SYSTEM, $uid); //--> Menu
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_GET['id']) && !empty($_GET['id'])){
$id = $_GET['id'];
$isReturn = $objInfoClass->delete($arrOperate, $id);
if($isReturn)
$error_message = 'delete successfully.';
else
$error_message = 'delete fail.';
}
echo "<script language='javascript'>";
echo "alert(\"$error_message\");";
echo "location.href=\"".$_SERVER['HTTP_REFERER']."\";";
echo "</script>";
//$backurl = $_SERVER['HTTP_REFERER'];
//header("Location: $backurl");
?>
| 123gohelmetsv2 | trunk/admin/info/listInfoClass_Delete.php | PHP | asf20 | 978 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
include_once("Attributes.php"); //--> Attributes
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$objAttributes = new Attributes(DB_TAG_SYSTEM, $uid); //--> Attributes
$error_message = '';
if(isset($_GET['page']))
$page = $_GET['page'];
else
$page = 1;
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(count($arrOperate) > 0){
$strQuery = $_SERVER["REQUEST_URI"];
$arrUrlInfo = pathinfo($strQuery);
$selfFileName = $arrUrlInfo['filename'];
$arrOperateAllInfo = $objOperate->listFromCustom($arrOperate, " WHERE id in (".implode(",", $arrOperate).") AND name != 'Add'");
$i = 0;
foreach($arrOperateAllInfo as $key => $value){
$strFileName = $selfFileName."_".$value['name'].".php";
if(file_exists($strFileName)){
$arrOperateInfo[$i]['name'] = $value['name'];
$arrOperateInfo[$i]['viewName'] = $value['name'];
$i++;
}
}
}
$arrDataList = array();
$arrTmpStack = array();
$arrLevelStack = array();
$i = 0;
$k = 0;
$iDisCount = DISPLAY_DATA_SIZE;
array_push($arrTmpStack,'0');
while(sizeof($arrTmpStack) > 0){
$strtmp = array_pop($arrTmpStack);
$i = array_pop($arrLevelStack);
if($strtmp > 0){
$arrback = $objAttributes->getFromID($arrOperate, $LANGEUAGE_ID, $strtmp);
if(is_array($arrback)){
$tmp = '';
for($j = 1; $j < $i; $j++){
$tmp.=' ';
}
$status = '';
$iStart = ($page - 1) * $iDisCount;
$iEnd = $iStart + $iDisCount;
if($k >= $iStart && $k < $iEnd)
$arrDataList[] = array("id" => $arrback['id'], "sorts" => $arrback['sorts'], "isLeaf" => $arrback['isLeaf'], "name" => $tmp.$arrback['name'], "level" => $i);
$k++;
if($k >= $iEnd)
break;
}
}
$mixBack = $objAttributes->listFromCustom($arrOperate, " WHERE parentid='$strtmp' ORDER BY sorts DESC");
if(is_array($mixBack)){
$i++;
foreach($mixBack as $value){
array_push($arrTmpStack,$value['id']);
array_push($arrLevelStack,$i);
}
}
}
$objAttributes->mutilPager($objAttributes->getCount(), $page, $iDisCount, '');
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_SYS_DIR;
$smarty->assign('error_message', $error_message);
$smarty->assign('backurl',$backurl);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('selfFileName', $selfFileName);
$smarty->assign('arrOperateInfo', $arrOperateInfo);
$smarty->assign('arrDataList', $arrDataList);
$smarty->assign('PAGE_BAR', $objAttributes->pagenav);
$smarty->display('listAttributes.htm');
?>
| 123gohelmetsv2 | trunk/admin/attributes/listAttributes.php | PHP | asf20 | 3,010 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
require_once("controlHeader.php"); //--> system control header
include_once("Attributes.php"); //--> Info Class
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$objAttributes = new Attributes(DB_TAG_SYSTEM, $uid); //--> Info Class
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
$error_message = '';
$summary = '';
$sorts = -1;
$arrAttributes = $objAttributes->getFromID($arrOperate, $LANGEUAGE_ID, $id);
if(is_array($arrAttributes)){
$strName = $arrAttributes['name'];
$strParentid = $arrAttributes['parentid'];
$strIsLeaf = $arrAttributes['isLeaf'];
$sorts = $arrAttributes['sorts'];
$summary = $arrAttributes['summary'];
}
if(isset($_POST['Submit'])){
$strParentid = $_POST['parentid'];
$strName = $_POST['name'];
$strIsLeaf = $_POST['isLeaf'];
$sorts = $_POST['sorts'];
$summary = $_POST['summary'];
if($strParentid == "")
$error_message = 'The UP to level class should\'t be empty.';
else if(empty($strName))
$error_message = 'The class name should\'t be empty.';
else{
$isReturn = $objAttributes->edit($arrOperate, $id, $strName, $strParentid, $sorts, $strIsLeaf, $summary);
if($isReturn)
$error_message = 'edit successfully.';
else
$error_message = 'edit failure.';
}
}
$arrParentid = array('0' => "root");
$arrIsLeaf = array('yes' => 'Yes', 'no' => 'No');
$arrTmpStack = array();
$arrLevelStack = array();
$i = 0;
array_push($arrTmpStack,'0');
while(sizeof($arrTmpStack) > 0){
$strtmp = array_pop($arrTmpStack);
$i = array_pop($arrLevelStack);
if($strtmp > 0){
$arrback = $objAttributes->getFromID($arrOperate, $LANGEUAGE_ID, $strtmp);
if(is_array($arrback)){
$tmp = '';
for($j = 0; $j < $i; $j++){
$tmp.=' ';
}
$arrParentid[$arrback['id']] = $tmp.$arrback['name'];
}
}
$mixBack = $objAttributes->listFromCustom($arrOperate, " WHERE parentid='$strtmp'");
if(is_array($mixBack)){
$i++;
foreach($mixBack as $value){
array_push($arrTmpStack,$value['id']);
array_push($arrLevelStack,$i);
}
}
}
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_SYS_DIR;
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('id', $id);
$smarty->assign('backurl',$backurl);
$smarty->assign('error_message', $error_message);
$smarty->assign('arrIsLeaf', $arrIsLeaf);
$smarty->assign('isLeafS', $strIsLeaf);
$smarty->assign('sorts', $sorts);
$smarty->assign('arrParentid', $arrParentid);
$smarty->assign('parentidS', $strParentid);
$smarty->assign('name', $strName);
$smarty->assign('summary', $summary);
$smarty->display('listAttributes_Edit.htm');
?>
| 123gohelmetsv2 | trunk/admin/attributes/listAttributes_Edit.php | PHP | asf20 | 3,005 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Authority
require_once("controlHeader.php"); //--> system control header
include_once("Attributes.php"); //--> info class
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$objAttributes = new Attributes(DB_TAG_SYSTEM, $uid); //--> Info Class
$error_message = '';
$strName = '';
$strParentid = '';
$strIsLeaf = 'no';
$sorts = -1;
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_POST['Submit'])){
$strParentid = $_POST['parentid'];
$strName = $_POST['name'];
$strIsLeaf = $_POST['isLeaf'];
$sorts = $_POST['sorts'];
$summary = $_POST['summary'];
if($strParentid == "")
$error_message = 'The UP to level class should\'t be empty.';
else if(empty($strName))
$error_message = 'The class name should\'t be empty.';
else{
$isReturn = $objAttributes->add($arrOperate, $strName, $strParentid, $sorts, $strIsLeaf, $summary);
if($isReturn)
$error_message = 'add successfully.';
else
$error_message = 'add failure.';
}
}
$arrParentid = array('0' => "root");
$arrIsLeaf = array('yes' => 'Yes', 'no' => 'No');
$arrTmpStack = array();
$arrLevelStack = array();
$i = 0;
array_push($arrTmpStack,'0');
while(sizeof($arrTmpStack) > 0){
$strtmp = array_pop($arrTmpStack);
$i = array_pop($arrLevelStack);
if($strtmp > 0){
$arrback = $objAttributes->getFromID($arrOperate, $LANGEUAGE_ID, $strtmp);
if(is_array($arrback)){
$tmp = '';
for($j = 0; $j < $i; $j++){
$tmp.=' ';
}
$arrParentid[$arrback['id']] = $tmp.$arrback['name'];
}
}
$mixBack = $objAttributes->listFromCustom($arrOperate, " WHERE parentid='$strtmp'");
if(is_array($mixBack)){
$i++;
foreach($mixBack as $value){
array_push($arrTmpStack,$value['id']);
array_push($arrLevelStack,$i);
}
}
}
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_SYS_DIR;
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('backurl',$backurl);
$smarty->assign('error_message', $error_message);
$smarty->assign('arrIsLeaf', $arrIsLeaf);
$smarty->assign('isLeafS', $strIsLeaf);
$smarty->assign('sorts', $sorts);
$smarty->assign('arrParentid', $arrParentid);
$smarty->assign('parentidS', $strParentid);
$smarty->assign('name', $strName);
$smarty->assign('summary', $summary);
$smarty->display('listAttributes_Add.htm');
?>
| 123gohelmetsv2 | trunk/admin/attributes/listAttributes_Add.php | PHP | asf20 | 2,783 |
<?php
include_once("../configure/admin.config.inc.php");//--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Operation.php"); //--> Operation
include_once("Attributes.php"); //--> Attributes
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation instance
$objAttributes = new Attributes(DB_TAG_SYSTEM, $uid); //--> Attributes
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_GET['id']) && !empty($_GET['id'])){
$id = $_GET['id'];
$isReturn = $objAttributes->delete($arrOperate, $id);
if($isReturn)
$error_message = 'delete successfully.';
else
$error_message = 'delete fail.';
}
echo "<script language='javascript'>";
echo "alert(\"$error_message\");";
echo "location.href=\"".$_SERVER['HTTP_REFERER']."\";";
echo "</script>";
//$backurl = $_SERVER['HTTP_REFERER'];
//header("Location: $backurl");
?>
| 123gohelmetsv2 | trunk/admin/attributes/listAttributes_Delete.php | PHP | asf20 | 993 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation class
include_once("Users.php"); //--> User
include_once("Logs.php"); //--> logs class
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation instance
$objLogs = new Logs($uid); //--> logs instance
$objUser = new Users($uid); //--> user
$selfFileName = '';
$error_message = '';
$strMenuGroupName = '';
if(isset($_GET['keyword']) && !empty($_GET['keyword'])){
$keyword = $_GET['keyword'];
$where = " WHERE userid=$keyword ORDER BY intYear, intMonth, intDay DESC";
}else{
$where = ' ORDER BY intYear, intMonth, intDay DESC';
$keyword = '';
}
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(count($arrOperate) > 0){
$strQuery = $_SERVER["REQUEST_URI"];
$arrUrlInfo = pathinfo($strQuery);
$selfFileName = $arrUrlInfo['filename'];
$arrOperateAllInfo = $objOperate->listFromCustom($arrOperate, " WHERE id in (".implode(",", $arrOperate).")");
$i = 0;
foreach($arrOperateAllInfo as $key => $value){
$strFileName = $selfFileName."_".$value['name'].".php";
if(file_exists($strFileName)){
$arrOperateInfo[$i]['name'] = $value['name'];
$arrOperateInfo[$i]['viewName'] = $value['viewName'];
$i++;
}
}
}
$arrDataList = $objLogs->listLoginStatistic($arrOperate, $where, $page, DISPLAY_DATA_SIZE, '');
foreach($arrDataList as $key => $value){
$arrUserInfo = $objUser->getFromID($arrOperate, $value['userid']);
$arrDataList[$key]['username'] = $arrUserInfo['name'];
}
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_SYS_DIR;
$smarty->assign('error_message', $error_message);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('selfFileName', $selfFileName);
$smarty->assign('arrOperateInfo', $arrOperateInfo);
$smarty->assign('arrDataList', $arrDataList);
$smarty->assign('keyword', $keyword);
$smarty->assign('PAGE_BAR', $objLogs->pagenav);
$smarty->display('listLoginStatistic.htm');
?>
| 123gohelmetsv2 | trunk/admin/log/listLoginStatistic.php | PHP | asf20 | 2,381 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation class
include_once("Access.php"); //--> Access class
include_once("Validation.php"); //--> validation
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation instance
$objAccess = new Access($objSession->getLanguage()); //--> Access instance
$objValidation = new Validation(); //--> Validation
$selfFileName = '';
$error_message = '';
$strMenuGroupName = '';
$where = '';
$keyword = '';
$searchType = '';
if(isset($_GET['keyword']) && (!empty($_GET['keyword']) || $_GET['keyword'] == '0')){
$searchType = $_GET['searchType'];
$keyword = $_GET['keyword'];
if($searchType == "ip")
$where = " WHERE ip='$keyword'";
else if($searchType == "date")
$where = " WHERE visitDate='$keyword' ORDER BY visitDate DESC";
else if($searchType == "classid"){
if($objValidation->isNumber($keyword)){
$where = " WHERE classid=$keyword ORDER BY visitDate DESC";
}else
$error_message = 'Keyword isn\'t number.';
}
}else{
$where = ' ORDER BY visitDate DESC';
}
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(count($arrOperate) > 0){
$strQuery = $_SERVER["REQUEST_URI"];
$arrUrlInfo = pathinfo($strQuery);
$selfFileName = $arrUrlInfo['filename'];
$arrOperateAllInfo = $objOperate->listFromCustom($arrOperate, " WHERE id in (".implode(",", $arrOperate).")");
$i = 0;
foreach($arrOperateAllInfo as $key => $value){
$strFileName = $selfFileName."_".$value['name'].".php";
if(file_exists($strFileName)){
$arrOperateInfo[$i]['name'] = $value['name'];
$arrOperateInfo[$i]['viewName'] = $value['viewName'];
$i++;
}
}
}
$arrDataList = $objAccess->lists($arrOperate, DB_TAG_SYSTEM, $where, $page, DISPLAY_DATA_SIZE, '');
foreach($arrDataList as $key => $value){
}
$arrSearchType = array("ip" => "IP", "pageid" => "Page", "date" => "Date");
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_SYS_DIR;
$smarty->assign('error_message', $error_message);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('searchTypeS', $searchType);
$smarty->assign('arrSearchType', $arrSearchType);
$smarty->assign('selfFileName', $selfFileName);
$smarty->assign('arrOperateInfo', $arrOperateInfo);
$smarty->assign('arrDataList', $arrDataList);
$smarty->assign('keyword', $keyword);
$smarty->assign('PAGE_BAR', $objAccess->pagenav);
$smarty->display('listAccessLog.htm');
?>
| 123gohelmetsv2 | trunk/admin/log/listAccessLog.php | PHP | asf20 | 2,844 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation class
include_once("Users.php"); //--> User
include_once("Logs.php"); //--> logs class
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation instance
$objLogs = new Logs($uid); //--> logs instance
$objUser = new Users($uid); //--> user
$selfFileName = '';
$error_message = '';
$strMenuGroupName = '';
if(isset($_GET['keyword']) && !empty($_GET['keyword'])){
$keyword = $_GET['keyword'];
$where = " WHERE userid=$keyword ORDER BY id DESC";
}else{
$where = ' ORDER BY id DESC';
$keyword = '';
}
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(count($arrOperate) > 0){
$strQuery = $_SERVER["REQUEST_URI"];
$arrUrlInfo = pathinfo($strQuery);
$selfFileName = $arrUrlInfo['filename'];
$arrOperateAllInfo = $objOperate->listFromCustom($arrOperate, " WHERE id in (".implode(",", $arrOperate).")");
$i = 0;
foreach($arrOperateAllInfo as $key => $value){
$strFileName = $selfFileName."_".$value['name'].".php";
if(file_exists($strFileName)){
$arrOperateInfo[$i]['name'] = $value['name'];
$arrOperateInfo[$i]['viewName'] = $value['viewName'];
$i++;
}
}
}
$arrDataList = $objLogs->listOperateLog($arrOperate, $where, $page, DISPLAY_DATA_SIZE, '');
foreach($arrDataList as $key => $value){
$arrUserInfo = $objUser->getFromID($arrOperate, $value['userid']);
$arrDataList[$key]['username'] = $arrUserInfo['name'];
}
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_DIR;
$smarty->assign('error_message', $error_message);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('selfFileName', $selfFileName);
$smarty->assign('arrOperateInfo', $arrOperateInfo);
$smarty->assign('arrDataList', $arrDataList);
$smarty->assign('keyword', $keyword);
$smarty->assign('PAGE_BAR', $objLogs->pagenav);
$smarty->display('listOperateLog.htm');
?>
| 123gohelmetsv2 | trunk/admin/log/listOperateLog.php | PHP | asf20 | 2,327 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation class
include_once("Users.php"); //--> User
include_once("Logs.php"); //--> logs class
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation instance
$objLogs = new Logs($uid); //--> logs instance
$objUser = new Users($uid); //--> user
$selfFileName = '';
$error_message = '';
$strMenuGroupName = '';
if(isset($_GET['keyword']) && !empty($_GET['keyword'])){
$keyword = $_GET['keyword'];
$where = " WHERE userid=$keyword ORDER BY id DESC";
}else{
$where = ' ORDER BY id DESC';
$keyword = '';
}
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(count($arrOperate) > 0){
$strQuery = $_SERVER["REQUEST_URI"];
$arrUrlInfo = pathinfo($strQuery);
$selfFileName = $arrUrlInfo['filename'];
$arrOperateAllInfo = $objOperate->listFromCustom($arrOperate, " WHERE id in (".implode(",", $arrOperate).")");
$i = 0;
foreach($arrOperateAllInfo as $key => $value){
$strFileName = $selfFileName."_".$value['name'].".php";
if(file_exists($strFileName)){
$arrOperateInfo[$i]['name'] = $value['name'];
$arrOperateInfo[$i]['viewName'] = $value['viewName'];
$i++;
}
}
}
$arrDataList = $objLogs->listLoginLog($arrOperate, $where, $page, DISPLAY_DATA_SIZE, '');
foreach($arrDataList as $key => $value){
$arrUserInfo = $objUser->getFromID($arrOperate, $value['userid']);
$arrDataList[$key]['username'] = $arrUserInfo['name'];
}
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_DIR;
$smarty->assign('error_message', $error_message);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('selfFileName', $selfFileName);
$smarty->assign('arrOperateInfo', $arrOperateInfo);
$smarty->assign('arrDataList', $arrDataList);
$smarty->assign('keyword', $keyword);
$smarty->assign('PAGE_BAR', $objLogs->pagenav);
$smarty->display('listLoginLog.htm');
?>
| 123gohelmetsv2 | trunk/admin/log/listLoginLog.php | PHP | asf20 | 2,320 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
require_once("controlHeader.php"); //--> system control header
include_once("Country.php"); //--> Country
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$objCountry = new Country($uid); //--> Country
$error_message = '';
$question = '';
$answer = '';
$status = 'approved';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_POST['Submit'])){
$name = $_POST['name'];
$status = $_POST['status'];
if(empty($name))
$error_message = 'name should\'t be empty.';
else if(empty($namecn))
$error_message = 'answer should\'t be empty.';
else{
$isReturn = $objCountry->add($arrOperate, $name, $status);
if($isReturn)
$error_message = 'add successfully.';
else
$error_message = 'add failure.';
}
}
$arrStatus = array('approved' => 'approved', 'unapproved' => 'unapproved');
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_SYS_DIR;
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('backurl',$backurl);
$smarty->assign('error_message', $error_message);
$smarty->assign('name', $name);
$smarty->assign('arrStatus', $arrStatus);
$smarty->assign('statusS', $status);
$smarty->display('listCountry_Add.htm');
?>
| 123gohelmetsv2 | trunk/admin/country/listCountry_Add.php | PHP | asf20 | 1,588 |
<?php
include_once("../configure/admin.config.inc.php");//--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Operation.php"); //--> Operation
include_once("Country.php"); //--> Country
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation instance
$objCountry = new Country($uid); //--> Country
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_GET['id']) && !empty($_GET['id'])){
$id = $_GET['id'];
$isReturn = $objCountry->delete($arrOperate, $id);
if($isReturn)
$error_message = 'delete successfully.';
else
$error_message = 'delete failure.';
}
echo "<script language='javascript'>";
echo "alert(\"$error_message\");";
echo "location.href=\"".$_SERVER['HTTP_REFERER']."\";";
echo "</script>";
//$backurl = $_SERVER['HTTP_REFERER'];
//header("Location: $backurl");
?>
| 123gohelmetsv2 | trunk/admin/country/listCountry_Delete.php | PHP | asf20 | 965 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
include_once("Country.php"); //--> Country
require_once("controlHeader.php"); //--> system control header
include_once("Strings.php"); //--> String
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$objCountry = new Country($uid); //--> Country
$objString = new Strings(); //--> String
$error_message = '';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
$arrOperateInfo = $objOperate->arrGetOPInfo($arrOperate);
$arrDataList = $objCountry->lists($arrOperate, "", $page, DISPLAY_DATA_SIZE, '');
if(is_array($arrDataList)){
foreach($arrDataList as $key => $value){
$arrDataList[$key]['summary'] = $objString->cut(strip_tags($value['summary']), 60);
}
}
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_SYS_DIR;
$smarty->assign('error_message', $error_message);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('selfFileName', $objOperate->strGetSelfFileName());
$smarty->assign('arrOperateInfo', $arrOperateInfo);
$smarty->assign('arrDataList', $arrDataList);
$smarty->assign('PAGE_BAR', $objQA->pagenav);
$smarty->display('listCountry.htm');
?>
| 123gohelmetsv2 | trunk/admin/country/listCountry.php | PHP | asf20 | 1,516 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
require_once("controlHeader.php"); //--> system control header
include_once("Country.php"); //--> Country
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$objCountry = new Country($uid); //--> Country
$error_message = '';
$question = '';
$answer = '';
$status = 'approved';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
$arrDataInfo = $objCountry->getFromID($arrOperate, $id);
if(is_array($arrDataInfo)){
$name = $arrDataInfo['name'];
$status = $arrDataInfo['status'];
}
if(isset($_POST['Submit'])){
$name = $_POST['name'];
$status = $_POST['status'];
if(empty($name))
$error_message = 'name should\'t be empty.';
else{
$isReturn = $objCountry->edit($arrOperate, $id, $name, $status);
if($isReturn)
$error_message = 'edit successfully.';
else
$error_message = 'edit failure.';
}
}
$arrStatus = array('approved' => 'approved', 'unapproved' => 'unapproved');
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_SYS_DIR;
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('backurl',$backurl);
$smarty->assign('error_message', $error_message);
$smarty->assign('name', $name);
$smarty->assign('arrStatus', $arrStatus);
$smarty->assign('statusS', $status);
$smarty->display('listCountry_Edit.htm');
?>
| 123gohelmetsv2 | trunk/admin/country/listCountry_Edit.php | PHP | asf20 | 1,688 |
<?php
define('TEMPLATE_DIR', $_SERVER['DOCUMENT_ROOT'].'/templates_en-US/');
define('COMPILE_DIR', $_SERVER['DOCUMENT_ROOT'].'/templates_en-US_c/');
define('CACHE_DIR', $_SERVER['DOCUMENT_ROOT'].'/cache_en-US/');
define('TEMPLATE_SYS_DIR', $_SERVER['DOCUMENT_ROOT'].'/admin/templates_sys_en-US/');
define('COMPILE_SYS_DIR', $_SERVER['DOCUMENT_ROOT'].'/admin/templates_sys_en-US_c/');
define('CACHE_SYS_DIR', $_SERVER['DOCUMENT_ROOT'].'/admin/cache_sys_US/');
?> | 123gohelmetsv2 | trunk/admin/configure/en-US.inc.php | PHP | asf20 | 473 |
<?php
include_once("Session.php"); //--> Session
$objSession = new Session(); //--> session
/*----- check session -----*/
if($objSession->exist()) {
$gid = $objSession->getGroupID();
$uid = $objSession->getUserID();
}else{
header("Location: ../login.php");
exit;
}
if(isset($_GET["Lan"])){
$arrLan = array("lan" => $_GET["Lan"]);
$objSession->add($arrLan);
}
if($objSession->getLanguage() == "zh-CN"){
include_once("zh-CN.inc.php"); //--> zh_CN
}else{
include_once("en-US.inc.php"); //--> us_EN
}
if(isset($_GET['menuGid']) && isset($_GET['menuid'])){
$menuGid = $_GET['menuGid'];
$menuid = $_GET['menuid'];
$id = $_GET['id'];
}else{
$menuGid = $_POST['menuGid'];
$menuid = $_POST['menuid'];
$id = $_POST['id'];
}
if(isset($_POST['backurl']))
$backurl = $_POST['backurl'];
else
$backurl = $_SERVER['HTTP_REFERER'];
?> | 123gohelmetsv2 | trunk/admin/configure/controlHeader.php | PHP | asf20 | 878 |
<?php
define('TEMPLATE_DIR', $_SERVER['DOCUMENT_ROOT'].'/admin/templates_zh-CN/');
define('COMPILE_DIR', $_SERVER['DOCUMENT_ROOT'].'/admin/templates_zh-CN_c/');
define('CACHE_DIR', $_SERVER['DOCUMENT_ROOT'].'/admin/cache_zh-CN/');
define('TEMPLATE_SYS_DIR', $_SERVER['DOCUMENT_ROOT'].'/admin/templates_sys_zh-CN/');
define('COMPILE_SYS_DIR', $_SERVER['DOCUMENT_ROOT'].'/admin/templates_sys_zh-CN_c/');
define('CACHE_SYS_DIR', $_SERVER['DOCUMENT_ROOT'].'/admin/cache_sys_zh-CN/');
?> | 123gohelmetsv2 | trunk/admin/configure/zh-CN.inc.php | PHP | asf20 | 494 |
<?php
define('DB_TAG_PUBLIC', 'gohelmets');
define('DB_TAG_SYSTEM', 'system');
$ARR_GLOGAL_DB_CONFIG[DB_TAG_PUBLIC]["host"] = "localhost:3306";
$ARR_GLOGAL_DB_CONFIG[DB_TAG_PUBLIC]["user"] = "root";
$ARR_GLOGAL_DB_CONFIG[DB_TAG_PUBLIC]["pwd"] = "242143";
$ARR_GLOGAL_DB_CONFIG[DB_TAG_PUBLIC]["db"] = "gohelmets_v2";
$ARR_GLOGAL_DB_CONFIG[DB_TAG_PUBLIC]["encoding"] = "UTF8";
$ARR_GLOGAL_DB_CONFIG[DB_TAG_SYSTEM]["host"] = "localhost:3306";
$ARR_GLOGAL_DB_CONFIG[DB_TAG_SYSTEM]["user"] = "root";
$ARR_GLOGAL_DB_CONFIG[DB_TAG_SYSTEM]["pwd"] = "242143";
$ARR_GLOGAL_DB_CONFIG[DB_TAG_SYSTEM]["db"] = "gohelmets_v2";
$ARR_GLOGAL_DB_CONFIG[DB_TAG_SYSTEM]["encoding"] = "UTF8";
?>
| 123gohelmetsv2 | trunk/admin/configure/db.inc.php | PHP | asf20 | 697 |
<?php
define(SYSTEM_SAFE_KEY, 'uagdvdvcxggb32t35y45j');
?>
| 123gohelmetsv2 | trunk/admin/configure/security.php | PHP | asf20 | 59 |
<?php
include_once("session.inc.php");
include_once("security.php");
define('HOME_PATH_URL','http://127.0.0.1:93/'); //--
define('DISPLAY_DATA_SIZE', 20);
define('DEFAULT_LAN', "en-US");
//define('DEFAULT_LAN', "zh-CN");
define('PRODUCT_IMAGE_DIR', $_SERVER['DOCUMENT_ROOT'] . "/images/product/");
define('DIR_IMAGE_HOME', $_SERVER['DOCUMENT_ROOT'] . "/ebay/");
define('PRODUCT_IMAGE_URL', HOME_PATH_URL . "/images/product/");
define('FCKeditor_BASE_PATH', "../tools/fckeditor/");
/*----- smarty safe -----*/
header('Content-Type: text/html; charset=UTF-8');
header("Cache-Control: no-store, no-cache, must-revalidate");
ini_set("display_errors",true); //-- show error
//--linux ini_set("include_path", ".:".$_SERVER['DOCUMENT_ROOT']."/lib:".$_SERVER['DOCUMENT_ROOT']."/configs:".$_SERVER['DOCUMENT_ROOT']."/admin/configs:".$_SERVER['DOCUMENT_ROOT']."/smarty");
ini_set("include_path", ".;".$_SERVER['DOCUMENT_ROOT']."/admin/lib;".$_SERVER['DOCUMENT_ROOT']."/configure;".$_SERVER['DOCUMENT_ROOT']."/admin/configure;".$_SERVER['DOCUMENT_ROOT']."/admin/tools/smarty/libs");
$ARR_FILTER_TAG = array('script');
$LANGEUAGE_ID = 1;
$ZONE_ID = 1;
$CURRENCY = '$';
?>
| 123gohelmetsv2 | trunk/admin/configure/admin.config.inc.php | PHP | asf20 | 1,203 |
<?php
/*
* Created on Feb 10, 2011
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
define("ENTER",chr(13).chr(10)); //--- enter
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Common.php"); //--> Common
include_once("Xml.php"); //--> Xml
include_once("Strings.php"); //--> String utils
$oCommon = new Common(); //--> Common
$oXml = new Xml(); //--> Xml
$objStrings = new Strings();
$oXml->add('url', '', '', 'start');
$url = ENTER . 'http://www.123gohelmets.com';
$oXml->add('loc', '', $url, 'start');
$oXml->add('loc', '', '', 'end');
$oXml->add('url', '', '', 'end');
$sql = "SELECT p.id, pd.name FROM products p, products_description pd WHERE p.status in ('hot', 'normal') AND p.id = pd.productID AND pd.languageID = 1";
$allproducts = $oCommon->getAllData(DB_TAG_PUBLIC, $sql);
foreach($allproducts as $row){
$arrImages = $oCommon->getHash(DB_TAG_PUBLIC, "SELECT u.id, u.extName FROM upload_files u, product_images p WHERE u.id = p.imageID AND p.productID = " . $row['id'] . ' AND u.type = 1 ORDER BY p.isMain');
$oXml->add('url', '', '', 'start');
$url = ENTER . 'http://www.123gohelmets.com/p/' . $row['id'] . '/' . $objStrings->getCharNum($row['name']) . '.html';
$oXml->add('loc', '', $url, 'start');
$oXml->add('loc', '', '', 'end');
if(count($arrImages) > 0){
foreach($arrImages as $imageid => $imageExt){
//<image:loc>http://example.com/image.jpg</image:loc>
$oXml->add('image:image', '', '', 'start');
$imageURL = ENTER . "http://www.123gohelmets.com/img/0/0/$imageid/" . $objStrings->getCharNum($row['name']) . '.' . $imageExt;
$oXml->add('image:loc', '', $imageURL, 'start');
$oXml->add('image:loc', '', '', 'end');
$oXml->add('image:image', '', '', 'end');
}
}
$oXml->add('url', '', '', 'end');
}
$sql = "SELECT id, name FROM info_class WHERE parentid > 0";
$allproducts = $oCommon->getAllData(DB_TAG_PUBLIC, $sql);
foreach($allproducts as $row){
$oXml->add('url', '', '', 'start');
$url = ENTER . 'http://www.123gohelmets.com/c/' . $row['id'] . '/1/' . $objStrings->getCharNum($row['name']) . '.html';
$oXml->add('loc', '', $url, 'start');
$oXml->add('loc', '', '', 'end');
$oXml->add('url', '', '', 'end');
}
$oXml->createXml('../../siteMapFiles/googleSiteMap.xml', 'urlset', ' xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"');
echo "Created file by Crontab"
?>
| 123gohelmetsv2 | trunk/admin/siteMap/googleSiteMap.php | PHP | asf20 | 2,712 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Orders.php"); //--> Orders
include_once("Operation.php"); //--> Operation
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation(); //--> Operation
$objOrders = new Orders(DB_TAG_PUBLIC, $uid); //--> Orders
$error_message = '';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
$arrOrders = $objOrders->getByID($arrOperate, $id);
$myStore = $objOrders->getRow(DB_TAG_PUBLIC, "SELECT c.title, c.values FROM configuration c, configuration_group g WHERE c.groupID=g.id AND g.title = 'My Store' AND c.keyes = 'STORE_NAME_ADDRESS'");
$ordersid = $id;
$arrOrders = $objOrders->getRow(DB_TAG_PUBLIC, "SELECT * FROM orders WHERE id = $ordersid");
$arrOrdersProducts = array();
$arrProducts = $objOrders->listCustom(DB_TAG_PUBLIC, '*', "orders_products WHERE ordersID=$ordersid", '', 0, 100, '');
foreach($arrProducts as $key => $row){
$arrAttribute = $objOrders->getAllData(DB_TAG_PUBLIC, "SELECT * FROM orders_products_attributes WHERE orderProdID = ".$row['id']." AND ordersID = $ordersid");
if(count($arrAttribute) > 0){
$row['attributes'] = $arrAttribute;
}
$arrOrdersProducts[] = $row;
}
//$arrDataList = $objOrders->listCustom(DB_TAG_PUBLIC, '*', "orders_products WHERE ordersID=$id", '', 0, 100, '');
$arrAccountList = $objOrders->listCustom(DB_TAG_PUBLIC, '*', "orders_account WHERE ordersID=$id", " ORDER BY classes", 0, 100, '');
//$arrStatusList = $objOrders->listCustom(DB_TAG_PUBLIC, '*', "orders_Status_history WHERE ordersID=$id", " ORDER BY id", 0, 100, '');
//$arrAttributes = $objOrders->listCustom(DB_TAG_PUBLIC, '*', "orders_products_attributes WHERE ordersID=$id", " ORDER BY id", 0, 100, '');
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = CACHE_SYS_DIR;
$smarty->assign('error_message', $error_message);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('backurl',$backurl);
$smarty->assign('id', $id);
$smarty->assign('myStore', $myStore);
$smarty->assign('arrOrders', $arrOrders);
$smarty->assign('arrOrdersProducts', $arrOrdersProducts);
//$smarty->assign('arrDataList', $arrDataList);
$smarty->assign('arrAccountList', $arrAccountList);
//$smarty->assign('arrStatusList', $arrStatusList);
$smarty->display('listOrders_Invoice.htm');
?>
| 123gohelmetsv2 | trunk/admin/orders/listOrders_Invoice.php | PHP | asf20 | 2,606 |
<?php
include_once("../configure/admin.config.inc.php");//--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Operation.php"); //--> Operation
include_once("Orders.php"); //--> Orders
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation instance
$objOrders = new Orders(DB_TAG_SYSTEM, $uid); //--> Manufacturer
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_GET['id']) && !empty($_GET['id'])){
$id = $_GET['id'];
$isReturn = $objOrders->delete($arrOperate, $id);
if($isReturn)
$error_message = 'delete successfully.';
else
$error_message = 'delete failure.';
}
echo "<script language='javascript'>";
echo "alert(\"$error_message\");";
echo "location.href=\"".$_SERVER['HTTP_REFERER']."\";";
echo "</script>";
//$backurl = $_SERVER['HTTP_REFERER'];
//header("Location: $backurl");
?>
| 123gohelmetsv2 | trunk/admin/orders/listOrders_Delete.php | PHP | asf20 | 981 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Orders.php"); //--> Orders
include_once("Operation.php"); //--> Operation
include_once("TimeZone.php"); //--> TimeZone
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation(); //--> Operation
$objOrders = new Orders(DB_TAG_PUBLIC, $uid); //--> Orders
$oTimeZone = new TimeZone(); //--> TimeZone
$error_message = '';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
$arrOrders = $objOrders->getByID($arrOperate, $id);
if(isset($_POST['Submit'])){
$id = $_POST['id'];
$status = $_POST['status'];
$comments = $_POST['comments'];
$notified = $_POST['notify'];
if(empty($notified))
$notified = 'Yes';
else
$notified = 'No';
if(empty($comments))
$error_message = 'The comments should\'t be empty.';
if(empty($error_message)){
$isReturn = $objOrders->addStatus($arrOperate, $id, $status, $notified, $comments);
if($isReturn){
$objOrders->update(DB_TAG_PUBLIC, "UPDATE orders SET status = '$status' WHERE id = $id");
if($status == 'shipped'){
$customer = $objOrders->getRow(DB_TAG_SYSTEM, "SELECT id, firstname, lastname, email FROM customers WHERE id = " . $arrOrders['customers_id']);
if(count($customer) > 0){
$emailContent = "<div><p>Dear " . $customer['firstname'] . ", <br />
<br />
Thank you for shopping at 123gohelmets.com. <br />
<br />
<br />
Your order is packaged and ready to leave our Distribution Center. <br />
<br />
Your order number is (#" . $arrOrders['id'] . ") and will be shipped via UNITED PARCEL SERVICE COMM GRNDTRA. <br />
Within 24-48 hours of receiving this email, you may track the delivery status of your order at: </p>
<p>UPS tracking #( ) </p>
<p>Please note: We have assigned a tracking number to your package(s) prior to the carrier's receipt of your order. If your tracking number does not appear immediately, the carrier may still be processing this information. You may need to check the carrier's site periodically for updated information. <br />
<br />
This message is electronically generated, please do not respond to this email. If you need further assistance please e-mail us at 123gohelmets@mail.com. <br />
<br />
Thanks again for choosing 123gohelmets.com. We look forward to serving your future Helmet and Goggles needs. </p>
</div>";
$subject = 'Thank you for shopping at 123gohelmets.com.';
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=utf8\r\n";
/* additional headers */
$headers .= "From: Sam <atvglove@gmail.com>\r\n";
/* and now mail it */
$siSuccess = mail($customer['email'], $subject, $emailContent, $headers);
if($siSuccess){
$error_message = 'Notice email send to ' . $customer['email'] . '<br>';
}else
$error_message = 'Notice email send to ' . $customer['email'] . ' failed. <br>';
}
}
$error_message .= 'edit successfully.';
}else{
$error_message = 'edit failure.';
}
}
}
$arrStatusList = array();
$arrDataList = $objOrders->listCustom(DB_TAG_PUBLIC, '*', "orders_products WHERE ordersID=$id", '', 0, 100, '');
$arrAccountList = $objOrders->listCustom(DB_TAG_PUBLIC, '*', "orders_account WHERE ordersID=$id", " ORDER BY classes", 0, 100, '');
$arrAllStatusList = $objOrders->listCustom(DB_TAG_PUBLIC, '*', "orders_status_history WHERE ordersID=$id", " ORDER BY id", 0, 100, '');
//$arrAttributes = $objOrders->listCustom(DB_TAG_PUBLIC, '*', "orders_products_attributes WHERE ordersID=$id", " ORDER BY id", 0, 100, '');
foreach($arrAllStatusList as $row){
$DatePurchased = $oTimeZone->getTime($row['createdTime'], 'UTC', 'America/Los_Angeles');
$row['datePurchased'] = $DatePurchased;
$arrStatusList[] = $row;
}
$arrOrdersProducts = array();
foreach($arrDataList as $key => $row){
$arrAttribute = $objOrders->getAllData(DB_TAG_PUBLIC, "SELECT * FROM orders_products_attributes WHERE orderProdID = ".$row['id']." AND ordersID = $id");
if(count($arrAttribute) > 0){
$row['attributes'] = $arrAttribute;
}
$arrOrdersProducts[] = $row;
}
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = CACHE_SYS_DIR;
$smarty->assign('error_message', $error_message);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('backurl',$backurl);
$smarty->assign('id', $id);
$smarty->assign('arrOrders', $arrOrders);
$smarty->assign('arrDataList', $arrOrdersProducts);
$smarty->assign('arrAccountList', $arrAccountList);
$smarty->assign('arrStatusList', $arrStatusList);
$smarty->display('listOrders_View.htm');
?>
| 123gohelmetsv2 | trunk/admin/orders/listOrders_View.php | PHP | asf20 | 5,048 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
include_once("Customer.php"); //--> Customer
include_once("Country.php"); //--> Country
include_once("AddressBook.php"); //--> AddressBook
include_once("Validation.php"); //--> Validation
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$objCustomer = new Customer(DB_TAG_SYSTEM, $uid); //--> Customer
$objCountry = new Country($uid); //--> Country
$objAddressBook = new AddressBook($uid); //--> AddressBook
$objValidation = new Validation($uid); //--> Validation
$error_message = '';
$gender = '';
$firstname = '';
$lastname = '';
$email = '';
$oldemail = '';
$telephone = '';
$fax = '';
$zoneid = 1;
$countryid = 223;
$company = '';
$postcode = '';
$state = '';
$city = '';
$street = '';
$newsletter = 'unsubscribed';
$address_id = 0;
$password = '';
$arrAddressBook = array();
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_POST['Submit'])){
$id = $_POST['id'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$fax = $_POST['fax'];
$countryid = $_POST['countryid'];
$company = $_POST['company'];
$postcode = $_POST['postcode'];
$state = $_POST['state'];
$city = $_POST['city'];
$street = $_POST['street'];
$newsletter = $_POST['newsletter'];
if(empty($firstname))
$error_message = 'The first name should\'t be empty.';
else if(empty($lastname)){
$error_message = 'The first name should\'t be empty.';
}else if(empty($email)){
$error_message = 'The email should\'t be empty.';
}else if(!$objValidation->isEmail($email)){
$error_message = 'The email format invalid.';
}else if($objCustomer->IsExistEmail($email) && $email != $oldemail){
$error_message = 'the email be existed.';
}
if(empty($error_message)){
if($address_id > 0)
$objAddressBook->edit($address_id, $id, $gender, $company, $firstname, $lastname, $street, $suburb, $postcode, $city, $state, $countryid, $zoneid);
$isReturnOrg = $objCustomer->edit($arrOperate, $id, $gender, $firstname, $lastname, $email, $address_id, $telephone, $fax, $newsletter, $password);
if($isReturnOrg)
$error_message = 'edit successfully.';
else{
$error_message = 'edit failure.';
}
}
}
$arrCountries = $objCountry->getGroupList();
$arrNewsletter = array('subscribed' => 'Subscribed', 'unsubscribed' => 'Unsubscribed');
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_SYS_DIR;
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('id', $id);
$smarty->assign('error_message', $error_message);
$smarty->assign('backurl',$backurl);
$smarty->assign('firstname', $firstname);
$smarty->assign('lastname', $lastname);
$smarty->assign('email', $email);
$smarty->assign('countryid', $countryid);
$smarty->assign('arrCountries', $arrCountries);
$smarty->assign('newsletter', $newsletter);
$smarty->assign('arrNewsletter', $arrNewsletter);
$smarty->assign('telephone', $telephone);
$smarty->assign('fax', $fax);
$smarty->assign('company', $company);
$smarty->assign('postcode', $postcode);
$smarty->assign('state', $state);
$smarty->assign('city', $city);
$smarty->assign('street', $street);
$smarty->display('listCustomer_Edit.htm');
?>
| 123gohelmetsv2 | trunk/admin/orders/listOrders_Edit.php | PHP | asf20 | 3,739 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Orders.php"); //--> Orders
include_once("Operation.php"); //--> Operation
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation(); //--> Operation
$objOrders = new Orders(DB_TAG_PUBLIC, $uid); //--> Orders
$error_message = '';
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
$arrOrders = $objOrders->getByID($arrOperate, $id);
$myStore = $objOrders->getRow(DB_TAG_PUBLIC, "SELECT c.title, c.values FROM configuration c, configuration_group g WHERE c.groupID=g.id AND g.title = 'My Store' AND c.keyes = 'STORE_NAME_ADDRESS'");
$arrDataList = $objOrders->listCustom(DB_TAG_PUBLIC, '*', "orders_products WHERE ordersID=$id", '', 0, 100, '');
//$arrAccountList = $objOrders->listCustom(DB_TAG_PUBLIC, '*', "orders_Account WHERE ordersID=$id", " ORDER BY classes", 0, 100, '');
//$arrStatusList = $objOrders->listCustom(DB_TAG_PUBLIC, '*', "orders_Status_history WHERE ordersID=$id", " ORDER BY id", 0, 100, '');
//$arrAttributes = $objOrders->listCustom(DB_TAG_PUBLIC, '*', "orders_products_attributes WHERE ordersID=$id", " ORDER BY id", 0, 100, '');
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = CACHE_SYS_DIR;
$smarty->assign('error_message', $error_message);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('backurl',$backurl);
$smarty->assign('id', $id);
$smarty->assign('myStore', $myStore);
$smarty->assign('arrOrders', $arrOrders);
$smarty->assign('arrDataList', $arrDataList);
//$smarty->assign('arrAccountList', $arrAccountList);
//$smarty->assign('arrStatusList', $arrStatusList);
$smarty->display('listOrders_Packingslip.htm');
?>
| 123gohelmetsv2 | trunk/admin/orders/listOrders_Packingslip.php | PHP | asf20 | 1,980 |
<?php
include_once("../configure/admin.config.inc.php"); //--> admin global var
include_once("db.inc.php"); //--> db global var
include_once("Smarty.class.php"); //--> out template
include_once("Operation.php"); //--> Operation
include_once("Orders.php"); //--> Orders
include_once("TimeZone.php"); //--> TimeZone
require_once("controlHeader.php"); //--> system control header
$objOperate = new Operation($objSession->getLanguage()); //--> Operation
$oOrders = new Orders(DB_TAG_PUBLIC, $uid); //--> Orders
$oTimeZone = new TimeZone(); //--> TimeZone
$error_message = '';
date_default_timezone_set('America/Los_Angeles');
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(count($arrOperate) > 0){
$strQuery = $_SERVER["REQUEST_URI"];
$arrUrlInfo = pathinfo($strQuery);
$selfFileName = $arrUrlInfo['filename'];
$arrOperateAllInfo = $objOperate->listFromCustom($arrOperate, " WHERE id in (".implode(",", $arrOperate).") AND name != 'Add'");
$i = 0;
foreach($arrOperateAllInfo as $key => $value){
$strFileName = $selfFileName."_".$value['name'].".php";
if(file_exists($strFileName)){
$arrOperateInfo[$i]['name'] = $value['name'];
$arrOperateInfo[$i]['viewName'] = $value['name'];
$i++;
}
}
}
$where = ' ORDER BY id DESC';
if(isset($_GET['id']) && !empty($_GET['id'])){
$customerid = $_GET['id'];
$where = " WHERE languageID = $LANGEUAGE_ID AND customers_id = $customerid ORDER BY id DESC";
}
if(isset($_GET['keyword']) && !empty($_GET['keyword'])){
$keyword = $_GET['keyword'];
$searchType = $_GET['searchType'];
if(empty($keyword)){
$error_message = 'The keyword should\'t be empty.';
}else{
if($searchType == 'id'){
if(is_numeric($keyword))
$where = " WHERE id = $keyword";
else
$error_message = 'The keyword should\'t be product ID.';
}else if($searchType == 'name'){
$where = " WHERE languageID = $LANGEUAGE_ID AND customers_name like '%$keyword%'";
}else if($searchType == 'status'){
$where = " WHERE languageID = $LANGEUAGE_ID AND status like '%$keyword%'";
}else{
$where = " WHERE languageID = $LANGEUAGE_ID AND customers_name like '%$keyword%'";
}
}
}
$arrDataList = array();
$arrAllDataList = $oOrders->lists($arrOperate, $where, $page, DISPLAY_DATA_SIZE, '');
foreach($arrAllDataList as $row){
$DatePurchased = $oTimeZone->getTime($row['createdTime'], 'UTC', 'America/Los_Angeles');
$row['datePurchased'] = $DatePurchased;
$arrDataList[] = $row;
}
$arrSearchType = array('id' => 'Number', 'name' => 'Name', 'status' => 'Status');
/*----- out html -----*/
$smarty = new Smarty(); //----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir = COMPILE_SYS_DIR;
$smarty->assign('error_message', $error_message);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('selfFileName', $selfFileName);
$smarty->assign('arrOperateInfo', $arrOperateInfo);
$smarty->assign('arrSearchType', $arrSearchType);
$smarty->assign('searchTypeS', $searchType);
$smarty->assign('keyword', $keyword);
$smarty->assign('arrDataList', $arrDataList);
$smarty->assign('PAGE_BAR', $oOrders->pagenav);
$smarty->display('listOrders.htm');
?>
| 123gohelmetsv2 | trunk/admin/orders/listOrders.php | PHP | asf20 | 3,257 |
<?php
/*
* Created on Dec 2, 2010
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
class CouponCustomer
{
private $id;
private $type;
private $couponID;
private $customerID;
public function CouponCustomer()
{
}
public function setID($id)
{
$this->id = $id;
}
public function getID()
{
return $this->id;
}
public function setCouponID($couponID)
{
$this->couponID = $couponID;
}
public function getCouponID()
{
return $this->couponID;
}
public function setCustomerID($customerID)
{
$this->customerID = $customerID;
}
public function getCustomerID()
{
return $this->customerID;
}
public function setType($type)
{
$this->type = $type;
}
public function getType()
{
return $this->type;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/CouponCustomer.php | PHP | asf20 | 908 |
<?php
/* explain: common class
* Project: marsems
* File: Common.php
*
* @ link http://www.marems.com/lib/
* @ Email ldmmyx@hotmail.com
* @ copyright 2007 ivan.ling
* @ author ivan.ling
* @ version 1.0
*
* @ --- function list ---
* @ mutilPager($total, $page, $disDataCount, $url) --> split page function
*/
include_once("Popedom.php");
class Common extends Popedom
{
public $total; //-- data total
public $pagenav; //-- navication bar
public $goNav; //-- navication bar
public $page; //-- current page
public $prePage; //-- previous page
public $nextPage; //-- next page
public $disDataCount; //-- display data total
public $disPageCount; //-- display page total
public $firstcount; //-- first page position
public $pagecount; //-- page total, lastest page
public $currentStartPostion;
public $currentEndPostion;
function Common()
{
parent::Popedom();
$this->total = 0;
$this->pagenav = '';
$this->page = 1;
$this->disDataCount = 20;
$this->disPageCount = 10;
$this->firstcount = 1;
}
public function getPage()
{
return $this->page;
}
public function getPrePage()
{
$this->prePage = $this->page - 1;
if($this->prePage > 1)
return $this->prePage;
else
return 1;
}
public function getNextPage()
{
$this->nextPage = $this->page + 1;
if($this->nextPage > 1)
return $this->nextPage;
else
return 1;
}
public function getPageList($pagecount = 5)
{
$arrReturn = array();
if($pagecount > $this->pagecount)
$pagecount = $this->pagecount;
$firstPage = $this->page - floor($pagecount / 2);
if(($this->pagecount - $this->page) < ($this->page - $firstPage)){
$firstPage = $this->pagecount - $pagecount;
}
if($firstPage <= 0)
$firstPage = 1;
$endPage = $firstPage + $pagecount;
if($endPage > $this->pagecount)
$pagecount = $this->pagecount;
for($i = $firstPage; $i < $endPage; $i++){
$arrReturn[] = $i;
}
return $arrReturn;
}
public function getStartPosition()
{
return $this->currentStartPostion;
}
public function getEndPostion()
{
return $this->currentEndPostion;
}
public function getTotal()
{
return $this->total;
}
public function getPageCount()
{
return $this->pagecount;
}
/**
* split page paramter
*
* @param string total data total
* @param string page current page
* @param string disDataCount current page
* @param string url defaul page url
* @param return string return navication bar string
*/
public function mutilPager($total, $page, $disDataCount, $url)
{
global $_SERVER, $_GET;
$this->total = $total;
if(empty($total)){
$this->page = 0;
$this->pagecount = 0;
$this->firstcount = 0;
$this->pagenav = '';
$this->goNav = '';
return 'There be not find data.';
}
if(empty($disDataCount)){
return 'find '.$total.' data.';
}
if(!isset($page) || empty($page)){
if(isset($_GET['page']))
$page = $_GET['page'];
else
$page = 1;
}
$this->page = $page;
if(empty($url))//--- if url is empty . url equal current page url
$url = $_SERVER["REQUEST_URI"];
/*--- URL process ---*/
$parse_url = parse_url($url);
if(isset($parse_url["query"]))
$url_query = $parse_url["query"]; //--- get url query string
else
$url_query = '';
if($url_query){
$url_query=ereg_replace("(^|&)page=$page","",$url_query);
$url = str_replace($parse_url["query"],$url_query,$url);//---
if($url_query)//---
$url .= "&page";
else
$url .= "page";
}else
$url .= "?page";
/*--- page process ---*/
$this->disDataCount = $disDataCount;
$this->pagecount = ceil($total/$disDataCount); //--- lastest page
$this->page = min($this->pagecount, $this->page);
//$prepg = $page-1;
//$nextpg =($page == $this->pagecount ? 0 : $page + 1);
$this->firstcount=($this->page - 1) * $this->disDataCount;
$this->currentStartPostion = $this->firstcount + 1;
$this->currentEndPostion = min($this->firstcount + $this->disDataCount, $total);
/*--- start navication bar ---*/
$this->pagenav = ' <B>'.($total?($this->firstcount + 1):0)."</B>-<B>".min($this->firstcount + $this->disDataCount, $total)."</B> of ". $total . " ";
$this->goNav ="<select name='topage' size='1' onchange='window.location=\"$url=\"+this.value'>\n";
for($i = 1;$i <= $this->pagecount; $i++){
if($i == $this->page)
$this->goNav .= "<option value='$i' selected>$i</option>\n";
else
$this->goNav .= "<option value='$i'>$i</option>\n";
}
$this->goNav .= "</select> ";
/*--- ---*/
if($this->pagecount <= 1){
return $this->pagenav;
}
if($this->page <= $this->pagecount){
$this->pagenav .= ' < ';
$istart = (floor($this->page / $this->disPageCount)) * $this->disPageCount;
if($this->page == $istart + 1 && $this->page != 1)
$istart = (floor($this->page / $this->disPageCount) - 1) * $this->disPageCount;
$iend = $istart + $this->disPageCount;
if($iend > $this->pagecount)
$iend = $this->pagecount;
for($i = $istart; $i < $iend; $i++){
if($this->page == ($i + 1))
$this->pagenav .= ($i + 1) . ' ';
else
$this->pagenav .= "<a href='$url=" . ($i + 1) . "'>" . ($i + 1) . "</a> ";
}
$this->pagenav .= '> ';
}
/*-- go to some page --
$this->pagenav.=" Go <select name='topage' size='1' onchange='window.location=\"$url=\"+this.value'>\n";
for($i = 1;$i <= $this->pagecount; $i++){
if($i == $page)
$this->pagenav .= "<option value='$i' selected>$i</option>\n";
else
$this->pagenav .= "<option value='$i'>$i</option>\n";
}
$this->pagenav .= "</select> ";*/
// $this->pagenav .= " Go " . $this->goNav;
return $this->pagenav;
}
/**
* split page paramter
*
* @param string total data total
* @param string page current page
* @param string disDataCount current page
* @param string url defaul page url
* @param return string return navication bar string
*/
public function mutilPagerRewriter($total, $page, $disDataCount, $url)
{
global $_SERVER, $_GET;
$this->total = $total;
if(empty($total)){
$this->page = 0;
$this->pagecount = 0;
$this->firstcount = 0;
$this->pagenav = '';
$this->goNav = '';
return 'There be not find data.';
}
if(empty($disDataCount)){
return 'find '.$total.' data.';
}
if(!isset($page) || empty($page)){
if(isset($_GET['page']))
$page = $_GET['page'];
else
$page = 1;
}
$this->page = $page;
if(empty($url))//--- if url is empty . url equal current page url
$url = $_SERVER["REQUEST_URI"];
/*--- URL process ---*/
$parse_url = parse_url($url);
$isBeforQuery = true;
$beforQuery = '';
$afterQuery = '';
$arrQuery = explode("_", basename($parse_url["path"]));
$paramTotal = count($arrQuery);
for($i = 0; $i < $paramTotal; $i++){
if($isBeforQuery) {
if(!empty($beforQuery))
$beforQuery .= '_';
if($i == $paramTotal - 1){//-->> file name
$beforQuery .= 'pg_';
$afterQuery .= '_';
$afterQuery .= $arrQuery[$i];
}else{
$beforQuery .= $arrQuery[$i];
if($arrQuery[$i] == 'pg'){//--> is page premeter
$beforQuery .= '_';
$isBeforQuery = false;
$i++;
}
}
}else{
if(!empty($beforQuery) && empty($afterQuery))
$afterQuery .= '_';
$afterQuery .= $arrQuery[$i];
}
}
/*--- page process ---*/
$this->disDataCount = $disDataCount;
$this->pagecount = ceil($total/$disDataCount); //--- lastest page
$this->page = min($this->pagecount, $this->page);
//$prepg = $page-1;
//$nextpg =($page == $this->pagecount ? 0 : $page + 1);
$this->firstcount=($this->page - 1) * $this->disDataCount;
/*--- start navication bar ---*/
$this->pagenav = ' <B>'.($total?($this->firstcount+1):0)."</B>-<B>".min($this->firstcount+$this->disDataCount,$total)."</B> of ". $total . " ";
$this->goNav ="<select name='topage' size='1' onchange='window.location=\"$beforQuery\"+this.value+\"$afterQuery\"'>\n";
for($i = 1;$i <= $this->pagecount; $i++){
if($i == $this->page)
$this->goNav .= "<option value='$i' selected>$i</option>\n";
else
$this->goNav .= "<option value='$i'>$i</option>\n";
}
$this->goNav .= "</select> ";
/*--- ---*/
if($this->pagecount <= 1){
return $this->pagenav;
}
if($this->page <= $this->pagecount){
$this->pagenav .= ' < ';
$istart = (floor($this->page / $this->disPageCount)) * $this->disPageCount;
if($this->page == $istart + 1 && $this->page != 1)
$istart = (floor($this->page / $this->disPageCount) - 1) * $this->disPageCount;
$iend = $istart + $this->disPageCount;
if($iend > $this->pagecount)
$iend = $this->pagecount;
for($i = $istart; $i < $iend; $i++){
$this->pagenav .= "<a href='$beforQuery" . ($i + 1) . "$afterQuery'>" . ($i + 1) . "</a> ";
}
$this->pagenav .= '> ';
}
$this->pagenav .= " Go " . $this->goNav;
return $this->pagenav;
}
public function arrMutilPage($arrData, $page, $pagesize)
{
$total = count($arrData);
if(empty($page))
$page = $this->page;
if(empty($pagesize))
$pagesize = $this->disDataCount;
$pageTotal = ceil($total / $pagesize);
if($page > $pageTotal)
$page = $pageTotal;
$startpos = ($page - 1) * $pagesize;
$endpos = $startpos + $pagesize;
$datalist = '';
for($i = 0; $i < $total; $i++){
if($i >= $startpos && $i < $endpos){
if(!empty($datalist))
$datalist .= ',';
$datalist .= $arrData[$i];
}
if($i > $endpos)
break;
}
$arrReturn = array();
$arrReturn['page'] = $page;
$arrReturn['pageTotal'] = $pageTotal;
$arrReturn['datalist'] = $datalist;
$arrReturn['pagesize'] = $pagesize;
return $arrReturn;
}
public function getRow($DBtag, $sql)
{
$arrBack = array();
$conn = null;
try{
$conn = $this->getConnection($DBtag);
$rs = mysql_query($sql, $conn) or die("Invalid query: " . $sql . mysql_error($conn));
if($rs && mysql_num_rows($rs) > 0){
$arrBack = mysql_fetch_array($rs);
}
mysql_free_result($rs);
}catch(Exception $e){
echo mysql_error($conn) . $sql;
}
if($conn != null)
$this->freeConnection($DBtag, $conn);
return $arrBack;
}
public function isExisted($DBtag, $sql)
{
$isReturn = false;
$conn = null;
try{
$conn = $this->getConnection($DBtag);
$rs = mysql_query($sql, $conn) or die("Invalid query: " . $sql . mysql_error($conn));
if($rs && mysql_num_rows($rs) > 0){
$isReturn = true;
}
}catch(Exception $e){
echo mysql_error($conn) . $sql;
}
if($conn != null)
$this->freeConnection($DBtag, $conn);
return $isReturn;
}
/* web list by condition
*
* @param String DBtag # DB tag
* @param String sql
* @return Array[][]
*/
public function getAllData($DBtag, $sql)
{
$arrBack = array();
$conn = null;
try{
$conn = $this->getConnection($DBtag);
$rs = mysql_query($sql, $conn) or die("Invalid query: " . $sql . mysql_error($conn));
if($rs){
while($arrCache = mysql_fetch_assoc($rs)){
$arrBack[] = $arrCache;
}
}
}catch(Exception $e){
echo mysql_error($conn) . $sql;
}
if($conn != null)
$this->freeConnection($DBtag, $conn);
return $arrBack;
}
/* web list by condition
*
* @param String DBtag # DB tag
* @param String sql
* @return Array[][]
*/
public function update($DBtag, $sql)
{
$isreturn = false;
$conn = null;
try{
$conn = $this->getConnection($DBtag);
$rs = mysql_query($sql, $conn) or die("Invalid query: " . $sql . mysql_error($conn));
if($rs){
$isreturn = true;
}
}catch(Exception $e){
echo mysql_error($conn) . $sql;
}
if($conn != null)
$this->freeConnection($DBtag, $conn);
return $isreturn;
}
public function insert($DBtag, $sql)
{
$returnID = 0;
$conn = null;
try{
$conn = $this->getConnection($DBtag);
$rs = mysql_query($sql, $conn) or die("Invalid query: " . $sql . mysql_error($conn));
if($rs){
$returnID = mysql_insert_id($conn);
}
}catch(Exception $e){
echo mysql_error($conn) . $sql;
}
if($conn != null)
$this->freeConnection($DBtag, $conn);
return $returnID;
}
function insertUpdate($DBtag, $table, $data, $action = 'insert', $parameters = '')
{
$isreturn = 0;
$conn = null;
try{
$conn = $this->getConnection($DBtag);
reset($data);
if ($action == 'insert') {
$query = 'insert into ' . $table . ' (';
while (list($columns, ) = each($data)) {
$query .= $columns . ', ';
}
$query = substr($query, 0, -2) . ') values (';
reset($data);
while (list(, $value) = each($data)) {
switch ((string)$value) {
case 'now()':
$query .= 'now(), ';
break;
case 'UTC_TIMESTAMP()':
$query .= 'UTC_TIMESTAMP(), ';
break;
case 'null':
$query .= 'null, ';
break;
default:
$query .= '\'' . $this->escape_string($value, $conn) . '\', ';
break;
}
}
$query = substr($query, 0, -2) . ')';
} elseif ($action == 'update') {
$query = 'update ' . $table . ' set ';
while (list($columns, $value) = each($data)) {
switch ((string)$value) {
case 'now()':
$query .= $columns . ' = now(), ';
break;
case 'UTC_TIMESTAMP()':
$query .= 'UTC_TIMESTAMP(), ';
break;
case 'null':
$query .= $columns .= ' = null, ';
break;
default:
$query .= $columns . ' = \'' . $this->escape_string($value, $conn) . '\', ';
break;
}
}
$query = substr($query, 0, -2) . ' where ' . $parameters;
}
$rs = mysql_query($query, $conn) or die("Invalid query: " . $query . mysql_error($conn));
if($rs){
if ($action == 'insert') {
$isreturn = mysql_insert_id($conn);
}else{
$isreturn = mysqli_affected_rows($conn);
}
}
}catch(Exception $e){
echo mysql_error($conn) . $query;
}
if($conn != null)
$this->freeConnection($DBtag, $conn);
return $isreturn;
}
function escape_string($string, $conn)
{
if (function_exists('mysql_real_escape_string')) {
return mysql_real_escape_string($string, $conn);
} elseif (function_exists('mysql_escape_string')) {
return mysql_escape_string($string);
}
return addslashes($string);
}
/* web list by condition
*
* @param String DBtag # DB tag
* @param String sql
* @return Array[][]
*/
public function getColumn($DBtag, $sql)
{
$isreturn = '';
$conn = null;
try{
$conn = $this->getConnection($DBtag);
$rs = mysql_query($sql, $conn) or die("Invalid query: " . $sql . mysql_error($conn));
if($arrCache = mysql_fetch_row($rs)){
$isreturn = $arrCache[0];
}
}catch(Exception $e){
echo mysql_error($conn) . $sql;
}
if($conn != null)
$this->freeConnection($DBtag, $conn);
return $isreturn;
}
public function getColumns($DBtag, $sql)
{
$isreturn = '';
$conn = null;
try{
$conn = $this->getConnection($DBtag);
$rs = mysql_query($sql, $conn) or die("Invalid query: " . $sql . mysql_error($conn));
while($arrCache = mysql_fetch_row($rs)){
$isreturn = $arrCache[0];
}
}catch(Exception $e){
echo mysql_error($conn) . $sql;
}
if($conn != null)
$this->freeConnection($DBtag, $conn);
return $isreturn;
}
/* web by condition
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function getAssoc($DBtag, $columns, $where, $orders = '', $page = 0, $discount = 20, $url = '')
{
$arrback = array();
$conHandle = null;
try{
$conHandle = $this->getConnection($DBtag);
$sql = 'SELECT count(*) FROM '.$where;
$rs = mysql_query($sql, $conHandle) or die (mysql_error($conHandle));
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(!empty($total)){
if(empty($discount))
$sql = "SELECT $columns FROM $where $orders";
else{
$sql = "SELECT $columns FROM $where $orders LIMIT $this->firstcount, $discount";
}
echo $sql;
$rs = mysql_query($sql, $conHandle) or die (mysql_error($conHandle));
if($rs){
while(is_array($arrtmp = mysql_fetch_assoc($rs))){
$arrback[] = $arrtmp;
}
}
}
}catch(Exception $e){
echo mysql_error($conHandle) . $sql;
}
if($conHandle != null)
$this->freeConnection($DBtag, $conHandle);
return $arrback;
}
/* web list by condition
*
* @param String DBtag # DB tag
* @param String sql
* @return Array[][]
*/
public function getHash($DBtag, $sql)
{
$arrBack = array();
$conHandle = null;
try{
$conHandle = $this->getConnection($DBtag);
$rs = mysql_query($sql, $conHandle) or die($sql . mysql_error($conHandle));
if($rs){
while($arrCache = mysql_fetch_row($rs)){
$arrBack[$arrCache[0]] = $arrCache[1];
}
}
}catch(Exception $e){
echo mysql_error($conHandle) . $sql;
}
if($conHandle != null)
$this->freeConnection($DBtag, $conHandle);
return $arrBack;
}
/* custom condition
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listCustom($DBTag, $columns, $where, $orders, $page = 0, $discount = 20, $url = '')
{
$arrback = array();
try{
$conn = $this->getConnection($DBTag);
$sql = 'SELECT count(*) FROM '.$where;
$rs = mysql_query($sql, $conn) or die ($sql . mysql_error($conn));
list($total) = mysql_fetch_row($rs) or die ($sql . mysql_error($conn));
$this->mutilPager($total, $page, $discount, $url);
if(!empty($total)){
if(empty($discount))
$sql = "SELECT $columns FROM $where";
else{
$sql = "SELECT $columns FROM $where $orders LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $conn) or die ($sql . mysql_error($conn));
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
}
}
}catch(Exception $e){
echo mysql_error($conn) . $sql;
}
if($conn != null)
$this->freeConnection($DBTag, $conn);
return $arrback;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Common.php | PHP | asf20 | 18,980 |
<?php
/* explain: logs class
* Project: marsems
* File: Logs.php
*
* @ link http://www.../lib/
* @ Email ldmmyx@hotmail.com
* @ copyright 2007 Ling Deming
* @ author Ivan Ling
* @ version 3.0
*
*/
include_once("Common.php");
class Logs extends Common
{
private $conHandle; // connect sign
private $strLanguage;
private $iUserID;
function Logs($userid)
{
parent::Common();
$this->conHandle = $this->getConnection("system");
$this->strLanguage = "en-US";
$this->iUserID = $userid;
}
/* write error log
*
* @ param string userid
* @ param strign errordate
* @ param string errorname
* @ param strign errorcode
* @ param string desctype
* @ param strign errormsg
* @ param strign status
* @ param return boolean
*/
public function addError($userid=0,$errordate,$errorname,$errorcode,$desctype=0,$errormsg,$status='1')
{
if($desctype == 1)
if(is_array($errormsg))
$errormsg = serialize(serialize($errormsg));
else
return 0;
$sql = "INSERT INTO error_log (userid,errordate,errorname,errorcode,desctype,errormsg,status) VALUES ($userid,'$errordate','$errorname',$errorcode,$desctype,'$errormsg','$status')";
$rs = mysql_query($sql,$this->conHandle);
$intErrorId = mysql_insert_id();
if($rs)
return $intErrorId;
else
return 0;
}
/* get error info
*
* @param int id
* @param return boolean
*/
public function getError($id)
{
$sql = "SELECT * FROM error_log WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if(mysql_num_rows($rs) > 0)
return mysql_fetch_array($rs);
else
return false;
}
/* write login log
*
* @ param string userid
* @ param datetime logintime
* @ param datetime logouttime
* @ param strign fromip
* @ param return boolean
*/
public function addLogin($userid, $logintime, $fromip)
{
$sql = "INSERT INTO login_log SET userid=$userid,logintime='$logintime', ip='$fromip'";
$rs = mysql_query($sql,$this->conHandle) or die ('error='.mysql_error());
$loginid = mysql_insert_id();
if($rs)
return $loginid;
else
return false;
}
/* modify login log
*
* @ param int id
* @ param string userid
* @ param datetime logintime
* @ param datetime logouttime
* @ param strign fromip
* @ param return boolean
*/
public function escLogout($id, $logouttime, $ip)
{
$sql = "UPDATE login_log SET logouttime='$logouttime', ip='$ip' WHERE id=$id";
$rs = mysql_query($sql,$this->conHandle);
if($rs)
return true;
else
return false;
}
/* get login log
*
* @param int id
* @param return array
*/
public function arrGetLoginLog($id)
{
$sql = "SELECT * FROM login_log WHERE id = $id";
$rs = mysql_query($sql,$this->conHandle);
if($rs)
return mysql_fetch_array($rs);
else
return array();
}
/* login log list
*
* @ param string where a?? where condition
* @ param string page a?? curent page
* @ param string discount a?? display data count
* @ param string url a?? user url
* @ param return array a?? data array
*/
public function listLoginLog($arrPopedom = array(), $where, $page = '', $discount = '', $url = '')
{
if($this->isUnallowable($arrPopedom, Popedom::STRING_VIEW))
die ($this->getNotPopedomInfo());
$this->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = "SELECT count(id) FROM login_log $where";
$rs = mysql_query($sql,$this->conHandle) or die(mysql_error());
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = "SELECT * FROM login_log $where";
else{
$sql = "SELECT * FROM login_log $where LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql,$this->conHandle);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
/* login statistic
*
* @ param int userid
* @ param int intYear
* @ param int intMonth
* @ param int intDay
* @ param return boolean
*/
public function addLoginStatistic($userid,$year,$month,$day)
{
$sql = "INSERT INTO login_statistic (userid,intYear,intMonth,intDay) VALUES ($userid,$year,$month,$day) ON DUPLICATE KEY UPDATE counts=VALUES(counts) + 1";
$rs = mysql_query($sql,$this->conHandle) or die(mysql_error($this->conHandle).$sql);
if($rs)
return true;
else
return false;
}
/* llist login statistic
*
* @ param string where a?? where condition
* @ param string page a?? curent page
* @ param string discount a?? display data count
* @ param string url a?? user url
* @ param return array a?? data array
*/
public function listLoginStatistic($arrPopedom = array(), $where, $page = '', $discount = '', $url = '')
{
if($this->isUnallowable($arrPopedom, Popedom::STRING_VIEW))
die ($this->getNotPopedomInfo());
$this->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = "SELECT count(*) FROM login_statistic $where";
$rs = mysql_query($sql,$this->conHandle) or die(mysql_error());
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = "SELECT * FROM login_statistic $where";
else{
$sql = "SELECT * FROM login_statistic $where LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql,$this->conHandle);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
/* get operaton info from id
*
* @param int id
* @param return array
*/
public function arrGetOperationFromID($id)
{
$sql = "SELECT * FROM operation WHERE id = $id";
$rs = mysql_query($sql,$this->conHandle);
if($rs)
return mysql_fetch_array($rs);
else
return array();
}
/* write operation log
*
* @ param int userid
* @ param strign method # operate method
* @ param int opid # operate id
* @ param string comments # comments
* @ param return boolean
*/
public function addOperate($userid, $method, $opid, $comments = '')
{
if(empty($userid) || empty($opid))
return false;
$arrOPInfo = $this->arrGetOperationFromID($opid);
if(count($arrOPInfo) > 0){
$sql = "INSERT INTO operate_log set userid = '$userid', method = '$method', operation = '" . $arrOPInfo['name'] . "', comments = '$comments', addTime = now()";
$rs = mysql_query($sql,$this->conHandle) or die("Invalid query log-addOperate: " . mysql_error($this->conHandle));
if($rs)
return true;
else
return false;
}else
return false;
}
/* llist operate log
*
* @ param string where a?? where condition
* @ param string page a?? curent page
* @ param string discount a?? display data count
* @ param string url a?? user url
* @ param return array a?? data array
*/
public function listOperateLog($arrPopedom = array(), $where, $page = '', $discount = '', $url = '')
{
if($this->isUnallowable($arrPopedom, Popedom::STRING_VIEW))
die ($this->getNotPopedomInfo());
$this->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = "SELECT count(*) FROM operate_log $where";
$rs = mysql_query($sql,$this->conHandle) or die(mysql_error());
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = "SELECT * FROM operate_log $where";
else{
$sql = "SELECT * FROM operate_log $where LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql,$this->conHandle);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
/* get temp login log
*
* @param string username
* @param return boolean
*/
public function funGetLoginLogTmp($username)
{
$sql = "SELECT * FROM login_log_tmp WHERE username = '$username'";
$rs = mysql_query($sql, $this->conHandle) or die (mysql_error());
if(mysql_num_rows($rs) > 0)
return mysql_fetch_array($rs);
else
return false;
}
/* write temp login log
*
* @ param strign username
* @ param string ip
* @ param return boolean
*/
public function funAddLoginLogTmp($username, $logintime, $ip)
{
$sql = "INSERT INTO login_log_tmp (username,logintime,logincount,ip) VALUES ('$username','$logintime',0,'$ip')";
$rs = mysql_query($sql, $this->conHandle) or die (mysql_error());
if($rs)
return true;
else
return false;
}
/* modify temp login log
*
* @ param string username
* @ param int logincount
* @ param return boolean
*/
public function funModLoginLogTmp($username, $logintime, $logincount)
{
$sql = "UPDATE login_log_tmp SET logincount=$logincount,logintime='$logintime' WHERE username='$username'";
$rs = mysql_query($sql,$this->conHandle) or die("Invalid query log-funAddOperate: " . mysql_error());
if($rs)
return true;
else
return false;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Logs.php | PHP | asf20 | 9,712 |
<?php
/* explain:
* Project:
* File: qa.php
*
* @ link http://www.../lib/
* @ Email ldmmyx@hotmail.com
* @ copyright 2007 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class Zone extends Common
{
private $intLinkSign;
private $iUserID;
private $objLog;
function Zone($usrid)
{
parent::Common();
$this->intLinkSign = $this->getConnection("system");
$this->objLog = new Logs($usrid);
$this->iUserID = $usrid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getById($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM zones WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/* add method
*
* @param string userid news class name
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @return int true: insert ID
*/
public function add($arrPopedom = array(), $name, $code2, $code3)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO zones SET name='$name', code2='$code2', code3='$code3'";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
$intDataID = mysql_insert_id($this->intLinkSign);
if($rs)
return $intDataID;
else
return false;
}
/* modify
*
* @param string userid news class name
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @param return boolean
*/
public function edit($arrPopedom = array(), $id, $name, $code2, $code3)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "id=$id");
$sql = "UPDATE zones SET name = '$name', code2='$code2', code3='$code3' WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return true;
else
return false;
}
/* delete news class
*
* @param int id
* @param string status
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "DELETE FROM zones WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return true;
else
return false;
}
/* list
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $where, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$arrback = array();
$sql = 'SELECT count(id) FROM zones'.$where;
$rs = mysql_query($sql, $this->intLinkSign);
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = 'SELECT * FROM zones'.$where;
else{
$sql = 'SELECT * FROM zones'.$where." LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
/* list by condition
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listFromCustom($arrPopedom = array(), $condition='')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrBack = array();
$sql = "SELECT * FROM zones".$condition;
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
public function getGroupList($countryid)
{
$sql = "SELECT id, name FROM zones WHERE countryID = $countryid";
$rs = mysql_query($sql, $this->intLinkSign);
$arrCache = array();
if($rs){
while ($arrData = mysql_fetch_array($rs)){
$arrCache[$arrData['id']] = $arrData['name'];
}
}
return $arrCache;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Zone.php | PHP | asf20 | 4,955 |
<?php
/* explain:
* Project:
* File: qa.php
*
* @ link http://www.../lib/
* @ Email ldmmyx@hotmail.com
* @ copyright 2007 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class Message extends Common
{
private $intLinkSign;
private $iUserID;
private $objLog;
function Message($userid)
{
parent::Common();
$this->intLinkSign = $this->getConnection("system");
$this->objLog = new Logs($userid);
$this->iUserID = $userid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getFromID($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM message WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/* �������
*
* @param string user id
* @return int true: insert ID
*/
public function add($arrPopedom = array(), $userid, $acceptid, $type, $title, $content, $level, $fromip)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO message SET userid='$userid', acceptid='$acceptid', type='$type', title='$title', content='$content', level='$level', fromip='$fromip', status='unRead', addtime=now()";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error());
$intDataID = mysql_insert_id($this->intLinkSign);
if($rs)
return $intDataID;
else
return false;
}
/* modify
*
* @param string userid
* @param return boolean
*/
public function edit($arrPopedom = array(), $id, $userid, $acceptid, $type, $title, $content, $level, $fromip)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "id=$id");
$sql = "UPDATE message SET userid='$userid', acceptid='$acceptid', type='$type', title='$title', content='$content', level='$level', fromip='$fromip', status='unRead' WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return true;
else
return false;
}
/* edit status
*
* @param string userid
* @param return boolean
*/
public function editStatus($arrPopedom = array(), $id)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "id=$id");
$sql = "UPDATE message SET status='read' WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return true;
else
return false;
}
/* delete news class
*
* @param int id
* @param string status
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "DELETE FROM message WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return true;
else
return false;
}
/* list
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $where, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = 'SELECT count(id) FROM message'.$where;
$rs = mysql_query($sql, $this->intLinkSign);
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = 'SELECT * FROM message'.$where;
else{
$sql = 'SELECT * FROM message'.$where." LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
/* list by condition
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listFromCustom($arrPopedom = array(), $condition='')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrBack = array();
$sql = "SELECT * FROM message".$condition;
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Message.php | PHP | asf20 | 4,948 |
<?php
/*
* Created on Feb 19, 2011
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
class TimeZone
{
public function TimeZone()
{
}
function getTimezoneOffset($sourceTZ, $target_dt = null)
{
if($target_dt === null) {
if(!is_string($target_dt = date_default_timezone_get())) {
return false; // A UTC timestamp was returned -- bail out!
}
}
$targetDTZ = new DateTimeZone($target_dt);
$sourceDTZ = new DateTimeZone($sourceTZ);
$target_dt = new DateTime("now", $targetDTZ);
$source_dt = new DateTime("now", $sourceDTZ);
$offset = $targetDTZ->getOffset($target_dt) - $sourceDTZ->getOffset($source_dt);
return $offset;
}
function getTime($time, $sourceTZ, $targetTZ)
{
$sourceDTZ = new DateTimeZone($sourceTZ);
$targetDTZ = new DateTimeZone($targetTZ);
$source_dt = new DateTime($time, $sourceDTZ);
$target_dt = new DateTime($time, $targetDTZ);
$offset = $targetDTZ->getOffset($target_dt) - $sourceDTZ->getOffset($source_dt);
$offset_time = strtotime($time) + $offset;
return date('Y-m-d H:i:s', $offset_time);
}
function getNowTime($targetTZ, $format)
{
$time = 'now';
$sourceTZ = 'UTC';
$sourceDTZ = new DateTimeZone($sourceTZ);
$targetDTZ = new DateTimeZone($targetTZ);
$source_dt = new DateTime($time, $sourceDTZ);
$target_dt = new DateTime($time, $targetDTZ);
$offset = $targetDTZ->getOffset($target_dt) - $sourceDTZ->getOffset($source_dt);
$offset_time = strtotime($time) + $offset;
return date($format, $offset_time);
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/TimeZone.php | PHP | asf20 | 1,832 |
<?php
/* explain:
* Project:
* File: Job.php
*
* @ link http://www.../lib/
* @ Email ldmmyx@hotmail.com
* @ copyright 2007 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class MenuGroup extends Common
{
public $conHandle;
public $errorInfo;
private $iUserID;
private $objLog;
function MenuGroup($strLanguage, $userid)
{
parent::Common();
$this->conHandle = $this->getConnection("system");
$this->strLanguage = $strLanguage;
$this->objLog = new Logs($userid);
$this->iUserID = $userid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getFromID($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM menu_groups WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/*
*
* @param string strOrders
* @param string name
* @param string namecn
* @return boolean true or fail
*
*/
public function add($arrPopedom = array(), $strOrders, $name, $status = 'normal')
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO menu_groups SET orders='$strOrders', name = '$name', status='$status'";
$rs = mysql_query($sql, $this->conHandle) or die(mysql_error());
return $rs ? true: false;
}
/* modify menu
*
* @param string id modify menu id
* @param string strOrders
* @param string name
* @param string namecn
* @return boolean true or fail
*/
public function edit($arrPopedom = array(), $id, $strOrders, $name)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "id=$id");
$sql = "UPDATE menu_groups SET orders='$strOrders', name = '$name' WHERE id=$id";
$rs = mysql_query($sql, $this->conHandle) or die ($sql . mysql_error($this->conHandle));
return $rs ? true: false;
}
/* delete menu
*
* @param int id
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "DELETE FROM menu_groups WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return true;
else
return false;
}
/* list menu
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $condition, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = "SELECT count(id) FROM menu_groups$condition";
$rs = mysql_query($sql, $this->conHandle);
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = "SELECT * FROM menu_groups$condition";
else{
$sql = "SELECT * FROM menu_groups$condition LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
/* list all custom condition data
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listFromCustom($arrPopedom = array(), $condition='')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrBack = array();
$sql = "SELECT * FROM menu_groups$condition";
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/MenuGroup.php | PHP | asf20 | 4,376 |
<?php
define("ENTER",chr(13).chr(10));
class Files
{
function __construct()
{
}
public function copyDirVSfiles($source, $destination)
{
$result = true;
if(!is_dir($source)){
return false;
}
if(!is_dir($destination)){
if(!mkdir($destination, 0700)){
trigger_error('Invalid Parameter', E_USER_ERROR);
}
}
$handle = opendir($source);
while(($file = readdir($handle)) !== false){
if($file != '.' && $file != '..'){
$src = $source . DIRECTORY_SEPARATOR . $file;
$dtn = $destination . DIRECTORY_SEPARATOR . $file;
if(is_dir($src)){
$this->copyDirVSfiles($src, $dtn);
}else{
if(! copy($src, $dtn)){
$result = false;
break;
}
}
}
}
closedir($handle);
return $result;
}
public function copyDir($source, $destination)
{
$result = true;
if(!is_dir($source)){
return false;
}
if(!is_dir($destination)){
if(!mkdir($destination, 0700)){
trigger_error('Invalid Parameter', E_USER_ERROR);
}
}
$handle = opendir($source);
while(($file = readdir($handle)) !== false){
if($file != '.' && $file != '..'){
$src = $source . DIRECTORY_SEPARATOR . $file;
$dtn = $destination . DIRECTORY_SEPARATOR . $file;
if(is_dir($src)){
$this->copyDirVSfiles($src, $dtn);
}
}
}
closedir($handle);
return $result;
}
public function copyFiles($source, $destination)
{
$result = true;
if(!is_dir($source)){
return $result;
}
if(!is_dir($destination)){
if(!mkdir($destination, 0700)){
trigger_error('Invalid Parameter', E_USER_ERROR);
}
}
$handle = opendir($source);
while(($file = readdir($handle)) !== false){
if($file != '.' && $file != '..'){
$src = $source . DIRECTORY_SEPARATOR . $file;
$dtn = $destination . DIRECTORY_SEPARATOR . $file;
if(!is_dir($src)){
if(! copy($src, $dtn)){
$result = false;
break;
}
}
}
}
closedir($handle);
return $result;
}
public function listFileName($dir)
{
$arrReturn = array();
if(!is_dir($dir)){
return $arrReturn;
}
$handle = opendir($dir);
while(($file = readdir($handle)) !== false){
if(is_file($dir. DIRECTORY_SEPARATOR . $file)){
$arrReturn[] = $file;
}
}
return $arrReturn;
}
public function copyFilesFilter($source, $destination, $strFilterType)
{
$result = true;
if(!is_dir($source)){
return $result;
}
if(!is_dir($destination)){
if(!mkdir($destination, 0700)){
trigger_error('Invalid Parameter', E_USER_ERROR);
}
}
$handle = opendir($source);
while(($file = readdir($handle)) !== false){
if($file != '.' && $file != '..'){
$src = $source . DIRECTORY_SEPARATOR . $file;
$dtn = $destination . DIRECTORY_SEPARATOR . $file;
if(!is_dir($src) AND strripos($stc, $strFilterType) != strlen($src) - strlen($strFilterType)){
if(! copy($src, $dtn)){
$result = false;
break;
}
}
}
}
closedir($handle);
return $result;
}
public function clearDir($dirName)
{
$result = true;
if(! is_dir($dirName)){
return $result;
}
$handle = opendir($dirName);
while(($file = readdir($handle)) !== false){
if($file != '.' && $file != '..'){
$dir = $dirName . DIRECTORY_SEPARATOR . $file;
is_dir($dir) ? $this->removeDir($dir) : unlink($dir);
}
}
closedir($handle);
return $result;
}
public function removeDir($dirName)
{
$result = false;
if(! is_dir($dirName)){
return $result;
}
$handle = opendir($dirName);
while(($file = readdir($handle)) !== false){
if($file != '.' && $file != '..'){
$dir = $dirName . DIRECTORY_SEPARATOR . $file;
is_dir($dir) ? $this->removeDir($dir) : unlink($dir);
}
}
closedir($handle);
return rmdir($dirName) ? true : false;
}
public function createCFGfileET($strSiteDirName, $siteID, $templateid)
{
$fp = fopen($_SERVER['DOCUMENT_ROOT']."/sites/" . $strSiteDirName . "/config.inc.php", "w");
fputs($fp, "<?php" . ENTER);
fputs($fp, "define('SITE_ID', '". $siteID . ENTER);
fputs($fp, "define('TEMPLATE_ID', '". $templateid . ENTER);
fputs($fp, "define('TEMPLATE_DIR', '". $_SERVER['DOCUMENT_ROOT']."/sites/" . $strSiteDirName . "/templates/');" . ENTER);
fputs($fp, "define('COMPILE_DIR', '". $_SERVER['DOCUMENT_ROOT']."/sites/" . $strSiteDirName . "/templates_c/');" . ENTER);
fputs($fp, "define('CACHE_DIR', '". $_SERVER['DOCUMENT_ROOT']."/sites/" . $strSiteDirName . "/cache/');" . ENTER);
fputs($fp, "?>" . ENTER);
}
public function arrSplitContent($strContent, $iSplitLength = 10)
{
$arrReturn = array();
$iContentLen = strlen($strContent);
if ($iContentLen > $iSplitLength){
$iStart = 0;
$iEnd = $iSplitLength;
while($i < $iContentLen){
for($i = $iStart; $i < $iEnd; $i++)
if (ord($strContent[$i]) > 128)
$i++;
$arrReturn[] = substr($strContent, $iStart, $iSplitLength);
$iStart = $iEnd;
$iEnd = $iEnd + $iSplitLength;
if($iEnd > $iContentLen)
$iEnd = $iContentLen;
}
}
return $arrReturn;
}
public function createDataFile($strPathDir, $arrContent)
{
$i = 0;
foreach ($arrContent as $value){
$fp = fopen($strPathDir . '/'. $i. ".dat", "w");
if($fp){
fputs($fp, $value);
fclose($fp);
}
}
}
public function getDirByID($id)
{
$strPathPosFromEnd_3_4 = '';
$strPathPosFromEND_1_2 = '';
switch (strlen($id)){
case 1: $strPathPosFromEND_1_2 = "0". $id; $strPathPosFromEnd_3_4 = "00"; break;
case 2: $strPathPosFromEND_1_2 = $id; $strPathPosFromEnd_3_4 = "00"; break;
case 3: $strPathPosFromEND_1_2 = substr($id, -2, 2); $strPathPosFromEnd_3_4 = "0" . substr($id, -3, 1); break;
default:$strPathPosFromEND_1_2 = substr($id, -2, 2); $strPathPosFromEnd_3_4 = substr($id, -4, 2); break;
}
return ($id % 10) . '/' . $strPathPosFromEnd_3_4 . '/' . $strPathPosFromEND_1_2;
}
public function getAbsolutePathByID($absolutePath, $id)
{
$strPath = $absolutePath . $this->getDirByID($id);
$this->createFolder($strPath);
return $strPath;
}
public function getFullPathByID($absolutePath, $id, $fileName)
{
$strPath = $absolutePath . $this->getDirByID($id);
$this->createFolder($strPath);
return $strPath . '/' . $fileName;
}
public function createFolder($path)
{
if (!file_exists($path)) {
$this->createFolder(dirname($path));
mkdir($path, 0777);
}
}
function Resize($Filename,$Thumbnail,$WIDTH,$HEIGHT)
{
$image = $Filename;
$thumbnail = $Thumbnail;
$imagesize = getimagesize($image);
$fwidth = $imagesize[0];
$fheight = $imagesize[1];
if($fheight <= $fwidth){
$percentage = round(($WIDTH/$fwidth) * 100);
$newwidth = round(($fwidth * $percentage)/100);
$newheight = round(($fheight * $percentage)/100);
}elseif($fheight > $fwidth){
$percentage = round(($HEIGHT/$fheight) * 100);
$newwidth = round(($fwidth * $percentage)/100);
$newheight = round(($fheight * $percentage)/100);
}else{
$percentage = round(($fwidth/$WIDTH) * 100);
$newwidth = round(($fwidth * $percentage)/100);
$newheight = round(($fheight * $percentage)/100);
}
$destImage = imagecreatetruecolor($newwidth,$newheight) or die($file.' - '.$newwidth.':'.$newheight);
$type = strtolower(substr($Filename,-3));
switch($type){
case 'gif':
$srcImage = ImageCreateFromGif($image);
ImageCopyResized($destImage, $srcImage, 0,0, 0, 0, $newwidth, $newheight, imagesx($srcImage), imagesy($srcImage));
ImageGif($destImage,$thumbnail);
break;
case 'jpg':
$srcImage = ImageCreateFromJPEG($image);
ImageCopyResized($destImage, $srcImage, 0,0, 0, 0, $newwidth, $newheight, imagesx($srcImage), imagesy($srcImage));
ImageJPEG($destImage,$thumbnail);
break;
case 'png':
$srcImage = ImageCreateFromPNG($image);
ImageCopyResized($destImage, $srcImage, 0,0, 0, 0, $newwidth, $newheight, imagesx($srcImage), imagesy($srcImage));
ImagePNG($destImage,$thumbnail);
break;
}
//free the memory used for the images
ImageDestroy($srcImage);
ImageDestroy($destImage);
if(file_exists($thumbnail)){
return true;
}else{
return false;
}
}
public function mk_dir($dirString, $initDir="./")
{
$dir = explode("/", $dirString);
if(substr($initDir,-1) != "/" && $initDir != "")
$initDir .= $initDir."/";
for($i=0; $i < count($dir)-1; $i++){
$initDir .= $dir[$i] . "/";
if(!file_exists($initDir) && count($dir) > 1)
mkdir($initDir);
$dir = $initDir;
};
//echo "create dir : $initDir\n";
return $dir;
}
public function zip($zipFile, $customDir = '')
{
$zip = zip_open($zipFile);
$returnDir = '';
if($zip){
if(empty($customDir))
$outDir = dirname($zipFile) . '/';
else
$outDir = $customDir;
while($zip_entry = zip_read($zip)){
if(substr(zip_entry_name($zip_entry),-1) != "/" && zip_entry_open($zip, $zip_entry, "r")) {
if (!file_exists(dirname(zip_entry_name($zip_entry)))){
$this->mk_dir(zip_entry_name($zip_entry));
}
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
$fout = fopen($outDir . zip_entry_name($zip_entry),"w");
fwrite($fout,$buf);
//echo "extract : ".zip_entry_name($zip_entry)."\n";
zip_entry_close($zip_entry);
} else {
$returnDir = $this->mk_dir(zip_entry_name($zip_entry), $outDir);
}
}
zip_close($zip);
}
return $returnDir;
}
public function removeZipExtractDir($zipFile, $customDir = '')
{
$zip = zip_open($zipFile);
if($zip){
if(empty($customDir))
$outDir = dirname($zipFile) . '/';
else
$outDir = $customDir;
while($zip_entry = zip_read($zip)){
if(is_dir(zip_entry_name($zip_entry))){
$this->removeDir($outDir.zip_entry_name($zip_entry));
//echo 'remove dir :'.$outDir.zip_entry_name($zip_entry).'<br>';
}else{
if(file_exists($outDir.zip_entry_name($zip_entry)))
unlink($outDir.zip_entry_name($zip_entry));
//echo 'remove file :'.$outDir.zip_entry_name($zip_entry).'<br>';
}
}
zip_close($zip);
}
}
public function getZipExtractDir($zipFile, $customDir = '')
{
$zip = zip_open($zipFile);
$returnDir = '';
if($zip){
if(empty($customDir))
$outDir = dirname($zipFile) . '/';
else
$outDir = $customDir;
if($zip_entry = zip_read($zip)){
if(is_dir(zip_entry_name($zip_entry))){
$returnDir = $outDir.zip_entry_name($zip_entry);
}
}
zip_close($zip);
}
return $returnDir;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Files.php | PHP | asf20 | 12,446 |
<?php
/* explain: news system
* Project:
* File: news.php
*
* @ link http://www.../modules/
* @ Email ldmmyx@hotmail.com
* @ copyright 2005 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class PromotionImpl extends Common
{
public $intLinkSign;
public $errorInfo;
private $iUserID;
private $objLog;
function PromotionImpl($strLanguage, $userid)
{
parent::Common();
$this->intLinkSign = $this->getConnection($strLanguage);
$this->objLog = new Logs($userid);
$this->iUserID = $userid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getById($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM promotion WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/*
*
* @param string userid
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @return int true: insert ID
*/
public function add($arrPopedom = array(), $productId, $descript, $status = 'normal')
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO promotion SET productId='$productId', descript = '$descript', status = '$status'";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
if($rs)
return true;
else
return false;
}
/* edit
*
* @param string userid news class name
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @param return boolean
*/
public function edit($arrPopedom = array(), $id, $productId, $descript)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$sql = "UPDATE promotion SET productId='$productId', descript = '$descript' WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return true;
else
return false;
}
/* delete news class
*
* @param int id
* @param string status
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "DELETE FROM promotion WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
if($rs)
return true;
else
return false;
}
/* list
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $languageID, $where, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = "SELECT count(*) FROM promotion s, products_description pd, products p WHERE p.id = pd.productID AND s.productID = pd.productID AND languageID=$languageID $where";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = "SELECT s.id, s.descript, pd.name, pd.description, s.productId, p.price, s.status FROM promotion s, products_description pd, products p WHERE p.id = pd.productID AND s.productId = pd.productID AND languageID=$languageID $where";
else{
$sql = "SELECT s.id, s.descript, pd.name, pd.description, s.productId, p.price, s.status FROM promotion s, products_description pd, products p WHERE p.id = pd.productID AND s.productId = pd.productID AND languageID=$languageID $where LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
public function IsExistName($languageID, $name)
{
$sql = "SELECT id FROM promotion WHERE languageID = $languageID AND name = '$name'";
$rs = mysql_query($sql, $this->intLinkSign) or die ("error: " . mysql_error());
if(mysql_num_rows($rs) > 0)
return true;
else
return false;
}
/* list by condition
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listByCustom($arrPopedom = array(), $condition='')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrBack = array();
$sql = "SELECT * FROM promotion".$condition;
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
/* edit user status
*
* @ param int userid
* @ param string status
* @ param return boolean
*/
public function setStatus($arrPopedom, $id, $status)
{
if($this->isUnallowable($arrPopedom, Popedom::STRING_EDIT))
die ($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "status=$status, id=$id");
$sql = "UPDATE promotion SET status='$status' WHERE id=$id";
$rs = mysql_query($sql,$this->intLinkSign);
if(mysql_affected_rows() > 0)
return true;
else
return false;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/PromotionImpl.php | PHP | asf20 | 6,225 |
<?php
/* explain: news system
* Project:
* File: news.php
*
* @ link http://www.../modules/
* @ Email ldmmyx@hotmail.com
* @ copyright 2005 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class Special extends Common
{
public $intLinkSign;
public $errorInfo;
private $iUserID;
private $objLog;
function Special($strLanguage, $userid)
{
parent::Common();
$this->intLinkSign = $this->getConnection($strLanguage);
$this->objLog = new Logs($userid);
$this->iUserID = $userid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getByID($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM specials WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/*
*
* @param string userid
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @return int true: insert ID
*/
public function add($arrPopedom = array(), $productID, $newPrice, $expireDate, $status = 'normal')
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$newPrice *= 100;
$sql = "INSERT INTO specials SET createdTime = UTC_TIMESTAMP(), modifiedTime = UTC_TIMESTAMP(), productID='$productID', newPrice = '$newPrice', expireDate = '$expireDate', status = '$status'";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
if($rs)
return true;
else
return false;
}
/* edit
*
* @param string userid news class name
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @param return boolean
*/
public function edit($arrPopedom = array(), $id, $productID, $newPrice, $expireDate)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$newPrice *= 100;
$sql = "UPDATE specials SET modifiedTime = UTC_TIMESTAMP(), productID='$productID', newPrice = '$newPrice', expireDate = '$expireDate' WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return true;
else
return false;
}
/* delete news class
*
* @param int id
* @param string status
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "DELETE FROM specials WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
if($rs)
return true;
else
return false;
}
/* list
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $languageID, $where, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = "SELECT count(*) FROM specials s, products_description pd, products p WHERE p.id = pd.productID AND s.productID = pd.productID AND languageID=$languageID $where";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = "SELECT s.id, s.newPrice, s.expireDate, pd.name, pd.description, s.productID, p.price, s.status FROM specials s, products_description pd, products p WHERE p.id = pd.productID AND s.productID = pd.productID AND languageID=$languageID $where";
else{
$sql = "SELECT s.id, s.newPrice, s.expireDate, pd.name, pd.description, s.productID, p.price, s.status FROM specials s, products_description pd, products p WHERE p.id = pd.productID AND s.productID = pd.productID AND languageID=$languageID $where LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
public function IsExistName($languageID, $name)
{
$sql = "SELECT id FROM specials WHERE languageID = $languageID AND name = '$name'";
$rs = mysql_query($sql, $this->intLinkSign) or die ("error: " . mysql_error());
if(mysql_num_rows($rs) > 0)
return true;
else
return false;
}
/* list by condition
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listByCustom($arrPopedom = array(), $condition='')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrBack = array();
$sql = "SELECT * FROM specials".$condition;
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
/* edit user status
*
* @ param int userid
* @ param string status
* @ param return boolean
*/
public function setStatus($arrPopedom, $id, $status)
{
if($this->isUnallowable($arrPopedom, Popedom::STRING_EDIT))
die ($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "status=$status, id=$id");
$sql = "UPDATE specials SET status='$status' WHERE id=$id";
$rs = mysql_query($sql,$this->intLinkSign);
if(mysql_affected_rows() > 0)
return true;
else
return false;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Special.php | PHP | asf20 | 6,451 |
<?php
/* explain: access class
* Project:
* File: Access.php
*
* @ link http://www.../lib/
* @ Email ldmmyx@hotmail.com
* @ copyright 2007 Ling Deming
* @ author Ivan Ling
* @ version 3.0
*
*/
include_once("Common.php");
class Access extends Common
{
function Access()
{
parent::Common();
}
/* write login log
*
* @ param string DBtag
* @ param datetime pageid
* @ param return id
*/
public function add($DBtag, $pageid)
{
global $_SERVER;
$loginid = 0;
$conn = null;
try{
$conn = $this->getConnection($DBtag);
$sql = "INSERT INTO access_log SET pageid=$pageid, ip='" . $_SERVER['REMOTE_ADDR'] . "', urlFrom='".addslashes($_SERVER['HTTP_REFERER'])."', userAgent='".addslashes($_SERVER['HTTP_USER_AGENT'])."', visitTime=UTC_TIME(), visitDate=UTC_DATE()";
$rs = mysql_query($sql, $conn);// or die ('error='.mysql_error());
if($rs)
$loginid = mysql_insert_id();
}catch(Exception $e){
echo mysql_error($conn) . $sql;
}
if($conn != null)
$this->freeConnection($DBtag, $conn);
return $loginid;
}
/* access log list
*
* @ param string where a?? where condition
* @ param string page a?? curent page
* @ param string discount a?? display data count
* @ param string url a?? user url
* @ param return array a?? data array
*/
public function lists($arrPopedom = array(), $DBtag, $where, $page = '', $discount = '', $url = '')
{
if($this->isUnallowable($arrPopedom, Popedom::STRING_VIEW))
die ($this->getNotPopedomInfo());
$arrback = array();
$conn = null;
try{
$conn = $this->getConnection($DBtag);
$sql = "SELECT count(id) FROM access_log $where";
$rs = mysql_query($sql,$conn) or die(mysql_error());
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(!empty($total)){
if(empty($discount))
$sql = "SELECT * FROM access_log $where";
else{
$sql = "SELECT * FROM access_log $where LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $conn);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
}
}
}catch(Exception $e){
echo mysql_error($conn) . $sql;
}
if($conn != null)
$this->freeConnection($DBtag, $conn);
return $arrback;
}
public function arrAnalyse()
{
global $_SERVER;
$arrReturn = array();
$osAndBrowse = $_SERVER['HTTP_USER_AGENT']; // visitor os and browse
//--> get browse
if(strpos($osAndBrowse,'NetCaptor')){
$arrReturn['browse'] = 'NetCaptor';
}elseif($iStartPos = strpos($osAndBrowse,'MSIE')){
$iEndPos = strpos($osAndBrowse, ";", $iStartPos);
if($iEndPos){
$arrReturn['browse'] = substr($osAndBrowse, $iStartPos, $iEndPos - $iStartPos);
}
}elseif(strpos($osAndBrowse,'Netscape')){
$arrReturn['browse'] = "Netscape";
}elseif(strpos($osAndBrowse,'Firefox')){
$arrReturn['browse'] = trim(strstr($osAndBrowse, 'Firefox'));
}elseif(strpos($osAndBrowse,'Opera')){
$arrReturn['browse'] = 'Opera';
}else{
$arrReturn['browse'] = 'other';
}
//--> get OS
if(strpos($osAndBrowse,'Windows NT 5.0'))
$arrReturn['os'] = 'Windows2000';
elseif(strpos($osAndBrowse,'Windows NT 5.1'))
$arrReturn['os'] = 'WindowsXP';
elseif(strpos($osAndBrowse,'Windows NT'))
$arrReturn['os'] = 'WindowsNT';
elseif(strpos($osAndBrowse,'Windows 9'))
$arrReturn['os'] = 'Windows9x';
elseif(strpos($osAndBrowse,'unix'))
$arrReturn['os'] = 'unix';
elseif(strpos($osAndBrowse,'linux'))
$arrReturn['os'] = 'linux';
elseif(strpos($osAndBrowse,'SunOS'))
$arrReturn['os'] = 'SunOS';
elseif(strpos($osAndBrowse,'BSD'))
$arrReturn['os'] = 'FreeBSD';
elseif(strpos($osAndBrowse,'Mac'))
$arrReturn['os'] = 'Mac';
else
$$arrReturn['os'] = 'Other';
//--> get IP
$arrReturn['ip'] = $_SERVER['REMOTE_ADDR'];
//--> from url
if($_SERVER['HTTP_REFERER'] == '')
$arrReturn['urlfrom'] = 'manual input';
else
$arrReturn['urlfrom'] = $_SERVER['HTTP_REFERER'];
return $arrReturn;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Access.php | PHP | asf20 | 4,326 |
<?php
/* explain:
* Project:
* File: InfoClass.php
*
* @ link http://www.../lib/
* @ Email ldmmyx@hotmail.com
* @ copyright 2008 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class Attributes extends Common
{
public $conHandle;
public $errorInfo;
private $iUserID;
private $objLog;
function Attributes($strLanguage, $userid)
{
parent::Common();
$this->conHandle = $this->getConnection($strLanguage);
$this->objLog = new Logs($userid);
$this->iUserID = $userid;
}
/* get news class via ID
*
* @param int id
* @return mixed false:
*/
public function getFromID($arrPopedom = array(), $languageID, $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM attributes WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/* get news class via ID
*
* @param int id
* @return mixed false:
*/
public function getByName($arrPopedom = array(), $languageID, $name)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM attributes WHERE languageID = $languageID AND name = '$name'";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/*
*
* @param string name news class name
* @param string parentid news parent ID
* @param string isLeaf is leaf node
* @return int true: insert ID
*/
public function add($arrPopedom = array(), $name, $parentid, $sorts = -1, $isLeaf = 'no', $summary = '')
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO attributes SET name = '$name', parentid='$parentid', sorts = '$sorts', isLeaf = '$isLeaf', summary='$summary'";
$rs = mysql_query($sql, $this->conHandle) or die ($sql . mysql_error($this->conHandle));
$intDataID = mysql_insert_id($this->conHandle);
if($rs)
return $intDataID;
else
return false;
}
/* edit
*
* @param int id
* @param string status
* @param return boolean
*/
public function edit($arrPopedom = array(), $id, $name, $parentid, $sorts = -1, $isLeaf, $summary)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "id=$id");
$sql = "UPDATE attributes SET name='$name', parentid='$parentid', sorts = '$sorts', isLeaf = '$isLeaf', summary='$summary' WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return true;
else
return false;
}
/* delete news class
*
* @param int id
* @param string status
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "DELETE FROM attributes WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return true;
else
return false;
}
/*
*
* @param int id
* @return mixed false:
*/
public function isLeaf($arrPopedom = array(), $id)
{
$sql = "SELECT * FROM attributes WHERE isLeaf='YES' AND id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs && mysql_num_rows($rs) > 0)
return true;
else
return false;
}
/*
*
* @param string condition
* @return mixed false
*/
public function listWeb($condition='')
{
$arrBack = array();
$sql = "SELECT * FROM attributes".$condition;
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
/* list
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $where, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = 'SELECT count(id) FROM attributes'.$where;
$rs = mysql_query($sql, $this->conHandle);
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = 'SELECT * FROM attributes'.$where;
else{
$sql = 'SELECT * FROM attributes'.$where." LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
/* list all custom condition data
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listFromCustom($arrPopedom = array(), $condition='')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$arrBack = array();
$sql = "SELECT * FROM attributes".$condition;
$rs = mysql_query($sql, $this->conHandle) or die($sql . mysql_error($this->conHandle));
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
public function getCount()
{
$sql = "SELECT count(id) FROM attributes";
$rs = mysql_query($sql, $this->conHandle) or die(mysql_error());
if($rs){
$arrCache = mysql_fetch_array($rs);
return $arrCache[0];
}
return 0;
}
public function getDir($arrOperate, $parentid)
{
$arrParentid = array();
$arrTmpStack = array();
$arrLevelStack = array();
$arrClassid = array();
$i = 0;
array_push($arrTmpStack, $parentid);
while(sizeof($arrTmpStack) > 0){
$strtmp = array_pop($arrTmpStack);
$i = array_pop($arrLevelStack);
if($strtmp > 0){
$arrback = $this->getFromID($arrOperate, $strtmp);
if(is_array($arrback)){
$tmp = '';
for($j = 0; $j < $i; $j++){
$tmp.=' ';
}
$arrClassid[$arrback['id']] = $tmp.$arrback['name'];
}
}
$mixBack = $this->listWeb(" WHERE parentid='$strtmp'");
if(is_array($mixBack)){
$i++;
foreach($mixBack as $value){
array_push($arrTmpStack,$value['id']);
array_push($arrLevelStack,$i);
}
}
}
return $arrClassid;
}
public function arrGetDirIDList($parentid)
{
$arrParentid = array();
$arrTmpStack = array();
$arrLevelStack = array();
$arrClassid = array();
$i = 0;
array_push($arrTmpStack, $parentid);
while(sizeof($arrTmpStack) > 0){
$strtmp = array_pop($arrTmpStack);
$i = array_pop($arrLevelStack);
if($strtmp > 0){
$sql = "SELECT isLeaf FROM attributes WHERE id = $strtmp";
$rs = mysql_query($sql, $this->conHandle) or die (mysql_error($this->conHandle));
if($rs){
$arrback = mysql_fetch_array($rs);
if($arrback['isLeaf'] == 'yes')
array_push($arrClassid, $strtmp);
}
}
$sql = "SELECT id FROM attributes WHERE parentid=$strtmp";
$rs = mysql_query($sql, $this->conHandle) or die (mysql_error($this->conHandle));
if($rs){
$mixBack = array();
while($arrCache = mysql_fetch_array($rs)){
$mixBack[] = $arrCache;
}
$i++;
foreach($mixBack as $value){
array_push($arrTmpStack,$value['id']);
array_push($arrLevelStack,$i);
}
}
}
return $arrClassid;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Attributes.php | PHP | asf20 | 7,949 |
<?php
/* explain: news system
* Project:
* File: news.php
*
* @ link http://www.../modules/
* @ Email ldmmyx@hotmail.com
* @ copyright 2005 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class Customer extends Common
{
public $intLinkSign;
public $errorInfo;
private $iUserID;
private $objLog;
function Customer($strLanguage, $userid)
{
parent::Common();
$this->intLinkSign = $this->getConnection($strLanguage);
$this->objLog = new Logs($userid);
$this->iUserID = $userid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getFromID($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM customers WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/*
*
* @param string userid
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @return int true: insert ID
*/
public function add($gender, $firstname, $lastname, $email, $address_id, $telephone, $fax, $newsletter, $password, $countryid)
{
$sql = "INSERT INTO customers SET createdTime = UTC_TIMESTAMP(), modifiedTime = UTC_TIMESTAMP(), gender='$gender', firstname = '$firstname', lastname = '$lastname', email = '$email', default_address_id = '$address_id', " .
"telephone = '$telephone', fax='$fax', newsletter='$newsletter', password='$password', countryid=$countryid";
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
if($rs){
return mysql_insert_id($this->intLinkSign);;
}else
return 0;
}
/* edit
*
* @param string userid news class name
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @param return boolean
*/
public function edit($arrPopedom = array(), $id, $gender, $firstname, $lastname, $email, $address_id, $telephone, $fax, $newsletter, $password)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$sql = "UPDATE customers SET modifiedTime = UTC_TIMESTAMP(), gender='$gender', firstname = '$firstname', lastname = '$lastname', email = '$email', default_address_id = '$address_id', " .
"telephone = '$telephone', fax='$fax', newsletter='$newsletter', password='$password' WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
if($rs)
return true;
else
return false;
}
/* delete news class
*
* @param int id
* @param string status
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "SELECT id FROM orders WHERE customers_id = $id";
$orderIDs = '';
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
if(!empty($orderIDs))
$orderIDs .= ',';
$orderIDs .= $arrtmp['id'];
}
}
if(!empty($orderIDs)){
$sql = "DELETE FROM orders WHERE id IN ($orderIDs)";
mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
$sql = "DELETE FROM orders_products WHERE ordersID IN ($orderIDs)";
mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
$sql = "DELETE FROM orders_products WHERE ordersID IN ($orderIDs)";
mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
$sql = "DELETE FROM orders_products_attributes WHERE ordersID IN ($orderIDs)";
mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
$sql = "DELETE FROM orders_status_history WHERE ordersID IN ($orderIDs)";
mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
}
$sql = "DELETE FROM address_book WHERE customerid = $id";
mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
$sql = "DELETE FROM customers WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
if($rs)
return true;
else
return false;
}
/* list
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $where, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = "SELECT count(*) FROM customers$where";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = "SELECT * FROM customers$where";
else{
$sql = "SELECT * FROM customers$where LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
public function IsExistName($firstname)
{
$sql = "SELECT id FROM customers WHERE firstname = '$firstname'";
$rs = mysql_query($sql, $this->intLinkSign) or die ("error: " . mysql_error());
if(mysql_num_rows($rs) > 0)
return true;
else
return false;
}
public function IsExistEmail($email)
{
$sql = "SELECT id FROM customers WHERE email = '$email'";
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
if(mysql_num_rows($rs) > 0)
return true;
else
return false;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Customer.php | PHP | asf20 | 6,478 |
<?php
/* explain:
* Project:
* File: qa.php
*
* @ link http://www.../lib/
* @ Email ldmmyx@hotmail.com
* @ copyright 2007 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class Country extends Common
{
private $intLinkSign;
private $iUserID;
private $objLog;
function Country($usrid)
{
parent::Common();
$this->intLinkSign = $this->getConnection("system");
$this->objLog = new Logs($usrid);
$this->iUserID = $usrid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getFromID($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM countries WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/* add method
*
* @param string userid news class name
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @return int true: insert ID
*/
public function add($arrPopedom = array(), $name, $code2, $code3)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO countries SET name='$name', code2='$code2', code3='$code3'";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
$intDataID = mysql_insert_id($this->intLinkSign);
if($rs)
return $intDataID;
else
return false;
}
/* modify
*
* @param string userid news class name
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @param return boolean
*/
public function edit($arrPopedom = array(), $id, $name, $code2, $code3)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "id=$id");
$sql = "UPDATE countries SET name = '$name', code2='$code2', code3='$code3' WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return true;
else
return false;
}
/* delete news class
*
* @param int id
* @param string status
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "DELETE FROM countries WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return true;
else
return false;
}
/* list
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $where, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$arrback = array();
$sql = 'SELECT count(id) FROM countries'.$where;
$rs = mysql_query($sql, $this->intLinkSign);
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = 'SELECT * FROM countries'.$where;
else{
$sql = 'SELECT * FROM countries'.$where." LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
/* list by condition
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listFromCustom($arrPopedom = array(), $condition='')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrBack = array();
$sql = "SELECT * FROM countries".$condition;
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
public function getGroupList()
{
$sql = "SELECT id, name FROM countries";
$rs = mysql_query($sql, $this->intLinkSign);
$arrCache = array();
if($rs){
while ($arrData = mysql_fetch_array($rs)){
$arrCache[$arrData['id']] = $arrData['name'];
}
}
return $arrCache;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Country.php | PHP | asf20 | 4,960 |
<?php
/* explain:
*
* @ link http://www.marsemd.com/
* @ Email ldmmyx@hotmail.com
* @ copyright 2005 ivan Ling Deming
* @ author gaby ivan Ling Deming
* @ version 2.0
*
*/
include_once("DB.php");
class Session extends DB
{
private $s_link;
private $execInfo;
private $sessionID;
private $session = array();
private $varCookie = array();
private $varServer = array();
private $arrDomain = array();
private $session_cfg = array();
private $session_existed = false;
private $session_data_max_len = 255;
private $session_table_name = '';
function Session($DBTag = 'system', $sessionTableName = 'sessionheap')
{
$this->sessionID = '';
$this->session_cfg["pconnect"] = false;
$this->session_cfg['expires'] = 1800; //--> expire unit: second
$this->session_cfg['cookie_name'] = 'SESSION_ID';
$this->session_cfg['cookie_path'] = '/';
$this->session_cfg['cookie_domain'] = '';
$this->session_table_name = $sessionTableName;
parent::DB();
$this->s_link = $this->getConnection($DBTag);
if($this->s_link){
$sql = "CREATE TABLE IF NOT EXISTS " . $this->session_table_name . " (
session_id CHAR(32) NOT NULL,
userid int(11) unsigned NOT NULL default '0',
start_time timestamp NOT NULL,
last_active_time timestamp NOT NULL,
session_data CHAR(255) NOT NULL DEFAULT '',
PRIMARY KEY (session_id),
UNIQUE sessionid_time (session_id, last_active_time)) TYPE=HEAP";
$rs = mysql_query($sql,$this->s_link);
}
$this->init();
}
/* Session
*
* @param array arrDomain
* @param int expires
*/
public function init($arrDomain = ARR_DOMAIN, $expires = INT_EXPIRES)
{
if(!empty($expires))
$this->session_cfg['expires'] = $expires;//--> timeout
if(!empty($arrDomain)){
$arrtmp = explode(",",$arrDomain);
if(in_array("127.0.0.1", $arrtmp) || in_array("localhost", $arrtmp)){
foreach ($arrtmp as $value){
if($value != '127.0.0.1' && $value != 'localhost')
$this->arrDomain[] = $value;
}
}else
$this->arrDomain = $arrtmp;
}
}
/* session
*
* @param return int 1: true 0: false
*/
public function exist()
{
if($this->session_existed)
return true;
if(!is_resource($this->s_link))
return 0;
global $_COOKIE,$_SERVER;
$this->varCookie = $_COOKIE;
$this->varServer = $_SERVER;
$this->sessionID = isset($this->varCookie[$this->session_cfg['cookie_name']]) ? $this->varCookie[$this->session_cfg['cookie_name']] : '';
if($this->sessionID == ''){
$this->session_existed = false;
return 0;
}else{
$sql = "SELECT * FROM " . $this->session_table_name . " WHERE session_id='".$this->sessionID."' AND last_active_time>date_sub(now(),INTERVAL ".$this->session_cfg['expires']." SECOND)";
$rs = mysql_query($sql, $this->s_link) or die (mysql_error());
if(mysql_num_rows($rs) == 0){
$this->session_existed=false;
$this->execInfo='session timeout.';
return 0;
}else{
$arrBack=mysql_fetch_array($rs);
$this->session = unserialize($arrBack['session_data']);
$this->session['uid'] = $arrBack['userid'];
$this->session['start_time'] = $arrBack['start_time'];
$this->session['last_active_time'] = $arrBack['last_active_time'];
$domainCount = count($this->arrDomain);
if($domainCount > 0){
if(strlen($this->session_cfg['cookie_name']) > 0)
setcookie($this->session_cfg['cookie_name'],$this->sessionID, time() + $this->session_cfg['expires'] ,$this->session_cfg['cookie_path'],$this->session_cfg['cookie_domain']);
for($i=0; $i < $domainCount; $i++)
setcookie($this->session_cfg['cookie_name'],$this->sessionID, time() + $this->session_cfg['expires'] ,$this->session_cfg['cookie_path'],$this->arrDomain[$i]);
}else if(strlen($this->session_cfg['cookie_domain']) > 0)
setcookie($this->session_cfg['cookie_name'],$this->sessionID, time() + $this->session_cfg['expires'], $this->session_cfg['cookie_path'],$this->session_cfg['cookie_domain']);
$this->session_existed = true;
register_shutdown_function(array(&$this,"save"));
return 1;
}
}
}
/*
*
* @param int userid
* @param string session_data
* @param return array
*/
public function start($userid = 0, $session_data = array())
{
if(!is_resource($this->s_link))
return 0;
$strSessionData = addslashes(serialize($session_data));
if(strlen($strSessionData) > $this->session_data_max_len)
return 0;
$this->sessionID = md5(uniqid(rand()));
$domainCount = count($this->arrDomain);
if($domainCount > 0){
if(strlen($this->session_cfg['cookie_name']) > 0)
setcookie($this->session_cfg['cookie_name'],$this->sessionID, time() + $this->session_cfg['expires'] ,$this->session_cfg['cookie_path'],$this->session_cfg['cookie_domain']);
for($i=0; $i < $domainCount; $i++)
setcookie($this->session_cfg['cookie_name'],$this->sessionID, time() + $this->session_cfg['expires'] ,$this->session_cfg['cookie_path'],$this->arrDomain[$i]);
}else if(strlen($this->session_cfg['cookie_domain']) > 0)
setcookie($this->session_cfg['cookie_name'],$this->sessionID, time() + $this->session_cfg['expires'], $this->session_cfg['cookie_path'],$this->session_cfg['cookie_domain']);
$sql = "INSERT INTO " . $this->session_table_name . " SET userid=$userid, session_id='".$this->sessionID."', start_time=now(), last_active_time=now(), session_data='".$strSessionData."'";
$rs = mysql_query($sql, $this->s_link) or die($sql . ': ' .mysql_error($this->s_link));
if($rs){
$this->session = $session_data;
$this->session['uid'] = $userid;
$this->session['start_time'] = date('Y-m-d H:i:s');
$this->session['last_active_time'] = date('Y-m-d H:i:s');
$this->session_existed = true;
return $this->session;
}else{
$this->session_existed=false;
return 0;
}
}
public function getUserID()
{
return $this->session['uid'];
}
public function getGroupID()
{
return $this->session['gid'];
}
public function getUserName()
{
return $this->session['uname'];
}
public function getStartTime()
{
return $this->session['start_time'];
}
public function getLastActiveTime()
{
return $this->session['last_active_time'];
}
public function getData()
{
return $this->session;
}
public function getSessionID()
{
return $this->sessionID;
}
public function getLanguage()
{
return $this->session['lan'];
}
public function getLoginID()
{
return $this->session['login_id'];
}
/*
*
*
* @param return int
*/
public function save()
{
if(!is_resource($this->s_link))
return 0;
$this->kill_timeout();
if($this->session_existed){
unset($this->session['start_time']);
unset($this->session['last_active_time']);
unset($this->session['uid']);
$strSessionData=addslashes(serialize($this->session));
if(strlen($strSessionData) > $this->session_data_max_len)
return 0;
else{
$sql = "UPDATE " . $this->session_table_name . " SET session_data='".$strSessionData."',last_active_time=now() where session_id='".$this->sessionID."'"; // �� ���� session��ݡ�
$rs = mysql_query($sql,$this->s_link);
if($rs)
return 1;
else
return 0;
}
}else
return 0;
}
/*
*
* @param array session_data
* @param return int
*/
public function add($session_data = array())
{
if(!is_resource($this->s_link))
return 0;
if($this->session_existed){
$arrSessionTmp = $this->session;
unset($arrSessionTmp['uid']);
unset($arrSessionTmp['start_time']);
unset($arrSessionTmp['last_active_time']);
$arrSessionTmp = array_merge($arrSessionTmp,$session_data);
$strSessionData = addslashes(serialize($arrSessionTmp));
if(strlen($strSessionData) > $this->session_data_max_len)
return 0;
else{
$sql = "UPDATE " . $this->session_table_name . " SET session_data='".$strSessionData."',last_active_time=now() WHERE session_id='".$this->sessionID."'"; // �� ����session��ݡ�
$rs = mysql_query($sql,$this->s_link);
if($rs){
$this->session['last_active_time'] = date('Y-m-d H:i:s');
$this->session = $arrSessionTmp;
return 1;
}else
return 0;
}
}else
return 0;
}
/* session_destroy()
*
* @param return int
*/
public function destroy()
{
if(!is_resource($this->s_link))
return 0;
$rs = mysql_query("DELETE FROM " . $this->session_table_name . " WHERE session_id='".$this->sessionID."'",$this->s_link);
if($rs)
return 1;
else
return 0;
}
/*
*
* @param return int
*/
public function kill_timeout()
{
if(!is_resource($this->s_link))
return 0;
$result = mysql_query("DELETE FROM " . $this->session_table_name . " WHERE last_active_time<DATE_SUB(now(),interval ".$this->session_cfg['expires']." SECOND)",$this->s_link);
if($result)
return 1;
else
return 0;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Session.php | PHP | asf20 | 9,385 |
<?php
/* explain:
* Project:
* File: InfoClass.php
*
* @ link http://www.../lib/
* @ Email ldmmyx@hotmail.com
* @ copyright 2008 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class InfoClass extends Common
{
public $conHandle;
public $errorInfo;
private $iUserID;
private $objLog;
function InfoClass($strLanguage, $userid)
{
parent::Common();
$this->conHandle = $this->getConnection($strLanguage);
$this->objLog = new Logs($userid);
$this->iUserID = $userid;
}
/* get news class via ID
*
* @param int id
* @return mixed false:
*/
public function getFromID($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM info_class WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/*
*
* @param string name news class name
* @param string parentid news parent ID
* @param string isLeaf is leaf node
* @return int true: insert ID
*/
public function add($arrPopedom = array(), $name, $parentid, $sorts = -1, $isLeaf = 'no', $summary = '')
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO info_class SET name = '$name', parentid='$parentid', sorts = '$sorts', isLeaf = '$isLeaf', summary='$summary'";
$rs = mysql_query($sql, $this->conHandle) or die (mysql_error());
$intDataID = mysql_insert_id($this->conHandle);
if($rs)
return $intDataID;
else
return false;
}
/* edit
*
* @param int id
* @param string status
* @param return boolean
*/
public function edit($arrPopedom = array(), $id, $name, $parentid, $sorts = -1, $isLeaf, $summary)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "id=$id");
$sql = "UPDATE info_class SET name='$name', parentid='$parentid', sorts = '$sorts', isLeaf = '$isLeaf', summary='$summary' WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return true;
else
return false;
}
/* delete news class
*
* @param int id
* @param string status
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "DELETE FROM info_class WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return true;
else
return false;
}
/*
*
* @param int id
* @return mixed false:
*/
public function isLeaf($arrPopedom = array(), $id)
{
$sql = "SELECT * FROM info_class WHERE isLeaf='YES' AND id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs && mysql_num_rows($rs) > 0)
return true;
else
return false;
}
/*
*
* @param string condition
* @return mixed false
*/
public function listWeb($condition='')
{
$arrBack = array();
$sql = "SELECT * FROM info_class".$condition;
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
/* list
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $where, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = 'SELECT count(id) FROM info_class'.$where;
$rs = mysql_query($sql, $this->conHandle);
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = 'SELECT * FROM info_class'.$where;
else{
$sql = 'SELECT * FROM info_class'.$where." LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
/* list all custom condition data
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listFromCustom($arrPopedom = array(), $condition='')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$arrBack = array();
$sql = "SELECT * FROM info_class".$condition;
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
public function getCount()
{
$sql = "SELECT count(id) FROM info_class";
$rs = mysql_query($sql, $this->conHandle) or die(mysql_error());
if($rs){
$arrCache = mysql_fetch_array($rs);
return $arrCache[0];
}
return 0;
}
public function getDir($arrOperate, $parentid)
{
$arrParentid = array();
$arrTmpStack = array();
$arrLevelStack = array();
$arrClassid = array();
$i = 0;
array_push($arrTmpStack, $parentid);
while(sizeof($arrTmpStack) > 0){
$strtmp = array_pop($arrTmpStack);
$i = array_pop($arrLevelStack);
if($strtmp > 0){
$arrback = $this->getFromID($arrOperate, $strtmp);
if(is_array($arrback)){
$tmp = '';
for($j = 0; $j < $i; $j++){
$tmp.=' ';
}
$arrClassid[$arrback['id']] = $tmp.$arrback['name'];
}
}
$mixBack = $this->listWeb(" WHERE parentid='$strtmp'");
if(is_array($mixBack)){
$i++;
foreach($mixBack as $value){
array_push($arrTmpStack,$value['id']);
array_push($arrLevelStack,$i);
}
}
}
return $arrClassid;
}
public function arrGetDirIDList($parentid)
{
$arrParentid = array();
$arrTmpStack = array();
$arrLevelStack = array();
$arrClassid = array();
$i = 0;
array_push($arrTmpStack, $parentid);
while(sizeof($arrTmpStack) > 0){
$strtmp = array_pop($arrTmpStack);
$i = array_pop($arrLevelStack);
if($strtmp > 0){
$sql = "SELECT isLeaf FROM info_class WHERE id = $strtmp";
$rs = mysql_query($sql, $this->conHandle) or die (mysql_error($this->conHandle));
if($rs){
$arrback = mysql_fetch_array($rs);
if($arrback['isLeaf'] == 'yes')
array_push($arrClassid, $strtmp);
}
}
$sql = "SELECT id FROM info_class WHERE parentid=$strtmp";
$rs = mysql_query($sql, $this->conHandle) or die (mysql_error($this->conHandle));
if($rs){
$mixBack = array();
while($arrCache = mysql_fetch_array($rs)){
$mixBack[] = $arrCache;
}
$i++;
foreach($mixBack as $value){
array_push($arrTmpStack,$value['id']);
array_push($arrLevelStack,$i);
}
}
}
return $arrClassid;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/InfoClass.php | PHP | asf20 | 7,398 |
<?php
/* explain:
* Project:
* File: Job.php
*
* @ link http://www.../lib/
* @ Email ldmmyx@hotmail.com
* @ copyright 2007 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class Menu extends Common
{
public $conHandle;
public $errorInfo;
private $iUserID;
private $objLog;
function Menu($strLanguage, $userid)
{
parent::Common();
$this->conHandle = $this->getConnection("system");
$this->strLanguage = $strLanguage;
$this->objLog = new Logs($userid);
$this->iUserID = $userid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getFromID($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM menu WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/*
*
* @param string groupid
* @param string strOrders
* @param string name
* @param string namecn
* @param string url menu url
* @param datetime remark
* @param datetime status
* @return boolean true or fail
*/
public function add($arrPopedom = array(), $groupid, $strOrders, $name, $url, $remark, $status = 'normal')
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO menu SET groupid = '$groupid', orders='$strOrders', name = '$name', url = '$url', remark = '$remark', status='$status'";
$rs = mysql_query($sql, $this->conHandle);
return $rs ? true: false;
}
/* modify menu
*
* @param string id modify menu id
* @param string groupid
* @param string strOrders
* @param string name
* @param string namecn
* @param string url menu url
* @param datetime remark
* @param datetime status
* @return boolean true or fail
*/
public function edit($arrPopedom = array(), $id, $groupid, $strOrders, $name, $url, $remark)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "id=$id");
$sql = "UPDATE menu SET groupid = '$groupid', orders='$strOrders', name = '$name', url = '$url', remark = '$remark' WHERE id = '$id'";
$rs = mysql_query($sql, $this->conHandle);
return $rs ? true: false;
}
/* delete menu
*
* @param int id
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "DELETE FROM menu WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return true;
else
return false;
}
/* list menu
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $condition, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = 'SELECT count(id) FROM menu'.$condition;
$rs = mysql_query($sql, $this->conHandle);
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = 'SELECT * FROM menu'.$condition;
else{
$sql = 'SELECT * FROM menu'.$condition." LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
/* list all custom condition data
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listFromCustom($arrPopedom = array(), $condition='')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrBack = array();
$sql = "SELECT * FROM menu".$condition;
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Menu.php | PHP | asf20 | 4,656 |
<?php
class Security
{
private $strEncrypt; //----- password key
private $intValidateNum; //----- check code
function __construct()
{
while(($this->intValidateNum = rand() % 10000) < 1000);
$this->strEncrypt='LingDeming20050519'.date('YmdH');
}
public function iGetCheckCode()
{
return $this->intValidateNum;
}
/* decrypt 和 encrypt 的中间方法
*
* @param return int ← 返回随机数
*/
private function keyED($txt,$encrypt_key) //-----decrypt and encrypt 使用的中间函数
{
$encrypt_key = md5($encrypt_key);
$ctr=0;
$tmp = "";
for ($i=0;$i<strlen($txt);$i++){
if ($ctr==strlen($encrypt_key)) $ctr=0;
$tmp.= substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1);
$ctr++;
}
return $tmp;
}
/* 数据加密(默认用来进行验证码登陆使用)
*
* @param string txt ← 要加密的数据
* @param string key ← 加密的密匙
* @param return string ← 返回加密后的字串
*/
public function encrypt($txt='',$key='')
{
if(empty($key))
$key=$this->strEncrypt;
if(empty($txt))
$txt=$this->intValidateNum;
srand((double)microtime()*1000000);
$encrypt_key = md5(rand(0,32000));
$ctr=0;
$tmp = "";
for ($i=0;$i<strlen($txt);$i++){
if ($ctr==strlen($encrypt_key)) $ctr=0;
$tmp.= substr($encrypt_key,$ctr,1) .(substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1));
$ctr++;
}
return urlencode($this->keyED($tmp,$key));
}
/* 数据解密(默认用来进行验证码登陆使用)
*
* @param string txt ← 要解密的数据
* @param string key ← 解密的密匙
* @param return string ← 返回解密后的字串,解密的数据为空时返回值为空
*/
public function decrypt($txt='',$key='')
{
if(empty($key))
$key=$this->strEncrypt;
$txt=urldecode($txt);
$txt = $this->keyED($txt,$key);
$tmp = "";
for ($i=0;$i<strlen($txt);$i++){
$md5 = substr($txt,$i,1);
$i++;
$tmp.= (substr($txt,$i,1) ^ $md5);
}
return $tmp;
}
/* funEncode 和 funDecode 的中间方法
*
* @param return int ← 返回随机数
*/
public function make_seed() {
list($usec, $sec) = explode(' ', microtime());
return(float) $sec +((float) $usec * 100000);
}
/* 数据加密---->要mcrypt库支持
*
* @param string data ← 要加密的数据
* @param string key ← 加密的密匙
* @param string arithmetic ← 加密用的算法,默认为( Twofish 算法, ECB 模式 ,MCRYPT_RIJNDAEL_128算法存在暗匙,可以给每个数据分一个密匙)
* @param return str OR arr ← 返回加密后的字串,加密的数据为空时返回值为空,MCRYPT_RIJNDAEL_128算法返回的是数组
*/
public function funEncode($data, $key,$arithmetic='Twofish')
{
if(empty($data))
return ''; //----- 加密的数据为空,返回值为空
else{
if($arithmetic == 'MCRYPT_RIJNDAEL_128'){
$arrData=array();
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB), MCRYPT_RAND);
$encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key,$data, MCRYPT_MODE_CBC, $iv);
$arrData['iv'] = $iv; //----- 加密的暗匙(解密时用)
$arrData['encrypted'] = $encrypted; //----- 加密后的字符串
return $arrData;
}else{
srand($this->make_seed());
$td = mcrypt_module_open('twofish', '', 'ecb', ''); //----- Twofish 算法, ECB 模式
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); //----- If u use MCRYPT_RAND, make sure to invoke strand() first.
$ks = mcrypt_enc_get_key_size($td);
$gen_key = substr(md5($key), 0, $ks);
mcrypt_generic_init($td, $gen_key, $iv);
$encrypted = mcrypt_generic($td, $data);
mcrypt_module_close($td);
return $encrypted;
}
}
}
/* 数据解密---->要mcrypt库支持
*
* @param string data ← 要解密的数据
* @param string key ← 解密的密匙
* @param string arithmetic ← 解密用的算法,默认为( Twofish 算法, ECB 模式 )
* @param return string ← 返回解密后的字串,解密的数据为空时返回值为空
*/
public function funDecode($data, $key, $arithmetic='Twofish')
{
if(!is_array($data))
if(empty($data))
return ''; //----- 解密的数据为空,返回值为空
if(is_array($data))
if(empty($data['encrypted']))
return ''; //----- 解密的数据为空,返回值为空
if($arithmetic == 'MCRYPT_RIJNDAEL_128'){
$decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $data['encrypted'], MCRYPT_MODE_CBC, $data['iv']);
return $decrypted;
}else{
srand($this->make_seed());
$td = mcrypt_module_open('twofish', '', 'ecb', ''); //----- Twofish algorithm, ECB Mode
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
$ks = mcrypt_enc_get_key_size($td);
$gen_key = substr(md5($key), 0, $ks);
mcrypt_generic_init($td, $gen_key, $iv);
$decrypted = mdecrypt_generic($td, $data);
mcrypt_generic_deinit($td); //----- Clear all buffer needed by the encryption
mcrypt_module_close($td); //----- Close the module
return trim($decrypted);
}
}
/* 数据加密应用
*
* @param string data ← 要加密的数据
* @param string key ← 加密的密匙
* @param int level ← 1:普通,2:中级,3:高级(默认) 级别越低速度更快
* @param boolean isEncode ← 是否对数据进行加密,默认为加密,为false时数据不加密
* @param return str OR arr ← 返回加密后的字串,加密的数据为空时返回值为空,加密失败后返回数组和错误信息
*/
public function funEncoding($data, $key,$level=3,$isEncode = true)
{
if(empty($data) OR !($isEncode))
return $data; //----- 加密的数据为空,返回值为空,或选择不对数据加密
$arrBack=array();
if($level == 3){
if(function_exists('mcrypt_encrypt')) //--- 要mcrypt库支持
return $this->funEncode($data, $key);
else{ //--- 加密失败后返回数组和错误信息
$this->errorInfo = 'PHP环境不支持mcrypt库';
$arrBack['data'] = $data;
$arrBack['errorInfo'] = 'PHP not abet mcrypt library';
$arrBack['errorLevel'] = 3; //--- 错误级别为系统环境错误
return $arrBack;
}
}else{ //--- 加密失败后返回数组和错误信息
$this->errorInfo = '没有找到相应的安全等级';
$arrBack['data'] = $data;
$arrBack['errorInfo'] = 'It not find secure level';
$arrBack['errorLevel'] = 1;//--- 其他错误 (警告级别)
return $arrBack;
}
}
/* 数据解密应用
*
* @param string data ← 要解密的数据
* @param string key ← 解密的密匙
* @param int level ← 1:普通,2:中级,3:高级(默认) 级别越低速度更快
* @param boolean isEncode ← 是否对数据进行解密,默认为解密,为false时数据不解密
* @param return str OR arr ← 返回解密后的字串,解密的数据为空时返回值为空,解密失败后返回数组和错误信息
*/
public function funDecoding($data, $key,$level=3,$isDecode = true)
{
if(empty($data) OR !($isDecode))
return $data; //----- 解密的数据为空,返回值为空,或选择不对数据解密
$arrBack=array();
if($level == 3){
if(function_exists('mcrypt_encrypt')){ //--- 要mcrypt库支持
return $this->funDecode($data, $key);
}else{ //--- 解密失败后返回数组和错误信息
$this->errorInfo = 'PHP环境不支持mcrypt库';
$arrBack['data'] = $data;
$arrBack['errorInfo'] = 'PHP not abet mcrypt library';
$arrBack['errorLevel'] = 3; //--- 错误级别为系统环境错误
return $arrBack;
}
}else{ //--- 解密失败后返回数组和错误信息
$this->errorInfo = '没有找到相应的安全等级';
$arrBack['data'] = $data;
$arrBack['errorInfo'] = 'It not find secure level';
$arrBack['errorLevel'] = 1;//--- 其他错误 (警告级别)
return $arrBack;
}
}
}
?> | 123gohelmetsv2 | trunk/admin/lib/Security.php | PHP | asf20 | 8,534 |
<?php
define("ENTER",chr(13).chr(10));
class HTMLUtils
{
private $arrPageFlag = array();
private $arrSearch = array();
private $arrReplace = array();
function __construct()
{
$this->arrSearch = array ("'<script[^>]*?>.*?</script>'si", "'<[\/\!]*?[^<>]*?>'si", "'([\r\n])[\s]+'", "'&(quot|#34);'i", "'&(amp|#38);'i", "'&(lt|#60);'i", "'&(gt|#62);'i", "'&(nbsp|#160);'i", "'&(iexcl|#161);'i", "'&(cent|#162);'i", "'&(pound|#163);'i", "'&(copy|#169);'i", "'&#(\d+);'e");
$this->arrReplace = array ("", "", "\\1", "\"", "&", "<", ">", " ", chr(161), chr(162), chr(163), chr(169), "chr(\\1)");
}
public function main()
{
$strUrl = "http://ent.sina.com.cn/film/chinese/more.html";
$strStartFlag = '<li>';
$strEndFlag = '<font size=1 color=#6666cc>(';
$page = 1;
$isList = 1;
$startPos = 0;
$endPos = 0;
$subffix = '';
$strNextStartFlag = '<!--正文开始-->';
$strEndStartFlag = '<!--正文内容结束-->';
$strTitleStartFlag = '<h1>';
$strTtitleStartFlag = '</h1>';
$strImageStartFlag = '<h1>';
$strImageStartFlag = '</h1>';
$objHtmlUtils = new HtmlUtils();
$objHtmlUtils->vdSetFlag(1, 2, $strStartFlag, $strEndFlag);
$objHtmlUtils->vdSetFlag(2, 0, $strNextStartFlag, $strEndStartFlag);
$i = 0;
$arrDataList = $objHtmlUtils->arrGetLabelContent($objHtmlUtils->strGetContent($strUrl, 1), "a", "href");
foreach ($arrDataList as $key => $value){
echo '================'.$key.'<br>';
if($i < 6){
echo '---------'.$key.'<br>';
echo $objHtmlUtils->strFilterLabel($objHtmlUtils->strGetContent($key, 2, true), 'h1').'<br>';
}
$i++;
}
}
public function getBusPathFromDDmap($content)
{
$arrReturn = array();
$iStartPos = 0;
$strContent = strtolower($content);
for($i = 1; $i < 100; $i++){
$strDataLabel = "<n>desc$i</n>";
$iStartPos = strpos($strContent, $strDataLabel, $iStartPos);
if($iStartPos !== false){
$iDataStartPos = strpos($strContent, "<string>", $iStartPos);
if($iDataStartPos !== false){
$iDataEndPos = strpos($strContent, "</string>", $iStartPos);
if($iDataEndPos !== false){
$arrReturn[] = substr($content, $iDataStartPos + 8, $iDataEndPos - $iDataStartPos - 8);
$iStartPos = $iDataEndPos;
}else
break;
}else
break;
}else
break;
}
return $arrReturn;
}
public function arrGetLabelContent($strContent, $strLabel)
{
$strLabelPre = '>';
$strLabelEnd = '</' . $strLabel . '>';
$strLabelStart = '<' . $strLabel;
$strContent = strtolower($strContent);
$arrReturn = array();
$iStartPos = stripos($strContent, $strLabelStart);
while($iStartPos){
$iEndPos = stripos($strContent, $strLabelEnd, $iStartPos);
if($iEndPos){
$iPrePos = stripos($strContent, $strLabelPre, $iStartPos);
if($iPrePos){
if($strLabel == 'a'){
$iHerfStartPos = stripos($strContent, "href=", $iStartPos);
if($iHerfStartPos and $iHerfStartPos < $iPrePos){
if(substr($strContent, $iHerfStartPos + 5, 1) == "\""){
$iHerfEndPos = stripos($strContent, "\"", $iHerfStartPos);
if($iHerfEndPos){
$arrReturn[substr($strContent, $iHerfStartPos + 5, $iHerfEndPos - $iHerfStartPos + 5)] = substr($strContent, $iPrePos + strlen($strLabelPre), $iEndPos - $iPrePos);
}
}else{
$iHerfEndPos = stripos($strContent, " ", $iHerfStartPos);
if($iHerfEndPos and $iHerfEndPos < $iPrePos){
echo '----------'.ENTER;
$arrReturn[substr($strContent, $iHerfStartPos + 5, $iHerfEndPos - $iHerfStartPos - 5)] = substr($strContent, $iPrePos + strlen($strLabelPre), $iEndPos - $iPrePos);
}else{
echo '++++++++++++'.ENTER;
$arrReturn[substr($strContent, $iHerfStartPos + 5, $iPrePos - $iHerfStartPos - 5)] = substr($strContent, $iPrePos + strlen($strLabelPre), $iEndPos - $iPrePos);
}
}
}
}else
$arrReturn[] = substr($strContent, $iPrePos + strlen($strLabelPre), $iEndPos - $iPrePos);
$iStartPos = stripos($strContent, $strLabelStart, $iEndPos);
}
}
}
return $arrReturn;
}
function getbusnamefromStr($strLine)
{
$arrReturn = array();
$iStartPos = stripos($strLine, "��");
while($iStartPos !== false){
$iEndPos = strpos($strLine, "(", $iStartPos);
if($iEndPos){
$arrReturn[] = substr($strLine, $iStartPos + 2, $iEndPos - $iStartPos - 4);
}else
break;
$iStartPos = strpos($strLine, "��", $iEndPos);;
}
return $arrReturn;
}
public function vdSetFlag($iPage, $iNextPage, $strStartFlag, $strEndFlag)
{
$arrFlag = array();
$arrFlag['start'] = $strStartFlag;
$arrFlag['end'] = $strEndFlag;
$arrFlag['nextPage'] = $iNextPage;
$this->arrPageFlag[$iPage] = $arrFlag;
}
public function strGetContent($strUrl, $iPage, $sourceCharset = "GB2312", $targetCharget = "UTF-8")
{
if(!is_array($this->arrPageFlag[$iPage]))
return '';
$arrFlag = $this->arrPageFlag[$iPage];
$strHtmlCode = @file_get_contents($strUrl);
$strHtmlCode = mb_convert_encoding($strHtmlCode, $targetCharget, $sourceCharset);
if(empty($arrFlag['start']) && empty($arrFlag['end']))
return $strHtmlCode;
else if ($strHtmlCode){
if(empty($arrFlag['start']))
$iStartPos = 0;
else
$iStartPos = mb_stripos($strHtmlCode, $arrFlag['start'], 0, $targetCharget);
if(empty($arrFlag['end']))
$iEndPos = mb_strlen($strHtmlCode, $targetCharget);
else
$iEndPos = mb_strrpos($strHtmlCode, $arrFlag['end'], 0, $targetCharget);
return mb_substr($strHtmlCode, $iStartPos + mb_strlen($arrFlag['start'], $targetCharget), $iEndPos - $iStartPos - mb_strlen($arrFlag['start'], $targetCharget), $targetCharget);
}
return $strHtmlCode;
}
public function strGetHTMLSource($strUrl)
{
return @file_get_contents($strUrl);
}
public function strConvertCharset($strHTMLSource, $sourceCharset = "GB2312", $targetCharget = "UTF-8")
{
return mb_convert_encoding($strHTMLSource, $targetCharget, $sourceCharset);
}
public function strGetLabelContent($strHTMLSource, $startTag, $endTag, $sourceCharset = "GB2312", $targetCharget = "UTF-8")
{
if(empty($startTag) && empty($endTag))
return $strHTMLSource;
else if ($strHTMLSource){
if(empty($startTag))
$iStartPos = 0;
else
$iStartPos = mb_stripos($strHTMLSource, $startTag, 0, $targetCharget);
if(empty($endTag))
$iEndPos = mb_strlen($strHTMLSource, $targetCharget);
else
$iEndPos = mb_strrpos($strHTMLSource, $endTag, 0, $targetCharget);
return mb_substr($strHTMLSource, $iStartPos + mb_strlen($startTag, $targetCharget), $iEndPos - $iStartPos - mb_strlen($startTag, $targetCharget), $targetCharget);
}
}
public function arrGetLabelAllContent($strContent, $strLabel, $strKeyAttribute = '')
{
$strLabelPre = '>';
$strLabelEnd = '</' . $strLabel . '>';
$strLabelStart = '<' . $strLabel;
$arrReturn = array();
$iStartPos = stripos($strContent, $strLabelStart);
while($iStartPos){
$iEndPos = stripos($strContent, $strLabelEnd, $iStartPos);
if($iEndPos){
$iPrePos = stripos($strContent, $strLabelPre, $iStartPos);
if($iPrePos){
$iAttriStartPos = stripos($strContent, $strKeyAttribute, $iStartPos);
if($iAttriStartPos and $iAttriStartPos < $iPrePos){
if(substr($strContent, $iAttriStartPos + strlen($strKeyAttribute) + 1, 1) == "\""){
$iAttriEndPos = stripos($strContent, "\"", $iAttriStartPos);
if($iAttriEndPos){
$arrReturn[substr($strContent, $iAttriStartPos + strlen($strKeyAttribute) + 1, $iAttriEndPos - $iAttriStartPos + strlen($strKeyAttribute) + 1)] = substr($strContent, $iPrePos + strlen($strLabelPre), $iEndPos - $iPrePos);
}
}else{
$iAttriEndPos = stripos($strContent, " ", $iAttriStartPos);
if($iAttriEndPos and $iAttriEndPos < $iPrePos){
$arrReturn[substr($strContent, $iAttriStartPos + strlen($strKeyAttribute) + 1, $iAttriEndPos - $iAttriStartPos - strlen($strKeyAttribute) - 1)] = substr($strContent, $iPrePos + strlen($strLabelPre), $iEndPos - $iPrePos);
}else{
$arrReturn[substr($strContent, $iAttriStartPos + strlen($strKeyAttribute) + 1, $iPrePos - $iAttriStartPos - strlen($strKeyAttribute) - 1)] = substr($strContent, $iPrePos + strlen($strLabelPre), $iEndPos - $iPrePos);
}
}
}else
$arrReturn[] = substr($strContent, $iPrePos + strlen($strLabelPre), $iEndPos - $iPrePos);
$iStartPos = stripos($strContent, $strLabelStart, $iEndPos);
}
}
}
return $arrReturn;
}
public function strFilterLabel($strContent, $strLabel)
{
$strLabelEnd = '</' . $strLabel . '>';
$strLabelStart = '<' . $strLabel . '>';
$iStartPos = stripos($strContent, $strLabelStart);
while($iStartPos){
$iEndPos = stripos($strContent, $strLabelEnd, $iStartPos);
if($iEndPos){
$strContent = substr_replace($strContent, '', $iStartPos, $iEndPos - $iStartPos + strlen($strLabelEnd));
$iStartPos = stripos($strContent, $strLabelStart);
}
}
return $strContent;
}
public function strGetLabelText($strContent, $strLabel, $targetCharget = "UTF-8")
{
$strLabelEnd = '</' . $strLabel . '>';
$strLabelStart = '<' . $strLabel . '>';
$iStartPos = mb_stripos($strContent, $strLabelStart, 0, $targetCharget);
echo 'iStartPos='.$iStartPos.'<br>';
if($iStartPos >= 0){
$j = 0;// inner the same tags count with start tag.
$iPosCache = $iStartPos + mb_strlen($strLabelStart, $targetCharget);
$iPos = mb_stripos($strContent, $strLabelStart, $iPosCache, $targetCharget);
while($iPos){
$j++;
$iPosCache = $iPos + mb_strlen($strLabelStart, $targetCharget);
$iPos = mb_stripos($strContent, $strLabelStart, $iPosCache, $targetCharget);
}
echo 'j='.$j.'<br>';
echo 'iPosCache='.$iPosCache.'<br>';
for($i = 0; $i < $j; $i++){
$iPos = mb_stripos($strContent, $strLabelEnd, $iPosCache, $targetCharget);
if($iPos == -1){//on has end tag in inner tag
return "";
}else
$iPosCache = $iPos + mb_strlen($strLabelEnd, $targetCharget);
}
echo 'iPosCache2='.$iPosCache.'<br>';
$iEndPos = mb_stripos($strContent, $strLabelEnd, $iPosCache, $targetCharget);
echo '$iEndPos='.$iEndPos.'<br>';
if($iEndPos){
return mb_substr($strContent, $iStartPos + mb_strlen($strLabelStart, $targetCharget), $iEndPos - $iStartPos - mb_strlen($strLabelStart, $targetCharget), $targetCharget);
//$iStartPos = stripos($strContent, $strLabelStart);
}else
return "";
}else
return "";
}
public function getTagContent($strHTMLSource, $tag, $arrFilterTag = array())
{
$returContent = '';
if(eregi("<$tag>(.*)</$tag>", $strHTMLSource ,$out)){
$returContent = $this->strip_selected_tags_Content($out[0],$arrFilterTag);
}
return $returContent;
}
public function strip_selected_tags($text, $tags = array())
{
$args = func_get_args();
$text = array_shift($args);
$tags = func_num_args() > 2 ? array_diff($args,array($text)) : (array)$tags;
foreach ($tags as $tag){
if( preg_match_all( '/<'.$tag.'[^>]*>([^<]*)<\/'.$tag.'>/iu', $text, $found) ){
$text = str_replace($found[0],$found[1],$text);
}
}
return preg_replace( '/(<('.join('|',$tags).')(\n|\r|.)*\/>)/iu', '', $text);
}
public function strip_selected_tags_Content($text, $tags = array())
{
$args = func_get_args();
$text = array_shift($args);
$tags = func_num_args() > 2 ? array_diff($args,array($text)) : (array)$tags;
foreach ($tags as $tag){
$text = preg_replace('/<'.$tag.'[^>]*>([^<]*)<\/'.$tag.'>/iu', '', $text);
}
return $text;
}
}
| 123gohelmetsv2 | trunk/admin/lib/HTMLUtils.php | PHP | asf20 | 12,173 |
<?php
/**
* Project:
* File: Strings.php
*
* @link http://.../lib
* @copyright 2007
* @author ivan <ldmmyx@hotmail.com>
* @version 1.0
*
* @ substr_cut($str_cut,$length = 65)
*/
class Strings
{
function Strings()
{
}
public function getCharNum($text)
{
$text = trim($text);
$return = '';
$len = strlen($text);
for($i = 0; $i < $len; $i++){
$ch = ord($text[$i]);
if($ch > 47 && $ch < 58 || $ch > 64 && $ch < 91 || $ch > 96 && $ch < 123)
$return .= $text[$i];
else
$return .= '-';
}
$return = $this->deleteSapces($return, '--', '');
return $return;
}
public function deleteSapces($text, $search, $replace)
{
$pos = strrpos($text, $search);
if ($pos === false) { // note: three equal signs
return $text;
}else{
while(true){
$pos = strrpos($text, $search);
if ($pos === false) { // note: three equal signs
break;
}else{
$text = str_replace($search, $replace, $text);
}
}
}
return $text;
}
function random($length)
{
$string = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$random = '';
$strlen = strlen($string);
for ($i=0; $i < $length; ++$i)
{
$random .= $string{mt_rand(0, $strlen-1)};
}
return $random;
}
public function filterHtml($str)
{
$str=preg_replace("/\s+/", " ", $str); //过滤多余回车
$str=preg_replace("/<[ ]+/si","<",$str); //过滤<__("<"号后面带空格)
$str=preg_replace("/<\!--.*?-->/si","",$str); //注释
$str=preg_replace("/<(\!.*?)>/si","",$str); //过滤DOCTYPE
$str=preg_replace("/<(\/?html.*?)>/si","",$str); //过滤html标签
$str=preg_replace("/<(\/?head.*?)>/si","",$str); //过滤head标签
$str=preg_replace("/<(\/?meta.*?)>/si","",$str); //过滤meta标签
$str=preg_replace("/<(\/?body.*?)>/si","",$str); //过滤body标签
$str=preg_replace("/<(\/?link.*?)>/si","",$str); //过滤link标签
$str=preg_replace("/<(\/?form.*?)>/si","",$str); //过滤form标签
$str=preg_replace("/cookie/si","COOKIE",$str); //过滤COOKIE标签
$str=preg_replace("/<(applet.*?)>(.*?)<(\/applet.*?)>/si","",$str); //过滤applet标签
$str=preg_replace("/<(\/?applet.*?)>/si","",$str); //过滤applet标签
$str=preg_replace("/<(style.*?)>(.*?)<(\/style.*?)>/si","",$str); //过滤style标签
$str=preg_replace("/<(\/?style.*?)>/si","",$str); //过滤style标签
$str=preg_replace("/<(title.*?)>(.*?)<(\/title.*?)>/si","",$str); //过滤title标签
$str=preg_replace("/<(\/?title.*?)>/si","",$str); //过滤title标签
$str=preg_replace("/<(object.*?)>(.*?)<(\/object.*?)>/si","",$str); //过滤object标签
$str=preg_replace("/<(\/?objec.*?)>/si","",$str); //过滤object标签
$str=preg_replace("/<(noframes.*?)>(.*?)<(\/noframes.*?)>/si","",$str); //过滤noframes标签
$str=preg_replace("/<(\/?noframes.*?)>/si","",$str); //过滤noframes标签
$str=preg_replace("/<(i?frame.*?)>(.*?)<(\/i?frame.*?)>/si","",$str); //过滤frame标签
$str=preg_replace("/<(\/?i?frame.*?)>/si","",$str); //过滤frame标签
$str=preg_replace("/<(script.*?)>(.*?)<(\/script.*?)>/si","",$str); //过滤script标签
$str=preg_replace("/<(\/?script.*?)>/si","",$str); //过滤script标签
$str=preg_replace("/javascript/si","Javascript",$str); //过滤script标签
$str=preg_replace("/vbscript/si","Vbscript",$str); //过滤script标签
$str=preg_replace("/on([a-z]+)\s*=/si","On\\1=",$str); //过滤script标签
$str=preg_replace("/&#/si","&#",$str); //过滤script标签,如javAsCript:alert(
return $str;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Strings.php | PHP | asf20 | 3,692 |
<?php
/* explain: Popedom system
* Project: marsems
* File: Popedom.php
*
* @ link http://www.marems.com/lib/
* @ Email ldmmyx@hotmail.com
* @ copyright 2007 ivan.ling
* @ author ivan.ling
* @ version 1.0
*
* @ --- function list ---
* @ getNotPopedomInfo() --> tip
*/
include_once("DB.php");
class Popedom extends DB
{
const STRING_WEB_VIEW = 'web_view';
const STRING_WEB_EDIT = 'web_edit';
const STRING_WEB_ADD = 'web_add';
const STRING_WEB_DELETE = 'web_delete';
const STRING_VIEW = '1';
const STRING_ADD = '2';
const STRING_LIVE = '3';
const STRING_DELETE = '4';
const STRING_EDIT = '5';
const STRING_STOP = '6';
const SYSTEM_SAFE_KEY = 'V!N@MY([RGF1*43$~';
private $INT_ADMINISTRATOR_GROUP = 1;
private $INT_SYSTEM_ADMIN_GROUP = 2;
private $INT_COMMON_ADMIN_GROUP = 4;
private $INT_MEMBER_GROUP = 6;
private $STRING_NOT_POPEDOM_INFO = 'There has not operate popedom.';
function Popedom()
{
parent::DB();
}
public function getNotPopedomInfo()
{
return $this->STRING_NOT_POPEDOM_INFO;
}
public function isUnallowableView($arrPopedom)
{
return is_array($arrPopedom) && in_array(Popedom::STRING_VIEW, $arrPopedom) ? false : true;
}
public function isUnallowableAdd($arrPopedom)
{
return is_array($arrPopedom) && in_array(Popedom::STRING_ADD, $arrPopedom) ? false : true;
}
public function isUnallowableLive($arrPopedom)
{
return is_array($arrPopedom) && in_array(Popedom::STRING_LIVE, $arrPopedom) ? false : true;
}
public function isUnallowableDelete($arrPopedom)
{
return is_array($arrPopedom) && in_array(Popedom::STRING_DELETE, $arrPopedom) ? false : true;
}
public function isUnallowableEdit($arrPopedom)
{
return is_array($arrPopedom) && in_array(Popedom::STRING_EDIT, $arrPopedom) ? false : true;
}
public function isUnallowableWait($arrPopedom)
{
return is_array($arrPopedom) && in_array(Popedom::STRING_WAIT, $arrPopedom) ? false : true;
}
public function isUnallowable($arrPopedom, $popedom)
{
return is_array($arrPopedom) && in_array($popedom, $arrPopedom) ? false : true;
}
public function getWebViewPopedom()
{
return Popedom::STRING_WEB_VIEW.__METHOD__.__LINE__;
}
public function getEditPopedom()
{
return Popedom::STRING_WEB_EDIT.__METHOD__.__LINE__;
}
public function getAddPopedom()
{
return Popedom::STRING_ADD_EDIT.__METHOD__.__LINE__;
}
public function getDeletePopedom()
{
return Popedom::STRING_EDIT_EDIT.__METHOD__.__LINE__;
}
public function isAdmin($groupid)
{
if($this->INT_COMMON_ADMIN_GROUP == $groupid || $this->INT_SYSTEM_ADMIN_GROUP == $groupid || $this->INT_ADMINISTRATOR_GROUP == $groupid)
return true;
else
return false;
}
public function isMember($groupid)
{
if($this->INT_MEMBER_GROUP == $groupid)
return true;
else
return false;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Popedom.php | PHP | asf20 | 2,940 |
<?php
/**
*
*
* @link http://ad.zjol.com.cn/
* @copyright 2005 WAM Chian Ltd.
* @author gabriel <deming@staff.service4media.com>
* @version 1.0
*/
class Validation
{
private $execinfo = '';
public function isChar($content)
{
if(ereg('^[a-zA-Z]+$',$content))
return TRUE;
else
return FALSE;
}
public function isCharVSnumber($content)
{
if(ereg('^[a-zA-Z0-9]+$',$content))
return TRUE;
else
return FALSE;
}
public function isNumber($content)
{
if(ereg("^[0-9]{1,}$",$content))
return TRUE;
else
return FALSE;
}
public function isEmail($content,$allowEmpty = 'notEmpty')
{
if($allowEmpty == 'empty' AND empty($content))
return TRUE;
if (eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$",$content))
return TRUE;
else
return FALSE;
}
public function isUrl($content,$allowEmpty = 'notEmpty')
{
if($allowEmpty == 'empty' AND empty($content))
return TRUE;
if (preg_match('/^http:\/\/[a-z0-9@:%_.~#-\?&]+$/i',$content))
return TRUE;
else
return FALSE;
}
public function isDate($content)
{
if (preg_match('/[0-2]\d\d\d-[01]\d-[0-3]\d/i',$content))
return TRUE;
else
return FALSE;
}
public function isChinese($content,$allowEmpty = 'notEmpty')
{
if($allowEmpty == 'empty' AND empty($content))
return TRUE;
if (eregi("^[\xa0-\xff]{0,}$",$content))
return TRUE;
else
return FALSE;
}
public function isPaper18($content)
{
if(strlen($content)==18){
for ($i=0;$i<18;$i++){
$arrPaper[$i]=substr($content,$i,1);
}
$arrGene=array(7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1);
$intTmp=0;
for ($i=0;$i<17;$i++){
$intTmp+=$arrPaper[$i]*$arrGene[$i];
}
$arrCheckCode=array('1','0','X','9','8','7','6','5','4','3','2');
$intCheckPosition=$intTmp%11;
if($arrCheckCode[$intCheckPosition]==strtoupper($arrPaper[17]))
return TRUE;
else{
$this->execinfo='������ĺ��벻�����֤����!';
return FALSE;
}
}else{
$this->execinfo='������ĺ��벻��18λ!';
return FALSE;
}
}
public function goto15To18Paper($content)
{
if(strlen($content)==15 AND $this->isNumber($content)){
$arrGene=array(7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1);
$arrCheckCode=array('1','0','X','9','8','7','6','5','4','3','2');
$strTmp=substr($content,0,6);
$strTmpContent=$strTmp.'19'.substr($content,6);
for ($i=0;$i<18;$i++){
$arrPaper[$i]=substr($strTmpContent,$i,1);
}
$intTmp=0;
for ($i=0;$i<17;$i++){
$intTmp+=$arrPaper[$i]*$arrGene[$i];
}
$intCheckPosition=$intTmp%11;
return $strTmpContent.$arrCheckCode[$intCheckPosition];
}else{
$this->execinfo='������ĺ��벻��15λ��������!';
return FALSE;
}
}
public function isPaper15($content)
{
if(preg_match("/^\d{15}$/i",$content)){
$arrAera=array(11,12,13,14,15,21,22,23,31,32,33,34,35,36,37,41,42,43,44,45,46,50,51,52,53,54,61,62,63,64,65,71,81,82,91);
if(in_array(substr($content,0,2),$arrAera)){
if(checkdate(substr($content,8,2),substr($content,10,2),'19'.substr($content,6,2)))
return TRUE;
else{
$this->execinfo='����������֤�����ǷǷ�������!';
return FALSE;
}
}else{
$this->execinfo='����������֤�����ǷǷ�����!';
return FALSE;
}
}else{
$this->execinfo='������ĺ��벻��15λ��������!';
return FALSE;
}
}
public function isPaper($content)
{
if(strlen($content) != 15 AND strlen($content) != 18){
$this->execinfo='������ĺ��벻��15λ��18λ�ĺ���!';
return FALSE;
}else if(strlen($content) == 15){
if($this->isPaper15($content))
return TRUE;
else
return FALSE;
}else{
if($this->isPaper18($content))
return TRUE;
else
return FALSE;
}
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Validation.php | PHP | asf20 | 4,067 |
<?php
/*
* Created on Dec 1, 2010
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
class AddressBookDao
{
private $id;
private $firstname;
private $lastname;
private $gender;
private $customerid;
private $company;
private $street;
private $suburb;
private $zipcode;
private $city;
private $state;
private $zoneid;
private $countryid;
private $country; // name
private $phoneNumber;
public function AddressBookDao()
{
}
public function setId($id)
{
$this->id = $id;
}
public function getId()
{
return $this->id;
}
public function setFirstName($firstname)
{
$this->firstname = $firstname;
}
public function getFirstName()
{
return $this->firstname;
}
public function setLastName($lastname)
{
$this->lastname = $lastname;
}
public function getLastName()
{
return $this->lastname;
}
public function setCountryid($countryid)
{
$this->countryid = $countryid;
}
public function getCountryid()
{
return $this->countryid;
}
public function setGender($gender)
{
$this->gender = $gender;
}
public function getGender()
{
return $this->gender;
}
public function setCustomerid($customerid)
{
$this->customerid = $customerid;
}
public function getCustomerid()
{
return $this->customerid;
}
public function setCompany($company)
{
$this->company = $company;
}
public function getCompany()
{
return $this->company;
}
public function setStreet($street)
{
$this->street = $street;
}
public function getStreet()
{
return $this->street;
}
public function setSuburb($suburb)
{
$this->suburb = $suburb;
}
public function getSuburb()
{
return $this->suburb;
}
public function setZipcode($zipcode)
{
$this->zipcode = $zipcode;
}
public function getZipcode()
{
return $this->zipcode;
}
public function setCity($city)
{
$this->city = $city;
}
public function getCity()
{
return $this->city;
}
public function setState($state)
{
$this->state = $state;
}
public function getState()
{
return $this->state;
}
public function setZoneid($zoneid)
{
$this->zoneid = $zoneid;
}
public function getZoneid()
{
return $this->zoneid;
}
public function setCountry($country)
{
$this->country = $country;
}
public function getCountry()
{
return $this->country;
}
public function setPhoneNumber($phoneNumber)
{
$this->phoneNumber = $phoneNumber;
}
public function getPhoneNumber()
{
return $this->phoneNumber;
}
public function getArray()
{
$data_array = array(
'customerid' => $this->customerid,
'gender' => $this->gender,
'firstname' => $this->firstname,
'lastname' => $this->lastname,
'street' => $this->street,
'suburb' => $this->suburb,
'city' => $this->city,
'zoneid' => $this->zoneid,
'state' => $this->state,
'postcode' => $this->zipcode,
'countryid' => $this->countryid,
'company' => $this->company
);
return $data_array;
}
public function setArray($arrAddressBook)
{
$this->id = $arrAddressBook['id'];
$this->customerid = $arrAddressBook['customerid'];
$this->gender = $arrAddressBook['gender'];
$this->firstname = $arrAddressBook['firstname'];
$this->lastname = $arrAddressBook['lastname'];
$this->street = $arrAddressBook['street'];
$this->suburb = $arrAddressBook['suburb'];
$this->city = $arrAddressBook['city'];
$this->zoneid = $arrAddressBook['zoneid'];
$this->state = $arrAddressBook['state'];
$this->zipcode = $arrAddressBook['postcode'];
$this->countryid = $arrAddressBook['countryid'];
$this->country = $arrAddressBook['countryname'];
$this->company = $arrAddressBook['company'];
return $arrAddressBook;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/AddressBookDao.php | PHP | asf20 | 4,234 |
<?php
/* explain:
* Project:
* File: Job.php
*
* @ link http://www.../lib/
* @ Email ldmmyx@hotmail.com
* @ copyright 2007 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
class Operation extends Common
{
public $conHandle;
public $errorInfo;
public static $SelfFileName;
function Operation($strLanguage = "en-US")
{
parent::Common();
$this->conHandle = $this->getConnection("system");
$this->strLanguage = $strLanguage;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getFromID($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM operation WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/* get data via groupid and menuid
*
* @param int id
* @return operate array
*/
public function arrGetFromGroupID($groupid, $menuid)
{
if($groupid == 1){
$sql = "SELECT id FROM operation";
$rs = mysql_query($sql, $this->conHandle);
if($rs){
$arrCache = array();
while ($arrData = mysql_fetch_array($rs)){
$arrCache[] = $arrData['id'];
}
return $arrCache;
}
}else{
$sql = "SELECT operate FROM group_authority WHERE menuid = '$menuid' AND groupid = '$groupid'";
$rs = mysql_query($sql, $this->conHandle);
if($rs){
if($arrData = mysql_fetch_array($rs)){
return explode(',', $arrData['operate']);
}
}
}
return false;
}
/* get data via groupid and menuid
*
* @param int id
* @return operate array
*/
public function arrGetFromGroupIDAndMenuID($groupid, $menuid)
{
$sql = "SELECT operate FROM group_authority WHERE menuid = '$menuid' AND groupid = '$groupid'";
$rs = mysql_query($sql, $this->conHandle);
if($rs){
if($arrData = mysql_fetch_array($rs)){
return explode(',', $arrData['operate']);
}
}
return array();
}
/*
*
* @param string name
* @param string namecn
* @return boolean true or fail
*
*/
public function add($arrPopedom = array(), $name)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "INSERT INTO operation SET name = '$name'";
$rs = mysql_query($sql, $this->conHandle) or die(mysql_error());
return $rs ? true: false;
}
/* modify menu
*
* @param string id modify menu id
* @param string strOrders
* @param string name
* @param string namecn
* @return boolean true or fail
*/
public function edit($arrPopedom = array(), $id, $name)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "UPDATE operation SET name = '$name', WHERE id='$id'";
$rs = mysql_query($sql, $this->conHandle) or die ('update error : ' . mysql_error($this->conHandle).$sql);
return $rs ? true: false;
}
/* delete menu
*
* @param int id
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "DELETE FROM operation WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return true;
else
return false;
}
/* list menu
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $condition, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$arrback = array();
$sql = "SELECT count(id) FROM operation$condition";
$rs = mysql_query($sql, $this->conHandle);
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = "SELECT * FROM operation$condition";
else{
$sql = "SELECT * FROM operation$condition LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
/* list all custom condition data
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listFromCustom($arrPopedom = array(), $condition='')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$arrBack = array();
$sql = "SELECT id, name FROM operation$condition";
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
/* operation list
*
* @ param return array �� data array
*/
public function listOperation()
{
$sql = "SELECT id, name FROM operation";
$rs = mysql_query($sql, $this->conHandle);
if($rs){
$arrback = array();
$arrID = array();
$arrName = array();
while(is_array($arrcache = mysql_fetch_array($rs))){
$arrID[] = $arrcache['id'];
$arrName[] = $arrcache['name'];
}
$arrback['id'] = $arrID;
$arrback['name'] = $arrName;
return $arrback;
}else
return false;
}
public function arrGetOPInfo($arrOperate)
{
$arrOperateInfo = array();
if(count($arrOperate) > 0){
$strQuery = $_SERVER["REQUEST_URI"];
$arrUrlInfo = pathinfo($strQuery);
Operation::$SelfFileName = $arrUrlInfo['filename'];
$arrOperateAllInfo = $this->listFromCustom($arrOperate, " WHERE id in (".implode(",", $arrOperate).")");
$i = 0;
foreach($arrOperateAllInfo as $key => $value){
$strFileName = Operation::$SelfFileName."_".$value['name'].".php";
if(file_exists($strFileName)){
$arrOperateInfo[$i]['name'] = $value['name'];
$arrOperateInfo[$i]['viewName'] = $value['viewName'];
$i++;
}
}
}
return $arrOperateInfo;
}
public function strGetSelfFileName()
{
return Operation::$SelfFileName;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Operation.php | PHP | asf20 | 6,201 |
<?php
/* explain:
* Project:
* File: vedioUpload.php
*
* @ link http://www.../lib/
* @ Email ldmmyx@hotmail.com
* @ copyright 2007 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class UploadFiles extends Common
{
const TYPE_IMAGE = 1;
private $intLinkSign;
private $iUserID;
private $objLog;
function UploadFiles($DBTag, $usrid)
{
parent::Common();
$this->intLinkSign = $this->getConnection($DBTag);
$this->objLog = new Logs($usrid);
$this->iUserID = $usrid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getByID($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM upload_files WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/*
*
* @param string name
* @return int true: insert ID
*/
public function add($arrPopedom = array(), $type, $extName, $md5, $width, $height, $fileSize)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$id = 0;
$sql = "INSERT INTO upload_files SET createdTime = UTC_TIMESTAMP(), modifiedTime = UTC_TIMESTAMP(), type='$type', extName='$extName', md5='$md5', width = $width, height = $height, fileSize='$fileSize'";
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
if($rs){
$id = mysql_insert_id($this->intLinkSign);
return $id;
}else
return $id;
}
public function addtmp($type, $extName, $md5, $width, $height, $fileSize)
{
$id = 0;
$sql = "INSERT INTO upload_files SET createdTime = UTC_TIMESTAMP(), modifiedTime = UTC_TIMESTAMP(), type='$type', extName='$extName', md5='$md5', width = $width, height = $height, fileSize='$fileSize'";
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
if($rs){
$id = mysql_insert_id($this->intLinkSign);
return $id;
}else
return $id;
}
public function isExistedtmp($type, $md5)
{
$sql = "SELECT id, extName, width, height, fileSize FROM upload_files WHERE type = $type AND md5 = '$md5'";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs && mysql_num_rows($rs) > 0){
return mysql_fetch_array($rs);
}else
return 0;
}
/* modify
*
* @param string name
* @param return boolean
*/
public function edit($arrPopedom = array(), $id, $type, $extName, $md5, $fileSize)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "picid = $picid AND formatid='$oldformatid'");
$sql = "UPDATE upload_files SET type='$type', extName='$extName', md5='$md5', fileSize='$fileSize' WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return true;
else
return false;
}
/* delete news class
*
* @param int id
* @param string status
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id = $id ");
$sql = "DELETE FROM upload_files WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return true;
else
return false;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function isExisted($arrPopedom = array(), $type, $md5)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT id FROM upload_files WHERE type = $type AND md5 = '$md5'";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs && mysql_num_rows($rs) > 0){
$row = mysql_fetch_array($rs);
return $row['id'];
}else
return 0;
}
/* list
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $where, $page, $discount, $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = 'SELECT count(*) FROM upload_files'.$where;
$rs = mysql_query($sql, $this->intLinkSign);
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = 'SELECT * FROM upload_files'.$where;
else{
$sql = 'SELECT * FROM upload_files'.$where." LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/UploadFiles.php | PHP | asf20 | 5,141 |
<?php
/* explain:
* Project:
* File: Job.php
*
* @ link http://www.../lib/
* @ Email ldmmyx@hotmail.com
* @ copyright 2007 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class TaxRates extends Common
{
public $conHandle;
public $errorInfo;
private $iUserID;
private $objLog;
function TaxRates($DBTag, $userid)
{
parent::Common();
$this->conHandle = $this->getConnection($DBTag);
$this->objLog = new Logs($userid);
$this->iUserID = $userid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getTaxRate($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM tax_rates WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getTaxRateByClassID($arrPopedom = array(), $classid, $zoneID)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM tax_rates WHERE classid = $classid AND zoneID = $zoneID";
echo $sql;
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/*
*
* @param string strOrders
* @param string name
* @param string namecn
* @return boolean true or fail
*
*/
public function add($arrPopedom = array(), $zoneID, $classID, $rate, $priority, $summary)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO tax_rates SET createdTime = UTC_TIMESTAMP(), modifiedTime = UTC_TIMESTAMP(), rate = '$rate', priority = '$priority', zoneID = '$zoneID', classID = '$classID', summary='" . addslashes($summary) . "'";
$rs = mysql_query($sql, $this->conHandle) or die(mysql_error());
return $rs ? true: false;
}
/* modify menu
*
* @param string id modify menu id
* @param string strOrders
* @param string name
* @param string summary
* @return boolean true or fail
*/
public function edit($arrPopedom = array(), $id, $zoneID, $classID, $rate, $priority, $summary)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "id=$id");
$sql = "UPDATE tax_rates SET summary='" . addslashes($summary) . "', zoneID = '$zoneID', classID = '$classID', rate = '$rate', priority = '$priority' WHERE id=$id";
$rs = mysql_query($sql, $this->conHandle) or die ($sql . mysql_error($this->conHandle));
return $rs ? true: false;
}
/* delete menu
*
* @param int id
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "DELETE FROM tax_rates WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return true;
else
return false;
}
/* list menu
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $condition, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = "SELECT count(id) FROM tax_rates$condition";
$rs = mysql_query($sql, $this->conHandle);
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = "SELECT * FROM tax_rates$condition";
else{
$sql = "SELECT * FROM tax_rates$condition LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
/* list all custom condition data
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listCustom($arrPopedom = array(), $condition='')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrBack = array();
$sql = "SELECT * FROM tax_rates$condition";
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/TaxRates.php | PHP | asf20 | 5,017 |
<?php
/*
* Created on Dec 1, 2010
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
include_once ("AddressBookDao.php"); //-- for payment
class OrdersDao
{
private $id;
private $languageID;
private $currency;
private $currency_value;
private $amount;
private $createdTime;
private $modifiedTime;
private $status;
private $paymentMethod;
private $cc_type;
private $cc_owner;
private $cc_number;
private $cc_expires;
private $comments;
public function OrdersDao()
{
}
public function setID($id)
{
$this->id = $id;
}
public function getID()
{
return $this->id;
}
public function setCCType($cc_type)
{
$this->cc_type = $cc_type;
}
public function getCCType()
{
return $this->cc_type;
}
public function setCCOwner($cc_owner)
{
$this->cc_owner = $cc_owner;
}
public function getCCOwner()
{
return $this->cc_owner;
}
public function setCCNumber($cc_number)
{
$this->cc_number = $cc_number;
}
public function getCCNumber()
{
return $this->cc_number;
}
public function setCCExpire($cc_expires)
{
$this->cc_expires = $cc_expires;
}
public function getCCExpire()
{
return $this->cc_expires;
}
public function setPaymentMethod($paymentMethod)
{
$this->paymentMethod = $paymentMethod;
}
public function getPaymentMethod()
{
return $this->paymentMethod;
}
public function setLanguageID($languageID)
{
$this->languageID = $languageID;
}
public function getLanguageID()
{
return $this->languageID;
}
public function setCurrency($currency)
{
$this->currency = $currency;
}
public function getCurrency()
{
return $this->currency;
}
public function setCurrencyValue($currency_value)
{
$this->currency_value = $currency_value;
}
public function getCurrencyValue()
{
return $this->currency_value;
}
public function setAmount($amount)
{
$this->amount = $amount;
}
public function getAmount()
{
return $this->amount;
}
public function setStatus($status)
{
$this->status = $status;
}
public function getStatus()
{
return $this->status;
}
public function setComments($comments)
{
$this->comments = $comments;
}
public function getComments()
{
return $this->comments;
}
public function getArray($customers, $customerAddress, $deliveryAddress, $billingAddress)
{
$data_array = array();
if(is_object($customers)){
$data_array['customers_id'] = $customers->getID();
$data_array['customers_name'] = $customers->getFirstName() . ' ' . $customers->getLastName();
$data_array['customers_street'] = $customerAddress->getStreet();
$data_array['customers_city'] = $customerAddress->getCity();
$data_array['customers_postcode'] = $customerAddress->getZipcode();
$data_array['customers_state'] = $customerAddress->getState();
$data_array['customers_country'] = $customerAddress->getCountry();
$data_array['customers_telephone'] = $customers->getTelephone();
$data_array['customers_email'] = $customers->getEmail();
}
if(is_object($deliveryAddress)){
$data_array['delivery_name'] = $deliveryAddress->getFirstName() . ' ' . $deliveryAddress->getLastName();
$data_array['delivery_street'] = $deliveryAddress->getStreet();
$data_array['delivery_city'] = $deliveryAddress->getCity();
$data_array['delivery_postcode'] = $deliveryAddress->getZipcode();
$data_array['delivery_state'] = $deliveryAddress->getState();
$data_array['delivery_country'] = $deliveryAddress->getCountry();
$data_array['delivery_suburb'] = $deliveryAddress->getSuburb();
}
if(is_object($billingAddress)){
$data_array['billing_name'] = $billingAddress->getFirstName() . ' ' . $billingAddress->getLastName();
$data_array['billing_street'] = $billingAddress->getStreet();
$data_array['billing_city'] = $billingAddress->getCity();
$data_array['billing_postcode'] = $billingAddress->getZipcode();
$data_array['billing_state'] = $billingAddress->getState();
$data_array['billing_country'] = $billingAddress->getCountry();
$data_array['billing_suburb'] = $billingAddress->getSuburb();
}
$data_array['languageID'] = $this->getLanguageID();
$data_array['currency'] = $this->currency;
$data_array['amount'] = $this->amount;
$data_array['status'] = $this->status;
$data_array['payment_method'] = $this->paymentMethod;
$data_array['cc_type'] = $this->cc_type;
$data_array['cc_owner'] = $this->cc_owner;
$data_array['cc_number'] = $this->cc_number;
$data_array['cc_expires'] = $this->cc_expires;
$data_array['comments'] = $this->comments;
$data_array['createdTime'] = 'UTC_TIMESTAMP()';
$data_array['modifiedTime'] = 'UTC_TIMESTAMP()';
return $data_array;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/OrdersDao.php | PHP | asf20 | 5,605 |
<?php
/* explain: news system
* Project:
* File: news.php
*
* @ link http://www.../modules/
* @ Email ldmmyx@hotmail.com
* @ copyright 2005 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class Orders extends Common
{
public $intLinkSign;
public $errorInfo;
private $iUserID;
private $objLog;
function Orders($DBTag, $userid)
{
parent::Common();
$this->intLinkSign = $this->getConnection($DBTag);
$this->objLog = new Logs($userid);
$this->iUserID = $userid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getByID($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM orders WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/*
*
* @param string userid
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @return int true: insert ID
*/
public function add($arrPopedom = array(), $languageid, $name, $URL)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO orders SET name='$name', languageID = $languageid, URL = '$URL'";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
if($rs)
return true;
else
return false;
}
/*
*
* @param string userid
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @return int true: insert ID
*/
public function addStatus($arrPopedom = array(), $ordersID, $status, $notified, $comments)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$comments = addslashes($comments);
$sql = "INSERT INTO orders_status_history SET createdTime = UTC_TIMESTAMP(), ordersID='$ordersID', status = '$status', notified = '$notified', comments = '$comments'";
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
if($rs)
return true;
else
return false;
}
/* edit
*
* @param string userid news class name
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @param return boolean
*/
public function edit($arrPopedom = array(), $id, $gender, $firstname, $lastname, $email, $address_id, $telephone, $fax, $newsletter, $password)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$password = md5($password);
$sql = "UPDATE orders SET gender='$gender', firstname = '$firstname', lastname = '$lastname', email = '$email', default_address_id = '$address_id', " .
"telephone = '$telephone', fax='$fax', newsletter='$newsletter', password='$password' WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
if($rs)
return true;
else
return false;
}
/* delete news class
*
* @param int id
* @param string status
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "DELETE FROM orders WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error());
if($rs)
return true;
else
return false;
}
/* list
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $where, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = "SELECT count(*) FROM orders$where";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = "SELECT * FROM orders$where";
else{
$sql = "SELECT * FROM orders$where LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
public function IsExistName($firstname)
{
$sql = "SELECT id FROM orders WHERE firstname = '$firstname'";
$rs = mysql_query($sql, $this->intLinkSign) or die ("error: " . mysql_error());
if(mysql_num_rows($rs) > 0)
return true;
else
return false;
}
public function IsExistEmail($email)
{
$sql = "SELECT id FROM orders WHERE email = '$email'";
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
if(mysql_num_rows($rs) > 0)
return true;
else
return false;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Orders.php | PHP | asf20 | 5,921 |
<?php
class Words
{
function __construct()
{
}
/*
* 在MySQL4中,是已经开始支持全文检索(索引)的了。但是只是对英文支持全文检索。
由于英文在书写上的特殊性,使得分词算法相对中文来说,简单得多。一般来说,我们可以通过单词与单词之间的空格,以及标点符号来完成这个分词过程。
但是就中文来说,就没有那么简单。MySQL无法对中文做出正确的分词,假设有如下英文句子:
"Hello world! Hello PHP!"
通过上面提及的方法,可以很简单的把这个句子分词为:
1 Hello
2 world
3 PHP
我们再来看看中文的句子:
"你好世界,你好PHP!"
按照英文的算法,分词如下:
1 你好世界
2 你好PHP
显然是不能满足我们的需要的。
所以,首先我们要做的是,把中文的句子转变为MySQL眼中的英文,以便使得它能以英文分词算法去对句子进行正确的分词处理。
先将上面中文句子进行标点过滤处理,得到以下句子:
你好世界 你好PHP
接着再使用中文分词中较简单实现的二元分词算法对句子进行二元分词,得到以下句子:
你好 好世 世界 你好 PHP
因为把标点符号替换为空格,以及PHP本身为英文字母的关系,可以不用进行二元切分,所以得到上面句子。
这个时候,我们来看看处理过后的句子,会发现,就其书写格式上来说,已经符合英文的书写格式,既以空格,标点来对单词形成自然间隔。只是上面句子没有标点,只有空格而已。
到此,我们已经成功的将中文“翻译”为MySQL能理解的“英文”书写格式。
但是,问题还没解决,首先,MySQL中,ft_min_word_len(分词词汇最小长度)这个参数的默认值为4,也就是4个字母以上长度的单词,才会被考虑,小于4个的,将会被忽略。
如果不改变这个长度,按照上面的分词结果,我们将无法通过 你好,世界,PHP等检索到相关的结果,因为分出来的词太短了,不在MySQL的选择范围内。
我们可以通过修改ft_min_word_len的值,将其设置为2来解决上面问题,但是这样做的话,在检索列表中的原本就为英文的短小词汇,如:PHP,MP3,也会被划入检索范围内,这样做的结果是,出现很多无意义的相关结果。
请看以下列表:
[MP3] the look
[MP3] because of you
因为他们都同有MP3在标题中,所以会出现上述提到的问题。
回到ft_min_word_len值的问题,我们之所以要修改他,是为了能让MySQL找到我们的二元分词,但是短小的英文又被“无辜”的卷入,我们目前要解决的问题就是,如何使得MySQL能检索到二个字的中文词汇,又能忽略掉原本的英数?第一个反应是把中文MD5,这样以上分词就将转化为以下结果:
你好 好世 世界 你好 PHP => b94ae3c6d892b29cf48d9bea819b27b9 f5625345be46432fb0fd51340fcf6679 9067de5206278a93823f9c5dc2c737fd b94ae3c6d892b29cf48d9bea819b27b9 PHP
这样做,首先是使得中文分词的长度超越了默认的2个字,同时消除了中文的歧义性。(MySQL4对中文的处理有问题),搜索“车轮”时候,不再会出现类似“发动机”结果的问题。(车轮的例子只是为了方便理解而做出的假设)
通过上面的做法,已经解决了分词最小长度的问题,顺利的把中文词汇长度升级,从而达到把中文词汇划入检索范围,把较短的英数划出检索范围。
休息一下,然后发现这个MD5后的字符串是否太长了点……比较占用空间,要不,于是想到区位码,4位数的区位码能表示一个GB汉字,一个词有二个汉字组成,转换为区位码后是8个数字。不但能确定惟一性,也就MD5而已减少了长度。下面是转换后的:
你好 好世 世界 你好 PHP => b94ae3c6d892b29cf48d9bea819b27b9 f5625345be46432fb0fd51340fcf6679 9067de5206278a93823f9c5dc2c737fd b94ae3c6d892b29cf48d9bea819b27b9 PHP => 36672635 26354232 42322971 36672635 PHP
呵呵,是不是比MD5的小了很多呢?最后我们把相同的词汇留一个,多余的删除。得到
36672635 26354232 42322971 PHP
于是就完成了 "你好世界,你好PHP!" 到 "36672635 26354232 42322971 PHP" 的转换。
通过上面方法结合MySQL全文检索语句,我们可以通过给出一个标题例如:"迈克尔·杰克逊 -《危险之旅之布加勒斯特站》"找出类似以下的相关标题
迈克尔杰克逊 -《迈克尔杰克逊危险布加勒斯特演唱会》
Michael Jackson -《迈克尔杰克逊 罗马尼亚 危险演唱会》
迈克尔杰克Michael Jackson -《危险之旅》
迈克尔杰克逊 -《迈克尔杰克逊 美国50annive演唱会危险片段》
迈克尔杰克逊 -《迈克尔杰克逊 终极收藏 原版DVD危险演唱会》
迈克尔杰克逊 杰克逊五兄弟 -《The Jackson Motown 25 演唱会》
迈克尔杰克逊 -《迈克尔杰克逊BAD曰本Yokohama演唱会》
迈克尔杰克逊 -《迈克尔杰克逊曰本大阪演唱会》
迈克尔杰克逊 -《迈克尔杰克逊之胜利-达拉丝演唱会》
迈克尔杰克逊 -《迈克尔杰克逊之胜利演唱会 比丽珍 片段》
迈克尔杰克逊 -《迈克尔杰克逊德国危险演唱会之 billie jean片段》
迈克尔杰克逊 -《Michael Jackson -30周年演唱会》
Michael Jackson -《迈克尔杰克逊 马尼拉 历史演唱会》
迈克尔杰克逊 -《1993年美国橄榄球中场休息精彩表演》
表结构 article
title varchar 200 -------- 用于存放标题 (显示用)
ft text ---- fulltext 用于存放标题分词结果 (检索用)
首先我们在把标题保存到数据库时候,就已经对标题进行分词转区位码,保存到ft字段中,用于相关性的检索。
然后把给出的标题"迈克尔·杰克逊 -《危险之旅之布加勒斯特站》"转为"34853143 31432291 22910104 01042960 29603143 31434923 46034753 47535414 54143435 34355414 54141828 18282851 28513253 32534325 43254456 44565330",最后进行全文检索查询:
SELECT title, MATCH( ft ) AGAINST( '34853143 31432291 22910104 01042960 29603143 31434923 46034753 47535414 54143435 34355414 54141828 18282851 28513253 32534325 43254456 44565330' IN BOOLEAN MODE ) AS score
FROM article
WHERE MATCH( ft ) AGAINST( '34853143 31432291 22910104 01042960 29603143 31434923 46034753 47535414 54143435 34355414 54141828 18282851 28513253 32534325 43254456 44565330' IN BOOLEAN MODE )
ORDER BY score DESC
LIMIT 0, 5
从SQL Query上来看,进行了两次全文检索,其实不然,MySQL会将其视为一次,所以不比担心。
同时使用了AS score,这个score是相似度,分值越高,自然越与给出的标题相近。
二点建议:
1.在实际使用中,挑选score大于1的作为检索结果。
2.检索结果会将本身标题也算入其中,根据score排序,为第一条,别忘记过滤哦 ^_^。
站在用户的立场来说,我们给用户提供了更多的相关内容,站在搜索引擎立场上来说,给关键字提供了更多的相关链接,形成了良好的站内互联结构,提高了搜索引擎对网页的评价。
如果各位碰到错误的不合理的地方,恳请指正,共同进步。谢谢!
*
* 1.Monkey的二元分词
首先,我们来想想MySQL不支持中文索引的关键原因还是中文是双字节的,如果能把中文转换成单字节的字母或数字,那不就可以使用全文索引了吗
基于这个目的,我们首先需要做的就是分词,如果要实现比较完美的分词的话,还是需要安装相应的插件,但我们很多是虚拟主机,根本没有条件来安装,所以只能采取比较原始的分词方法,二元分词法。
所谓二元分词法,就是将一句话从头到尾,两个字两个字地分开,比如:我们的祖国是花园。就可以划分为:我们,们的,的祖,祖国,国是,是花,花园。虽然有点浪费,但至少面面俱到了。
PHP的相应函数
//Monkey's 二元分词
function sp_str($str) {
//所有汉字后添加ASCII的0字符,此法是为了排除特殊中文拆分错误的问题
$str=preg_replace("/[\x80-\xff]{2}/","\\0".chr(0x00),$str);
//拆分的分割符
$search = array(",", "/", "\\", ".", ";", ":", "\"", "!", "~", "`", "^", "(", ")", "?", "-", "\t", "\n", "'", "<", ">", "\r", "\r\n", "$", "&", "%", "#", "@", "+", "=", "{", "}", "[", "]", ":", ")", "(", ".", "。", ",", "!", ";", "“", "”", "‘", "’", "[", "]", "、", "—", " ", "《", "》", "-", "…", "【", "】",);
//替换所有的分割符为空格
$str = str_replace($search,' ',$str);
//用正则匹配半角单个字符或者全角单个字符,存入数组$ar
preg_match_all("/[\x80-\xff]?./",$str,$ar);$ar=$ar[0];
//去掉$ar中ASCII为0字符的项目
for ($i=0;$i<count($ar);$i++) if ($ar[$i]!=chr(0x00)) $ar_new[]=$ar[$i];
$ar=$ar_new;unset($ar_new);$oldsw=0;
//把连续的半角存成一个数组下标,或者全角的每2个字符存成一个数组的下标
for ($ar_str='',$i=0;$i<count($ar);$i++) {
$sw=strlen($ar[$i]);
if ($i>0 and $sw!=$oldsw) $ar_str.=" ";
if ($sw==1) $ar_str.=$ar[$i];
else
if (strlen($ar[$i+1])==2) $ar_str.=$ar[$i].$ar[$i+1].' ';
elseif ($oldsw==1 or $oldsw==0) $ar_str.=$ar[$i];
$oldsw=$sw;
}
//去掉连续的空格
$ar_str=trim(preg_replace("# {1,}#i"," ",$ar_str));//$ar_str = "Monkey s 二元 元分 分词"
//返回拆分后的结果
return explode(' ',$ar_str);
}
接下来,就该考虑如何把分好的词转换成单字节的,可以使用base64,sha1,md5。但有个问题就是转换后的字符有点长,那如何才能缩短字符呢,对了,就是使用区位码,因为区位码短啊,一个中文只占四个字节。
每个中文都有对应的区位码(除了标点符号和特殊符号),这样只要将上面分词的结果通过区位码转换后,然后存储到数据库里,就可以了。
PHP区位码函数
function quweima($str){
if(preg_match("/^[a-z0-9 ]+$/i",$str)){
return $str;
}else{
$str1 = substr($str,0,2);
//echo $str1;
$str_qwm = sprintf("%02d%02d",ord($str[0])-160,ord($str[1])-160);
$str2 = substr($str,2,4);
//echo $str2;
$str_qwm .= sprintf("%02d%02d",ord($str[0])-160,ord($str[1])-160);
return $str_qwm;
}
}
这里我加了判断,如果是英文或数字直接返回不做处理
经过这两步处理后,准备工作就基本完成了,下面就是建立数据库
我的数据库结构是这样的
id,title,title_ft(fulltext)
添加数据的时候,title存放标题,ft_title存放处理后的标题,内容应该是像这样的:43557401 54903471 …
SQL代码
$query = "SELECT title, MATCH( title_ft ) AGAINST( '$title_ft' IN BOOLEAN MODE ) AS score
FROM info
WHERE MATCH( title_ft ) AGAINST( '$title_ft' IN BOOLEAN MODE )
ORDER BY score DESC ";
其中 $title_ft是经过两个函数处理后的字符串,用它去匹配title_ft。
[解决]monkey的二元分词,分utf编码的中文时出现乱码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>momoca test</title>
</head>
<body>
<?php
function dualDecom($str)
{
//所有汉字后添加ASCII的0字符,此法是为了排除特殊中文拆分错误的问题
$str = preg_replace("/[\x80-\xff]{3}/","\\0".chr(0x00),$str);
//拆分的分割符
$search = array(",", "/", "\\", ".", ";", ":", "\"", "!", "~", "`", "^", "(", ")", "?", "-", "\t", "\n", "'", "<", ">", "\r", "\r\n", "$", "&", "%", "#", "@", "+", "=", "{", "}", "[", "]", ":", ")", "(", ".", "。", ",", "!", ";", "“", "”", "‘", "’", "[", "]", "、", "—", " ", "《", "》", "-", "…", "【", "】",);
//替换所有的分割符为空格
$str = str_replace($search,' ',$str);
//用正则匹配半角单个字符或者全角单个字符,存入数组$ar
preg_match_all("/[\x80-\xff]+?\\x00/",$str,$ar);
$ar = $ar[0];
//去掉$ar中ASCII为0字符的项目
for ( $i = 0; $i < count($ar); $i++ )
if ($ar[$i] != chr(0x00)) $ar_new[]=$ar[$i];
$ar = $ar_new;
unset($ar_new);
$oldsw = 0;
//把连续的半角存成一个数组下标,或者全角的每2个字符存成一个数组的下标
for ( $ar_str = '', $i = 0; $i < count($ar); $i++)
{
$sw=strlen($ar[$i]);
if ( $i > 0 and $sw != $oldsw) $ar_str.=" ";
if ( $sw == 1 )
$ar_str.= $ar[$i];
else
if ( strlen($ar[$i+1]) >= 2 )
$ar_str.= $ar[$i].$ar[$i+1].' ';
elseif ( $oldsw == 1 OR $oldsw == 0 )
$ar_str.= $ar[$i];
$oldsw=$sw;
}
//去掉连续的空格
$ar_str = trim(preg_replace("# {1,}#i"," ",$ar_str));
return explode(' ',$ar_str);
}
print_r(dualDecom('比如有一个字符串是“你好PHP!”就只能分出“你好”一个词 '));
?>
</body>
</html>
2.PHP里如何实现汉字转区位码
<?php
global $PHP_SELF;
//echo $PHP_SELF;
$t1=$_POST['textfield1'];
$t2=$_POST['textfield2'];
$t3=$_POST['textfield3'];
$t4=$_POST['textfield4'];
// 汉字--区位码
if($t1!=""){
$t2= sprintf("%02d%02d",ord($t1[0])-160,ord($t1[1])-160);
//echo $t2;
}
// 区位码--汉字
if($t3!=""){
$t4 = chr(substr($t3,0,2)+160).chr(substr($t3,2,2)+160);
//echo $t4;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
.STYLE1 {font-size: 18px}
-->
</style>
</head>
<body>
<table width="528" height="146" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="524" height="50"><div align="center" class="STYLE1">汉字区位码查询系统</div></td>
</tr>
<tr>
<td><form id="form1" name="form1" method="post" action="<?=$PHP_SELF ?>">
<label>输入汉字
<input name="textfield1" type="text" value="<?=$t1?>" />
</label>
<label>
<input type="submit" name="Submit" value=" 转 换 " />
</label>
<label>
<input name="textfield2" type="text" value="<?=$t2?>" />
</label>
</form>
<br />
<form id="form2" name="form2" method="post" action="<?=$PHP_SELF ?>">
<label>输入区位码
<input name="textfield3" type="text" value="<?=$t3?>" />
</label>
<input type="submit" name="Submit2" value=" 转 换 " />
<input name="textfield4" type="text" value="<?=$t4?>" />
</form>
</td>
</tr>
</table>
</body>
</html>
3.对dvbbs.php全文搜索的完全分析
这次给大家渗透些比较高级些的.关于搜索的东西.
首先,大家先去下载一份dvbbs.php beta1的代码.解压放在手头上
已经有的同学们就可以继续往下看了.
首先抛开php代码.
找出你的mysql手册.(没有?那直接看下面的吧.)
mysql全文搜索,sql的写法:
MATCH (col1,col2,…) AGAINST (expr [IN BOOLEAN MODE | WITH QUERY EXPANSION])
比如:
SELECT * FROM articles WHERE MATCH (title,body) AGAINST (’database’);
MATCH()函数对于一个字符串执行资料库内的自然语言搜索。一个资料库就是1套1个或2个包含在FULLTEXT内的列。搜索字符串作为对 AGAINST()的参数而被给定。对于表中的每一行, MATCH() 返回一个相关值,即, 搜索字符串和 MATCH()表中指定列中该行文字之间的一个相似性度量。
下面的例子则更加复杂。询问返回相关值,同时对行按照相关性渐弱的顺序进行排序。为实现这个结果,你应该两次指定 MATCH(): 一次在 SELECT 列表中而另一次在 WHERE子句中。这不会引起额外的内务操作,原因是MySQL 优化程序注意到两个MATCH()调用是相同的,从而只会激活一次全文搜索代码。
mysql> SELECT id, body, MATCH (title,body) AGAINST
-> (’Security implications of running MySQL as root’) AS score
-> FROM articles WHERE MATCH (title,body) AGAINST
-> (’Security implications of running MySQL as root’);
所以,到这里你应该会mysql 英文全文搜索了.
===
请注意一个问题.
一些词在全文搜索中会被忽略:
* 任何过于短的词都会被忽略。 全文搜索所能找到的词的默认最小长度为 4个字符。
* 停止字中的词会被忽略。
===
mysql还自带查询扩展功能.这里不做过多讨论.
===
下面进行php中文全文搜索的分析.
曾经有一个版本的mysql支持中文全文搜索(海量 mysql chinese+,说是GPL但是最终没有开源)
中文全文搜索的关键是在分词上.mysql本身不支持cjk的分词(cjk:chinese,japanese,korean),
所以
!!!!****如何用php模拟分词是mysql全文索引的关键****!!!!
中文分词是语言分词中最困难的.现在也没有人能够彻底完美的解决(虽然这些搜索引擎做的都还不错.)
//fcicq:下面给大家看看这里php的分词是怎么做的.
function &DV_ChineseWordSegment($str,$encodingName=’gbk’){
static $objEnc = null;
if( $objEnc === null ){
if( !class_exists(’DV_Encoding’) ){
require_once ROOT_PATH.’inc/DV_Encoding.class.php’;
}
$objEnc =& DV_Encoding::GetEncoding($encodingName);
}
$strLen = $objEnc->StrLength($str);
$returnVal = array();
if( $strLen < = 1 ){
return $str;
}
$arrStopWords =& DV_GetStopWordList();
//print_r($arrStopWords);
//过滤所有HTML标签
$str = preg_replace('#<[a-zA-Z]+?.*?>|#is’, ”, $str);
//过滤所有stopword
$str = str_replace($arrStopWords[’StrRepl’],’ ‘,$str);
$str = preg_replace($arrStopWords[’PregRepl’],’ ‘,$str);
//echo “$str:{$str}
“;
$arr = explode(’ ‘,$str);
//fcicq:好了,这下面的才是php分词关键 *******************************************
foreach( $arr as $tmpStr ){
if ( preg_match(”/^[x00-x7f]+$/i”,$tmpStr) === 1 ) { //fcicq:全是E文,没关系,mysql可以认识的
$returnVal[] = ‘ ‘.$tmpStr;
} else{ //fcicq:中英混合…
preg_match_all(”/([a-zA-Z]+)/i”, $tmpStr, $matches);
if( !empty($matches) ){ //fcicq:英语部分
foreach( $matches[0] as $matche ){
$returnVal[] = $matche;
}
}
//过滤ASCII字符
$tmpStr = preg_replace(”/([x00-x7f]+)/i”, ”, $tmpStr); //fcicq:你看,剩下的不就全是中文了?
$strLen = $objEnc->StrLength($tmpStr)-1;
for( $i = 0 ; $i < $strLen ; $i++ ){
$returnVal[] = $objEnc->SubString($tmpStr,$i,2); //fcicq:注意这里的substr,不是手册上的.
//fcicq:你仔细看,所有的词都是分成两个.
//比如”数据库的应用”,会被分成数据 据库 库的 的应 应用…
//全文搜索: 全文 文搜 搜索
//这分词自然是不怎么样的
//但是,搜索的时候同样这么做.
//比如搜索数据库,就相当于搜索了数据 据库.
//这是一种相当传统的全文搜索分词方法.
}
}
}
return $returnVal;
}//end function DV_ChineseWordSegment
//fcicq:这就是传说中的substr.偶相信许多人写出来的php代码都比这个好.
function &SubString(&$str,$start,$length=null){
if( !is_numeric($start) ){
return false;
}
$strLen = strlen($str);
if( $strLen < = 0 ){
return false;
}
if( $start < 0 || $length < 0 ){
$mbStrLen = $this->StrLength($str);
} else{
$mbStrLen = $strLen;
}
if( !is_numeric($length) ){
$length = $mbStrLen;
} elseif( $length < 0 ){
$length = $mbStrLen + $length - 1;
}
if( $start < 0 ){
$start = $mbStrLen + $start;
}
$returnVal = '';
$mbStart = 0;
$mbCount = 0;
for( $i = 0 ; $i < $strLen ; $i++ ){
if( $mbCount >= $length ){
break;
}
$currOrd = ord($str{$i});
if( $mbStart >= $start ){
$returnVal .= $str{$i};
if( $currOrd > 0×7f ){
$returnVal .= $str{$i+1}.$str{$i+2};
$i += 2;
}
$mbCount++;
} elseif( $currOrd > 0×7f ){
$i += 2;
}
$mbStart++;
}
return $returnVal;
}//end function SubString
//插入全文搜索分词表.一共两个,一个 topic_ft,一个bbs_ft
$arrTopicIndex =& DV_ChineseWordSegment($topic);
if( !empty($arrTopicIndex) && is_array($arrTopicIndex) ){
$topicindex = $db->escape_string(implode(’ ‘,$arrTopicIndex));
if( $topicindex !== ” ){
$db->query(”UPD ATE {$dv}topic_ft SET topicindex=’{$topicindex}’ WHERE topicid=’{$RootID}’”);
} else{
$db->query(”DEL ETE FROM {$dv}topic_ft WHERE topicid=’{$RootID}’”);
}
}
}
明白了吧?这就是所谓的mysql全文搜索分词
mysql不会分词,而php会.就这么简单.
这虽然是一种比较过时的方法,但被dv这么一炒作就成了香饽饽.
很好理解的.
之后,mysql把这些全文搜索分词的结果
implode(’ ‘,$arrTopicIndex)
再分词(呵呵,数据,据库…),把这些词生硬的记住了.
下面回到mysql上来,下面是php+mysql实现的全文搜索查询.
$arrFTKeyWord =& DV_ChineseWordSegment($keyword);
//$ftKeyWords = implode(’ ‘,$arrFTKeyWord);
$ftKeyWords = ”.implode(’ ‘,$arrFTKeyWord);
//fcicq:中间省略了很多….
$stmt = “SELECT {$SQL_CACHE} \/*SQL_CALC_FOUND_ROWS*\/ ft.topicid FROM {$dv}topic_ft AS ft WHERE MATCH(ft.topicindex) AGAINST(’{$ftKeyWords}’ IN BOOLEAN MODE) “.($boardid>0?” AND ft.boardid=’{$boardid}’”:”).” AND ft.posttable=’{$stable}’”;
//in boolean mode,能够保证每一条都查到.
$TopicIDList = ‘0′;
if( $query = $db->query($stmt,array(’absolutePage’=>$page,’pageSize’=>$pagesize,’debug’=>QUERY_DEBUG)) ){
//$Record_Count = $db->scalar(”SELECT FOUND_ROWS()”);
if( $Record_Count < = 0 ){ //没有就输出错误.
head(1,0,0,$arrNavMenu);
showmsg($lang['str_42'].$lang['str_43']);
exit;
}
while( $tmpResult =& $db->fetch_row($query) ){ //fcicq:注意注意….这里就是保存刚才的id了.这里可以优化一下
$TopicIDList .= “,{$tmpResult[0]}”;
}
}
$PCount = ceil( (float)$Record_Count / (float)$pagesize );
//fcicq:上面用php进行分页预处理,不用管它.
$__dbResults =& $db->getResultSet(”SELECT {$SQL_CACHE} t.boardid,t.topicid AS rootid,t.title AS topic,t.expression,t.postusername AS username,t.postuserid,t.dateandtime,t.isbest,t.locktopic,t.child,t.hits,t.hidename FROM {$dv}topic AS t WHERE t.topicid IN({$TopicIDList}) ORDER BY t.topicid DESC”);
//fcicq:这里就直接按主题的先后顺序(ORDER BY t.topicid DESC)进行了输出.
讲到这里大家都应该明白了吧,这就是最简单的php,mysql全文搜索分词方式.
肯定有更好的办法,具体如何做,还是要你自己去想.
*
*/
}
?> | 123gohelmetsv2 | trunk/admin/lib/Words.php | PHP | asf20 | 22,348 |
<?php
/* explain: news system
* Project:
* File: news.php
*
* @ link http://www.../modules/
* @ Email ldmmyx@hotmail.com
* @ copyright 2005 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class Merchant extends Common
{
public $intLinkSign;
public $errorInfo;
private $iUserID;
private $objLog;
function Merchant($strLanguage, $userid)
{
parent::Common();
$this->intLinkSign = $this->getConnection($strLanguage);
$this->objLog = new Logs($userid);
$this->iUserID = $userid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getFromID($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM merchant WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/*
*
* @param string userid
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @return int true: insert ID
*/
public function add($arrPopedom = array(), $name, $URL, $summary)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO merchant SET name='$name', summary='$summary', URL = '$URL'";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
if($rs)
return true;
else
return false;
}
/* edit
*
* @param string userid news class name
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @param return boolean
*/
public function edit($arrPopedom = array(), $id, $name, $summary, $URL)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$sql = "UPDATE merchant SET name='$name', summary='$summary', URL = '$URL' WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return true;
else
return false;
}
/* delete news class
*
* @param int id
* @param string status
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "DELETE FROM merchant WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error());
if($rs)
return true;
else
return false;
}
/* list
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $where, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = "SELECT count(*) FROM merchant$where";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = "SELECT * FROM merchant$where";
else{
$sql = "SELECT * FROM merchant$where LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
public function IsExistName($name)
{
$sql = "SELECT id FROM merchant WHERE name = '$name'";
$rs = mysql_query($sql, $this->intLinkSign) or die ("error: " . mysql_error());
if(mysql_num_rows($rs) > 0)
return true;
else
return false;
}
/* list by condition
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listFromCustom($arrPopedom = array(), $condition='')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrBack = array();
$sql = "SELECT * FROM merchant".$condition;
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
/* list by condition
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listSimple($arrPopedom = array())
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$arrBack = array();
$sql = "SELECT id, name FROM merchant";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[$arrCache['id']] = $arrCache['name'];
}
return $arrBack;
}else
return false;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Merchant.php | PHP | asf20 | 5,541 |
<?php
/*
* Created on Dec 2, 2010
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
class CouponDomain
{
const TYPE_PERECENT = 'Percent';
const TYPE_SAVE_OFF = 'SaveOff';
const TYPE_FREE_SHIPPING = 'FreeShipping';
private $id;
private $code;
private $scope;
private $scopeID;
private $isBinding;
private $usedLimit;
private $usedCount;
private $expireTime;
private $type;
private $offValue;
private $oCouponCustomer;
public function CouponDomain()
{
}
public function setID($id)
{
$this->id = $id;
}
public function getID()
{
return $this->id;
}
public function setCouponCustomer($oCouponCustomer)
{
$this->oCouponCustomer = $oCouponCustomer;
}
public function getCouponCustomer()
{
return $this->oCouponCustomer;
}
public function setCode($code)
{
$this->code = $code;
}
public function getCode()
{
return $this->code;
}
public function setScope($scope)
{
$this->scope = $scope;
}
public function getScope()
{
return $this->scope;
}
public function setScopeID($scopeID)
{
$this->scopeID = $scopeID;
}
public function getScopeID()
{
return $this->scopeID;
}
public function setIsBinding($isBinding)
{
$this->isBinding = $isBinding;
}
public function getIsBinding()
{
return $this->isBinding;
}
public function setUsedLimit($usedLimit)
{
$this->usedLimit = $usedLimit;
}
public function getUsedLimit()
{
return $this->usedLimit;
}
public function setUsedCount($usedCount)
{
$this->usedCount = $usedCount;
}
public function getUsedCount()
{
return $this->usedCount;
}
public function setExpireTime($expireTime)
{
$this->expireTime = $expireTime;
}
public function getExpireTime()
{
return $this->expireTime;
}
public function setType($type)
{
$this->type = $type;
}
public function getType()
{
return $this->type;
}
public function setOffValue($offValue)
{
$this->offValue = $offValue;
}
public function getOffValue()
{
return $this->offValue;
}
public function isExpire()
{
if(empty($this->expireTime) || $this->expireTime == '0000-00-00 00:00:00'){
if($this->getUsedLimit() == 0){
return false;
}else if($this->getUsedLimit() <= $this->getUsedCount()){
return true;
}else{
return false;
}
}else{
$result = strtotime(date("Y-m-d H:i:s")) - strtotime($this->getExpireTime());
if($result < 0){
if($this->getUsedLimit() == 0){
return false;
}else if($this->getUsedLimit() <= $this->getUsedCount()){
return true;
}else{
return false;
}
}else{
return true;
}
}
}
public function isPercent()
{
if($this->type == CouponDomain::TYPE_PERECENT){
return true;
}else
return false;
}
public function isSaveOff()
{
if($this->type == CouponDomain::TYPE_SAVE_OFF){
return true;
}else
return false;
}
public function isFreeShipping()
{
if($this->type == CouponDomain::TYPE_FREE_SHIPPING){
return true;
}else
return false;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/CouponDomain.php | PHP | asf20 | 3,312 |
<?php
/* explain: news system
* Project:
* File: news.php
*
* @ link http://www.../modules/
* @ Email ldmmyx@hotmail.com
* @ copyright 2005 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class ShippingFee extends Common
{
public $intLinkSign;
public $errorInfo;
private $iUserID;
private $objLog;
function ShippingFee($DBTag, $userid)
{
parent::Common();
$this->intLinkSign = $this->getConnection($DBTag);
$this->objLog = new Logs($userid);
$this->iUserID = $userid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getByID($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM shipping_fee WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/*
*
* @param string userid
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @return int true: insert ID
*/
public function add($arrPopedom = array(), $zoneid, $shippingMethodID, $shippingTypeID, $amount, $amount2, $summary, $status)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO shipping_fee SET createdTime = UTC_TIMESTAMP(), modifiedTime = UTC_TIMESTAMP(), zoneID='$zoneid', shippingMethodID = $shippingMethodID, shippingTypeID = '$shippingTypeID', amount = '$amount', amount2 = '$amount2', summary = '$summary', status = '$status'";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
if($rs)
return true;
else
return false;
}
/* edit
*
* @param string userid news class name
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @param return boolean
*/
public function edit($arrPopedom = array(), $id, $zoneid, $shippingMethodID, $shippingTypeID, $amount, $amount2, $summary)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$password = md5($password);
$sql = "UPDATE shipping_fee SET modifiedTime = UTC_TIMESTAMP(), zoneID='$zoneid', shippingMethodID = $shippingMethodID, shippingTypeID = '$shippingTypeID', amount = '$amount', amount2 = '$amount2', summary = '$summary' WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
if($rs)
return true;
else
return false;
}
/* delete news class
*
* @param int id
* @param string status
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "DELETE FROM shipping_fee WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error());
if($rs)
return true;
else
return false;
}
/* list
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $where, $order, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = "SELECT count(*) FROM shipping_fee$where";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = "SELECT * FROM shipping_fee$where $order";
else{
$sql = "SELECT * FROM shipping_fee$where $order LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
public function IsExistName($firstname)
{
$sql = "SELECT id FROM shipping_fee WHERE firstname = '$firstname'";
$rs = mysql_query($sql, $this->intLinkSign) or die ("error: " . mysql_error());
if(mysql_num_rows($rs) > 0)
return true;
else
return false;
}
/* edit user status
*
* @ param int userid
* @ param string status
* @ param return boolean
*/
public function setStatus($arrPopedom, $id, $status)
{
if($this->isUnallowable($arrPopedom, Popedom::STRING_EDIT))
die ($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "status=$status, id=$id");
$sql = "UPDATE shipping_fee SET status='$status' WHERE id=$id";
$rs = mysql_query($sql,$this->intLinkSign);
if(mysql_affected_rows() > 0)
return true;
else
return false;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/ShippingFee.php | PHP | asf20 | 5,560 |
<?php
/* comments-->xml operation
*
* @link http://....
* @copyright 2005 ling de ming
* @author ivan <ldmmyx@hotmail.com>
* @version 1.0
*
* function --> comment(x.y: --->x same module,y is a funtion in same module)
*
* 1.1 funCreateXml($filename,$root,$code='gb2312') //---> create XML file
* 2.1 funAddElement($name,$attribute,$value,$location='') //---> add element
*/
define("ENTER",chr(13).chr(10)); //--- enter
class Xml
{
private $data = array(); //--- save elements in XML file(element: element name, value: element value,attribute:(string include all attributs),location:,tag position,value is top that position is in top,there isn't the end tag, footer is the end tag,add the end tag undefine in the end tag
/*
*
*/
public function __construct()
{
}
/* create XML file
* @param string filename ← XML file name
* @param string root ← XML root element
* @param string code ← XML decode(default utf-8)
*/
function createXml($filename, $root, $rootAttribute, $code='utf-8')
{
$strtmp = '<?xml version="1.0" encoding="'.$code.'"?>'.ENTER; // document type
$strtmp .= "<$root$rootAttribute>".ENTER; //--- set root
foreach($this->data as $value){
switch($value['location']){
case 'start': $strtmp .= '<'.$value['name'].$value['attribute'].'>'.$value['value'].ENTER; break;
case 'end': $strtmp .= '</'.$value['name'].'>'.ENTER; break;
default : $strtmp .= '<'.$value['name'].$value['attribute'].'>'.$value['value'].'</'.$value['name'].'>'.ENTER; break;
}
}
$strtmp .= "</$root>".ENTER;
$fp = fopen( $filename , "w" );
fwrite($fp,$strtmp);
fclose($fp);
}
/* add element
* @param string name ← element name
* @param string attribute ← element attribute
* @param string value ← element value
* @param string location ← element position,default after last line to add ,begin is begin element, end is end element
* @param boolean return ← true: add success,false:add failure
*/
public function add($name, $attribute, $value, $location = '')
{
if(!empty($name)){
$this->data[] = array('name' => $name,'attribute' => $attribute,'value' => $value,'location' => $location);
return true;
}else
return false;
}
/* OUT XML file
* @param string filename ← XML file name
* @param string root ← XML root
* @param string code ← XML code(default utf-8)
* return string ← return xml file source code
*/
public function outXml($filename, $root, $rootAttribute, $code='utf-8')
{
$strtmp = '<?xml version="1.0" encoding="'.$code.'"?>'.ENTER; //--- document type
$strtmp .= "<".$root.">".ENTER; //--- set root element
foreach($this->data as $value){
switch($value['location']){
case 'begin': $strtmp .= '<'.$value['name'].$value['attribute'].'>'.$value['value'].ENTER; break;
case 'end': $strtmp .= '</'.$value['name'].'>'.ENTER; break;
default : $strtmp .= '<'.$value['name'].$value['attribute'].'>'.$value['value'].'</'.$value['name'].'>'.ENTER; break;
}
}
$strtmp .= "</".$root.">".ENTER;
return $strtmp;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Xml.php | PHP | asf20 | 3,352 |
<?php
/* explain:
* Project:
* File: Job.php
*
* @ link http://www.../lib/
* @ Email ldmmyx@hotmail.com
* @ copyright 2007 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
include_once("CouponDomain.php");
include_once("CouponCustomer.php");
class CouponImpl extends Common
{
public $conHandle;
public $errorInfo;
private $iUserID;
private $objLog;
function CouponImpl($DBTag, $userid)
{
parent::Common();
$this->conHandle = $this->getConnection($DBTag);
$this->objLog = new Logs($userid);
$this->iUserID = $userid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getByID($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM coupon WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/*
*
* @param string strOrders
* @param string name
* @param string namecn
* @return boolean true or fail
*
*/
public function add($arrPopedom = array(), $name, $summary)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO coupon SET createdTime = UTC_TIMESTAMP(), modifiedTime = UTC_TIMESTAMP(), name = '$name', summary='" . addslashes($summary) . "'";
$rs = mysql_query($sql, $this->conHandle) or die(mysql_error());
return $rs ? true: false;
}
/* modify menu
*
* @param string id modify menu id
* @param string strOrders
* @param string name
* @param string summary
* @return boolean true or fail
*/
public function edit($arrPopedom = array(), $id, $name, $summary)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "id=$id");
$sql = "UPDATE coupon SET summary='" . addslashes($summary) . "', name = '$name' WHERE id=$id";
$rs = mysql_query($sql, $this->conHandle) or die ($sql . mysql_error($this->conHandle));
return $rs ? true: false;
}
/* delete menu
*
* @param int id
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "DELETE FROM coupon WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return true;
else
return false;
}
/* list menu
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $condition, $page = 1, $discount = 20, $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = "SELECT count(id) FROM coupon$condition";
$rs = mysql_query($sql, $this->conHandle);
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = "SELECT * FROM coupon$condition";
else{
$sql = "SELECT * FROM coupon$condition LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
/* list all custom condition data
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listCustom($arrPopedom = array(), $condition='')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrBack = array();
$sql = "SELECT * FROM coupon$condition";
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
public function getCoupon($DBtag, $code)
{
$isreturn = false;
$conn = null;
try{
$sql = "SELECT id, scope, scopeID, type, offValue, isBinding, usedLimit, usedCount, expireTime FROM coupon WHERE code = '$code'";
$conn = $this->getConnection($DBtag);
$rs = mysql_query($sql, $conn) or die("Invalid query: " . $sql . mysql_error($conn));
if($arrData = mysql_fetch_assoc($rs)){
$coupon = new CouponDomain();
$coupon->setID($arrData['id']);
$coupon->setScope($arrData['scope']);
$coupon->setScopeID($arrData['scopeID']);
$coupon->setType($arrData['type']);
$coupon->setOffValue($arrData['offValue']);
$coupon->setIsBinding($arrData['isBinding']);
$coupon->setUsedLimit($arrData['usedLimit']);
$coupon->setUsedCount($arrData['usedCount']);
$coupon->setExpireTime($arrData['expireTime']);
$coupon->setCode($code);
if($arrData['isBinding'] == 'YES'){
$sql = "SELECT id, customerID, type, couponID FROM customer_coupon WHERE couponID = " . $arrData['id'];
$rs = mysql_query($sql, $conn) or die("Invalid query: " . $sql . mysql_error($conn));
if($arrData = mysql_fetch_row($rs)){
$couponCustomer = new CouponCustomer();
$couponCustomer->setID($arrData['id']);
$couponCustomer->setType($arrData['type']);
$couponCustomer->setCustomerID($arrData['customerID']);
$couponCustomer->setCouponID($arrData['couponID']);
$coupon->setCouponCustomer($couponCustomer);
}else
$coupon->setCouponCustomer(false);
}
return $coupon;
}
}catch(Exception $e){
echo mysql_error($conn) . $sql;
}
if($conn != null)
$this->freeConnection($DBtag, $conn);
return $isreturn;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/CouponImpl.php | PHP | asf20 | 6,191 |
<?php
/* explain:
* Project:
* File: qa.php
*
* @ link http://www.../lib/
* @ Email ldmmyx@hotmail.com
* @ copyright 2007 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class QA extends Common
{
private $intLinkSign;
private $iUserID;
private $objLog;
function QA($strLanguage, $usrid)
{
parent::Common();
$this->intLinkSign = $this->getConnection($strLanguage);
$this->objLog = new Logs($usrid);
$this->iUserID = $usrid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getFromID($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM qa WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/* �������
*
* @param string userid news class name
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @return int true: insert ID
*/
public function add($arrPopedom = array(), $user, $question, $answer, $status = "unapproved")
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO qa SET user='$user', question = '$question', answer='$answer', status='$status', addTime=now()";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error());
$intDataID = mysql_insert_id($this->intLinkSign);
if($rs)
return $intDataID;
else
return false;
}
/* modify
*
* @param string userid news class name
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @param return boolean
*/
public function edit($arrPopedom = array(), $user, $id, $question, $answer, $status)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "id=$id");
$sql = "UPDATE qa SET user='$user', question = '$question', answer='$answer', status='$status' WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return true;
else
return false;
}
/* delete news class
*
* @param int id
* @param string status
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "DELETE FROM qa WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return true;
else
return false;
}
/* list
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $where, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = 'SELECT count(id) FROM qa'.$where;
$rs = mysql_query($sql, $this->intLinkSign);
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = 'SELECT * FROM qa'.$where;
else{
$sql = 'SELECT * FROM qa'.$where." LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
/* list by condition
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listFromCustom($arrPopedom = array(), $condition='')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrBack = array();
$sql = "SELECT * FROM qa".$condition;
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/QA.php | PHP | asf20 | 4,784 |
<?php
/* explain: news system
* Project:
* File: news.php
*
* @ link http://www.../modules/
* @ Email ldmmyx@hotmail.com
* @ copyright 2005 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class Product extends Common
{
public $intLinkSign;
public $errorInfo;
private $iUserID;
private $objLog;
function Product($strLanguage, $userid)
{
parent::Common();
$this->intLinkSign = $this->getConnection($strLanguage);
$this->objLog = new Logs($userid);
$this->iUserID = $userid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getFromID($arrPopedom = array(), $id, $languageid)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM products p, products_description pd WHERE p.id = pd.productID AND pd.languageID = $languageid AND p.id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/*
*
* @param string userid
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @return int true: insert ID
*/
public function add($arrPopedom = array(), $categoryID, $price, $weight, $totalCount, $model, $manufacturerID, $taxRateID, $UPC, $URL, $languageid, $name, $description, $status = 'pause', $shippingTypeID)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$id = 0;
$weight = $weight * 100;
$price = $price * 100;
$sql = "INSERT INTO products SET createdTime = UTC_TIMESTAMP(), modifiedTime = UTC_TIMESTAMP(), price='$price', weight='$weight', status='$status'";
$sql .= ", model='$model', manufacturerID='$manufacturerID', UPC = '$UPC', r_totalCount = '$totalCount', categoryID = $categoryID, shippingTypeID = $shippingTypeID";
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
if($rs){
$id = mysql_insert_id($this->intLinkSign);
$sql = "INSERT INTO products_description SET productID = $id, taxRateID = '$taxRateID', URL = '$URL', name='" . addslashes($name) . "', description='" . addslashes($description) . "', languageID = '$languageid'";
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
if($rs){
return $id;
}else{
$sql = "DELETE FROM products WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
return $id;
}
}else
return $id;
}
/*
*
* @param string name
* @param string namecn
* @param string status normal, stop
* @return boolean true or fail
*
*/
public function addAttribute($arrPopedom = array(), $productID, $attributeID, $attributePrice, $pricePrefix = '+')
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO products_attributes SET productID = '$productID', attributeID='$attributeID', attributePrice='$attributePrice', pricePrefix='$pricePrefix'";
$rs = mysql_query($sql, $this->intLinkSign) or die($sql . mysql_error($this->intLinkSign));
if($rs){
return mysql_insert_id($this->intLinkSign);
}else
return 0;
}
public function addAttributeOption($arrPopedom = array(), $productID, $attributeID, $attributeOptionID)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO products_attributes_options SET productID = '$productID', attributeID='$attributeID', attributeOptionID='$attributeOptionID' ON DUPLICATE KEY UPDATE attributeOptionID=VALUES(attributeOptionID)";
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
$intDataID = mysql_insert_id($this->intLinkSign);
if($rs)
return $intDataID;
else
return false;
}
/*
*
* @param string name
* @param string namecn
* @param string status normal, stop
* @return boolean true or fail
*
*/
public function addImage($arrPopedom = array(), $productID, $imageID, $attributeID, $isMain = 'no')
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO product_images SET productID = '$productID', imageID='$imageID', attributeID='$attributeID', isMain = '$isMain'";
$rs = mysql_query($sql, $this->intLinkSign) or die(mysql_error($this->intLinkSign));
return $rs ? true: false;
}
public function addImagetmp($productID, $imageID)
{
$sql = "INSERT IGNORE INTO product_images SET productID = '$productID', imageID='$imageID'";
$rs = mysql_query($sql, $this->intLinkSign) or die(mysql_error($this->intLinkSign));
return $rs ? true: false;
}
public function deleteImage($arrPopedom = array(), $productID, $imageID)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "DELETE FROM product_images WHERE productID = '$productID' AND imageID='$imageID'";
$rs = mysql_query($sql, $this->intLinkSign) or die(mysql_error($this->intLinkSign));
return $rs ? true: false;
}
public function deleteRelated($arrPopedom = array(), $productID)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "DELETE FROM products_related WHERE productID = '$productID'";
$rs = mysql_query($sql, $this->intLinkSign) or die(mysql_error($this->intLinkSign));
return $rs ? true: false;
}
public function productIDsOfImage($arrPopedom = array(), $imageID)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$productIDs = '';
$sql = "SELECT productID FROM product_images WHERE imageID='$imageID'";
$rs = mysql_query($sql, $this->intLinkSign) or die(mysql_error($this->intLinkSign));
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
if(!empty($productIDs))
$productIDs .= ',';
$productIDs .= $arrtmp[0];
}
}
return $productIDs;
}
/* edit
*
* @param string userid news class name
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @param return boolean
*/
public function edit($arrPopedom = array(), $id, $categoryID, $price, $weight, $totalCount, $model, $manufacturerID, $taxRateID, $UPC, $URL, $languageid, $name, $description, $status)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$weight = $weight * 100;
$price = $price * 100;
$sql = "UPDATE products SET modifiedTime = UTC_TIMESTAMP(), price='$price', weight='$weight', status='$status', model='$model', manufacturerID='$manufacturerID', UPC = '$UPC', r_totalCount = '$totalCount', categoryID = $categoryID WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
if($rs){
$sql = "UPDATE products_description SET taxRateID = '$taxRateID', URL = '$URL', name='" . addslashes($name) . "', description='" . addslashes($description) . "', languageID = '$languageid' WHERE productID = $id";
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
if($rs){
return true;
}else{
return false;
}
}else
return false;
}
/* delete news class
*
* @param int id
* @param string status
* @param return boolean
*/
public function delete($arrPopedom = array(), $id, $languageID)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "SELECT count(*) FROM products_description WHERE productID = $id";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
list($total) = mysql_fetch_row($rs);
if($total == 1){
$sql = "DELETE FROM products WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
$sql = "DELETE FROM products_attributes WHERE productID = $id";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
}
$sql = "DELETE FROM products_description WHERE productID = $id AND languageID = $languageID";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
if($rs)
return true;
else
return false;
}
/*
*
* @param string name
* @param string namecn
* @param string status normal, stop
* @return boolean true or fail
*
*/
public function deleteAttribute($arrPopedom = array(), $productID)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "DELETE FROM products_attributes WHERE productID = '$productID'";
$rs = mysql_query($sql, $this->intLinkSign) or die(mysql_error($this->intLinkSign));
return $rs ? true: false;
}
public function deleteAttributeOption($arrPopedom = array(), $productID)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "DELETE FROM products_attributes_options WHERE productID = '$productID'";
$rs = mysql_query($sql, $this->intLinkSign) or die(mysql_error($this->intLinkSign));
return $rs ? true: false;
}
/* edit user status
*
* @ param int userid
* @ param string status
* @ param return boolean
*/
public function setStatus($arrPopedom, $id, $status)
{
if($this->isUnallowable($arrPopedom, Popedom::STRING_EDIT))
die ($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "status=$status, id=$id");
$sql = "UPDATE products SET status='$status' WHERE id=$id";
$rs = mysql_query($sql,$this->intLinkSign);
if(mysql_affected_rows() > 0)
return true;
else
return false;
}
public function setIsNew($arrPopedom, $id, $isNew)
{
if($this->isUnallowable($arrPopedom, Popedom::STRING_EDIT))
die ($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "isNew=$isNew, id=$id");
$sql = "UPDATE products SET isNew='$isNew' WHERE id=$id";
$rs = mysql_query($sql,$this->intLinkSign);
if(mysql_affected_rows() > 0)
return true;
else
return false;
}
public function setIsHot($arrPopedom, $id, $isHot)
{
if($this->isUnallowable($arrPopedom, Popedom::STRING_EDIT))
die ($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "isHot=$isHot, id=$id");
$sql = "UPDATE products SET isHot='$isHot' WHERE id=$id";
$rs = mysql_query($sql,$this->intLinkSign);
if(mysql_affected_rows() > 0)
return true;
else
return false;
}
public function setIsFeatured($arrPopedom, $id, $isFeatured)
{
if($this->isUnallowable($arrPopedom, Popedom::STRING_EDIT))
die ($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "isFeatured=$isFeatured, id=$id");
$sql = "UPDATE products SET isFeatured='$isFeatured' WHERE id=$id";
$rs = mysql_query($sql,$this->intLinkSign);
if(mysql_affected_rows() > 0)
return true;
else
return false;
}
/* list
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $languageid, $where, $order, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = "SELECT count(*) FROM products p, products_description pd WHERE p.id = pd.productID AND pd.languageID = $languageid $where";
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = "SELECT * FROM products p, products_description pd WHERE p.id = pd.productID AND pd.languageID = $languageid $where $order";
else{
$sql = "SELECT * FROM products p, products_description pd WHERE p.id = pd.productID AND pd.languageID = $languageid $where $order LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
public function IsExistName($languageID, $name)
{
$sql = "SELECT productID FROM products_description WHERE name = '$name' AND languageID = $languageID";
$rs = mysql_query($sql, $this->intLinkSign) or die ("error: " . mysql_error($this->intLinkSign));
if(mysql_num_rows($rs) > 0)
return true;
else
return false;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Product.php | PHP | asf20 | 14,113 |
<?php
/*
* Created on Dec 1, 2010
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
class CustomerDao
{
private $id;
private $firstname;
private $lastname;
private $countryid;
private $addressid;
private $gender;
private $email;
private $telephone;
private $fax;
private $newsletter;
private $password;
private $paypal_payerid;
private $paypal_ec;
private $createdTime;
private $modifiedTime;
private $isAutoRegister = 0;
public function CustomerDao()
{
}
public function setID($id)
{
$this->id = $id;
}
public function getID()
{
return $this->id;
}
public function setFirstName($firstname)
{
$this->firstname = $firstname;
}
public function getFirstName()
{
return $this->firstname;
}
public function setLastName($lastname)
{
$this->lastname = $lastname;
}
public function getLastName()
{
return $this->lastname;
}
public function setCountryid($countryid)
{
$this->countryid = $countryid;
}
public function getCountryid()
{
return $this->countryid;
}
public function setAddressid($addressid)
{
$this->addressid = $addressid;
}
public function getAddressid()
{
return $this->addressid;
}
public function setGender($gender)
{
$this->gender = $gender;
}
public function getGender()
{
return $this->gender;
}
public function setEmail($email)
{
$this->email = $email;
}
public function getEmail()
{
return $this->email;
}
public function setTelephone($telephone)
{
$this->telephone = $telephone;
}
public function getTelephone()
{
return $this->telephone;
}
public function setFax($fax)
{
$this->fax = $fax;
}
public function getFax()
{
return $this->fax;
}
public function setNewsletter($newsletter)
{
$this->newsletter = $newsletter;
}
public function getNewsletter()
{
return $this->newsletter;
}
public function setPassword($password)
{
$this->password = $password;
}
public function getPassword()
{
return $this->password;
}
public function setPaypalPayerid($paypal_payerid)
{
$this->paypal_payerid = $paypal_payerid;
}
public function getPaypalPayerid()
{
return $this->paypal_payerid;
}
public function setPaypalEC($paypal_ec)
{
$this->paypal_ec = $paypal_ec;
}
public function getPaypalEC()
{
return $this->paypal_ec;
}
public function setCreatedTime($createdTime)
{
$this->createdTime = $createdTime;
}
public function getCreatedTime()
{
return $this->createdTime;
}
public function setModifiedTime($modifiedTime)
{
$this->modifiedTime = $modifiedTime;
}
public function getModifiedTime()
{
return $this->modifiedTime;
}
public function setAutoRegister($isAutoRegister)
{
$this->isAutoRegister = $isAutoRegister;
}
public function getAutoRegister()
{
return $this->isAutoRegister;
}
public function getArray()
{
$data_array = array(
'firstname' => $this->firstname,
'lastname' => $this->lastname,
'email' => $this->email,
'telephone' => $this->telephone,
'fax' => $this->fax,
'gender' => $this->gender,
'newsletter' => $this->newsletter,
'paypal_ec' => $this->paypal_ec,
'createdTime' => $this->createdTime,
'modifiedTime' => $this->modifiedTime,
'password' => $this->password,
'paypal_payerid'=> $this->paypal_payerid,
'isAutoRegister'=> $this->isAutoRegister,
'countryid' => $this->countryid
);
return $data_array;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/CustomerDao.php | PHP | asf20 | 3,902 |
<?php
/*
* Created on Jan 7, 2011
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
class CSVFileParser
{
private $hasError = false;
private $errorInfo = '';
private $rowIndex = 0;
private $arrTitle = array();
private $arrRowList = array();
private $arrCurrentRow = array();
private $arrNameList = array();
function CSVFileParser()
{
}
public function parser($filePath)
{
$isFileExisted = file_exists($filePath);
if($isFileExisted){
$row = 0;
$nameIndex = 0;
$handle = fopen($filePath, "r");
while ($data = fgetcsv($handle)) {
$num = count($data);
$row++;
if($row == 1){
for ($c = 0; $c < $num; $c++) {
$this->arrTitle[] = strtolower(trim($data[$c]));
}
$nameIndex = $this->getKeyIndex('name');
if($nameIndex == -1){
$errorInfo = 'not found name index.';
echo $errorInfo . '<br>';
}
}else{
$arrData = array();
for ($c = 0; $c < $num; $c++) {
$arrData[] = trim($data[$c]);
}
$this->arrRowList[] = $arrData;
$this->arrNameList[] = trim($data[$nameIndex]);
if($row == 2){
$this->arrCurrentRow = $arrData;
}
}
}
fclose($handle);
}else{
$errorInfo = "file existed : $filePath";
echo $errorInfo . '<br>';
}
}
public function getNameList()
{
return $this->arrNameList;
}
public function isHasError()
{
return $this->hasError;
}
public function isEnd()
{
if($this->rowIndex == count($this->arrRowList))
return true;
else
return false;
}
public function nextLine()
{
$this->arrCurrentRow = $this->arrRowList[$this->rowIndex];
$this->rowIndex++;
if($this->rowIndex > count($this->arrRowList))
$this->rowIndex = count($this->arrRowList);
}
public function getValue($key)
{
$keyIndex = $this->getKeyIndex($key);
if($keyIndex != -1){
return $this->arrCurrentRow[$keyIndex];
}else
return '';
}
public function getKeyIndex($key)
{
if(in_array($key, $this->arrTitle)){
$arrKeys = array_keys($this->arrTitle, $key);
return $arrKeys[0];
}else{
return -1;
}
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/CSVFileParser.php | PHP | asf20 | 2,468 |
<?php
/* explain:
* Project:
* File: Job.php
*
* @ link http://www.../lib/
* @ Email ldmmyx@hotmail.com
* @ copyright 2007 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class TaxClass extends Common
{
public $conHandle;
public $errorInfo;
private $iUserID;
private $objLog;
function TaxClass($DBTag, $userid)
{
parent::Common();
$this->conHandle = $this->getConnection($DBTag);
$this->objLog = new Logs($userid);
$this->iUserID = $userid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getFromID($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM tax_class WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/*
*
* @param string strOrders
* @param string name
* @param string namecn
* @return boolean true or fail
*
*/
public function add($arrPopedom = array(), $name, $summary)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO tax_class SET createdTime = UTC_TIMESTAMP(), modifiedTime = UTC_TIMESTAMP(), name = '$name', summary='" . addslashes($summary) . "'";
$rs = mysql_query($sql, $this->conHandle) or die(mysql_error());
return $rs ? true: false;
}
/* modify menu
*
* @param string id modify menu id
* @param string strOrders
* @param string name
* @param string summary
* @return boolean true or fail
*/
public function edit($arrPopedom = array(), $id, $name, $summary)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "id=$id");
$sql = "UPDATE tax_class SET summary='" . addslashes($summary) . "', name = '$name' WHERE id=$id";
$rs = mysql_query($sql, $this->conHandle) or die ($sql . mysql_error($this->conHandle));
return $rs ? true: false;
}
/* delete menu
*
* @param int id
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "DELETE FROM tax_class WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return true;
else
return false;
}
/* list menu
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $condition, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = "SELECT count(id) FROM tax_class$condition";
$rs = mysql_query($sql, $this->conHandle);
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = "SELECT * FROM tax_class$condition";
else{
$sql = "SELECT * FROM tax_class$condition LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
/* list all custom condition data
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listCustom($arrPopedom = array(), $condition='')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrBack = array();
$sql = "SELECT * FROM tax_class$condition";
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/TaxClass.php | PHP | asf20 | 4,368 |
<?php
/*
* Created on Sep 14, 2010
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
class HttpDownload {
var $data = null;
var $data_len = 0;
var $data_mod = 0;
var $data_type = 0;
var $data_section = 0; //section download
var $sentSize=0;
var $handler = array('auth' => null);
var $use_resume = true;
var $use_autoexit = false;
var $use_auth = false;
var $filename = null;
var $mime = null;
var $bufsize = 2048;
var $seek_start = 0;
var $seek_end = -1;
var $totalsizeref = 0;
var $bandwidth = 0;
var $speed = 0;
function initialize() {
global $HTTP_SERVER_VARS;
if ($this->use_auth) //use authentication
{
if (!$this->_auth()) //no authentication
{
header('WWW-Authenticate: Basic realm="Please enter your username and password"');
header('HTTP/1.0 401 Unauthorized');
header('status: 401 Unauthorized');
if ($this->use_autoexit) exit();
return false;
}
}
if ($this->mime == null) $this->mime = "application/octet-stream"; //default mime
if (isset($_SERVER['HTTP_RANGE']) || isset($HTTP_SERVER_VARS['HTTP_RANGE']))
{
if (isset($HTTP_SERVER_VARS['HTTP_RANGE'])) $seek_range = substr($HTTP_SERVER_VARS['HTTP_RANGE'] , strlen('bytes='));
else $seek_range = substr($_SERVER['HTTP_RANGE'] , strlen('bytes='));
$range = explode('-',$seek_range);
if ($range[0] > 0)
{
$this->seek_start = intval($range[0]);
}
if ($range[1] > 0) $this->seek_end = intval($range[1]);
else $this->seek_end = -1;
if (!$this->use_resume)
{
$this->seek_start = 0;
//header("HTTP/1.0 404 Bad Request");
//header("Status: 400 Bad Request");
//exit;
//return false;
}
else
{
$this->data_section = 1;
}
}
else
{
$this->seek_start = 0;
$this->seek_end = -1;
}
$this->sentSize=0;
return true;
}
function header($size,$seek_start=null,$seek_end=null) {
header('Content-type: ' . $this->mime);
header('Content-Disposition: attachment; filename="' . $this->filename . '"');
header('Last-Modified: ' . date('D, d M Y H:i:s \G\M\T' , $this->data_mod));
if ($this->data_section && $this->use_resume)
{
header("HTTP/1.0 206 Partial Content");
header("Status: 206 Partial Content");
header('Accept-Ranges: bytes');
header("Content-Range: bytes $seek_start-$seek_end/$size");
header("Content-Length: " . ($seek_end - $seek_start + 1));
}
else
{
header("Content-Length: $size");
}
}
function download_ex($size)
{
if (!$this->initialize()) return false;
ignore_user_abort(true);
//Use seek end here
if ($this->seek_start > ($size - 1)) $this->seek_start = 0;
if ($this->seek_end <= 0) $this->seek_end = $size - 1;
$this->header($size,$seek,$this->seek_end);
$this->data_mod = time();
return true;
}
function download() {
if (!$this->initialize()) return false;
try
{
error_log("begin download\n", 3,"download.err");
$seek = $this->seek_start;
$speed = $this->speed;
$bufsize = $this->bufsize;
$packet = 1;
//do some clean up
@ob_end_clean();
$old_status = ignore_user_abort(true);
@set_time_limit(0);
$this->bandwidth = 0;
$size = $this->data_len;
if ($this->data_type == 0) //download from a file
{
$size = filesize($this->data);
if ($seek > ($size - 1)) $seek = 0;
if ($this->filename == null) $this->filename = basename($this->data);
$res = fopen($this->data,'rb');
if ($seek) fseek($res , $seek);
if ($this->seek_end < $seek) $this->seek_end = $size - 1;
$this->header($size,$seek,$this->seek_end); //always use the last seek
$size = $this->seek_end - $seek + 1;
while (!(connection_aborted() || connection_status() == 1) && $size > 0)
{
if ($size < $bufsize)
{
echo fread($res , $size);
$this->bandwidth += $size;
$this->sentSize+=$size;
}
else
{
echo fread($res , $bufsize);
$this->bandwidth += $bufsize;
$this->sentSize+=$bufsize;
}
$size -= $bufsize;
flush();
if ($speed > 0 && ($this->bandwidth > $speed*$packet*1024))
{
sleep(1);
$packet++;
}
}
fclose($res);
}
elseif ($this->data_type == 1) //download from a string
{
if ($seek > ($size - 1)) $seek = 0;
if ($this->seek_end < $seek) $this->seek_end = $this->data_len - 1;
$this->data = substr($this->data , $seek , $this->seek_end - $seek + 1);
if ($this->filename == null) $this->filename = time();
$size = strlen($this->data);
$this->header($this->data_len,$seek,$this->seek_end);
while (!connection_aborted() && $size > 0) {
if ($size < $bufsize)
{
$this->bandwidth += $size;
$this->sentSize+=$size;
}
else
{
$this->bandwidth += $bufsize;
$this->sentSize+=$bufsize;
}
echo substr($this->data , 0 , $bufsize);
$this->data = substr($this->data , $bufsize);
$size -= $bufsize;
flush();
if ($speed > 0 && ($this->bandwidth > $speed*$packet*1024))
{
sleep(1);
$packet++;
}
}
} else if ($this->data_type == 2) {
//just send a redirect header
header('location: ' . $this->data);
}
if($this->totalsizeref==$this->sentSize )error_log("end download\n", 3,"download.err");
else error_log("download is canceled\n", 3,"download.err");
if ($this->use_autoexit) exit();
//restore old status
ignore_user_abort($old_status);
set_time_limit(ini_get("max_execution_time"));
}
catch(Exception $e)
{
error_log("cancel download\n".$e, 3,"download.err");
}
return true;
}
function set_byfile($dir) {
if (is_readable($dir) && is_file($dir)) {
$this->data_len = 0;
$this->data = $dir;
$this->data_type = 0;
$this->data_mod = filemtime($dir);
$this->totalsizeref = filesize($dir);
return true;
} else return false;
}
function set_bydata($data) {
if ($data == '') return false;
$this->data = $data;
$this->data_len = strlen($data);
$this->data_type = 1;
$this->data_mod = time();
return true;
}
function set_byurl($data) {
$this->data = $data;
$this->data_len = 0;
$this->data_type = 2;
return true;
}
function set_lastmodtime($time) {
$time = intval($time);
if ($time <= 0) $time = time();
$this->data_mod = $time;
}
function _auth() {
if (!isset($_SERVER['PHP_AUTH_USER'])) return false;
if (isset($this->handler['auth']) && function_exists($this->handler['auth']))
{
return $this->handler['auth']('auth' , $_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']);
}
else return true; //you must use a handler
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/HttpDownload.php | PHP | asf20 | 7,021 |
<?php
class ServerUtils
{
function __construct()
{
}
/**
* get currently site domain
*
* @param boolean $isport is return port info in return info.
* @return string
*/
public function gethost($isport = false) {
$scheme = (isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://';
if(!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
$t = strpos($_SERVER['HTTP_X_FORWARDED_HOST'], ':');
if($t > 0) {
$host = substr($_SERVER['HTTP_X_FORWARDED_HOST'], 0, $t);
$port = substr($_SERVER['HTTP_X_FORWARDED_HOST'], $t+1);
} else {
$host = $_SERVER['HTTP_X_FORWARDED_HOST'];
}
} else if(!empty($_SERVER['HTTP_HOST'])) {
$t = strpos($_SERVER['HTTP_HOST'], ':');
if($t >0) {
$host = substr($_SERVER['HTTP_HOST'], 0, $t);
$port = substr($_SERVER['HTTP_HOST'], $t+1);
} else {
$host = $_SERVER['HTTP_HOST'];
}
} else if(!empty($_SERVER['SERVER_NAME'])) {
$host = $_SERVER['SERVER_NAME'];
}
if(empty($port)) {
$port = $_SERVER['SERVER_PORT'];
}
if($isport) {
return $scheme . $host . ':' . $port;
} else {
return $scheme . $host;
}
}
}
?> | 123gohelmetsv2 | trunk/admin/lib/ServerUtils.php | PHP | asf20 | 1,310 |
<?php
include_once("db.inc.php");
class DB
{
private static $isPconnection = false;
private static $usedConns = array(array());
private static $usableConns = array(array());
private static $arrConnConfig = array(array());
public function DB()
{
global $ARR_GLOGAL_DB_CONFIG;
DB::$arrConnConfig = $ARR_GLOGAL_DB_CONFIG;
}
public function getConnection($DBTag)
{
if(array_key_exists($DBTag, DB::$usableConns) && count(DB::$usableConns[$DBTag]) > 0){
return array_pop(DB::$usableConns[$DBTag]);
}else{
return $this->newConnection($DBTag);
}
}
public function newConnection($DBTag)
{
$db_connect = DB::$isPconnection ? 'mysql_pconnect' : 'mysql_connect';
$conResource = $db_connect(DB::$arrConnConfig[$DBTag]["host"], DB::$arrConnConfig[$DBTag]["user"], DB::$arrConnConfig[$DBTag]["pwd"], true);
if($conResource){
mysql_select_db(DB::$arrConnConfig[$DBTag]["db"], $conResource);
if(!empty(DB::$arrConnConfig[$DBTag]["encoding"])){
$init_connect = "SET names " . DB::$arrConnConfig[$DBTag]["encoding"];
mysql_query($init_connect, $conResource);
}
if(@mysql_error()) die('<b>error: connect database fail.</b> error : ' . mysql_error($conResource));
if(array_key_exists($DBTag, DB::$usedConns)){
$conns = DB::$usedConns[$DBTag];
$conns[] = $conResource;
}else{
$conns = array();
$conns[] = $conResource;
DB::$usedConns[$DBTag] = $conns;
}
return $conResource;
}else{
return false;
}
}
public function freeConnection($DBTag, $conn)
{
if(array_key_exists($DBTag, DB::$usedConns)){
$conns = DB::$usedConns[$DBTag];
if(in_array($conn, $conns)){
if(array_key_exists($DBTag, DB::$usableConns)){
$conns = DB::$usableConns[$DBTag];
$conns[] = $conn;
DB::$usableConns[$DBTag] = $conns;
}else{
$conns = array();
$conns[] = $conn;
DB::$usableConns[$DBTag] = $conns;
}
return true;
}
}else{
return false;
}
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/DB.php | PHP | asf20 | 2,109 |
<?php
/* explain:
* Project:
* File: qa.php
*
* @ link http://www.../lib/
* @ Email ldmmyx@hotmail.com
* @ copyright 2007 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class AddressBook extends Common
{
private $intLinkSign;
private $iUserID;
private $objLog;
function AddressBook($usrid)
{
parent::Common();
$this->intLinkSign = $this->getConnection("system");
$this->objLog = new Logs($usrid);
$this->iUserID = $usrid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getByID($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM address_book WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/* add method
*
* @param string userid news class name
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @return int true: insert ID
*/
public function add($customerid, $gender, $company, $firstname, $lastname, $street, $suburb, $postcode, $city, $state, $countryid, $zoneid)
{
$sql = "INSERT INTO address_book SET customerid = '$customerid', gender='$gender', company='$company', firstname='$firstname', lastname='$lastname'," .
" street='$street', suburb='$suburb', postcode='$postcode', city='$city', state='$state', countryid='$countryid', zoneid='$zoneid'";
$rs = mysql_query($sql, $this->intLinkSign) or die ($sql . mysql_error($this->intLinkSign));
$intDataID = mysql_insert_id($this->intLinkSign);
if($rs)
return $intDataID;
else
return false;
}
/* modify
*
* @param string userid news class name
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @param return boolean
*/
public function edit($arrPopedom = array(), $id, $customerid, $gender, $company, $firstname, $lastname, $street, $suburb, $postcode, $city, $state, $countryid, $zoneid)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "id=$id");
$sql = "UPDATE address_book SET customerid = '$customerid', gender='$gender', company='$company', firstname='$firstname', lastname='$lastname'," .
" street='$street', suburb='$suburb', postcode='$postcode', city='$city', state='$state', countryid='$countryid', zoneid='$zoneid' WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return true;
else
return false;
}
/* delete news class
*
* @param int id
* @param string status
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "DELETE FROM address_book WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return true;
else
return false;
}
/* list
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $where, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$arrback = array();
$sql = 'SELECT count(id) FROM address_book'.$where;
$rs = mysql_query($sql, $this->intLinkSign);
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = 'SELECT * FROM address_book'.$where;
else{
$sql = 'SELECT * FROM address_book'.$where." LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
/* list by condition
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listByCustom($arrPopedom = array(), $condition='')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrBack = array();
$sql = "SELECT * FROM address_book".$condition;
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/AddressBook.php | PHP | asf20 | 5,109 |
<?php
/* explain:
* Project:
* File: Job.php
*
* @ link http://www.../lib/
* @ Email ldmmyx@hotmail.com
* @ copyright 2007 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class UserGroup extends Common
{
public $conHandle;
public $errorInfo;
private $strLanguage;
private $iUserID;
private $objLog;
function UserGroup($strLanguage, $userid)
{
parent::Common();
$this->conHandle = $this->getConnection("system");
$this->strLanguage = $strLanguage;
$this->objLog = new Logs($userid);
$this->iUserID = $userid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getFromID($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM user_groups WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/*
*
* @param string name
* @param string namecn
* @param string status normal, stop
* @return boolean true or fail
*
*/
public function add($arrPopedom = array(), $name, $status = 'normal')
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO user_groups SET name = '$name', status='$status'";
$rs = mysql_query($sql, $this->conHandle) or die(mysql_error());
return $rs ? true: false;
}
/* edit
*
* @param string id modify id
* @param string name
* @param string namecn
* @return boolean true or fail
*/
public function edit($arrPopedom = array(), $id, $name)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_EDIT, "id=$id");
$sql = "UPDATE user_groups SET name = '$name', WHERE id='$id'";
$rs = mysql_query($sql, $this->conHandle);
return $rs ? true: false;
}
/* delete
*
* @param int id
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "DELETE FROM user_groups WHERE id = $id";
$rs = mysql_query($sql, $this->conHandle);
if($rs)
return true;
else
return false;
}
/* list menu
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $condition, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = "SELECT count(id) FROM user_groups$condition";
$rs = mysql_query($sql, $this->conHandle);
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = "SELECT * FROM user_groups$condition";
else{
$sql = "SELECT * FROM user_groups$condition LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
/* list all custom condition data
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listFromCustom($arrPopedom = array(), $condition='')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrBack = array();
$sql = "SELECT * FROM user_groups$condition";
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
public function arrGetGroupList($groupid)
{
$sql = "SELECT id, name FROM user_groups WHERE id >= $groupid";
$rs = mysql_query($sql, $this->conHandle);
$arrCache = array();
if($rs){
while ($arrData = mysql_fetch_array($rs)){
$arrCache[$arrData['id']] = $arrData['name'];
}
}
return $arrCache;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/UserGroup.php | PHP | asf20 | 4,576 |
<?php
/* explain: news system
* Project:
* File: news.php
*
* @ link http://www.../modules/
* @ Email ldmmyx@hotmail.com
* @ copyright 2005 Ling Deming
* @ author ivan.ling Ling Deming
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class Manufacturer extends Common
{
public $intLinkSign;
public $errorInfo;
private $iUserID;
private $objLog;
function Manufacturer($strLanguage, $userid)
{
parent::Common();
$this->intLinkSign = $this->getConnection($strLanguage);
$this->objLog = new Logs($userid);
$this->iUserID = $userid;
}
/* get data via ID
*
* @param int id
* @return mixed false:
*/
public function getFromID($arrPopedom = array(), $id)
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "SELECT * FROM manufacturers WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return mysql_fetch_array($rs);
else
return false;
}
/*
*
* @param string userid
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @return int true: insert ID
*/
public function add($arrPopedom = array(), $languageid, $name, $URL)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = "INSERT INTO manufacturers SET name='$name', languageID = $languageid, URL = '$URL'";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
if($rs)
return true;
else
return false;
}
/* edit
*
* @param string userid news class name
* @param string number man number
* @param string position position
* @param string summary summary
* @param string descript descript
* @param datetime startDate start date
* @param datetime endDate end date
* @param return boolean
*/
public function edit($arrPopedom = array(), $id, $name, $URL)
{
if($this->isUnallowableEdit($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$sql = "UPDATE manufacturers SET name='$name', URL = '$URL' WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs)
return true;
else
return false;
}
/* delete news class
*
* @param int id
* @param string status
* @param return boolean
*/
public function delete($arrPopedom = array(), $id)
{
if($this->isUnallowableDelete($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_DELETE, "id=$id");
$sql = "DELETE FROM manufacturers WHERE id = $id";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error());
if($rs)
return true;
else
return false;
}
/* list
*
* @ param string class id
* @ param string page
* @ param string discount
* @ param string url
* @ param return array
*/
public function lists($arrPopedom = array(), $where, $page = '', $discount = '', $url = '')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrback = array();
$sql = "SELECT count(*) FROM manufacturers$where";
$rs = mysql_query($sql, $this->intLinkSign) or die (mysql_error($this->intLinkSign));
list($total) = mysql_fetch_row($rs);
$this->mutilPager($total, $page, $discount, $url);
if(empty($total))
return $arrback;
if(empty($discount))
$sql = "SELECT * FROM manufacturers$where";
else{
$sql = "SELECT * FROM manufacturers$where LIMIT $this->firstcount, $discount";
}
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while(is_array($arrtmp = mysql_fetch_array($rs))){
$arrback[] = $arrtmp;
}
return $arrback;
}else
return $arrback;
}
public function IsExistName($languageID, $name)
{
$sql = "SELECT id FROM manufacturers WHERE languageID = $languageID AND name = '$name'";
$rs = mysql_query($sql, $this->intLinkSign) or die ("error: " . mysql_error());
if(mysql_num_rows($rs) > 0)
return true;
else
return false;
}
/* list by condition
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listFromCustom($arrPopedom = array(), $condition='')
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
$arrBack = array();
$sql = "SELECT * FROM manufacturers".$condition;
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[] = $arrCache;
}
return $arrBack;
}else
return false;
}
/* list by condition
*
* @param string condition
* @return mixed false: sql error array: news info
*/
public function listSimple($arrPopedom = array())
{
if($this->isUnallowableView($arrPopedom))
die($this->getNotPopedomInfo());
$arrBack = array();
$sql = "SELECT id, name FROM manufacturers";
$rs = mysql_query($sql, $this->intLinkSign);
if($rs){
while($arrCache = mysql_fetch_array($rs)){
$arrBack[$arrCache['id']] = $arrCache['name'];
}
return $arrBack;
}else
return false;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Manufacturer.php | PHP | asf20 | 5,620 |
<?php
/* explain: authority class
* Project: marsems
* File: Authority.php
*
* @ link http://www.marsems.com/lib
* @ Email ldmmyx@hotmail.com
* @ copyright 2007 Ling Deming
* @ author ivan.ling
* @ version 1.0
*
*/
include_once("Common.php");
include_once("Logs.php");
class Authority extends Common
{
private $conHandle;
public $strLanguage;
private $iUserID;
private $objLog;
function Authority($strLanguage, $uid)
{
parent::Common();
$this->conHandle = $this->getConnection("system");
$this->strLanguage = $strLanguage;
$this->objLog = new Logs($usrid);
$this->iUserID = $usrid;
}
public function setLan($strLan)
{
$this->strLanguage = $strLan;
}
public function getMenuFromUserID($userid)
{
if($this->strLanguage == "zh-CN"){
$strGname = "namecn";
$strMname = "namecn";
}else{
$strGname = "name";
$strMname = "name";
}
if($userid == 1)
$sql = "SELECT g.id as gid, m.id as mid, g.$strGname as gname, m.$strMname as mname, m.url FROM menu_groups g, menu m WHERE g.id = m.groupid";
else
$sql = "SELECT g.id as gid, m.id as mid, g.$strGname as gname, m.$strMname as mname, m.url FROM authority a, menu_groups g, menu m WHERE g.id = m.groupid AND m.id = a.menuid AND a.userid = '$userid'";
$rs = mysql_query($sql, $this->conHandle);
$arrReturn = array();
if($rs){
while($arrData = mysql_fetch_array($rs)){
$arrReturn[$arrData['gid']][] = $arrData;
}
}
return $arrReturn;
}
public function getMenuFromGroupID($groupid)
{
if($this->strLanguage == "zh-CN"){
$strGname = "namecn";
$strMname = "namecn";
}else{
$strGname = "name";
$strMname = "name";
}
if($groupid == 1)
$sql = "SELECT g.id as gid, m.id as mid, g.$strGname as gname, m.$strMname as mname, m.url FROM menu_groups g, menu m WHERE g.id = m.groupid ORDER BY g.orders, m.orders";
else
$sql = "SELECT g.id as gid, m.id as mid, g.$strGname as gname, m.$strMname as mname, m.url FROM group_authority a, menu_groups g, menu m WHERE g.id = m.groupid AND m.id = a.menuid AND a.groupid = '$groupid' ORDER BY g.orders, m.orders";
$rs = mysql_query($sql, $this->conHandle) or die (mysql_error($this->conHandle).$sql);
$arrReturn = array();
if($rs){
while($arrData = mysql_fetch_array($rs)){
$arrReturn[$arrData['gid']][] = $arrData;
}
}
return $arrReturn;
}
/* permission list
*
* @ param int userid
* @ param return array data array
*/
public function listPermission($userid)
{
if(empty($userid))
return false;
$sql = "SELECT m.id as mid, m.name as name, m.remark as remark, a.operate as operate FROM menu m left join authority a on (m.id = a.id AND a.userid = $userid)";
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while(is_array($arrcache = mysql_fetch_array($rs))){
$arrback[] = $arrcache;
}
return $arrback;
}else
return false;
}
/* permission list
*
* @ param int userid
* @ param return array data array
*/
public function listGroupPermission($groupid)
{
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_VIEW);
if($this->strLanguage == "zh-CN"){
$strMname = "namecn";
}else{
$strMname = "name";
}
$sql = "SELECT m.id as mid, m.$strMname as name, m.remark as remark, a.menuid as authMenuID, a.operate as operate FROM menu m left join group_authority a on (m.id = a.menuid AND a.groupid = $groupid)";
$rs = mysql_query($sql, $this->conHandle);
if($rs){
while(is_array($arrcache = mysql_fetch_array($rs))){
$arrback[] = $arrcache;
}
return $arrback;
}else
return false;
}
public function delAuthority($userid, $arrPopedom = array()){
if($this->isUnallowableDELETE($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "DELETE FROM authority WHERE userid = $userid'";
//$rs = mysql_query($sql, $this->conHandle);
echo $sql.'<br>';
$rs = true;
return $rs ? true: false;
}
public function addAuthority($userid, $menuid, $operate, $arrPopedom = array())
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$sql = "INSERT INTO authority SET userid = '$userid', menuid='$menuid', operate='$operate'";
$rs = mysql_query($sql, $this->conHandle);
$rs = true;
return $rs ? true: false;
}
public function addAuthTransaction($userid, $arrOperateCache, $arrPopedom = array())
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = 'set session autocommit=false';
$rs = mysql_query($sql, $this->conHandle) or die (mysql_error());
$sql = 'start transaction';
$rs = mysql_query($sql, $this->conHandle) or die (mysql_error());
$sql = "DELETE FROM authority WHERE userid = '$userid'";
$rs = mysql_query($sql, $this->conHandle);
foreach ($arrOperateCache as $menuid => $arrOperation){
$sql = "INSERT INTO authority SET userid = '$userid', menuid='$menuid', operate='" . implode(',', $arrOperation) . "'";
$rs = mysql_query($sql, $this->conHandle);
if(!$rs){
$sql = 'rollback';
$rs = mysql_query($sql, $this->conHandle);
break;
}
}
$sql = 'commit';
$rs = mysql_query($sql, $this->conHandle) or die (mysql_error());
if(!$rs){
$sql = 'rollback';
$rs = mysql_query($sql, $this->conHandle);
}
$sql = 'set session autocommit=true';
$rs = mysql_query($sql, $this->conHandle) or die (mysql_error());
return $rs ? true: false;
}
public function addGroupAuthTransaction($arrPopedom = array(), $groupid, $arrOperateCache)
{
if($this->isUnallowableAdd($arrPopedom))
die($this->getNotPopedomInfo());
$this->objLog->addOperate($this->iUserID, __METHOD__, Popedom::STRING_ADD);
$sql = 'set session autocommit=false';
$rs = mysql_query($sql, $this->conHandle) or die (mysql_error());
$sql = 'start transaction';
$rs = mysql_query($sql, $this->conHandle) or die (mysql_error());
$sql = "DELETE FROM group_authority WHERE groupid = '$groupid'";
$rs = mysql_query($sql, $this->conHandle);
foreach ($arrOperateCache as $menuid => $arrOperation){
$sql = "INSERT INTO group_authority SET groupid = '$groupid', menuid='$menuid', operate='" . implode(',', $arrOperation) . "'";
$rs = mysql_query($sql, $this->conHandle);
if(!$rs){
$sql = 'rollback';
$rs = mysql_query($sql, $this->conHandle);
break;
}
}
$sql = 'commit';
$rs = mysql_query($sql, $this->conHandle) or die (mysql_error());
if(!$rs){
$sql = 'rollback';
$rs = mysql_query($sql, $this->conHandle);
}
$sql = 'set session autocommit=true';
$rs = mysql_query($sql, $this->conHandle) or die (mysql_error());
return $rs ? true: false;
}
}
?>
| 123gohelmetsv2 | trunk/admin/lib/Authority.php | PHP | asf20 | 6,996 |