}else{ */ if (isset($_REQUEST['cust_id']) && isset($_REQUEST['subs_id']) && isset($_REQUEST['ref'])) { $db->db_connect(); $cust_id = $_REQUEST['cust_id']; $url = '/customers/' . $cust_id . '/subscriptions.xml'; $result = $connector->sendRequest($url, $format = 'xml', $method = 'GET', $data = ''); if ($result->code == 200) { $objxml = simplexml_load_string($result->response); $state = $objxml->subscription->state; $expiry = $objxml->subscription->current_period_ends_at; $subs_id = $_REQUEST['subs_id']; $fname = $objxml->subscription->customer->first_name; $lname = $objxml->subscription->customer->last_name; $email = $objxml->subscription->customer->email; $productId = $objxml->subscription->product->id; $cust_id = $_REQUEST['cust_id']; $date = date('Y-m-d h:i:s'); $gId = $_REQUEST['ref']; $_SESSION['newcreated'] = time(); mysql_query("UPDATE businessUserGroup SET chargify_cust_id ={$cust_id}, subscription_id ={$subs_id} , email='{$email}',state='{$state}',addLoc=0,productId={$productId},expiration='{$expiry}' WHERE gId={$gId}"); $result = mysql_query("SELECT id FROM businessUsers WHERE userGroupId={$gId} AND permission = 0") or die(mysql_error()); $row = mysql_fetch_object($result); $cookie = new cookie(); $cookie->setCookie($row->id); $db->db_disconnect(); header("Location: index.html"); } else { die('internal server error'); } } //}
case 'signup': include_once 'class/class.cookie.php'; $fname = mysql_real_escape_string($_REQUEST['fname']); $lname = mysql_real_escape_string($_REQUEST['lname']); $email = mysql_real_escape_string($_REQUEST['email']); $pwd = mysql_real_escape_string($_REQUEST['pwd']); $date = date('Y-m-d H:i:s'); $plan = $connect->liteID; $result = mysql_query("INSERT INTO businessUserGroup SET productId=" . $plan . ", email='{$email}',state='active',addLoc=0,created='{$date}',type=0,expiration=''") or die(mysql_error()); $groupId = mysql_insert_id(); echo json_encode(array('type' => $plan, 'groupId' => $groupId)); $sql = "INSERT INTO businessUsers SET userGroupId={$groupId},fname='{$fname}',lname='{$lname}',pwd='" . $pwd . "',email='{$email}'"; mysql_query($sql) or die(mysql_error()); $lastid = mysql_insert_id(); $cookie = new cookie(); $cookie->setCookie($lastid); $time = time(); $name = $fname . ' ' . $lname; //optional $join_date = round(time() / 60) * 60; mysql_query('INSERT INTO subscribers (userID, email, name, custom_fields, list, timestamp, join_date) VALUES (1, "' . $email . '", "' . $name . '", "", 2, ' . $time . ', ' . $join_date . ')'); break; case 'wizardsetupdone': $placeid = $_REQUEST['placeId']; $sql = "UPDATE `businessList` SET `setup` = 1 WHERE `id` = {$placeid}"; mysql_query($sql) or die(mysql_error()); break; case 'texthour': $placeId = $_REQUEST['placeId']; $val = $_REQUEST['val']; $result = mysql_query("SELECT id FROM businessOpeningHours WHERE openingPlaceId = {$placeId}");