'; $result = mysql_query($query) or die("Insert order query failed"); $_SESSION[ 'order_id' ] = mysql_insert_id(); //print 'order_id1: ' . $_SESSION[ 'order_id' ] . '
'; if( $_SESSION['enroll_type'] == 'purchase' ) { $query = " update customer " . " set " . "first_name" . " = '" . $_POST['billTo_firstName'] . "', " . " last_name" . " = '" . $_POST['billTo_lastName'] . "', " . " street1" . " = '" . $_POST['billTo_street1'] . "', " . " street2" . " = '" . $_POST['billTo_street2'] . "', " . " city" . " = '" . $_POST['billTo_city'] . "', " . " state" . " = '" . $_POST['billTo_state'] . "', " . " postal_code" . " = '" . $_POST['billTo_postalCode'] . "', " . " country" . " = '" . $_POST['billTo_country'] . "', " . " phone_area_code" . " = '" . $_POST['area_code'] . "', " . " phone_prefix" . " = '" . $_POST['prefix'] . "', " . " phone_suffix" . " = '" . $_POST['suffix'] . "' " . " where customer_id = " . $_SESSION[ 'customer_id' ] . ""; //print $query . "

"; $result = mysql_query($query) or die("Update customer_info query failed"); } } function checkUserDomain( $sUsername, $sDomain ) { include '../base/cpanel_account_vars.inc'; //Checking to see if username already exists $aAccounts = listaccts($host,$user,$accesshash,$usessl); //print_r( array_keys( $aAccounts ) ); //alert( 'sUsername: ' . $sUsername . ' sDomain: ' . $sUsername . ' accounts_username: ' . $aAccounts[ $sUsername ][ 0 ] ); //first check to see if the automatically created username already exists in cpanel if( !array_key_exists( $sUsername, $aAccounts ) ) { return $sUsername; } else { //alert( 'debug1' ); //make sure that the automatically created username is associated with the domain name that is being attempted to be updated if( $aAccounts[ $sUsername ][ 0 ] == $sDomain ) { //if the logged in user owns a domain, ensure it is the same one that the user in cpanel is associated with //alert( count( $_SESSION[ 'hosting_current_domains' ] ) ); if( count( $_SESSION[ 'hosting_current_domains' ] ) == 0 ) { return $sUsername; } else { if( gettype( $_SESSION[ 'hosting_current_domains' ] ) == 'array' ) { if( in_array( $aAccounts[ $sUsername ][ 0 ], $_SESSION[ 'hosting_current_domains' ] ) ) { return $sUsername; } else { alert( 'You are not authorized to modify settings for the domain: ' . $aAccounts[ $sUsername ][ 0 ] . '. Contact us with any questions.' ); return ''; } } } } else { //Should do something here to create a unique username $sChangeUsername = $sUsername; $i = 0; while( array_key_exists( $sChangeUsername, $aAccounts ) ) { $iStrlen = strlen( $i ); $iSubstr = 8 - $iStrlen; $sChangeUsername = substr( $sUsername, 0, $iSubstr ) . $i; //alert( $sChangeUsername ); $i++; if( $i > 9999999 ) { alert( 'Error. Contact system admin.' ); return ''; } } return $sChangeUsername; } //alert( 'debug1' ); } } function updateOrderStatus( $sDecision, $iOrderID, $sCYBSubscriptionID, $iAmount, $bOwner, $sSubscriptionStatus ) { if( $bOwner or $sSubscriptionStatus == 'TRY' ) { $query = " update subscription " . " set " . "subscription_status" . " = '" . $sDecision . "', " . " amount = " . $iAmount . " where order_id = " . $iOrderID . ""; //print $query . "

"; $result = mysql_query($query) or die("Update subscription_status query failed"); } else { $query = " insert into subscription " . " ( " . " order_id, " . " cyb_subscription_id, " . " amount, " . " subscription_status " . " ) " . " values " . " ( " . $iOrderID . ", " . "'" . $sCYBSubscriptionID . "', " . " " . $iAmount . ", " . " '" . $sDecision . "' " . " ) "; //print 'query: ' . $query . '
'; $result = mysql_query($query) or die("Insert subscription query failed"); $_SESSION[ 'subscription_id' ] = mysql_insert_id(); } $query = " update orders " . " set " . "order_status" . " = '" . $sDecision . "' " . " where order_id = " . $iOrderID . ""; //print $query . "

"; $result = mysql_query($query) or die("Update order_status query failed"); } function updateGalleryOrderStatus( $iOrderID, $iAddStorage, $bOwner, $sSubscriptionStatus ) { $query = " insert into order_item " . " ( " . " order_id, " . " description, " . " units " . " ) " . " values " . " ( " . " " . $iOrderID . ", " . " " . "'additional gallery storage'," . " " . " " . $iAddStorage . " " . " ) "; //print 'query: ' . $query . '
'; $result = mysql_query($query) or die("Insert order_item: additional gallery storage query failed"); if( $bOwner or $sSubscriptionStatus == 'TRY' ) { $query = " update gallery_subscription " . " set " . "add_storage_units" . " = " . $iAddStorage . " " . " where order_id = " . $iOrderID . ""; //print $query . "

"; $result = mysql_query($query) or die("Update gallery_subscription query failed"); } else { $query = " insert into gallery_subscription " . " ( " . " order_id, " . " add_storage_units " . " ) " . " values " . " ( " . "" . $iOrderID . ", " . " " . $iAddStorage . " " . " ) "; //print 'query: ' . $query . '
'; $result = mysql_query($query) or die("Insert gallery_subscription query failed"); } } function updateHostingOrderStatus( $iOrderID, $sHostingPackage, $bOwner, $sSubscriptionStatus, $sDomain, $sUsername ) { include '../base/cpanel_account_vars.inc'; $query = " insert into order_item " . " ( " . " order_id, " . " description, " . " units " . " ) " . " values " . " ( " . " " . $iOrderID . ", " . " " . "'hosting package'," . " " . " " . "1" . " " . " ) "; //print 'query: ' . $query . '
'; $result = mysql_query($query) or die("Insert order_item: hosting package query failed"); /* $bUpdateSubscription = false; if( gettype( $_SESSION[ 'hosting_current_domains' ] ) == 'array' ) { if( in_array( $sDomain, $_SESSION[ 'hosting_current_domains' ] ) ) { $bUpdateSubscription = true; } } */ //alert( 'sDomain: ' . $sDomain . ' hosting_current_domains: ' . $_SESSION[ 'hosting_current_domains' ] ); //if( ( $bOwner or $sSubscriptionStatus == 'TRY' ) and $bUpdateSubscription ) if( $bOwner or $sSubscriptionStatus == 'TRY' ) { //alert( 'bOwner: ' . $bOwner . ' sSubscriptionStatus: ' . $sSubscriptionStatus . ' bUpdateSubscription: ' . $bUpdateSubscription ); //alert( 'debug1' ); $query = " update hosting_subscription " . " set " . "package" . " = '" . $sHostingPackage . "', " . " domain" . " = '" . $sDomain . "', " . " username" . " = '" . $sUsername . "' " . " where order_id = " . $iOrderID . ""; //print $query . "

"; $result = mysql_query($query) or die("Update hosting_subscription query failed"); $updown = updown( $host, $user, $accesshash, $usessl, $sUsername, $sHostingPackage ); } else { //alert( 'debug2' ); $query = " insert into hosting_subscription " . " ( " . " order_id, " . " package, " . " domain, " . " username " . " ) " . " values " . " ( " . " " . $iOrderID . ", " . " '" . $sHostingPackage . "', " . " '" . $sDomain . "', " . " '" . $sUsername . "' " . " ) "; //print 'query: ' . $query . '
'; $result = mysql_query($query) or die("Insert hosting_subscription query failed"); $sCreateAcctError = createacct( $host, $user, $accesshash, $usessl, $sDomain, $sUsername, getPassword(), $sHostingPackage ); } /* alert( 'host: ' . $host . '\n' . 'user: ' . $user . '\n' . 'accesshash: ' . $accesshash . '\n' . 'usessl: ' . $usessl . '\n' . 'updownuser: ' . $updownuser . '\n' . 'plan: ' . $sHostingPackage . '' ); */ /* alert( $sCreateAcctError ); alert( 'host: ' . $host . '\n' . 'user: ' . $user . '\n' . 'accesshash: ' . $accesshash . '\n' . 'usessl: ' . $usessl . '\n' . 'domain: ' . $sDomain . '\n' . 'username: ' . $_POST[ 'username' ] . '\n' . 'getPassword: ' . getPassword() . '\n' . 'hosting_package: ' . $sHostingPackage . '' ); */ } function displaySuccess( $iOrderNumber, $bOwner, $sOwnerType ) { //alert( $sOwnerType ); $sSuccessMessage = ''; if( $bOwner ) { $sSuccessMessage .= 'Thank you for your purchase.

'; } else { $sSuccessMessage .= 'Thank you for your interest.

'; } $sSuccessMessage .= 'Your order number is: ' . $iOrderNumber . '.

'; $sSuccessMessage .= 'We appreciate your business.

'; $sEmailAddress = $_SESSION[ 'secure_user_session' ]; if( $sOwnerType == 'gallery_owner' ) { $sQuery = " select * from subscription s, gallery_subscription gs where s.order_id = " . $iOrderNumber . " and s.order_id = gs.order_id"; //print $sQuery . '
'; $result = mysql_query($sQuery) or die("Gallery Subscription Query failed"); $row = mysql_fetch_array($result, MYSQL_ASSOC); if( strlen( $row[ 'order_id' ] ) > 0 ) { if( $bOwner ) { $iAdditionalSpace = $row[ 'add_storage_units' ] * $_SESSION[ 'gallery_additional_storage' ]; $iSpaceTotal = $iAdditionalSpace + $_SESSION[ 'gallery_initial_storage' ]; $sSuccessMessage .= 'You will be billed $' . number_format( $row[ 'amount' ], 2 ) . ' per month.

'; $sSuccessMessage .= 'You have purchased a total of ' . $iSpaceTotal . 'MB storage space.

'; } else { $sSuccessMessage .= 'You have been given a trial account.

'; $sSuccessMessage .= 'After 48 hours have passed we will disable any galleries that you have created.
'; $sSuccessMessage .= 'Once you have purchased the Easy Photo Gallery it will be enabled.
'; $sSuccessMessage .= 'If you wish to continue testing, create another gallery that will last for another 48 hours.

'; } $sCustomerEmailSubject = 'DarwinsWeb Easy Photo Gallery'; $sFinalMessage .= ' Go to the Gallery Admin Page to begin using your photo gallery.

'; } } //alert( $sOwnerType ); if( $sOwnerType == 'hosting_owner' ) { //alert( 'debug1' ); $sQuery = " select * from subscription s, hosting_subscription hs where s.order_id = " . $iOrderNumber . " and s.order_id = hs.order_id"; //print $sQuery . '
'; $result = mysql_query($sQuery) or die("Hosting Subscription Query failed"); $row = mysql_fetch_array($result, MYSQL_ASSOC); if( strlen( $row[ 'order_id' ] ) > 0 ) { //alert( 'debug2' ); if( $bOwner ) { //alert( 'debug3' ); $sSuccessMessage .= 'You will be billed $' . number_format( $row[ 'amount' ], 2 ) . ' per month.

'; $sSuccessMessage .= 'You have purchased the ' . $row[ 'package' ] . ' hosting package.

'; } } $sCustomerEmailSubject = 'DarwinsWeb Hosting'; $sFinalMessage .= ' Go to the Customer Home to administer your website.

'; } include 'email_receipt.inc'; mail ( $sEmailAddress, $sCustomerEmailSubject, $sEmailReceipt, $headers ); if( $bOwner ) { $sSubject = 'SMILE YOU\'RE GOING TO BE RICH.'; } else { $sSubject = 'SMILE SOMEONE IS TRYING IT.'; } $sSuccessMessage .= 'You will receive an email shortly for your records.

'; mail( 'kevin@darwinsweb.com', $sSubject, $sEmailReceipt, $headers ); $sSuccessMessage .= $sFinalMessage; print $sSuccessMessage . '
'; } ?>