function splitTracks($filename) { //This function will export tracks from a users savedLines.sol file $file = fopen($filename, "r"); skip($file, 2); // 00BF $fileSize = readLong($file); // File Size skip($file, 12); // T C S O 0004 0000 0000 000A if (readString($file, 9) == "undefined") { //Old version fclose($file); upgradeSol($filename); $file = fopen($filename, "r"); skip($file, 2); // 00BF $fileSize = readLong($file); // File Size skip($file, 12); // T C S O 0004 0000 0000 000A if (readString($file, 9) != "undefined") { skip($file, 1); // s (from end of savedLines) } else { //Error: Unable to upgrade .sol } } else { skip($file, 1); // s (from end of savedLines) } skip($file, 4); // 0000 0000 $currentTrack = -1; $trackNames = ''; while (ftell($file) < $fileSize - 6) { $skipIt = false; $length = readShort($file); if ($length == 0) { if (readByte($file) == 9) { //End Array/Object $skipIt = true; } else { skip($file, -1); //Invalid item of length 0 $skipIt = true; } } if ($skipIt == false) { $name = readString($file, $length); $type = readByte($file); if ($type == 0) { //Double $value = readDouble($file); } if ($type == 1) { //Boolean (Show) skip($file, 1); } if ($type == 2) { //String $strlength = readShort($file); $value = readString($file, $strlength); $trackLengthOff[$currentTrack] = ftell($file) - $trackStartOff[$currentTrack] + 3; if ($name == 'label') { $trackNames .= $value . chr(9); } } if ($type == 3) { //Object $currentTrack = (int) $name; $trackStartOff[$currentTrack] = ftell($file); } // Type 6: Undefined: Do Nothing if ($type == 8) { //Array $value = readLong($file); } } } $trackNames = substr($trackNames, 0, strlen($trackNames) - 1); $ret = ''; for ($i = 0; $i < count($trackStartOff); $i++) { fseek($file, $trackStartOff[$i]); $bytes = fread($file, $trackLengthOff[$i]); for ($j = 0; $j > -1; $j++) { if (file_exists("tracks/" . $j . ".track") == false) { $wfile = fopen("tracks/" . $j . ".track", "w"); $ret .= $j . chr(9); $mem = $j; break; } } fwrite($wfile, $bytes); fclose($wfile); $thisName = explode(chr(9), $trackNames); $thisName = $thisName[$i]; addDetails($j, $thisName); } fclose($file); $ret = substr($ret, 0, strlen($ret) - 1); return $ret . chr(0) . $trackNames; //Returns an array containing the location of the tracks }
break; case 'addDetails': if ($invalidArg === false) { $assassinationId = arg('assassinationId'); if ($assassinationId === false) { $invalidArg = 'assassinationId'; } } if ($invalidArg === false) { $details = arg('details'); if ($details === false) { $invalidArg = 'details'; } } if ($invalidArg === false) { addDetails($playerId, $assassinationId, $details); } break; case 'startDispute': if ($invalidArg === false) { $gameId = arg('gameId'); if ($gameId === false) { $invalidArg = 'gameId'; } } if ($invalidArg === false) { $against = arg('against'); if ($against === false) { $invalidArg = 'against'; } }
checkPost($_POST); // Will kill the script if there are errors. echo ' "message": "data written", '; $phone = ereg_replace("[^0-9]", "", escapeData($DBS['comet'], $_POST['phone'])); $zip = ereg_replace("[^0-9]", "", escapeData($DBS['comet'], $_POST['zip'])); // Join Date Validation $joinMonth = isset($_POST['joinDate']) ? (int) substr($_POST['joinDate'], 5, 2) : 0; $joinDay = isset($_POST['joinDate']) ? (int) substr($_POST['joinDate'], 8, 2) : 0; $joinYear = isset($_POST['joinDate']) ? (int) substr($_POST['joinDate'], 0, 4) : 0; $joinDate = checkdate($joinMonth, $joinDay, $joinYear) ? "{$joinYear}-{$joinMonth}-{$joinDay}" : date('Y-m-d'); // Share price validation $sharePrice = isset($_POST['sharePrice']) && is_numeric($_POST['sharePrice']) && $_POST['sharePrice'] >= 0 ? (int) $_POST['sharePrice'] : $_SESSION['sharePrice']; // Plan validation $plan = isset($_POST['plan']) && is_numeric($_POST['plan']) && $_POST['plan'] > 0 ? (int) $_POST['plan'] : 1; // Details then owners. addDetails($_SESSION['cardNo'], $_POST['address'], $phone, $_POST['city'], $_POST['state'], $zip, $_POST['email'], isset($_POST['noMail']) ? 1 : 0, $plan, $joinDate, $sharePrice, $_SESSION['userID']); for ($i = 1; $i <= $_SESSION['houseHoldSize']; $i++) { if (!empty($_POST['first'][$i]) && !empty($_POST['last'][$i])) { addOwner($_SESSION['cardNo'], $i, $_POST['first'][$i], $_POST['last'][$i], $_POST['discount'][$i], isset($_POST['memType'][$i]) ? escapeData($DBS['comet'], $_POST['memType'][$i]) : 0, isset($_POST['staff'][$i]) ? escapeData($DBS['comet'], $_POST['staff'][$i]) : 0, isset($_POST['charge'][$i]) && $_POST['charge'][$i] == 'on' ? 1 : 0, isset($_POST['checks'][$i]) && $_POST['checks'][$i] == 'on' ? 1 : 0, $_SESSION['userID']); } } echo ' "message": "data written", '; } else { // Partially filled in. Error. echo ' "errorMsg": "Partially Filled In." }'; exit; } } elseif ($numRows == 1) { // Already existing row. Update or not. if (!$details && !$owners) { // Empty. Error out.