0) { $key = $attribs["name"]; }else { $key = $name } } */ //$tag=array("name"=>$name,"attrs"=>$attribs); //array_push($stack,$tag); } // end_element_handler ( resource parser, string name ) function endElement($parser, $name) { /* global $stack,$lastStore; $stack[count($stack)-2]['children'][] = $stack[count($stack)-1]; array_pop($stack); */ global $stack, $currentStoreData, $currentStoreName; if($name == "store") { $stack[$currentStoreName] = $currentStoreData; } } // handler ( resource parser, string data ) function characterData($parser, $data) { /* global $stack,$i; if(trim($data)) { $stack[count($stack)-1]['data'] .= $data; } */ global $currentElementName,$currentStoreData,$currentAttrib; if($currentElementName == "map" && trim($data)) { $currentStoreData[$currentAttrib] = $data; } } function defaultHandler($parser, $data) { } function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId, $publicId) { if ($systemId) { if (!list($parser, $fp) = new_xml_parser($systemId)) { printf("Could not open entity %s at %s\n", $openEntityNames, $systemId); return false; } while ($data = fread($fp, 4096)) { if (!xml_parse($parser, $data, feof($fp))) { printf("XML error: %s at line %d while parsing entity %s\n", xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser), $openEntityNames); xml_parser_free($parser); return false; } } xml_parser_free($parser); return true; } return false; } function new_xml_parser($file) { global $parser_file; $xml_parser = xml_parser_create(); xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); xml_set_default_handler($xml_parser, "defaultHandler"); xml_set_external_entity_ref_handler($xml_parser, "externalEntityRefHandler"); if (!($fp = @fopen($file, "r"))) { return false; } if (!is_array($parser_file)) { settype($parser_file, "array"); } $parser_file[$xml_parser] = $file; return array($xml_parser, $fp); } if (!(list($xml_parser, $fp) = new_xml_parser($xmlfile))) { die("could not open XML input"); } //ERROR while ($data = fread($fp, 4096)) { if (!xml_parse($xml_parser, $data, feof($fp))) { die(sprintf("XML error: %s at line %d\n", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); } } //END xml_parser_free($xml_parser); $product_db_id = ''; $product_db_name = ''; //get the product ID to get the serial number from foreach ($stack as $key => $value) { if ($key == $storename) { foreach ($value as $pid => $pcode) { if ($pid == $order['productId']) { $product_db_name = $pcode; if ($fp = @file_get_contents($productsfile)) { $product_sec = strstr($fp, ""); $product_db_id_loc = strpos($product_sec, '') + strlen(''); $product_db_id_loc2 = strpos($product_sec, ''); $product_db_id = substr($product_sec, $product_db_id_loc, $product_db_id_loc2 - $product_db_id_loc); } break; } } break; } } if ($product_db_id == '') exit; //Registration can now work include('../includes/dbFuncs.inc'); $dbConn = WebIS_DBConnect(); //check to see if its already registered /*$sqlstr = "select OrderNumber from webis_software.softwareregistration where OrderNumber = '" . $order['refId'] . "' and iSoftwareID = $product_db_id and EmailAddress like '" . mysql_real_escape_string($order['emailAddress']) ."'"; $result = mysql_query($sqlstr); $number = mysql_num_rows($result); if ($number > 0) exit; */ //get the serial number $sqlstr = "select IDNum, RegistrationCode from webis_software.codes where bDisabled = 0 and bUsed=0 and iSoftwareID = " . $product_db_id. " LIMIT " . $order['qty']; $result = mysql_query($sqlstr); if ($result === FALSE) { echo '
' . $sqlstr . '
' . mysql_error(); exit; } $number = mysql_num_rows($result); if ($number <= 0) exit; if ($showRegCodeLine == true) echo "Reg Codes:\n"; for ($nQty = 1; $nQty <= $number; $nQty++) { $line = mysql_fetch_assoc ($result); $reg_code = $line['RegistrationCode']; if ($reg_code == '') { echo '
' . $sqlstr . '
' . mysql_error(); exit; } if ($testmode != 'testmode') { $sqlstr = "update codes set bUsed=1 where IDNum = " . $line['IDNum']; $resultUpdate = mysql_query($sqlstr); if ($resultUpdate === FALSE) { echo '
' . $sqlstr . '
'. $reg_code.'
'. $number.'
' . mysql_error(); exit; } $sqlstr = "insert into softwareregistration (OrderNumber,EmailAddress,szProduct,bContactMe,bPromotions,iSoftwareID,RegistrationCode,bRetail, order_email,iRegCodeVersion,tsOrder,tsRegistration, szOrigination) values ('". mysql_real_escape_string($order['refId']) ."','". mysql_real_escape_string($order['emailAddress']) ."','". $product_db_name ."',1,1,". $product_db_id.",'". $reg_code ."',0,'". mysql_real_escape_string($order_email) ."',4, NOW(),NOW(), '".mysql_real_escape_string($storename) ."')"; $resultUpdate = mysql_query($sqlstr); if ($resultUpdate === FALSE) { echo '
' . $sqlstr . '
' . mysql_error(); exit; } } echo $reg_code . "\n"; ob_flush(); } ?>