Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once("../include/session.php");
- require_once("../include/business.php");
- require_once("../include/newcategory.php");
- if(isset($_POST['action'])){
- $module = $_POST['action'];
- switch($module){
- case 'login2':
- login2($_POST['regid']);
- break;
- case 'login':
- login($_POST['password'],$_POST['remember'],$_POST['email']);
- break;
- case 'register':
- registerUser($_POST['email'],$_POST['password'],$_POST['gender'],$_POST['mobile'],$_POST['categoryid'], $_POST['facebookid']);
- break;
- case 'updatePassword':
- changePassword($_POST['currpass'],$_POST['newpass'],$_POST['userid']);
- break;
- default:
- return "Unknown Request. Please Contact Customer Care.";
- }
- }
- if(isset($_GET['action'])){
- $module = $action = $_GET['action'];
- switch ($module){
- case 'register_device_uid3':
- register_device_uid3($_GET['device_uid'],$_GET['device_type'],$_GET['regid']);
- break;
- case 'register_device_uid2':
- register_device_uid2($_GET['device_uid'],$_GET['device_type'],$_GET['regid']);
- break;
- case 'register_device_uid':
- register_device_uid($_GET['device_uid'],$_GET['device_type']);
- break;
- case 'getDeals':
- getDeals($_GET['categoryid'],$_GET['dealid']);
- break;
- case 'savedeal':
- saveDeal($_GET['dealid'],$_GET['custid']);
- break;
- case 'savebusiness':
- saveBusiness($_GET['userid'],$_GET['businessid']);
- break;
- case 'getCategory':
- getCategory(); //this will output all the category
- break;
- case 'getSubCategory':
- getSubCategory($_GET['catid']); //will output all the subcategory which falls under the given category.
- break;
- case 'updateLatLong':
- updateLatLong($_GET['lat'], $_GET['long'],$_GET['device_token'], $_GET['userid']);
- break;
- case 'logout':
- logOut();
- break;
- case 'forgotPass':
- forgotPass($_GET['email']);
- break;
- case 'getBusinessInfo':
- getBusinessInfo($_GET['businessid']);
- break;
- case 'getFavBusiness':
- if(isset($_GET['catid'])){
- getFavBusiness($_GET['userid'], $_GET['catid']);
- }else{
- getFavBusiness($_GET['userid']);
- }
- break;
- case 'getProfile':
- getProfile($_GET['userid']);
- break;
- case 'updateGender':
- updateGender($_GET['gender'],$_GET['userid']);
- break;
- case 'saveBusiness':
- saveFavBusiness($_GET['businessid'], $_GET['userid'], $_GET['mode']);
- break;
- case 'saveCategory':
- saveFavCategory($_GET['catid'], $_GET['userid'], $_GET['mode']);
- break;
- case 'updateCategory';
- updateFavCategories($_GET['catid'], $_GET['userid']);
- break;
- case 'updateNotification':
- updateNotificationStatus($_GET['userid'], $_GET['status']);
- break;
- case 'getBusinessWithDeal':
- getBusinessWithDeal($_GET['entityid'],$_GET['userid'],$_GET['mode']);
- break;
- case 'searchBusiness':
- searchBusiness($_GET['business_name'],$_GET['userid']);
- break;
- default:
- print "Unknown Request.";
- break;
- }
- }
- function register_device_uid3($device_uid,$device_type,$regid){
- global $database,$session,$business, $form;
- error_log("saurabh");
- $user = $database->findOrCreateUserForDevice3($device_uid,$device_type,$regid);
- $xml = new DOMDocument("1.0");
- if($user){
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $statusTxt = $status->appendChild($xml->createTextNode("Success"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode($user['userid']));
- $userXML = $response->appendChild($xml->createElement("user"));
- $id = $userXML->appendChild($xml->createElement("id"));
- $idTxt = $id->appendChild($xml->createTextNode($user['userid']));
- $notification = $userXML->appendChild($xml->createElement("notification"));
- $notification = $notification->appendChild($xml->createTextNode($user['notification']));
- //getsaved categories
- $query = sprintf(" SELECT catid from user_category where userid = '%s'", $user['userid']);
- $resultCategory = $database->query($query) or die(mysql_error());
- if(mysql_num_rows($resultCategory) < 1){
- $catids = Null;
- }
- else{
- while($categoryid = mysql_fetch_assoc($resultCategory)){
- $catids[] = $categoryid['catid'];
- }
- $catids = implode(",", $catids);
- }
- //var_dump('hiren:',$catids);
- $savedCategory = $userXML->appendChild($xml->createElement("savedCategory"));
- $savedCategory = $savedCategory->appendChild($xml->createTextNode($catids));
- //
- //get all categories
- $XMLcategories = $response->appendChild($xml->createElement("categories"));
- $q = "SELECT * FROM category ORDER BY categoryName";
- $result = $database->query($q) or die(mysql_error());
- while($category = mysql_fetch_array($result)){
- $image = getCategoryImage($category['catid']);
- $XMLcategory = $XMLcategories->appendChild($xml->createElement("category"));
- $categoryid = $XMLcategory->appendChild($xml->createElement("categoryID"));
- $categoryid = $categoryid->appendChild($xml->createTextNode($category['catid']));
- $categoryName= $XMLcategory->appendChild($xml->createElement("categoryName"));
- $categoryName = $categoryName->appendChild($xml->createTextNode($category['categoryName']));
- $categoryParentId = $XMLcategory->appendChild($xml->createElement("categoryParentID"));
- $categoryParentId = $categoryParentId->appendChild($xml->createTextNode($category['parent_id']));
- $categoryImage = $XMLcategory->appendChild($xml->createElement("catImage"));
- $categoryImage = $categoryImage->appendChild($xml->createTextNode($image));
- }
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- else{
- $Output = $form->error("user").$form->error("email").$form->error("pass").$form->error("notactivated");
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Failure"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode($Output));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- }
- function register_device_uid2($device_uid,$device_type,$regid){
- global $database,$session,$business, $form;
- error_log("saurabh");
- $user = $database->findOrCreateUserForDevice2($device_uid,$device_type,$regid);
- $xml = new DOMDocument("1.0");
- if($user){
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $statusTxt = $status->appendChild($xml->createTextNode("Success"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode($user['userid']));
- $userXML = $response->appendChild($xml->createElement("user"));
- $id = $userXML->appendChild($xml->createElement("id"));
- $idTxt = $id->appendChild($xml->createTextNode($user['userid']));
- $notification = $userXML->appendChild($xml->createElement("notification"));
- $notification = $notification->appendChild($xml->createTextNode($user['notification']));
- //getsaved categories
- $query = sprintf(" SELECT catid from user_category where userid = '%s'", $user['userid']);
- $resultCategory = $database->query($query) or die(mysql_error());
- if(mysql_num_rows($resultCategory) < 1){
- $catids = Null;
- }
- else{
- while($categoryid = mysql_fetch_assoc($resultCategory)){
- $catids[] = $categoryid['catid'];
- }
- $catids = implode(",", $catids);
- }
- $savedCategory = $userXML->appendChild($xml->createElement("savedCategory"));
- $savedCategory = $savedCategory->appendChild($xml->createTextNode($catids));
- //
- //get all categories
- $XMLcategories = $response->appendChild($xml->createElement("categories"));
- $q = "SELECT * FROM category ORDER BY categoryName";
- $result = $database->query($q) or die(mysql_error());
- while($category = mysql_fetch_array($result)){
- $image = getCategoryImage($category['catid']);
- $XMLcategory = $XMLcategories->appendChild($xml->createElement("category"));
- $categoryid = $XMLcategory->appendChild($xml->createElement("categoryID"));
- $categoryid = $categoryid->appendChild($xml->createTextNode($category['catid']));
- $categoryName= $XMLcategory->appendChild($xml->createElement("categoryName"));
- $categoryName = $categoryName->appendChild($xml->createTextNode($category['categoryName']));
- $categoryParentId = $XMLcategory->appendChild($xml->createElement("categoryParentID"));
- $categoryParentId = $categoryParentId->appendChild($xml->createTextNode($category['parent_id']));
- $categoryImage = $XMLcategory->appendChild($xml->createElement("catImage"));
- $categoryImage = $categoryImage->appendChild($xml->createTextNode($image));
- }
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- else{
- $Output = $form->error("user").$form->error("email").$form->error("pass").$form->error("notactivated");
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Failure"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode($Output));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- }
- function register_device_uid($device_uid,$device_type){
- global $database,$session,$business, $form;
- error_log("saurabh");
- $user = $database->findOrCreateUserForDevice($device_uid,$device_type);
- $xml = new DOMDocument("1.0");
- if($user){
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $statusTxt = $status->appendChild($xml->createTextNode("Success"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode($user['userid']));
- $userXML = $response->appendChild($xml->createElement("user"));
- $id = $userXML->appendChild($xml->createElement("id"));
- $idTxt = $id->appendChild($xml->createTextNode($user['userid']));
- $notification = $userXML->appendChild($xml->createElement("notification"));
- $notification = $notification->appendChild($xml->createTextNode($user['notification']));
- //getsaved categories
- $query = sprintf(" SELECT catid from user_category where userid = '%s'", $user['userid']);
- $resultCategory = $database->query($query) or die(mysql_error());
- if(mysql_num_rows($resultCategory) < 1){
- $catids = Null;
- }
- else{
- while($categoryid = mysql_fetch_assoc($resultCategory)){
- $catids[] = $categoryid['catid'];
- }
- $catids = implode(",", $catids);
- }
- $savedCategory = $userXML->appendChild($xml->createElement("savedCategory"));
- $savedCategory = $savedCategory->appendChild($xml->createTextNode($catids));
- //
- //get all categories
- $XMLcategories = $response->appendChild($xml->createElement("categories"));
- $q = "SELECT * FROM category ORDER BY categoryName";
- $result = $database->query($q) or die(mysql_error());
- while($category = mysql_fetch_array($result)){
- $image = getCategoryImage($category['catid']);
- $XMLcategory = $XMLcategories->appendChild($xml->createElement("category"));
- $categoryid = $XMLcategory->appendChild($xml->createElement("categoryID"));
- $categoryid = $categoryid->appendChild($xml->createTextNode($category['catid']));
- $categoryName= $XMLcategory->appendChild($xml->createElement("categoryName"));
- $categoryName = $categoryName->appendChild($xml->createTextNode($category['categoryName']));
- $categoryParentId = $XMLcategory->appendChild($xml->createElement("categoryParentID"));
- $categoryParentId = $categoryParentId->appendChild($xml->createTextNode($category['parent_id']));
- $categoryImage = $XMLcategory->appendChild($xml->createElement("catImage"));
- $categoryImage = $categoryImage->appendChild($xml->createTextNode($image));
- }
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- else{
- $Output = $form->error("user").$form->error("email").$form->error("pass").$form->error("notactivated");
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Failure"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode($Output));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- }
- function getDeals($categoryid=NULL, $dealid=NULL){
- global $business,$session,$database;
- if(isset($dealid) && strlen($dealid=trim($dealid)) != 0){
- $q = sprintf("SELECT * FROM deals WHERE dealid = '%s'", mysql_real_escape_string($dealid));
- $result = $database->query($q) or die(mysql_error());
- $xml = new DOMDocument("1.0");
- $root = $xml->appendChild($xml->createElement("response"));
- while($dealid = mysql_fetch_array($result)){
- $queryCat = sprintf("select catid from business where businessid= '%s'", mysql_real_escape_string($dealid['businessid']));
- $result2 = $database->query($queryCat) or die(mysql_error());
- $catid2 = mysql_fetch_array($result2);
- $catid = $catid2['catid'];
- $dealinfo = $business->getDealInfo($dealid['dealid']);
- $businessid = $business->getBusinessId($dealid['dealid']);
- $businessinfo = $business->getBusinessInfo($businessid);
- $dealImageLocation = $business->getDealImage($dealid['dealid']);
- $businessImageLocation = $business->getBusinessImage($businessid);
- $dealCat = $business->getCat($catid);
- $deal = $root->appendChild($xml->createElement("deal"));
- $dealid = $deal->appendChild($xml->createElement("dealId"));
- $dealid = $dealid->appendChild($xml->createTextNode($dealinfo['dealid']));
- $dealname = $deal->appendChild($xml->createElement("dealName"));
- $dealname = $dealname->appendChild($xml->createTextNode($dealinfo['dealname']));
- $dealDescription = $deal->appendChild($xml->createElement("dealDescription"));
- $dealDescription = $dealDescription->appendChild($xml->createTextNode($dealinfo['desc']));
- $dealPrice = $deal->appendChild($xml->createElement("dealPrice"));
- $dealPrice = $dealPrice->appendChild($xml->createTextNode($dealinfo['dealoffer']));
- $dealExpiryDate = $deal->appendChild($xml->createElement("dealExpiry"));
- $dealExpiryDate = $dealExpiryDate->appendChild($xml->createTextNode($dealinfo['expirytimestamp']));
- $dealImage = $deal->appendChild($xml->createElement("dealImage"));
- $dealImage = $dealImage->appendChild($xml->createTextNode($dealImageLocation));
- $dealCategory = $deal->appendChild($xml->createElement("dealCategoryId"));
- $dealCategory = $dealCategory->appendChild($xml->createTextNode($catid));
- $dealCatName = $deal->appendChild($xml->createElement("dealCatName"));
- $dealCatName = $dealCatName->appendChild($xml->createTextNode($dealCat));
- $lat = $deal->appendChild($xml->createElement("lat"));
- $lat = $lat->appendChild($xml->createTextNode($businessinfo['lattitude']));
- $long = $deal->appendChild($xml->createElement("long"));
- $long = $long->appendChild($xml->createTextNode($businessinfo['longitude']));
- $merchantId = $deal->appendChild($xml->createElement("merchantId"));
- $merchantId = $merchantId->appendChild($xml->createTextNode($businessinfo['businessid']));
- $merchantName = $deal->appendChild($xml->createElement("merchantName"));
- $merchantName = $merchantName->appendChild($xml->createTextNode($businessinfo['bname']));
- $merchantAddress = $deal->appendChild($xml->createElement("merchantAddress"));
- $merchantName = $merchantAddress->appendChild($xml->createTextNode($businessinfo['street'].", ".$businessinfo['suburb'].", ".$businessinfo['state']));
- }
- $xml->formatOutput=true;
- print ($result= $xml->saveXML());
- }
- elseif(isset($categoryid) && strlen($categoryid=trim($categoryid)) !=0){
- $catids = getTree($categoryid);
- print_r($catids);
- if(count($catids) < 1){
- return "No deals";
- }
- $xml = new DOMDocument("1.0");
- $root = $xml->appendChild($xml->createElement("response"));
- foreach($catids as $catid){
- $time = gmdate("Y-m-d H:i:s");
- $q = sprintf("SELECT deals.*, business.catid from deals LEFT JOIN business ON deals.businessid = business.businessid
- WHERE business.catid ='%s' AND deals.expirytimestamp >= '%s' AND UTC_TIMESTAMP() >= deals.dealtimestamp AND deals.status = 1",
- mysql_real_escape_string($catid),
- $time
- );
- $result = $database->query($q) or die(mysql_error());
- while($dealid = mysql_fetch_array($result)){
- $dealinfo = $business->getDealInfo($dealid['dealid']);
- $businessid = $business->getBusinessId($dealid['dealid']);
- $dealImageLocation = $business->getDealImage($dealid['dealid']);
- $businessImageLocation = $business->getBusinessImage($businessid);
- $dealCat = $business->getCat($catid);
- $deal = $root->appendChild($xml->createElement("deal"));
- $dealid = $deal->appendChild($xml->createElement("dealId"));
- $dealid = $dealid->appendChild($xml->createTextNode($dealinfo['dealid']));
- $dealname = $deal->appendChild($xml->createElement("dealName"));
- $dealname = $dealname->appendChild($xml->createTextNode($dealinfo['dealname']));
- $dealDescription = $deal->appendChild($xml->createElement("dealDescription"));
- $dealDescription = $dealDescription->appendChild($xml->createTextNode($dealinfo['desc']));
- $dealPrice = $deal->appendChild($xml->createElement("dealPrice"));
- $dealPrice = $dealPrice->appendChild($xml->createTextNode($dealinfo['dealoffer']));
- $dealExpiryDate = $deal->appendChild($xml->createElement("dealExpiry"));
- $dealExpiryDate = $dealExpiryDate->appendChild($xml->createTextNode($dealinfo['expirytimestamp']));
- $dealImage = $deal->appendChild($xml->createElement("dealImage"));
- $dealImage = $dealImage->appendChild($xml->createTextNode($dealImageLocation));
- $dealCategory = $deal->appendChild($xml->createElement("dealCategoryId"));
- $dealCategory = $dealCategory->appendChild($xml->createTextNode($catid));
- $dealCatName = $deal->appendChild($xml->createElement("dealCatName"));
- $dealCatName = $dealCatName->appendChild($xml->createTextNode($dealCat));
- $lat = $deal->appendChild($xml->createElement("lat"));
- $lat = $lat->appendChild($xml->createTextNode($businessinfo['lattitude']));
- $long = $deal->appendChild($xml->createElement("long"));
- $long = $long->appendChild($xml->createTextNode($businessinfo['longitude']));
- $merchantId = $deal->appendChild($xml->createElement("merchantId"));
- $merchantId = $merchantId->appendChild($xml->createTextNode($businessinfo['businessid']));
- $merchantName = $deal->appendChild($xml->createElement("merchantName"));
- $merchantName = $merchantName->appendChild($xml->createTextNode($businessinfo['bname']));
- $merchantAddress = $deal->appendChild($xml->createElement("merchantAddress"));
- $merchantName = $merchantAddress->appendChild($xml->createTextNode($businessinfo['street'].", ".$businessinfo['suburb'].", ".$businessinfo['state']));
- }
- }
- //$catid = $categoryid;
- $xml->formatOutput=true;
- print ($result= $xml->saveXML());
- }
- else{ //when neither category or subcategory is given the server will output all the deals...
- $time = gmdate("Y-m-d H:i:s");
- $q = sprintf("SELECT * FROM deals WHERE deals.expirytimestamp >= '%s' AND deals.status = 1", $time);
- $result = $database->query($q) or die(mysql_error());
- $xml = new DOMDocument("1.0");
- $root = $xml->appendChild($xml->createElement("response"));
- while($dealid = mysql_fetch_array($result)){
- $dealinfo = $business->getDealInfo($dealid['dealid']);
- $businessid = $business->getBusinessId($dealid['dealid']);
- $businessinfo = $business->getBusinessInfo($businessid);
- $dealImageLocation = $business->getDealImage($dealid['dealid']);
- $businessImageLocation = $business->getBusinessImage($businessid);
- $dealCat = $business->getCat($dealinfo['catid']);
- $deal = $root->appendChild($xml->createElement("deal"));
- $dealid = $deal->appendChild($xml->createElement("dealId"));
- $dealid = $dealid->appendChild($xml->createTextNode($dealinfo['dealid']));
- $dealname = $deal->appendChild($xml->createElement("dealName"));
- $dealname = $dealname->appendChild($xml->createTextNode($dealinfo['dealname']));
- $dealDescription = $deal->appendChild($xml->createElement("dealDescription"));
- $dealDescription = $dealDescription->appendChild($xml->createTextNode($dealinfo['desc']));
- $dealPrice = $deal->appendChild($xml->createElement("dealPrice"));
- $dealPrice = $dealPrice->appendChild($xml->createTextNode($dealinfo['dealoffer']));
- $dealExpiryDate = $deal->appendChild($xml->createElement("dealExpiry"));
- $dealExpiryDate = $dealExpiryDate->appendChild($xml->createTextNode($dealinfo['expirytimestamp']));
- $dealImage = $deal->appendChild($xml->createElement("dealImage"));
- $dealImage = $dealImage->appendChild($xml->createTextNode($dealImageLocation));
- $dealCategory = $deal->appendChild($xml->createElement("dealCategoryId"));
- $dealCategory = $dealCategory->appendChild($xml->createTextNode($dealinfo['catid']));
- $dealCatName = $deal->appendChild($xml->createElement("dealCatName"));
- $dealCatName = $dealCatName->appendChild($xml->createTextNode($dealCat));
- $lat = $deal->appendChild($xml->createElement("lat"));
- $lat = $lat->appendChild($xml->createTextNode($dealinfo['lattitude']));
- $long = $deal->appendChild($xml->createElement("long"));
- $long = $long->appendChild($xml->createTextNode($dealinfo['longitude']));
- $merchantId = $deal->appendChild($xml->createElement("merchantId"));
- $merchantId = $merchantId->appendChild($xml->createTextNode($dealinfo['businessid']));
- $merchantName = $deal->appendChild($xml->createElement("merchantName"));
- $merchantName = $merchantName->appendChild($xml->createTextNode($dealinfo['bname']));
- $merchantAddress = $deal->appendChild($xml->createElement("merchantAddress"));
- $merchantName = $merchantAddress->appendChild($xml->createTextNode($dealinfo['street'].", ".$dealinfo['suburb'].", ".$dealinfo['state']));
- }
- $xml->formatOutput=true;
- print ($result= $xml->saveXML());
- }
- }
- function registerUser($subemail,$subpassword1,$subgender,$submobile=NULL,$subcategoryid=NULL, $facebookid=NULL){
- global $database,$business, $session, $form;
- if(isset($subcategoryid) && strlen($subcategoryid) > 0){
- $catids = explode("," ,$subcategoryid);
- }
- $result = $session->registeriPhone($subemail,$subpassword1,$subgender,$submobile,$catids);
- if($result == 0){
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $statusTxt = $status->appendChild($xml->createTextNode("Success"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode("CONGRATULATIONS! Welcome to MyPype. You may now log in with the details you had registered with."));
- $result = $xml->saveXML();
- print $result;
- }
- elseif($result == 1){
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Failure"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode($form->error("email").$form->error("password").$form->error("mobile")));
- $result = $xml->saveXML();
- $xml->formatOutput=true;
- print $result;
- }
- elseif($result == 2){
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Failure"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode("Oops Something's wrong. Please Try again Later."));
- $result = $xml->saveXML();
- $xml->formatOutput=true;
- print $result;
- }
- }
- function saveDeal($custid,$dealid,$dealcategory,$dealsubcategory){
- global $database;
- $q = sprintf("INSERT into savedeal VALUES('%s','%s,'%s','%s')",
- mysql_real_escape_string($custid),
- mysql_real_escape_string($dealid),
- mysql_real_escape_string($dealcategoryid),
- mysql_real_escape_string($dealsubcategoryid)
- );
- if($result = $database->query($q) or die(mysql_error())){
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $statusTxt = $status->appendChild($xml->createTextNode("Success"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode(""));
- $result = $xml->saveXML();
- print $result;
- }
- else{
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Failure"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode(""));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- }
- function updateGender($gender, $userid){
- global $database;
- $q = sprintf("UPDATE users set users.gender='%s' where userid = '%s'",
- mysql_real_escape_string($gender),
- mysql_real_escape_string($userid));
- if($result = $database->query($q) or die(mysql_error())){
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $statusTxt = $status->appendChild($xml->createTextNode("Success"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode("Gender updated successfully"));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- else{
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Failure"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode("Fail to update"));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- }
- function login2($regid){
- global $database,$session,$business, $form;
- $result = $session->login2($regid);
- if($result){
- $q = "SELECT * FROM " . TBL_USERS . " WHERE device_uid ='$regid'";
- $valid = $database -> query($q);
- $valid = mysql_fetch_array($valid);
- // $Output = $session->userinfo['userid'];
- $output=$valid['userid'];
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $statusTxt = $status->appendChild($xml->createTextNode("Success"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode($Output));
- $user = $response->appendChild($xml->createElement("user"));
- $id = $user->appendChild($xml->createElement("id"));
- $idTxt = $id->appendChild($xml->createTextNode($Output));
- $notification = $user->appendChild($xml->createElement("notification"));
- $notification = $notification->appendChild($xml->createTextNode($session->userinfo['notification']));
- ////////getsaved categories
- $query = sprintf(" SELECT catid from user_category where userid = '%s'", $Output);
- $resultCategory = $database->query($query) or die(mysql_error());
- if(mysql_num_rows($resultCategory) < 1){
- $catids = Null;
- }
- else{
- while($categoryid = mysql_fetch_assoc($resultCategory)){
- $catids[] = $categoryid['catid'];
- }
- $catids = implode(",", $catids);
- }
- $savedCategory = $user->appendChild($xml->createElement("savedCategory"));
- $savedCategory = $savedCategory->appendChild($xml->createTextNode($catids));
- /////////////categories added to xml
- $XMLcategories = $response->appendChild($xml->createElement("categories"));
- $q = "SELECT * FROM category ORDER BY categoryName";
- $result = $database->query($q) or die(mysql_error());
- while($category = mysql_fetch_array($result)){
- $image = getCategoryImage($category['catid']);
- $XMLcategory = $XMLcategories->appendChild($xml->createElement("category"));
- $categoryid = $XMLcategory->appendChild($xml->createElement("categoryID"));
- $categoryid = $categoryid->appendChild($xml->createTextNode($category['catid']));
- $categoryName= $XMLcategory->appendChild($xml->createElement("categoryName"));
- $categoryName = $categoryName->appendChild($xml->createTextNode($category['categoryName']));
- $categoryParentId = $XMLcategory->appendChild($xml->createElement("categoryParentID"));
- $categoryParentId = $categoryParentId->appendChild($xml->createTextNode($category['parent_id']));
- $categoryImage = $XMLcategory->appendChild($xml->createElement("catImage"));
- $categoryImage = $categoryImage->appendChild($xml->createTextNode($image));
- }
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- if(!$result){
- // $Output = $form->error("user").$form->error("email").$form->error("pass").$form->error("notactivated");
- $q = "INSERT INTO users(regid) VALUES('$regid')";
- $valid = $database -> query($q);
- $Output=0;
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $reg_status = $response->appendChild($xml->createElement("reg_status"));
- $responseText = $reg_status->appendChild($xml->createTextNode("1"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Failure"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode($Output));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- }
- function login($password, $remember=NULL, $email){
- global $database,$session,$business, $form;
- $checkLogin = $session->checkLoginMobile();
- if($checkLogin){
- print $Output = "Already Logged in";
- }
- else{
- $result = $session->login($email,$password,$remember);
- if($result){
- $Output = $session->userinfo['userid'];
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $statusTxt = $status->appendChild($xml->createTextNode("Success"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode($Output));
- $user = $response->appendChild($xml->createElement("user"));
- $id = $user->appendChild($xml->createElement("id"));
- $idTxt = $id->appendChild($xml->createTextNode($Output));
- $notification = $user->appendChild($xml->createElement("notification"));
- $notification = $notification->appendChild($xml->createTextNode($session->userinfo['notification']));
- ////////getsaved categories
- $query = sprintf(" SELECT catid from user_category where userid = '%s'", $Output);
- $resultCategory = $database->query($query) or die(mysql_error());
- if(mysql_num_rows($resultCategory) < 1){
- $catids = Null;
- }
- else{
- while($categoryid = mysql_fetch_assoc($resultCategory)){
- $catids[] = $categoryid['catid'];
- }
- $catids = implode(",", $catids);
- }
- $savedCategory = $user->appendChild($xml->createElement("savedCategory"));
- $savedCategory = $savedCategory->appendChild($xml->createTextNode($catids));
- /////////////categories added to xml
- $XMLcategories = $response->appendChild($xml->createElement("categories"));
- $q = "SELECT * FROM category ORDER BY categoryName";
- $result = $database->query($q) or die(mysql_error());
- while($category = mysql_fetch_array($result)){
- $image = getCategoryImage($category['catid']);
- $XMLcategory = $XMLcategories->appendChild($xml->createElement("category"));
- $categoryid = $XMLcategory->appendChild($xml->createElement("categoryID"));
- $categoryid = $categoryid->appendChild($xml->createTextNode($category['catid']));
- $categoryName= $XMLcategory->appendChild($xml->createElement("categoryName"));
- $categoryName = $categoryName->appendChild($xml->createTextNode($category['categoryName']));
- $categoryParentId = $XMLcategory->appendChild($xml->createElement("categoryParentID"));
- $categoryParentId = $categoryParentId->appendChild($xml->createTextNode($category['parent_id']));
- $categoryImage = $XMLcategory->appendChild($xml->createElement("catImage"));
- $categoryImage = $categoryImage->appendChild($xml->createTextNode($image));
- }
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- if(!$result){
- $Output = $form->error("user").$form->error("email").$form->error("pass").$form->error("notactivated");
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Failure"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode($Output));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- }
- }
- function logOut(){
- global $database,$session,$business;
- $result = $session->logout();
- if($result){
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $statusTxt = $status->appendChild($xml->createTextNode("Success"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode("Logged Out"));
- $result = $xml->saveXML();
- print $result;
- }
- else{
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Failure"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode("Fail to logOut"));
- $result = $xml->saveXML();
- $xml->formatOutput=true;
- print $result;
- }
- }
- function getCategory(){
- global $database, $session,$business;
- $q = "SELECT * FROM category ORDER BY categoryName";
- $result = $database->query($q) or die(mysql_error());
- $xml = new DOMDocument("1.0");
- $root = $xml->appendChild($xml->createElement("response"));
- while($category = mysql_fetch_array($result)){
- $image = getCategoryImage($category['catid']);
- $XMLcategory = $root->appendChild($xml->createElement("category"));
- $categoryid = $XMLcategory->appendChild($xml->createElement("categoryID"));
- $categoryid = $categoryid->appendChild($xml->createTextNode($category['catid']));
- $categoryName= $XMLcategory->appendChild($xml->createElement("categoryName"));
- $categoryName = $categoryName->appendChild($xml->createTextNode($category['categoryName']));
- $categoryParentId = $XMLcategory->appendChild($xml->createElement("categoryParentID"));
- $categoryParentId = $categoryParentId->appendChild($xml->createTextNode($category['parent_id']));
- $categoryImage = $XMLcategory->appendChild($xml->createElement("catImage"));
- $categoryImage = $categoryImage->appendChild($xml->createTextNode($image));
- }
- $xml->formatOutput=true;
- $myXML = $xml->saveXML();
- print $myXML;
- }
- function updateLatLong($lat=NULL, $long=NULL, $devicetoken, $userid ){
- global $database, $business;
- $devicetoken = strtoupper($devicetoken);
- if(($lat || strlen(trim($lat)) !== 0) && (!$long || strlen(trim($long)) !== 0)){
- $query = sprintf("INSERT INTO push VALUES($lat,$long,'%s','%s',1)
- ON DUPLICATE KEY UPDATE push.lat=$lat, push.long=$long", mysql_real_escape_string($devicetoken), mysql_real_escape_string($userid));
- $result = $database->query($query) or die(mysql_error());
- $messageresult = "Latitude Longitude updated";
- }
- else{
- $query = sprintf("INSERT INTO push (device_token,userid, notification) VALUES('%s','%s',1)
- ON DUPLICATE KEY UPDATE push.device_token='%s'",
- mysql_real_escape_string($devicetoken),
- mysql_real_escape_string($userid),
- mysql_real_escape_string($devicetoken));
- $result = $database->query($query) or die(mysql_error());
- $messageresult = "Device Token updated";
- }
- if($result){
- //-----GET THE API FOR GETTING NEARBY DEALS OF THE SUBSCRIBED CATEGORY------//
- $catids = $business->getSavedCategories($userid);
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $statusTxt = $status->appendChild($xml->createTextNode("Success"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode($messageresult));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- else{
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Failure"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode("SEVER BUSY.. TRY AGAIN LATER"));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- }
- function forgotPass($email){
- global $session;
- $result = $session->forgotPassMobile($email);
- if($result == 1){
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $statusTxt = $status->appendChild($xml->createTextNode("Success"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode("A new Password has been sent to the provided Email Address"));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- else{
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Failure"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode("Email Address provided was not found on our records"));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- }
- /*-------Business and deal XML----------//
- * 2 scenarios are handled depending upon mode.
- * In business mode business is extracted first and
- * if a non expired deal is availble is passed through
- * In deal mode , the specific deal is extracted first
- * and the its associated business is passed through
- */
- function getBusinessWithDeal($entityid,$userid,$mode){
- global $database,$business;
- if($mode == "business"){
- //get business from entityid
- $businessinfo = $business->getBusinessInfo($entityid);
- //get deals of business
- $time = gmdate("Y-m-d H:i:s");
- $q = sprintf("SELECT * FROM deals WHERE businessid = '%d' AND deals.expirytimestamp >= '%s' AND UTC_TIMESTAMP() >= deals.dealtimestamp AND deals.status = '1'",
- mysql_real_escape_string($entityid),$time);
- $deals = $database->query($q) or die(mysql_error());
- //create xml
- createBusinessAndDealsXml($businessinfo,$deals,$userid);
- }
- else if($mode == "deal"){
- //get deal from entity id
- $q = sprintf("SELECT * FROM deals WHERE dealid = '%s'", mysql_real_escape_string($entityid));
- $deals = $database->query($q) or die(mysql_error());
- //get business for the deal
- $deal = mysql_fetch_array($deals);
- $businessinfo = $business->getBusinessInfo($deal['businessid']);
- $deals = $database->query($q) or die(mysql_error());
- createBusinessAndDealsXml($businessinfo,$deals,$userid);
- }
- }
- function createBusinessAndDealsXml($businessinfo,$deals,$userid){
- global $database,$business;
- $timing = array(
- 'monday' => $businessinfo['monday'],
- 'tuesday' => $businessinfo['tuesday'],
- 'wednesday' => $businessinfo['wednesday'],
- 'thursday' => $businessinfo['thursday'],
- 'friday' => $businessinfo['friday'],
- 'saturday' => $businessinfo['saturday'],
- 'sunday' => $businessinfo['sunday']);
- // print_r($timing);
- $opentime; $closetime;
- foreach($timing as $day=>$time){
- if($time!=""){
- list($open, $close) = explode("-", $time);
- list($openhour, $openminutes, $openseconds) = explode(":", $open);
- list($closehour, $closeminutes, $closeseconds) = explode(":", $close);
- if(isset($openhour) && isset($openminutes) && isset($openseconds)){
- $opentime[$day]= date("h:i:s A", mktime($openhour,$openminutes, $openseconds));
- $closetime[$day] =date("h:i:s A", mktime($closehour,$closeminutes, $closeseconds));
- }
- }else{
- $opentime[$day]="";
- $closetime[$day]="";
- }
- }
- $businessImage = $business->getBusinessImage($businessinfo['businessid']);
- $businessCategory = $business->getCat($businessinfo['catid']);
- $xml = new DOMDocument("1.0");
- $root = $xml->appendChild($xml->createElement("response"));
- $businessXML = $root->appendChild($xml->createElement("business"));
- $businessId = $businessXML->appendChild($xml->createElement("businessID"));
- $businessId = $businessId->appendChild($xml->createTextNode($businessinfo['businessid']));
- $businessname = $businessXML->appendChild($xml->createElement("businessName"));
- $businessname = $businessname->appendChild($xml->createTextNode($businessinfo['bname']));
- $businessDesc = $businessXML->appendChild($xml->createElement("businessDescription"));
- $businessDesc = $businessDesc->appendChild($xml->createTextNode($businessinfo['bdesc']));
- $businessCatId = $businessXML->appendChild($xml->createElement("businessCatId"));
- $businessCatId = $businessCatId->appendChild($xml->createTextNode($businessinfo['catid']));
- $businessCatName = $businessXML->appendChild($xml->createElement("businessCatName"));
- $businessCatName = $businessCatName->appendChild($xml->createTextNode($businessCategory));
- $businessAdd = $businessXML->appendChild($xml->createElement("businessAddress"));
- $businessname = $businessAdd->appendChild($xml->createTextNode($businessinfo['street'].", ".$businessinfo['suburb'].", ".$businessinfo['state']));
- $businessSite = $businessXML->appendChild($xml->createElement("businessWebsite"));
- $businessSite = $businessSite->appendChild($xml->createTextNode($businessinfo['site']));
- $businessContact = $businessXML->appendChild($xml->createElement("businessContact"));
- $businessContact = $businessContact->appendChild($xml->createTextNode($businessinfo['phone']));
- $businessLat = $businessXML->appendChild($xml->createElement("businessLat"));
- $businessLat = $businessLat->appendChild($xml->createTextNode($businessinfo['lattitude']));
- $businessLong = $businessXML->appendChild($xml->createElement("businessLong"));
- $businessLong = $businessLong->appendChild($xml->createTextNode($businessinfo['longitude']));
- $businessImg = $businessXML->appendChild($xml->createElement("businessImage"));
- $businessImage = $businessImg->appendChild($xml->createTextNode($businessImage));
- $businessTiming = $businessXML->appendChild($xml->createElement("timing"));
- $businessMonday = $businessTiming->appendChild($xml->createElement("monday"));
- if($opentime['monday']!=""){
- $businessMonday = $businessMonday->appendChild($xml->createTextNode($opentime['monday']." - ".$closetime['monday']));
- }else{
- $businessMonday = $businessMonday->appendChild($xml->createTextNode(''));
- }
- $businessMonday = $businessTiming->appendChild($xml->createElement("tuesday"));
- if($opentime['tuesday']!=""){
- $businessMonday = $businessMonday->appendChild($xml->createTextNode($opentime['tuesday']." - ".$opentime['tuesday']));
- }else{
- $businessMonday = $businessMonday->appendChild($xml->createTextNode(''));
- }
- $businessMonday = $businessTiming->appendChild($xml->createElement("wednesday"));
- if($opentime['wednesday']!=""){
- $businessMonday = $businessMonday->appendChild($xml->createTextNode($opentime['wednesday']." - ".$opentime['wednesday']));
- }else{
- $businessMonday = $businessMonday->appendChild($xml->createTextNode(''));
- }
- $businessMonday = $businessTiming->appendChild($xml->createElement("thursday"));
- if($opentime['thursday']!=""){
- $businessMonday = $businessMonday->appendChild($xml->createTextNode($opentime['thursday']." - ".$opentime['thursday']));
- }else{
- $businessMonday = $businessMonday->appendChild($xml->createTextNode(''));
- }
- $businessMonday = $businessTiming->appendChild($xml->createElement("friday"));
- if($opentime['friday']!=""){
- $businessMonday = $businessMonday->appendChild($xml->createTextNode($opentime['friday']." - ".$opentime['friday']));
- }else{
- $businessMonday = $businessMonday->appendChild($xml->createTextNode(''));
- }
- $businessMonday = $businessTiming->appendChild($xml->createElement("saturday"));
- if($opentime['saturday']!=""){
- $businessMonday = $businessMonday->appendChild($xml->createTextNode($opentime['saturday']." - ".$opentime['saturday']));
- }else{
- $businessMonday = $businessMonday->appendChild($xml->createTextNode(''));
- }
- $businessMonday = $businessTiming->appendChild($xml->createElement("sunday"));
- if($opentime['wednesday']!=""){
- $businessMonday = $businessMonday->appendChild($xml->createTextNode($opentime['wednesday']." - ".$opentime['sunday']));
- }else{
- $businessMonday = $businessMonday->appendChild($xml->createTextNode(''));
- }
- $queryrow = sprintf("SELECT * FROM savedbusiness where userid = '%s' and businessid='%s'", mysql_real_escape_string($userid),mysql_real_escape_string($businessinfo['businessid']));
- $businessSaved = $businessXML->appendChild($xml->createElement("businessSaved"));
- $results = $database->query($queryrow) or die(mysql_error());
- $resultrow = mysql_num_rows($results);
- //print $resultrow;
- if($resultrow >= 1){
- //$messageoutput = "This business is already one of your loved businesses";
- $businessSaved = $businessSaved->appendChild($xml->createTextNode("1"));
- }
- else{
- $businessSaved = $businessSaved->appendChild($xml->createTextNode("0"));
- }
- if(mysql_num_rows($deals) >0){
- $dealsXML = $root->appendChild($xml->createElement("deals"));
- while($dealid = mysql_fetch_array($deals)){
- $dealinfo = $business->getDealInfo($dealid['dealid']);
- //$businessid = $business->getBusinessId($dealid['dealid']);
- //$businessinfo = $business->getBusinessInfo($businessid);
- //$dealCat = $business->getCat($dealinfo['catid']);
- $dealImageLocation = $business->getDealImage($dealid['dealid']);
- //$businessImageLocation = $business->getBusinessImage($businessid);
- $deal = $dealsXML->appendChild($xml->createElement("deal"));
- $dealid = $deal->appendChild($xml->createElement("dealId"));
- $dealid = $dealid->appendChild($xml->createTextNode($dealinfo['dealid']));
- $dealname = $deal->appendChild($xml->createElement("dealName"));
- $dealname = $dealname->appendChild($xml->createTextNode($dealinfo['dealname']));
- $dealDescription = $deal->appendChild($xml->createElement("dealDescription"));
- $dealDescription = $dealDescription->appendChild($xml->createTextNode($dealinfo['desc']));
- $dealPrice = $deal->appendChild($xml->createElement("dealPrice"));
- $dealPrice = $dealPrice->appendChild($xml->createTextNode($dealinfo['dealoffer']));
- $dealExpiryDate = $deal->appendChild($xml->createElement("dealExpiry"));
- $dealExpiryDate = $dealExpiryDate->appendChild($xml->createTextNode($dealinfo['expirytimestamp']));
- $dealImage = $deal->appendChild($xml->createElement("dealImage"));
- $dealImage = $dealImage->appendChild($xml->createTextNode($dealImageLocation));
- // $dealCategory = $deal->appendChild($xml->createElement("dealCategoryId"));
- // $dealCategory = $dealCategory->appendChild($xml->createTextNode($dealinfo['catid']));
- //
- // $dealCatName = $deal->appendChild($xml->createElement("dealCatName"));
- // $dealCatName = $dealCatName->appendChild($xml->createTextNode($dealCat));
- //
- // $lat = $deal->appendChild($xml->createElement("lat"));
- // $lat = $lat->appendChild($xml->createTextNode($dealinfo['lattitude']));
- //
- // $long = $deal->appendChild($xml->createElement("long"));
- // $long = $long->appendChild($xml->createTextNode($dealinfo['longitude']));
- //
- // $merchantId = $deal->appendChild($xml->createElement("merchantId"));
- // $merchantId = $merchantId->appendChild($xml->createTextNode($dealinfo['businessid']));
- //
- // $merchantName = $deal->appendChild($xml->createElement("merchantName"));
- // $merchantName = $merchantName->appendChild($xml->createTextNode($dealinfo['bname']));
- //
- // $merchantAddress = $deal->appendChild($xml->createElement("merchantAddress"));
- // $merchantName = $merchantAddress->appendChild($xml->createTextNode($dealinfo['street'].", ".$dealinfo['suburb'].", ".$dealinfo['state']));
- //
- }
- }
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- //fetching full detail of business
- function getBusinessInfo($businessid){
- global $business;
- $businessinfo = $business->getBusinessInfo($businessid);
- $timing = array(
- monday => $businessinfo['monday'],
- tuesday => $businessinfo['tuesday'],
- wednesday => $businessinfo['wednesday'],
- thursday => $businessinfo['thursday'],
- friday => $businessinfo['friday'],
- saturday => $businessinfo['saturday'],
- sunday => $businessinfo['sunday']);
- // print_r($timing);
- $opentime; $closetime;
- foreach($timing as $day=>$time){
- list($open, $close) = explode("-", $time);
- list($openhour, $openminutes, $openseconds) = explode(":", $open);
- list($closehour, $closeminutes, $closeseconds) = explode(":", $close);
- if(isset($openhour) && isset($openminutes) && isset($openseconds)){
- $opentime[$day]= date("h:i:s A", mktime($openhour,$openminutes, $openseconds));
- $closetime[$day] =date("h:i:s A", mktime($closehour,$closeminutes, $closeseconds));
- }
- }
- $businessImage = $business->getBusinessImage($businessid);
- $businessCategory = $business->getCat($businessinfo['catid']);
- $xml = new DOMDocument("1.0");
- $root = $xml->appendChild($xml->createElement("response"));
- $businessId = $root->appendChild($xml->createElement("businessID"));
- $businessId = $businessId->appendChild($xml->createTextNode($businessinfo['businessid']));
- $businessname = $root->appendChild($xml->createElement("businessName"));
- $businessname = $businessname->appendChild($xml->createTextNode($businessinfo['bname']));
- $businessDesc = $root->appendChild($xml->createElement("businessDescription"));
- $businessDesc = $businessDesc->appendChild($xml->createTextNode($businessinfo['bdesc']));
- $businessCatId = $root->appendChild($xml->createElement("businessCatId"));
- $businessCatId = $businessCatId->appendChild($xml->createTextNode($businessinfo['catid']));
- $businessCatName = $root->appendChild($xml->createElement("businessCatName"));
- $businessCatName = $businessCatName->appendChild($xml->createTextNode($businessCategory));
- $businessAdd = $root->appendChild($xml->createElement("businessAddress"));
- $businessname = $businessAdd->appendChild($xml->createTextNode($businessinfo['street'].", ".$businessinfo['suburb'].", ".$businessinfo['state']));
- $businessSite = $root->appendChild($xml->createElement("businessWebsite"));
- $businessSite = $businessSite->appendChild($xml->createTextNode($businessinfo['site']));
- $businessContact = $root->appendChild($xml->createElement("businessContact"));
- $businessContact = $businessContact->appendChild($xml->createTextNode($businessinfo['phone']));
- $businessLat = $root->appendChild($xml->createElement("businessLat"));
- $businessLat = $businessLat->appendChild($xml->createTextNode($businessinfo['lattitude']));
- $businessLong = $root->appendChild($xml->createElement("businessLong"));
- $businessLong = $businessLong->appendChild($xml->createTextNode($businessinfo['longitude']));
- $businessImg = $root->appendChild($xml->createElement("businessImage"));
- $businessImage = $businessImg->appendChild($xml->createTextNode($businessImage));
- $businessTiming = $root->appendChild($xml->createElement("timing"));
- $businessMonday = $businessTiming->appendChild($xml->createElement("monday"));
- $businessMonday = $businessMonday->appendChild($xml->createTextNode($opentime['monday']." - ".$closetime['monday']));
- $businessMonday = $businessTiming->appendChild($xml->createElement("tuesday"));
- $businessMonday = $businessMonday->appendChild($xml->createTextNode($opentime['tuesday']." - ".$closetime['tuesday']));
- $businessMonday = $businessTiming->appendChild($xml->createElement("wednesday"));
- $businessMonday = $businessMonday->appendChild($xml->createTextNode($opentime['wednesday']." - ".$closetime['wednesday']));
- $businessMonday = $businessTiming->appendChild($xml->createElement("thursday"));
- $businessMonday = $businessMonday->appendChild($xml->createTextNode($opentime['thursday']." - ".$closetime['thursday']));
- $businessMonday = $businessTiming->appendChild($xml->createElement("friday"));
- $businessMonday = $businessMonday->appendChild($xml->createTextNode($opentime['friday']." - ".$closetime['friday']));
- $businessMonday = $businessTiming->appendChild($xml->createElement("saturday"));
- $businessMonday = $businessMonday->appendChild($xml->createTextNode($opentime['saturday']." - ".$closetime['saturday']));
- $businessMonday = $businessTiming->appendChild($xml->createElement("sunday"));
- $businessMonday = $businessMonday->appendChild($xml->createTextNode($opentime['sunday']." - ".$closetime['sunday']));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- function getProfile($userid){
- global $session, $database, $business;
- $q = sprintf("SELECT users.*, savedbusiness.businessid from users LEFT JOIN
- savedbusiness on users.userid = savedbusiness.userid WHERE users.userid= '%s'", mysql_real_escape_string($userid));
- $result = $database->query($q) or die(mysql_error());
- if(!$result || mysql_num_rows($result) < 1){
- return;
- }
- $userinfo = mysql_fetch_assoc($result);
- $query = sprintf(" SELECT catid from user_category where userid = '%s'", $userid);
- $resultCategory = $database->query($query) or die(mysql_error());
- if(mysql_num_rows($resultCategory) < 1){
- $catids = Null;
- }
- else{
- while($categoryid = mysql_fetch_assoc($resultCategory)){
- $catids[] = $categoryid['catid'];
- }
- $catids = implode(",", $catids);
- }
- //$category = $business->getCat($categoryid['catid']);
- $businessinfo = $business->getBusinessInfo($userinfo['businessid']);
- $xml = new DOMDocument("1.0");
- $root = $xml->appendChild($xml->createElement("response"));
- $email = $root->appendChild($xml->createElement("email"));
- $email = $email->appendChild($xml->createTextNode($userinfo['email']));
- $gender = $root->appendChild($xml->createElement("gender"));
- $gender = $gender->appendChild($xml->createTextNode($userinfo['gender']));
- $savedBusiness = $root->appendChild($xml->createElement("savedBusiness"));
- $saveBusiness = $savedBusiness->appendChild($xml->createTextNode($businessinfo['bname']));
- $notification = $root->appendChild($xml->createElement("notification"));
- $notification = $notification->appendChild($xml->createTextNode($userinfo['notification']));
- $savedCategory = $root->appendChild($xml->createElement("savedCategory"));
- $savedCategory = $savedCategory->appendChild($xml->createTextNode($catids));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- function changePassword($currentPass, $newPass, $userid){
- global $database, $session;
- $status = $database->confirmUserPassword($userid, md5($currentPass));
- if($status == 1 || $status == 2){
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Failure"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode("Current Password or userid is invalid"));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- elseif($status == 0){
- $q = sprintf("UPDATE users set password = '%s' where userid='%s'", md5($newPass), $userid);
- $result = $database->query($q) or die(mysql_error());
- if($result){
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $statusTxt = $status->appendChild($xml->createTextNode("Success"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode("Your Password has been changed successfully"));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- }
- }
- function saveFavCategory($catid, $userid, $mode){
- global $database;
- if($mode == "save"){
- $queryrow = sprintf("SELECT * FROM user_category where userid = '%s' and catid='%s'", mysql_real_escape_string($userid),
- mysql_real_escape_string($catid));
- $results = $database->query($queryrow) or die(mysql_error());
- $resultrow = mysql_num_rows($results);
- //print $resultrow;
- if($resultrow >= 1){
- $messageoutput = "Category already Added as Favourite";
- }
- else{
- $queryinsert = sprintf("INSERT INTO user_category VALUES('%s', '%s')",
- mysql_real_escape_string($userid),
- mysql_real_escape_string($catid));
- $resultinsert = $database->query($queryinsert) or die(mysql_error());
- $messageoutput ="Category added successfully to your favourite list";
- }
- }
- elseif($mode == "delete"){
- $query = sprintf("DELETE FROM user_category WHERE catid = '%s'", mysql_real_escape_string($catid));
- $resultdelete = $database->query($query);
- $messageoutput ="Category removed successfully from your fav list";
- }
- if($resultdelete || $resultinsert){
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Success"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode($messageoutput));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- else{
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Failure"));
- $message = $response->appendChild($xml->createElement("message"));
- $message = $message->appendChild($xml->createTextNode($messageoutput));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- }
- function saveFavBusiness($businessid, $userid, $mode){
- global $database;
- if($mode == "save"){
- $queryrow = sprintf("SELECT * FROM savedbusiness where userid = '%s' and businessid='%s'", mysql_real_escape_string($userid),
- mysql_real_escape_string($businessid));
- $results = $database->query($queryrow) or die(mysql_error());
- $resultrow = mysql_num_rows($results);
- //print $resultrow;
- if($resultrow >= 1){
- $messageoutput = "This place is already one of your 'myLoved' places";
- }
- else{
- $queryinsert = sprintf("INSERT INTO savedbusiness VALUES('%s', '%s')",
- mysql_real_escape_string($userid),
- mysql_real_escape_string($businessid));
- $resultinsert = $database->query($queryinsert);
- $queryinsertloved = sprintf("INSERT INTO loved (userid,businessid,action) VALUES('%s', '%s','0')",
- mysql_real_escape_string($userid),
- mysql_real_escape_string($businessid));
- $resultinsertloved = $database->query($queryinsertloved) or die(mysql_error());
- }
- }
- elseif($mode == "delete"){
- $query = sprintf("DELETE FROM savedbusiness WHERE businessid = '%s' and userid = '%s'",
- mysql_real_escape_string($businessid),
- mysql_real_escape_string($userid));
- $resultdelete = $database->query($query);
- $queryloved = sprintf("INSERT INTO loved (userid,businessid,action) VALUES('%s', '%s','1')",
- mysql_real_escape_string($userid),
- mysql_real_escape_string($businessid)
- );
- $resultdeleteloved = $database->query($queryloved);
- }
- if($resultdelete || $resultinsert){
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Success"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode("Your Favourite business has been updated successfully"));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- else{
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Failure"));
- $message = $response->appendChild($xml->createElement("message"));
- $message = $message->appendChild($xml->createTextNode($messageoutput));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- }
- function updateNotificationStatus($userid, $status){
- global $database;
- $q = sprintf("SELECT * FROM push where userid='%s'", mysql_real_escape_string($userid));
- $result = mysql_num_rows($database->query($q));
- if($status == "on"){
- global $database;
- $query = sprintf("UPDATE users SET users.notification = '1' WHERE userid='%s'", mysql_real_escape_string($userid));
- $result = $database->query($query) or die(mysql_error());
- $outputMsg = "Notification has been turned On Successfully";
- }
- if($status == "off"){
- global $database;
- $query = sprintf("UPDATE users SET users.notification = '0' WHERE userid='%s'", mysql_real_escape_string($userid));
- $result = $database->query($query) or die(mysql_error());
- $outputMsg = "Notification has been turned Off Successfully";
- }
- if($result){
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Success"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode($outputMsg));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- else{
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Failure"));
- $message = $response->appendChild($xml->createElement("message"));
- $message = $message->appendChild($xml->createTextNode($outputMsg));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- }
- function getFavBusiness($userid, $catid = NULL){
- global $database, $business, $session;
- if(isset($catid) && strlen(trim($catid)) !== 0){
- $allCatIds = getTree($catid);
- $xml = new DOMDocument("1.0");
- $root = $xml->appendChild($xml->createElement("response"));
- foreach($allCatIds as $catid){
- $q = sprintf("SELECT business.businessid, savedbusiness.* FROM business
- INNER JOIN savedbusiness ON business.businessid= savedbusiness.businessid
- WHERE business.catid= '$catid'
- AND savedbusiness.userid = '%s'", mysql_real_escape_string($userid));
- $data = $database->query($q) or die(mysql_error());
- while($businessinfo = mysql_fetch_assoc($data)){
- $bid = $businessinfo['businessid'];
- $image = $business->getBusinessImage($bid);
- $info = $business->getBusinessInfo($bid);
- $businessCategoryName = $business->getCat($businessinfo['catid']);
- $time = gmdate("Y-m-d H:i:s");
- $q = sprintf("SELECT * FROM deals WHERE businessid = '%s' AND deals.expirytimestamp >= '$time' AND UTC_TIMESTAMP() >= deals.dealtimestamp AND deals.status = 1",
- mysql_real_escape_string($bid));
- $resultdeals = $database->query($q) or die(mysql_error());
- $numrow = mysql_num_rows($resultdeals);
- $businessnode = $root->appendChild($xml->createElement("business"));
- $businessid = $businessnode->appendChild($xml->createElement("businessid"));
- $businessid = $businessid->appendChild($xml->createTextNode($info['businessid']));
- $businessname = $businessnode->appendChild($xml->createElement("businessname"));
- $businessname = $businessname->appendChild($xml->createTextNode($info['bname']));
- $businessDesc = $businessnode->appendChild($xml->createElement("businessDescription"));
- $businessDesc = $businessDesc->appendChild($xml->createTextNode($info['bdesc']));
- $businessCategory = $businessnode->appendChild($xml->createElement("businessCatId"));
- $businessCategory = $businessCategory->appendChild($xml->createTextNode($info['catid']));
- $businessCatName = $businessnode->appendChild($xml->createElement("businessCatName"));
- $businessCatName = $businessCatName->appendChild($xml->createTextNode($businessCategoryName));
- $businessAdd = $businessnode->appendChild($xml->createElement("businessAddress"));
- $businessname = $businessAdd->appendChild($xml->createTextNode($info['suburb']));
- $businessSite = $businessnode->appendChild($xml->createElement("businessWebsite"));
- $businessSite = $businessSite->appendChild($xml->createTextNode($info['site']));
- $businessContact = $businessnode->appendChild($xml->createElement("businessContact"));
- $businessContact = $businessContact->appendChild($xml->createTextNode($info['phone']));
- $businessLat = $businessnode->appendChild($xml->createElement("businessLat"));
- $businessLat = $businessLat->appendChild($xml->createTextNode($info['lattitude']));
- $businessLong = $businessnode->appendChild($xml->createElement("businessLong"));
- $businessLong = $businessLong->appendChild($xml->createTextNode($info['longitude']));
- $businessImg = $businessnode->appendChild($xml->createElement("businessImage"));
- $businessImage = $businessImg->appendChild($xml->createTextNode($image));
- $businessDeals = $businessnode->appendChild($xml->createElement("availableDeals"));
- $businessDeals = $businessDeals->appendChild($xml->createTextNode($numrow));
- }
- }
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- else{
- $info = $business->getSavedBusiness($userid);
- $num = count($info);
- $xml = new DOMDocument("1.0");
- $root = $xml->appendChild($xml->createElement("response"));
- for($i=0; $i<$num; $i++){
- //-------CHECKING FOR THE DEALS NOW---------//
- $image = $business->getBusinessImage($info[$i]['businessid']);
- $businessCategoryName = $business->getCat($info[$i]['catid']);
- $time = gmdate("Y-m-d H:i:s");
- $q = sprintf("SELECT * FROM deals WHERE businessid = '%s' AND deals.expirytimestamp >= '$time' AND UTC_TIMESTAMP() >= deals.dealtimestamp AND deals.status = 1",
- mysql_real_escape_string($info[$i]['businessid']));
- $resultdeals = $database->query($q) or die(mysql_error());
- $numrow = mysql_num_rows($resultdeals);
- $businessnode = $root->appendChild($xml->createElement("business"));
- $businessid = $businessnode->appendChild($xml->createElement("businessid"));
- $businessid = $businessid->appendChild($xml->createTextNode($info[$i]['businessid']));
- $businessname = $businessnode->appendChild($xml->createElement("businessname"));
- $businessname = $businessname->appendChild($xml->createTextNode($info[$i]['bname']));
- $businessDesc = $businessnode->appendChild($xml->createElement("businessDescription"));
- $businessDesc = $businessDesc->appendChild($xml->createTextNode($info[$i]['bdesc']));
- $businessCategory = $businessnode->appendChild($xml->createElement("businessCatId"));
- $businessCategory = $businessCategory->appendChild($xml->createTextNode($info[$i]['catid']));
- $businessCatName = $businessnode->appendChild($xml->createElement("businessCatName"));
- $businessCatName = $businessCatName->appendChild($xml->createTextNode($businessCategoryName));
- $businessAdd = $businessnode->appendChild($xml->createElement("businessAddress"));
- $businessname = $businessAdd->appendChild($xml->createTextNode($info[$i]['suburb']));
- $businessSite = $businessnode->appendChild($xml->createElement("businessWebsite"));
- $businessSite = $businessSite->appendChild($xml->createTextNode($info[$i]['site']));
- $businessContact = $businessnode->appendChild($xml->createElement("businessContact"));
- $businessContact = $businessContact->appendChild($xml->createTextNode($info[$i]['phone']));
- $businessLat = $businessnode->appendChild($xml->createElement("businessLat"));
- $businessLat = $businessLat->appendChild($xml->createTextNode($info[$i]['lattitude']));
- $businessLong = $businessnode->appendChild($xml->createElement("businessLong"));
- $businessLong = $businessLong->appendChild($xml->createTextNode($info[$i]['longitude']));
- $businessImg = $businessnode->appendChild($xml->createElement("businessImage"));
- $businessImage = $businessImg->appendChild($xml->createTextNode($image));
- $businessDeals = $businessnode->appendChild($xml->createElement("availableDeals"));
- $businessDeals = $businessDeals->appendChild($xml->createTextNode($numrow));
- }
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- }
- function updateFavCategories($subcatids=NULL, $userid){
- global $database;
- $querydel = sprintf("DELETE FROM user_category WHERE userid = '%s'", mysql_real_escape_string($userid));
- $resultdel = $database->query($querydel) or die(mysql_error());
- if($resultdel && strlen(trim($subcatids)) !== 0){
- $q = "INSERT INTO user_category(userid, catid) VALUES ";
- $subcatids = explode("," ,$subcatids);
- foreach ($subcatids as $catid){
- $values[] = "('".$userid."','".$catid."')";
- }
- $newvalues = implode(",", $values);
- $q .= $newvalues;
- $result = $database->query($q) or die(mysql_error());
- }
- file_put_contents("response.txt", $subcatids);
- if($result){
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Success"));
- $message = $response->appendChild($xml->createElement("message"));
- $messageTxt = $message->appendChild($xml->createTextNode("Your fav category list has been Updated"));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- else{
- $xml = new DOMDocument("1.0");
- $response = $xml->appendChild($xml->createElement("response"));
- $status = $response->appendChild($xml->createElement("status"));
- $responseText = $status->appendChild($xml->createTextNode("Failure"));
- $message = $response->appendChild($xml->createElement("message"));
- $message = $message->appendChild($xml->createTextNode("Category list update failed. Please try again later"));
- $xml->formatOutput=true;
- $result = $xml->saveXML();
- print $result;
- }
- }
- function searchBusiness($business_name,$userid)
- {
- global $database, $session,$business;
- $querySearch = "select * FROM business WHERE bname like '%".$business_name."%'";
- $resultSearch = $database->query($querySearch) or die(mysql_error());
- $xml = new DOMDocument("1.0");
- $root = $xml->appendChild($xml->createElement("response"));
- $opentime; $closetime;
- while($business_search = mysql_fetch_array($resultSearch)){
- $businessid=$business_search['businessid'];
- $businessinfo = $business->getBusinessInfo($businessid);
- $queryrow = sprintf("SELECT * FROM savedbusiness where userid = '%s' and businessid='%s'", mysql_real_escape_string($userid),
- mysql_real_escape_string($businessid));
- $results = $database->query($queryrow) or die(mysql_error());
- $resultrow = mysql_num_rows($results);
- if(isset($businessinfo['monday']))
- {
- $timing = array('monday' => $businessinfo['monday'],
- 'tuesday' => $businessinfo['tuesday'],
- 'wednesday' => $businessinfo['wednesday'],
- 'thursday' => $businessinfo['thursday'],
- 'friday' => $businessinfo['friday'],
- 'saturday' => $businessinfo['saturday'],
- 'sunday' => $businessinfo['sunday']);
- }
- foreach($timing as $day=>$time)
- {
- if($time!='')
- {
- list($open, $close) = explode("-", $time);
- }
- list($openhour, $openminutes, $openseconds) = explode(":", $open);
- list($closehour, $closeminutes, $closeseconds) = explode(":", $close);
- if(isset($openhour) && isset($openminutes) && isset($openseconds))
- {
- $opentime[$day]= date("h:i:s A", mktime($openhour,$openminutes, $openseconds));
- $closetime[$day] =date("h:i:s A", mktime($closehour,$closeminutes, $closeseconds));
- }
- }
- $businessImage = $business->getBusinessImage($business_search['businessid']);
- $businessCategory = $business->getCat($business_search['catid']);
- $XMLbusiness = $root->appendChild($xml->createElement("business"));
- $businessid = $XMLbusiness->appendChild($xml->createElement("businessid"));
- $businessid = $businessid->appendChild($xml->createTextNode($business_search['businessid']));
- $businessname = $XMLbusiness->appendChild($xml->createElement("businessname"));
- $businessname = $businessname->appendChild($xml->createTextNode($business_search['bname']));
- $businessDesc = $XMLbusiness->appendChild($xml->createElement("businessDescription"));
- $businessDesc = $businessDesc->appendChild($xml->createTextNode($business_search['bdesc']));
- $businessCatId = $XMLbusiness->appendChild($xml->createElement("businessCatId"));
- $businessCatId = $businessCatId->appendChild($xml->createTextNode($business_search['catid']));
- $businessCatName = $XMLbusiness->appendChild($xml->createElement("businessCatName"));
- $businessCatName = $businessCatName->appendChild($xml->createTextNode($businessCategory));
- $businessAdd = $XMLbusiness->appendChild($xml->createElement("businessAddress"));
- $businessname = $businessAdd->appendChild($xml->createTextNode($business_search['street'].", ".$business_search['suburb'].", ".$business_search['state']));
- $businessSite = $XMLbusiness->appendChild($xml->createElement("businessWebsite"));
- $businessSite = $businessSite->appendChild($xml->createTextNode($business_search['site']));
- $businessContact = $XMLbusiness->appendChild($xml->createElement("businessContact"));
- $businessContact = $businessContact->appendChild($xml->createTextNode($business_search['phone']));
- $businessLat = $XMLbusiness->appendChild($xml->createElement("businessLat"));
- $businessLat = $businessLat->appendChild($xml->createTextNode($business_search['lattitude']));
- $businessLong = $XMLbusiness->appendChild($xml->createElement("businessLong"));
- $businessLong = $businessLong->appendChild($xml->createTextNode($business_search['longitude']));
- $businessImg = $XMLbusiness->appendChild($xml->createElement("businessImage"));
- $businessImage = $businessImg->appendChild($xml->createTextNode($businessImage));
- $businessTiming = $XMLbusiness->appendChild($xml->createElement("businessTiming"));
- if(isset($opentime['monday']) && isset($closetime['monday']))
- {
- $businessMonday = $XMLbusiness->appendChild($xml->createElement("businessMonday"));
- $businessMonday = $businessMonday->appendChild($xml->createTextNode($opentime['monday']." - ".$closetime['monday']));
- }
- if(isset($opentime['tuesday']) && isset($closetime['tuesday']))
- {
- $businessTuesday = $XMLbusiness->appendChild($xml->createElement("businessTuesday"));
- $businessTuesday = $businessTuesday->appendChild($xml->createTextNode($opentime['tuesday']." - ".$closetime['tuesday']));
- }
- if(isset($opentime['wednesday']) && isset($closetime['wednesday']))
- {
- $businessWednesday = $XMLbusiness->appendChild($xml->createElement("businessWednesday"));
- $businessWednesday = $businessWednesday->appendChild($xml->createTextNode($opentime['wednesday']." - ".$closetime['wednesday']));
- }
- if(isset($opentime['thursday']) && isset($closetime['thursday']))
- {
- $businessThursday = $XMLbusiness->appendChild($xml->createElement("businessThursday"));
- $businessThursday = $businessThursday->appendChild($xml->createTextNode($opentime['thursday']." - ".$closetime['thursday']));
- }
- if(isset($opentime['friday']) && isset($closetime['friday']))
- {
- $businessFriday = $XMLbusiness->appendChild($xml->createElement("businessFriday"));
- $businessFriday = $businessFriday->appendChild($xml->createTextNode($opentime['friday']." - ".$closetime['friday']));
- }
- if(isset($opentime['saturday']) && isset($closetime['saturday']))
- {
- $businessSaturday = $XMLbusiness->appendChild($xml->createElement("businessSaturday"));
- $businessSaturday = $businessSaturday->appendChild($xml->createTextNode($opentime['saturday']." - ".$closetime['saturday']));
- }
- if(isset($opentime['sunday']) && isset($closetime['sunday']))
- {
- $businessSunday = $XMLbusiness->appendChild($xml->createElement("businessSunday"));
- $businessSunday = $businessSunday->appendChild($xml->createTextNode($opentime['sunday']." - ".$closetime['sunday']));
- }
- $businessSaved = $XMLbusiness->appendChild($xml->createElement("businessSaved"));
- $businessSaved = $businessSaved->appendChild($xml->createTextNode($resultrow));
- }
- $xml->formatOutput=true;
- $myXML = $xml->saveXML();
- print $myXML;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement