$value){ $_REQUEST[$value] = str_replace('"', "", $_REQUEST[$value]); $_REQUEST[$value] = str_replace("'", "", $_REQUEST[$value]); $_REQUEST[$value] = stripslashes($_REQUEST[$value]); if(empty($_REQUEST[$value])||!isset($_REQUEST[$value])){ $_REQUEST[$value] = null; switch($value){ case'register': $_REQUEST[$value] = false; break; case'viewOrderDetails': $_REQUEST[$value] = false; break; } }else{ switch($value){ case'myspace': $_REQUEST[$value] = "http://www.facebook.com/".$_REQUEST[$value]; break; case'youtube': $_REQUEST[$value] = "http://www.youtube.com/user/".$_REQUEST[$value]; break; case'soundcloud': $_REQUEST[$value] = "http://soundcloud.com/".$_REQUEST[$value]; break; case'reverbnation': $_REQUEST[$value] = "http://www.reverbnation.com/".$_REQUEST[$value]; break; } } } if(empty($_REQUEST['step'])){ $page = 'includes/pages/music-contest-step-1.html'; } // Create Instances of Needed Objects $contestant = new contestant(); $database = new database(); $order = new order(); $error = new error(); $music = new music(); $email = new email(); $errors = false; // Set the Entry Price $result = $database->select('SELECT * FROM items WHERE id=1'); $entry_price = mysql_result($result,0,'price'); switch($_REQUEST['step']){ // Register Contestant, Store Order and Process Transaction. case 1: // Register Contestant $date = $database->sql_date_format(time()); $minor = $_REQUEST['underage']=='yes'?1:0; $ip_address = $_SERVER['REMOTE_ADDR']; $host_address = gethostbyaddr($ip_address); $browser_info = $_SERVER['HTTP_USER_AGENT']; // SET URLS $myspace = strtolower($_REQUEST['myspace']); $youtube = $_REQUEST['youtube']; $website = strtolower($_REQUEST['website']); $soundcloud = strtolower($_REQUEST['soundcloud']); $reverbnation = strtolower($_REQUEST['reverbnation']); // GET OPERATING SYSTEM $OSList = array ( // Match user agent string with operating systems 'Windows 3.11' => 'Win16', 'Windows 95' => '(Windows 95)|(Win95)|(Windows_95)', 'Windows 98' => '(Windows 98)|(Win98)', 'Windows 2000' => '(Windows NT 5.0)|(Windows 2000)', 'Windows XP' => '(Windows NT 5.1)|(Windows XP)', 'Windows Server 2003' => '(Windows NT 5.2)', 'Windows Vista' => '(Windows NT 6.0)', 'Windows 7' => '(Windows NT 6.1)', 'Windows NT 4.0' => '(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)', 'Windows ME' => '(Windows 98)|(Win 9x 4.90)|(Windows ME)', 'Open BSD' => 'OpenBSD', 'Sun OS' => 'SunOS', 'Linux' => '(Linux)|(X11)', 'Mac OS' => '(Mac_PowerPC)|(Macintosh)', 'QNX' => 'QNX', 'BeOS' => 'BeOS', 'OS/2' => 'OS/2', 'Search Bot'=>'(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp)|(MSNBot)|(Ask Jeeves/Teoma)|(ia_archiver)' ); // Loop through the array of user agents and matching operating systems foreach($OSList as $CurrOS=>$Match) { // Find a match if (eregi($Match, $_SERVER['HTTP_USER_AGENT'])) { // We found the correct match break; } } $page = 'includes/pages/music-contest-step-1.html'; $contestant_array = array('fname' => $_REQUEST['fname'], 'lname' => $_REQUEST['lname'], 'address' => $_REQUEST['address'], 'address2' => $_REQUEST['address2'], 'city' => $_REQUEST['city'], 'state' => $_REQUEST['state'], 'zip' => $_REQUEST['zip'], 'country' => $_REQUEST['country'], 'phone' => $_REQUEST['phone'], 'email' => $_REQUEST['email'], 'minor' => $minor, 'refferal' => $_REQUEST['ad'], 'registration_date' => $date, 'ip_address' => $ip_address, 'host_address' => $host_address, 'browser_info' => $browser_info, 'operating_system' => $CurrOS, 'website' => $website, 'myspace' => $myspace, 'youtube' => $youtube, 'soundcloud' => $soundcloud, 'reverbnation' => $reverbnation); if($contestant->create($contestant_array)){ // Contestant Created Successfully. Go ahead and store the order then process the transaction. // Store Order Information $order_array = array('item_id' => '1', 'contestant_id' => $_SESSION['contestant_id'], 'quantity' => $_REQUEST['number_entries'], 'paid' => 0, 'amount_paid' => 0, 'fname' => $_REQUEST['b_fname'], 'lname' => $_REQUEST['b_lname'], 'address' => $_REQUEST['b_address'], 'address2' => $_REQUEST['b_address2'], 'city' => $_REQUEST['b_city'], 'state' => $_REQUEST['b_state'], 'zip' => $_REQUEST['b_zip'], 'country' => $_REQUEST['b_country'], 'phone' => $_REQUEST['b_phone'], 'create_date' => $date, 'status_comment' => 'Order Created. Awaiting Payment.', 'promo_code' => $_REQUEST['promo']); if($order->create($order_array)){ // Order Stored Successfully, process the transaction and store the result into the database. if($order->process_transaction($_SESSION['order_id'])){ // Transaction Processed Proceed to Music Upload. $page = 'includes/pages/music-contest-step-2.html'; $_SESSION['authorized_upload'] = true; // Pull the order from the DB $result = $database->select('SELECT * FROM orders WHERE id=' . $_SESSION['order_id'] . ' AND item_id = 1'); if($result){ $row = mysql_fetch_assoc($result); $number_entries = $row['quantity']; $resultItem = $database->select('SELECT * FROM items WHERE id=1'); $rowItem = mysql_fetch_assoc($resultItem); // Setup Greeting Text for Ibox Popup $greetingJavascriptHTML = "html = '

Congratulations!

'; html += '

Your transaction was a success! You have paid a total of $" . $row['amount_paid'] . " for $number_entries " . $rowItem['name'] . " at $" . $rowItem['price'] . " each. Now that you have successfully completed your transaction you may upload your music and lyrics for the judges to see. Thank you for participating in this competition. Please click here to proceed.

';"; }else{ $greetingJavascriptHTML = '

There Was an Error Please Click Here To Go Back and Try Again

'; } }else{ // There was an error processing the transaction. Output error. $page = 'includes/pages/music-contest-step-1.html'; $error_output = $order->error->output(); $errors = true; } }else{ // There was an error storing the order. Output error. $error_output = $order->error->output(); $errors = true; } }else{ // There was an error on setting up the contestant. Output error. $error_output = $contestant->error->output(); $errors = true; } break; // Store the Contestant's Lyrics and / or Files. case 2: $page = 'includes/pages/music-contest-step-thank-you-2.html'; if(!$_REQUEST['viewOrderDetails']){ $count = 1; //Check file size on all the files before proceeding foreach($_REQUEST['file'] as $key => $value){ if(!$music->checkFileSizes($count, $_REQUEST['file'][$count]['type'])){ $errors = true; } $count++; } if($errors){ $error_output = $music->error->output(); $errors = true; }else{ $count = 1; $date = $database->sql_date_format(time()); foreach($_REQUEST['file'] as $key => $value){ $file_array = Array( 'contestant_id' => $_SESSION['contestant_id'], 'category' => $_REQUEST['file'][$key]['category'], 'title' => $_REQUEST['file'][$key]['title'], 'file' => 'files'.$count, 'type_id' => $_REQUEST['file'][$key]['type'], 'lyrics' => $_REQUEST['file'][$key]['lyrics'], 'collaborators' => $_REQUEST['file'][$key]['collaborators'], 'create_date' => $date ); if($music->getFileType($file_array['type_id'])=="YouTube"||$music->getFileType($file_array['type_id'])=="SoundCloud"||$music->getFileType($file_array['type_id'])=="ReverbNation"||$music->getFileType($file_array['type_id'])=="MySpace"){ $file_array['file'] = $_REQUEST['files'.$count]; } if($music->verifyEntry($_REQUEST['file'][$key]['title'])){ if($music->createEntry($file_array)){ $date = $music->database->sql_date_format(time()); $update_order = array( 'status_comment' => 'The contestant has paid in full and has successfully uploaded all of his/her music/lyrics.' ); $order->update($update_order, $_SESSION['order_id']); $_SESSION['current_entry']++; if($_SESSION['number_entries']< $_SESSION['current_entry']){ $page = 'includes/pages/music-contest-step-thank-you-2.html'; }else{ $page = 'includes/pages/music-contest-step-2.html'; } if(count($music->error)>0){ $error_output = $music->error->output(); $errors = true; } }else{ $error_output = $music->error->output(); $errors = true; } }else{ $error_output = $music->error->output(); $errors = true; } $count++; } //Send emails. } } break; } include($page); ?>