120)) { html_error( "Company name is not within size limits (2 to 120 chars)" ); } if ((strlen($contact) < 3) || (strlen($contact) > 120)) { html_error( "Contact is not within size limits (3 to 120 chars)" ); } if ((strlen($address) < 5) || (strlen($address) > 120)) { html_error( "Address is not within size limits (5 to 120 chars)" ); } if ((strlen($city) < 2) || (strlen($city) > 40)) { html_error( "City is not within size limits (2 to 40 chars)" ); } if ((strlen($state) < 2) || (strlen($state) > 20)) { html_error( "State is not within size limits (2 to 20 chars)" ); } if ((strlen($zip) < 1) || (strlen($zip) > 15)) { html_error( "ZIP Code is not within size limits (1 to 15 chars)" ); } if ((strlen($country) < 2) || (strlen($country) > 30)) { html_error( "Country is not within size limits (2 to 30 chars)" ); } if (strlen($phone) > 20) { html_error( "Phone is not within size limits (up to 20 chars)" ); } if (($country == "US") && ($ssn < 9)) { html_error( "US Residents MUST Enter a Tax ID or SSN" ); } else { if (strlen($ssn) > 30) { html_error( "Tax ID is not within size limits (up to 30 chars)" ); } } if ($country != "US") { $ssn = "na"; } if ($pass1 != $pass2) { html_error( "Passwords must match" ); } else { $pass = $pass1; if ((strlen($pass) < 6) || (strlen($pass) > 20)) { html_error( "Password is not within size limits (6 to 20 chars)" ); } } if ($GLOBALS["form_errors"]) { include "error-page.inc"; } else { $mysql_link = mysql_pconnect($db_host, $db_user, $db_pass); mysql_select_db($database); // Looks valid enough, let's get the current ID and assign it to this partner. $query = "SELECT id_prefix, next_id from State_data"; $mysql_result = mysql_query($query, $mysql_link); $row = mysql_fetch_row($mysql_result); $new_id = $row[0] . $row[1]; // Advance the ID number $query = "UPDATE State_data set next_id = (next_id + 1)"; $mysql_result = mysql_query($query, $mysql_link); // Let's built the database query and insert it into the Queue table $query = "INSERT into Queue values('$new_id','$sitename','$url','$company','$contact','$email','$address','$city','$state','$zip','$country','$phone','$ssn','$pass',NULL,NULL)"; $mysql_result = mysql_query($query, $mysql_link); // Now we'll build a submission for Epoch and send it $epoch["rs_code"] = $new_id; $epoch["rs_co_code"] = "789"; $epoch["rs_co_password"] = "5tg76e"; $epoch["rs_name"] = $company; $epoch["rs_contact"] = $contact; $epoch["rs_street"] = $address; $epoch["rs_city"] = $city; $epoch["rs_state"] = $state; $epoch["rs_zip"] = $zip; $epoch["rs_country"] = $country; $epoch["rs_phone"] = $phone; $epoch["rs_email"] = $email; $epoch["rs_paymethod"] = "chk"; $epoch["rs_taxid"] = $ssn; $epoch["rs_password"] = $pass; $epoch["rs_percentage"] = "50"; // Epoch changed their api. // $result = PostIt($epoch, "http://reports.epochsystems.com/servlet/addReseller/index.cgi"); // New Post URL // http://wnu.com/secure/addresellerapi.cgi?& $result = PostIt($epoch, "http://www.epochsystems.com/secure/addresellerapi.cgi"); if (isset($result["errno"])) { // An error happened while trying to talk to Epoch.. let's just leave // this one in the Queue and we'll send a note to the admin, plus to // the partner (webpage). $mail_subject = "TargetTraffic ERROR Talking to Epoch"; $mail_headers = "From: webmaster@pregnantpics.com\nCc: kc@wintelcom.net"; $mail_body = "We encounted an error while trying to submit " . $new_id . " to the Epoch database.\n\n"; $mail_body .= "The error response was: " . $result["errstr"] . "\n\n"; $mail_body .= "You should check Epoch for this ID and then manually add the partner based\n"; $mail_body .= "on the following information. Once they're added, go into queue_view (admin utils)\n"; $mail_body .= "and click on the 'make live' button to activate their ID and send them a welcome.\n\n"; $mail_body .= "Sitename: $sitename\n"; $mail_body .= "URL: $url\n"; $mail_body .= "Payable to: $company\n"; $mail_body .= "Contact: $contact\n"; $mail_body .= "E-mail: $email\n"; $mail_body .= "Address: $address\n"; $mail_body .= "City: $city\n"; $mail_body .= "State: $state\n"; $mail_body .= "ZIP: $zip\n"; $mail_body .= "Country: $country\n"; $mail_body .= "Phone: $phone\n"; $mail_body .= "SSN: $ssn\n"; $mail_body .= "Password: $pass\n"; mail("webmaster@pregnantpics.com", $mail_subject, $mail_body, $mail_headers); $GLOBALS['display_text'] = get_template("jointemplates/epoch-bad.txt", $new_id, $pass); include "send-page.inc"; } else { // Ok, it seemingly went though to Epoch -- let's go ahead and send off // the mail to the admin, mail to the partner, add them to the Partners // table, remove them from the queue and display the webpage (whew) // Admin Mail $mail_subject = "Someone joined TargetTraffic with ID $new_id"; $mail_headers = "From: partners@pregnantpics.com\nCc: trevor@unixforever.net"; $mail_body = "A new partner was added to TargetTraffic with ID $new_id.\n\n"; $mail_body .= "You should check Epoch, but we didn't receive a bad response\n"; $mail_body .= "code either.\n\n"; $mail_body .= "Sitename: $sitename\n"; $mail_body .= "URL: $url\n"; $mail_body .= "Payable to: $company\n"; $mail_body .= "Contact: $contact\n"; $mail_body .= "E-mail: $email\n"; $mail_body .= "Address: $address\n"; $mail_body .= "City: $city\n"; $mail_body .= "State: $state\n"; $mail_body .= "ZIP: $zip\n"; $mail_body .= "Country: $country\n"; $mail_body .= "Phone: $phone\n"; $mail_body .= "SSN: $ssn\n"; $mail_body .= "Password: $pass\n"; mail("webmaster@pregnantpics.com", $mail_subject, $mail_body, $mail_headers); // Partner Mail $mail_subject = "Welcome " . $new_id . " to the program!"; $mail_headers = "From: partners@pregnantpics.com"; $mail_body = get_template("jointemplates/partner-mail.txt", $new_id, $pass); mail($email, $mail_subject, $mail_body, $mail_headers); // Compose a nice message and send the web page $GLOBALS['display_text'] = get_template("jointemplates/epoch-good.txt", $new_id, $pass); include "send-page.inc"; // Add them to the Partners database $query = "INSERT INTO Partners VALUES ('$new_id', '$sitename', '$url', '$company', '$contact', '$email', '$address', '$city', '$state', '$zip', '$country', '$phone', '$ssn', '$pass', NULL, NULL, NULL, NULL, 'R')"; mysql_query($query); // Remove them from the Queue $query = "DELETE FROM Queue WHERE id = '$new_id'"; mysql_query($query); } // Ok, close up the database -- we don't need it anymore and no sense in leaving it open mysql_close($mysql_link); } } ?>