/** * Tests creation of valid maintenacne task entries */ public function testValidMaintenanceTaskCreation() { try { $maintenanceTask = new MaintenanceTaskEntry(1, "Tire Rotation", new ElectricCar("Tesla", "Model S", 2000, 12345), new DateTime(), false); $maintenanceTask = new MaintenanceTaskEntry(1, "Tire Rotation", new GasCar("Ford", "Focus", 2000, 12345), new DateTime(), false); $maintenanceTask = new MaintenanceTaskEntry(1, "Tire Rotation", new GasCar("Ford", "Fusion", 1970, 12345), new DateTime(), false); $maintenanceTask = new MaintenanceTaskEntry(1, "Tire Rotation", new DieselCar("Ford", "Super Duty", 2000, 12345), new DateTime(), false); $maintenanceTask = new MaintenanceTaskEntry(1, "Tire Rotation", new ElectricCar("Tesla", "Model S", 2000, 12345), new DateTime(), false); echo "testValidMaintenanceTaskCreation test Successful\n"; } catch (Exception $e) { echo "testValidMaintenanceTaskCreation test failed\n"; Assert . Fail(); } }
private function Query($string) { $URL = Config::get("URL"); $query = curl_init($URL); curl_setopt($query, CURLOPT_HEADER, 0); curl_setopt($query, CURLOPT_RETURNTRANSFER, 1); curl_setopt($query, CURLOPT_POST, 1); curl_setopt($query, CURLOPT_POSTFIELDS, $string); $result = curl_exec($query); if (curl_errno($query)) { Fail($query); } curl_close($query); return $result; }
function Submit(&$arg) { $pid = safefetch($arg, 'pid'); $cid = safefetch($arg, 'cid'); $lang = safefetch($arg, 'language'); $source = isset($arg['source']) ? $arg['source'] : ''; $ret = submit_source($pid, $cid, $lang, $source); if (is_numeric($ret)) { Output("status", "success"); Output("sid", $ret); } else { Fail($ret); } }
// If we got more than one entry, then something is really messed up with // the database, there must not be more than one entry with the same data } elseif ($result_count > 1) { MultipleResults(); // If we got one coincidence, then we can proceed to modification } elseif ($result_count == 1) { // What dn are we going to modify? $moddn = $search_entries['0']['dn']; // We fill in our attribute modificator array $in['userPassword'] = $userPassword; // Modifying ... $mod = AssistedLDAPModify($ldapc, $moddn, $in); // If the modifying went OK, we send the notification e-mail to the user if ($mod) { $send = AssistedEMail("ChangePasswordDo", $mail); } // If the mailing went OK ... if ($send) { // We log the event WriteLog("ChangePasswordDo"); // Print the good news to the user Success("ChangePasswordDo"); } else { // We fail nicely, at least Fail("ChangePasswordDo"); } } } // Closing the connection $ldapx = AssistedLDAPClose($ldapc); require_once "./themes/{$app_theme}/footer.php";
$result = mysql_query($sql, $conn) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { foreach ($row as $name => $value) { if ($name == "starbase_id") { $starbase_id = $value; } } } $sql = "CALL sp_AddStarbaseKey(" . $starbase_id . ", " . $keyPK . ")"; $result = mysql_query($sql, $conn) or die(mysql_error()); } else { if ($update != $today) { $sql = "CALL sp_UpdateStarbase(" . $starbasePK . ", " . $locationIDs[$i] . ", " . $moonIDs[$i] . ", " . $states[$i] . ", '" . $stateTimes[$i] . "', '" . $onlineTimes[$i] . "', '" . $today . "')"; $result = mysql_query($sql, $conn) or die(mysql_error()); } else { //Same Day } } } Success(); } else { Fail("Failed to get the List of Towers"); } function Fail($error) { header('Location: ./TDSInError.php?Error=' . $error . ''); } function Success() { header('Location: ./TDSInTowers.php'); }
$api->Init($key_ID, $v_Code); $ret = $api->getCharXML(); if ($ret) { $charIds = $api->getValueArrayFromXML($ret, "characterID"); $charNames = $api->getValueArrayFromXML($ret, "name"); $corpIds = $api->getValueArrayFromXML($ret, "corporationID"); $corpNames = $api->getValueArrayFromXML($ret, "corporationName"); } else { $fail = true; } if (!$fail) { if (IsProduction()) { mysql_select_db("eve.tdsin"); } else { mysql_select_db("naed_Sapphire"); } $sql = "CALL sp_AddAPIKey(" . $key_ID . ", '" . $v_Code . "', " . $charIds[0] . ", '" . $charNames[0] . "', " . $corpIds[0] . ", '" . $corpNames[0] . "')"; $result = mysql_query($sql, $conn) or die(mysql_error()); Success(); } else { Fail("Invalid input was provided"); } } function Fail($error) { header('Location: ./TDSInError.php?Error=' . $error . ''); } function Success() { header('Location: ./TDSInAdminTools.php'); }
break; case 'T': //设下陷阱 关于Special,陷阱未开启为null,被npc开启为0,被玩家开启则为玩家id Trap($touseid); $durable--; if ($durable == 0) { $result0 = mysql_query("UPDATE roleset SET {$usename} = NULL WHERE Name='{$nam}'"); } else { $result0 = mysql_query("UPDATE itemset SET Durable = {$durable} WHERE id='{$touseid}'"); } break; case 'X': Fail(); break; case 'Z': Fail(); break; case 'Gp': Lord($effect, $durable, $type, $skillid); break; case 'V': Learn($skillid); $durable--; if ($durable == 0) { $result0 = mysql_query("UPDATE roleset SET {$usename} = NULL WHERE Name='{$nam}'"); } else { $result0 = mysql_query("UPDATE itemset SET Durable = {$durable} WHERE id='{$touseid}'"); } break; case 'P': Open($durable);
//Update $sql = "CALL sp_UpdateSpeedItem(" . $itemPKs[$x] . "," . $eveItemIds[$x] . ")"; $result = mysql_query($sql, $conn) or die(mysql_error()); } } //Redirect to AddOps with Info if ($speedCount > 0) { $redirectInfo = "?SpeedId0=" . $itemPKs[0] . "&SpeedAmount0=" . $eveItemAmounts[0]; for ($x = 1; $x < $speedCount; $x++) { $redirectInfo = $redirectInfo . "&SpeedId" . $x . "=" . $itemPKs[$x] . "&SpeedAmount" . $x . "=" . $eveItemAmounts[$x]; } //Redirect Success($redirectInfo); } else { Fail("We got nothing"); } } else { Fail("Critical Failure"); } function Fail($error) { header('Location: ./TDSInError.php?Error=' . $error); //echo "<br />"; //echo $error; } function Success($info) { //echo "<br />"; //echo $info; header('Location: ./TDSInAddOp.php' . $info); }
function AccessGranted($isAdmin) { global $conn; $sql = "SELECT\n\t\t\t\t\t\tkey_id\n\t\t\t\t\tFROM\n\t\t\t\t\t\tEveAPIKeys\n\t\t\t\t\tWhere\n\t\t\t\t\t\tinUse = 1"; $result = mysql_query($sql, $conn) or die(mysql_error()); $fail = false; $keyIdYo = -1; $targetStarbase = -1; $targetUser = -1; while ($row = mysql_fetch_assoc($result)) { foreach ($row as $name => $value) { if ($name == "key_id") { $keyIdYo = $value; } } } if ($keyIdYo == -1) { $fail = true; } if (isset($_REQUEST["ViewStarbase"])) { $targetStarbase = $_REQUEST["ViewStarbase"]; } else { if (isset($_REQUEST["TargetUser"])) { $targetUser = $_REQUEST["TargetUser"]; } else { $fail = true; } } if (!$fail) { $sql = "Select\n\t\t\t\t\t\t\ts.starbase_id As 'starbase_id',\n\t\t\t\t\t\t\ts.itemID As 'itemID',\n\t\t\t\t\t\t\tt.typeName As 'typeID',\n\t\t\t\t\t\t\ts.locationID As 'locationID',\n\t\t\t\t\t\t\td.itemName As 'moonID',\n\t\t\t\t\t\t\tss.name As 'state',\n\t\t\t\t\t\t\ts.stateTimestamp As 'stateTimestamp',\n\t\t\t\t\t\t\ts.onlineTimestamp As 'onlineTimestamp',\n\t\t\t\t\t\t\ts.lastUpdate As 'lastUpdate'\n\t\t\t\t\t\tFrom\n\t\t\t\t\t\t\tStarbase_Key k\n\t\t\t\t\t\tLeft Join\n\t\t\t\t\t\t\tStarbases s on s.starbase_id = k.starbase_id\n\t\t\t\t\t\tLeft Join\n\t\t\t\t\t\t\tStarbase_States ss on ss.state = s.state\n\t\t\t\t\t\tLeft Join\n\t\t\t\t\t\t\tinvTypes t on t.typeID = s.typeID\n\t\t\t\t\t\tleft join\n\t\t\t\t\t\t\tmapDenormalize d on d.itemID = s.moonID"; if ($targetUser != -1) { $sql = $sql . " left join\n\t\t\t\t\t\t\t\tStarbase_Users su on su.starbase_id = s.starbase_id"; } $sql = $sql . " Where\n\t\t\t\t\t\t\tkey_id = " . $keyIdYo; if ($targetStarbase != -1) { $sql = $sql . " And s.Starbase_id = " . $targetStarbase; } if ($targetUser != -1) { $sql = $sql . " And su.user_id = " . $targetUser; } $sql = $sql . " order by d.itemName"; $result = mysql_query($sql, $conn) or die(mysql_error()); $starbaseIDs[0] = 0; $itemIDs[0] = 0; $typeIDs[0] = 0; $locationIDs[0] = 0; $moonIDs[0] = ""; $states[0] = ""; $stateTimes[0] = ""; $onlineTimes[0] = ""; $lastUpdates[0] = ""; $starbaseCount = 0; while ($row = mysql_fetch_assoc($result)) { foreach ($row as $name => $value) { if ($name == "starbase_id") { $starbaseIDs[$starbaseCount] = $value; } if ($name == "itemID") { $itemIDs[$starbaseCount] = $value; } if ($name == "typeID") { $typeIDs[$starbaseCount] = $value; } if ($name == "locationID") { $locationIDs[$starbaseCount] = $value; } if ($name == "moonID") { $moonIDs[$starbaseCount] = $value; } if ($name == "state") { $states[$starbaseCount] = $value; } if ($name == "stateTimestamp") { $stateTimes[$starbaseCount] = $value; } if ($name == "onlineTimestamp") { $onlineTimes[$starbaseCount] = $value; } if ($name == "lastUpdate") { $lastUpdates[$starbaseCount] = $value; $starbaseCount++; } } } $starbaseFuelType[0] = array(); $starbaseFuel[0] = array(); $starbaseUpdate[0] = array(); $posMembers[0] = array(); $posMemberIds[0] = array(); $memberCount[0] = 0; $landlord[0] = ""; for ($i = 0; $i < $starbaseCount; $i++) { $fuelCount = 0; $sql = "Select\n\t\t\t\t\t\t\t\ts.lastUpdate,\n\t\t\t\t\t\t\t\tt.typeName as 'fuel_type',\n\t\t\t\t\t\t\t\td.amount\n\t\t\t\t\t\t\tFrom\n\t\t\t\t\t\t\t\tStarbase_Details s\n\t\t\t\t\t\t\tLeft Join\n\t\t\t\t\t\t\t\tDetails d on d.detail_id = s.detail_id\n\t\t\t\t\t\t\tLeft Join\n\t\t\t\t\t\t\t\tinvTypes t on t.typeID = d.fuel_typeID\n\t\t\t\t\t\t\tWhere\n\t\t\t\t\t\t\t\ts.starbase_id =" . $starbaseIDs[$i]; $result = mysql_query($sql, $conn) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { foreach ($row as $name => $value) { if ($name == "lastUpdate") { $starbaseUpdate[$i][$fuelCount] = $value; } if ($name == "fuel_type") { $starbaseFuelType[$i][$fuelCount] = $value; } if ($name == "amount") { $starbaseFuel[$i][$fuelCount] = $value; $fuelCount++; } } } $landlordName = "-= No Landlord =-"; $sql = "Select\n\t\t\t\t\t\t\t\tCount(user_id) as 'Residents'\n\t\t\t\t\t\t\tFrom\n\t\t\t\t\t\t\t\tStarbase_Users\n\t\t\t\t\t\t\tWhere\n\t\t\t\t\t\t\t\tisRemoved = 0\n\t\t\t\t\t\t\t\tAnd\n\t\t\t\t\t\t\t\tStarbase_id = " . $starbaseIDs[$i]; $result = mysql_query($sql, $conn) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { foreach ($row as $name => $value) { if ($name == "Residents") { $memberCount[$i] = $value; } } } $sql = "Select\n\t\t\t\t\t\t\t\tu.user_name\n\t\t\t\t\t\t\tFrom\n\t\t\t\t\t\t\t\tStarbase_Users su\n\t\t\t\t\t\t\tLeft Join\n\t\t\t\t\t\t\t\tUsers u on u.user_id = su.user_id\n\t\t\t\t\t\t\tWhere\n\t\t\t\t\t\t\t\tsu.isRemoved = 0\n\t\t\t\t\t\t\t\tAnd\n\t\t\t\t\t\t\t\tsu.isLandlord = 1\n\t\t\t\t\t\t\t\tAnd\n\t\t\t\t\t\t\t\tsu.Starbase_id = " . $starbaseIDs[$i] . "\n\t\t\t\t\t\t\tLimit 1"; $landlord[$i] = $landlordName; $result = mysql_query($sql, $conn) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { foreach ($row as $name => $value) { if ($name == "user_name") { $landlord[$i] = $value; } } } $tempCount = 0; $sql = " Select\n\t\t\t\t\t\t\t\tu.user_name,\n\t\t\t\t\t\t\t\tu.user_id\n\t\t\t\t\t\t\tFrom\n\t\t\t\t\t\t\t\tStarbase_Users su\n\t\t\t\t\t\t\tLeft Join\n\t\t\t\t\t\t\t\tUsers u on u.user_id = su.user_id\n\t\t\t\t\t\t\tWhere\n\t\t\t\t\t\t\t\tsu.isRemoved = 0\n\t\t\t\t\t\t\t\tAnd\n\t\t\t\t\t\t\t\tsu.starbase_id = " . $starbaseIDs[$i] . "\n\t\t\t\t\t\t\torder by user_name"; $result = mysql_query($sql, $conn) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { foreach ($row as $name => $value) { if ($name == "user_name") { $posMembers[$i][$tempCount] = $value; } if ($name == "user_id") { $posMemberIds[$i][$tempCount] = $value; $tempCount++; } } } } $userCount = 0; $userList[0] = "None"; $userIdList[0] = 0; $sql = "Select\n\t\t\t\t\t\t\tuser_id, user_name\n\t\t\t\t\t\tFrom\n\t\t\t\t\t\t\tUsers\n\t\t\t\t\t\tleft join\n\t\t\t\t\t\t\tRanks on Users.rank_id = Ranks.rank_id\n\t\t\t\t\t\tWhere\n\t\t\t\t\t\t\trank_power > 0\n\t\t\t\t\t\torder by user_name"; $result = mysql_query($sql, $conn) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { foreach ($row as $name => $value) { if ($name == "user_id") { $userIdList[$userCount] = $value; } if ($name == "user_name") { $userList[$userCount] = $value; $userCount++; } } } //echo "<a href = './processGetTowers.php'><input type = 'button' value = 'Refresh Towers' /></a>"; //echo "<a href = './processTowerDetails.php'><input type = 'button' value = 'Refresh All Tower Details' /></a>"; //echo "<br />"; //echo "<br />"; echo "<form action='processTowerMembers.php' method='post'/>"; echo "<fieldset>"; echo "<legend>Towers</legend>"; for ($i = 0; $i < $starbaseCount; $i++) { echo "<fieldset>"; echo "<legend><span class='DisplayBlue'>" . $moonIDs[$i] . "</span> -> <span class='DisplayYellow'>" . $typeIDs[$i] . "</span> ---> " . $states[$i] . "</legend>"; echo "<table class='Tower' border='' align='center' >"; echo "<tr>"; echo "<th>Pilot</th>"; if ($isAdmin) { echo "<th>Remove</th>"; } echo "</tr>"; for ($x = 0; $x < $memberCount[$i]; $x++) { echo "<tr>"; echo "<td>" . $posMembers[$i][$x] . "</td>"; if ($isAdmin) { echo "<td><input type='checkbox' name='remove" . $posMemberIds[$i][$x] . "' value = 'removeMe' /></td>"; } echo "</tr>"; } echo "<tr>"; echo "</table>"; echo "<table class='Tower' border='' align='center' >"; echo "<tr>"; echo "<th>Type</th>"; echo "<th>Amount</th>"; echo "<th>lastUpdate</th>"; echo "</tr>"; for ($x = 0; $x < $fuelCount; $x++) { echo "<tr>"; echo "<td>" . $starbaseFuelType[$i][$x] . "</td>"; echo "<td>" . $starbaseFuel[$i][$x] . "</td>"; echo "<td>" . $starbaseUpdate[$i][$x] . "</td>"; echo "</tr>"; } echo "</table>"; if ($states[$i] == "Reinforced") { echo "<span class = 'Display'>This tower is currently Reinforced. It will exit at: " . $stateTimes[$i]; } echo "Current Number of Residents: " . $memberCount[$i]; echo "<br />"; echo "Current Landlord: " . $landlord[$i]; //echo "<br />"; //echo "<a href = './TDSInTowerAdvance.php?ViewStarbase=".$starbaseIDs[$i]."'><input type = 'button' value = 'Tower Advance View' /></a>"; //echo "<a href = './processTowerDetails.php?UpdateStarbase=".$starbaseIDs[$i]."'><input type = 'button' value = 'Refresh Tower Details' /></a>"; if ($isAdmin) { echo "<br />"; echo "<br />"; echo "<input type='hidden' name='targetTower' value='" . $starbaseIDs[$i] . "' />"; echo "<br />"; echo "<br />"; echo "<label>Landlord:</label>"; echo "<select name = 'selLandlord'>"; echo "<option value='-1'>-= Select A Landlord =-</option>"; for ($x = 0; $x < $memberCount[$i]; $x++) { echo "<option value = '" . $posMemberIds[$i][$x] . "'>" . $posMembers[$i][$x] . "</option>"; } echo "</select>"; echo "<br />"; echo "<button type = 'button' onclick='newPilot()'>"; echo "Add Residents"; echo "</button>"; echo "<input type = 'text' id = 'txtPilots' value = '0' />"; echo "<div id = 'divOutput'>"; echo "</div>"; echo "<input type='submit' value='Submit Changes' />"; } echo "</fieldset>"; } echo "</fieldset>"; echo "</form>"; if ($isAdmin) { echo "<script type = 'text/javascript'>"; echo "\n"; echo "//<![CDATA["; echo "\n"; echo "//from TDSInTowerAdvance.php"; echo "\n"; echo "function newPilot()"; echo "\n"; echo "{"; echo "\n"; echo "var result = \"\";"; echo "\n"; echo "var pilots = txtPilots.value;"; echo "\n"; echo "var users = new Array();"; echo "\n"; echo "var usersIds = new Array();"; echo "\n"; echo "var count = " . ($userCount + 1) . ";"; echo "\n"; echo "\n"; echo "users[0] = \"-= Select Pilot =-\";"; echo "\n"; echo "usersIds[0] = 0;"; echo "\n"; for ($x = 1; $x < $userCount; $x++) { echo "users[" . $x . "] = \"" . $userList[$x] . "\";"; echo "\n"; echo "usersIds[" . $x . "] = " . $userIdList[$x] . ";"; echo "\n"; } echo "result += \"<input type = 'hidden' name = 'AddedPilotCountYo' value = '\"+pilots+\"' />\";"; echo "for(var i = 0; i < pilots; i++)"; echo "\n"; echo "{"; echo "\n"; echo "result += \"<label>Pilot Name:</label>\";"; echo "\n"; echo "result += \"<select name = 'selType\" + i + \"'>\""; echo "\n"; echo "for(var y = 0; y < users.length; y++)"; echo "\n"; echo "{"; echo "\n"; echo "result += \"<option value = '\"+usersIds[y]+\"'>\"+users[y]+\"</option>\";"; echo "\n"; echo "}"; echo "\n"; echo "result += \"</select>\";"; echo "\n"; /*echo"result += \"<label>Shares:</label>\";"; echo "\n"; echo"result += \"<input type = 'text' name = 'Shares\" + i + \"' />\";"; echo "\n";*/ echo "result += \"<br />\";"; //divOutput.innerHTML += result; echo "\n"; echo "}"; echo "\n"; //result += "<p>"+ count +"</p>"; echo "divOutput.innerHTML = result;"; echo "\n"; echo "}"; echo "\n"; echo "//]]>"; echo "\n"; echo "</script>"; } } else { Fail("There is required information missing"); } }
/** * Testes expected behaviour of adding entries to tracker list */ public function testAddMaintenanceTaskEntryInvalid() { $maintenanceTracker = MaintenanceTracker::getMaintenanceTracker(); //gets instance of tracker try { $maintenanceTracker->addMaintenanceTaskEntry(null); //null not valid echo "testAddMaintenanceTaskEntryInvalid null test failed\n"; Assert . Fail(); } catch (InvalidArgumentException $e) { echo "testAddMaintenanceTaskEntryInvalid null test successful\n"; } catch (Exception $e) { echo "testAddMaintenanceTaskEntryInvalid null test failed\n"; Assert . Fail(); } $maintenanceTracker = MaintenanceTracker::getMaintenanceTracker(); try { $maintenanceTracker->addMaintenanceTaskEntry(new DateTime()); //date time not valid echo "testAddMaintenanceTaskEntryInvalid invalid object test failed\n"; Assert . Fail(); } catch (InvalidArgumentException $e) { echo "testAddMaintenanceTaskEntryInvalid invalid object test successful\n"; } catch (Exception $e) { echo "testAddMaintenanceTaskEntryInvalid invalid object test failed\n"; Assert . Fail(); } try { $maintenaceTaskEntry = new MaintenanceTaskEntry(4, "Oil Change", new GasCar("Ford", "Focus", 2000, 23424), new DateTime(), false); if (!$maintenanceTracker->addMaintenanceTaskEntry($maintenaceTaskEntry)) { echo "testAddMaintenanceTaskEntryInvalid allready in list object test failed\n"; // should have been added sucessfully Assert . Fail(); } if ($maintenanceTracker->addMaintenanceTaskEntry($maintenaceTaskEntry)) { echo "testAddMaintenanceTaskEntryInvalid allready in list object test failed\n"; // should have been first initially added Assert . Fail(); } else { echo "testAddMaintenanceTaskEntryInvalid allready in list object test successful\n"; } } catch (InvalidArgumentException $e) { echo "testAddMaintenanceTaskEntryInvalid allready in list test failed\n"; Assert . Fail(); } catch (Exception $e) { echo "testAddMaintenanceTaskEntryInvalid allready in list test failed\n"; Assert . Fail(); } }
<?php $fail = false; $key_id = 0; if (isset($_POST["key"])) { $key_id = $_POST["key"]; } else { $fail = true; } include 'connection.php'; if (IsProduction()) { mysql_select_db("eve.tdsin"); } else { mysql_select_db("naed_Sapphire"); } if (!$fail) { $sql = "CALL sp_ChangeActiveAPIKey(" . $key_id . ")"; $result = mysql_query($sql, $conn) or die(mysql_error()); Success(); } else { Fail("No Key was selected"); } function Fail($error) { header('Location: ./TDSInError.php?Error=' . $error . ''); } function Success() { header('Location: ./TDSInAdminTools.php'); }
// More than one result is IMPOSSIBLE, didn't we already limit it to 1 on // the SQL query? } elseif ($sel_n > 1) { RuntimeError(); // If there is at least one resend petition, we continue } elseif ($sel_n == 1) { // Reading query result while ($row = mysql_fetch_array($sel_r, MYSQL_ASSOC)) { // Getting user info to use it on mail $uid = $row['uid']; $mail = $row['mail']; $token = $row['token']; $givenName = $row['givenName']; // Sending e-mail ... $send = AssistedEMail("ResendMailDo", $mail); // If the mailing went OK ... if ($send) { // We log the event WriteLog("ResendMailDo"); // Print the good news to the user Success("ResendMailDo"); } else { // We fail nicely, at least Fail("ResendMailDo"); } } } } // Closing the connection $mysqlx = AssistedMYSQLClose($mysqlc); require_once "./themes/{$app_theme}/footer.php";
$val_r = AssistedMYSQLQuery($val_q); // Create the table if we don't have it if (!$val_r) { require_once "./libraries/CreatePasswordTable.inc.php"; } // We build up our query to insert the user data into a temporary MYSQL Database // while the user gets the confirmation e-mail and clicks the link $ins_q = sprintf("INSERT INTO ResetPassword " . "(uid, mail, token, description) " . "VALUES ('%s', '%s', '%s', '%s')", mysql_real_escape_string($uid), mysql_real_escape_string($mail), mysql_real_escape_string($newtoken), mysql_real_escape_string($description)); // Inserting the row on the table ... $ins_r = AssistedMYSQLQuery($ins_q); // If the insert went OK, we send the notification e-mail to the user if ($ins_r) { $send = AssistedEMail("ResetPasswordMail", $mail); } // If the mailing went OK ... if ($send) { // We log the event WriteLog("ResetPasswordMail"); // Print the good news to the user Success("ResetPasswordMail"); } else { // We fail nicely, at least Fail("ResetPasswordMail"); } } } // Closing the connection $ldapx = AssistedLDAPClose($ldapc); // Closing the connection $mysqlx = AssistedMYSQLClose($mysqlc); require_once "./themes/{$app_theme}/footer.php";
/** * Tests electric car creation with improper model argument, ensuring proper exceptions are thrown */ public function testElectricCarCreationWithImproperModelArgument() { try { $ElectricCar = new ElectricCar("Tesla", "Invalid", 2000, 123); //Invalid is not a valid model echo "testElectricCarCreationWithImproperModelArgument Invalid Make test failed\n"; Assert . Fail(); } catch (InvalidArgumentException $e) { echo "testElectricCarCreationWithImproperModelArgument Invalid Make test successful\n"; } catch (Exception $e) { echo "testElectricCarCreationWithImproperModelArgument Invalid Make test failed\n"; Assert . Fail(); } }
<br/> <div id="ControlPanel"> <br/> <table class="CPanel Searchd"> <tbody> <tr> <th class="Desc">Searchd: </th> <th>Status</th> </tr> <tr> <td>Status: </td> <td> <?php if ($Settings['Status']->SearchdRunning) { Success('Running'); } else { Fail('Not Running'); } ?> </td> </tr> </tbody> </table> <br/> </div> <br/> <h3>Changelog</h3> 20140115 <ol> <li>Deleted non-working links in the control panel</li>
$result = mysql_query($sql, $conn) or die(mysql_error()); } } //sp_UpdateUserIsk(userIsk, userID) //sp_OpTransaction(userID, opID, _amount, _date) //sp_AddUserToOpAttendence(opID, userID, _shares) //Foreach Item for ($x = 0; $x < $oldItemCount; $x++) { $sql = "Call sp_UpdateOpLoot(" . $oldItemIds[$x] . ", " . $op_id . ", " . $oldItemNewAmounts[$x] . ")"; $result = mysql_query($sql, $conn) or die(mysql_error()); } //sp_UpdateOpLoot(itemID, opID, _amount) //Foreach New Item for ($x = 0; $x < $newItemCount; $x++) { $sql = "Call sp_AddItemToOpLoot(" . $op_id . ", " . $newItemIds[$x] . ", " . $newItemAmounts[$x] . ")"; $result = mysql_query($sql, $conn) or die(mysql_error()); } //sp_AddItemToOpLoot(opID, itemID, _amount) Success(); } else { Fail($error); } function Fail($inError) { header('Location: ./TDSInError.php?Error=' . $inError . ''); } function Success() { //Go to View Op header('Location: ./TDSInAdminTools.php'); }
if ($update != $today) { //Update Fuel; $sql = "CALL sp_UpdateDetail(" . $details[$x] . ", " . $amounts[$x] . ")"; $result = mysql_query($sql, $conn) or die(mysql_error()); $sql = "CALL sp_UpdateStarbaseDetail(" . $starBasePks[$i] . ", " . $details[$x] . ", '" . $today . "')"; $result = mysql_query($sql, $conn) or die(mysql_error()); } } } } } else { $fail = true; break; } } if ($fail) { Fail("There was an Error getting Tower Details"); } else { Success(); } } else { Fail("Failed to Get Tower Details"); } function Fail($error) { header('Location: ./TDSInError.php?Error=' . $error . ''); } function Success() { header('Location: ./TDSInTowers.php'); }
if ($result_count == 0) { NoResults(); // If we got more than one entry, then something is really messed up with // the database, there must not be more than one entry with the same data } elseif ($result_count > 1) { MultipleResults(); // If we got one coincidence, then we can proceed to deletion } elseif ($result_count == 1) { // Assigning DN to delete $dn = $search_entries[0]["dn"]; // Deleting ... $del = AssistedLDAPDelete($ldapc, $dn); // If the deleting went OK, we send the notification e-mail to the user if ($del) { $send = AssistedEMail("DeleteUserDo", $mail); } // If the mailing went OK ... if ($send) { // We log the event WriteLog("DeleteUserDo"); // Print the good news to the user Success("DeleteUserDo"); } else { // We fail nicely, at least Fail("DeleteUserDo"); } } } // Closing the connection $ldapx = AssistedLDAPClose($ldapc); require_once "./themes/{$app_theme}/footer.php";
/** * Test gas gar creation with improper model argument, ensuring proper exceptions are thrown */ public function testGasCarCreationWithImproperModelArgument() { try { $gasCar = new GasCar("Ford", "Invalid", 2000, 123); //Invalid is not a proper model echo "testGasCarCreationWithImproperModelArgument Invalid Make test failed\n"; Assert . Fail(); } catch (InvalidArgumentException $e) { echo "testGasCarCreationWithImproperModelArgument Invalid Make test successful\n"; } catch (Exception $e) { echo "testGasCarCreationWithImproperModelArgument Invalid Make test failed\n"; Assert . Fail(); } }
if (!$val_r) { require_once "./libraries/CreateUserTable.inc.php"; } // Encoding the password $userPassword = EncodePassword($userPassword, $ldap_enc); // We build up our query to insert the user data into a temporary MYSQL Database // while the user gets the confirmation e-mail and clicks the link $ins_q = sprintf("INSERT INTO NewUser " . "(uid, givenName, sn, mail, userPassword, description, token) " . "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s')", mysql_real_escape_string($uid), mysql_real_escape_string($givenName), mysql_real_escape_string($sn), mysql_real_escape_string($mail), mysql_real_escape_string($userPassword), mysql_real_escape_string($description), mysql_real_escape_string($newtoken)); // Inserting the row on the table ... $ins_r = AssistedMYSQLQuery($ins_q); // If the insert went OK, we send the notification e-mail to the user if ($ins_r) { $send = AssistedEMail("NewUserMail", $mail); } // If the mailing went OK ... if ($send) { // We log the event WriteLog("NewUserMail"); // Print the good news to the user Success("NewUserMail"); } else { // We fail nicely, at least Fail("NewUserMail"); } } } // Closing the connection $ldapx = AssistedLDAPClose($ldapc); // Closing the connection $mysqlx = AssistedMYSQLClose($mysqlc); require_once "./themes/{$app_theme}/footer.php";
$in2['uidNumber'] = $in['uidNumber']; // Incrementing maxUID entry $mod = AssistedLDAPModify($ldapc, $moddn, $in2); } // If the modification went OK, we send the notification e-mail to the user if ($mod) { $send = AssistedEMail("NewUserDo", $mail); } // If the mailing went OK ... if ($send) { // We need to get rid of the temporary entry $del_q = sprintf("DELETE FROM NewUser" . " WHERE uid='%s'" . " AND token='%s'", mysql_real_escape_string($uid), mysql_real_escape_string($token)); // Deleting the row from the table ... $del_r = AssistedMYSQLQuery($del_q); // We log the event WriteLog("NewUserDo"); // Print the good news to the user Success("NewUserDo"); } else { // We fail nicely, at least Fail("NewUserDo"); } } } } } // Closing the connection $ldapx = AssistedLDAPClose($ldapc); // Closing the connection $mysqlx = AssistedMYSQLClose($mysqlc); require_once "./themes/{$app_theme}/footer.php";
} else { $fail = true; } if (trim($passwordOne) == "") { $fail = true; } if ($passwordOne != $passwordTwo) { $fail = true; } if (!$fail) { $userSalt = uniqid(); $newHash = crypt($passwordOne, '$6$rounds=10000$' + $userSalt + '$'); $sql = "Call sp_UpdateUserPassword(" . $targetUserID . ", '" . $newHash . "', '" . $userSalt . "')"; $result = mysql_query($sql, $conn) or die(mysql_error()); $sql = "Call sp_UpdateUserReset(" . $targetUserID . ", 1)"; $result = mysql_query($sql, $conn) or die(mysql_error()); $sql = "Call sp_UpdateUserLock(" . $targetUserID . ", 0)"; $result = mysql_query($sql, $conn) or die(mysql_error()); //echo $sql; Success(); } else { Fail("You failed to change the password of the target user"); } function Fail($error) { header('Location: ./TDSInError.php?Error=' . $error . ''); } function Success() { header('Location: ./TDSInAdminTools.php'); }
function AccessGranted() { global $conn; $sql = "SELECT\n\t\t\t\t\t\tkey_id\n\t\t\t\t\tFROM\n\t\t\t\t\t\tEveAPIKeys\n\t\t\t\t\tWhere\n\t\t\t\t\t\tinUse = 1"; $result = mysql_query($sql, $conn) or die(mysql_error()); $fail = false; $keyIdYo = -1; while ($row = mysql_fetch_assoc($result)) { foreach ($row as $name => $value) { if ($name == "key_id") { $keyIdYo = $value; } } } if ($keyIdYo == -1) { $fail = true; } if (!$fail) { $sql = "Select\n\t\t\t\t\t\t\ts.starbase_id As 'starbase_id',\n\t\t\t\t\t\t\ts.itemID As 'itemID',\n\t\t\t\t\t\t\tt.typeName As 'typeID',\n\t\t\t\t\t\t\ts.locationID As 'locationID',\n\t\t\t\t\t\t\td.itemName As 'moonID',\n\t\t\t\t\t\t\tss.name As 'state',\n\t\t\t\t\t\t\ts.stateTimestamp As 'stateTimestamp',\n\t\t\t\t\t\t\ts.onlineTimestamp As 'onlineTimestamp',\n\t\t\t\t\t\t\ts.lastUpdate As 'lastUpdate'\n\t\t\t\t\t\tFrom\n\t\t\t\t\t\t\tStarbase_Key k\n\t\t\t\t\t\tLeft Join\n\t\t\t\t\t\t\tStarbases s on s.starbase_id = k.starbase_id\n\t\t\t\t\t\tLeft Join\n\t\t\t\t\t\t\tStarbase_States ss on ss.state = s.state\n\t\t\t\t\t\tLeft Join\n\t\t\t\t\t\t\tinvTypes t on t.typeID = s.typeID\n\t\t\t\t\t\tleft join\n\t\t\t\t\t\t\tmapDenormalize d on d.itemID = s.moonID\n\t\t\t\t\t\tWhere\n\t\t\t\t\t\t\tkey_id = " . $keyIdYo . "\n\t\t\t\t\t\torder by d.itemName"; $result = mysql_query($sql, $conn) or die(mysql_error()); $starbaseIDs[0] = 0; $itemIDs[0] = 0; $typeIDs[0] = 0; $locationIDs[0] = 0; $moonIDs[0] = ""; $states[0] = ""; $stateTimes[0] = ""; $onlineTimes[0] = ""; $lastUpdates[0] = ""; $starbaseCount = 0; while ($row = mysql_fetch_assoc($result)) { foreach ($row as $name => $value) { if ($name == "starbase_id") { $starbaseIDs[$starbaseCount] = $value; } if ($name == "itemID") { $itemIDs[$starbaseCount] = $value; } if ($name == "typeID") { $typeIDs[$starbaseCount] = $value; } if ($name == "locationID") { $locationIDs[$starbaseCount] = $value; } if ($name == "moonID") { $moonIDs[$starbaseCount] = $value; } if ($name == "state") { $states[$starbaseCount] = $value; } if ($name == "stateTimestamp") { $stateTimes[$starbaseCount] = $value; } if ($name == "onlineTimestamp") { $onlineTimes[$starbaseCount] = $value; } if ($name == "lastUpdate") { $lastUpdates[$starbaseCount] = $value; $starbaseCount++; } } } $starbaseFuelType[0] = array(); $starbaseFuel[0] = array(); $starbaseUpdate[0] = array(); $memberCount[0] = 0; $landlord[0] = ""; for ($i = 0; $i < $starbaseCount; $i++) { $fuelCount = 0; $sql = "Select\n\t\t\t\t\t\t\t\ts.lastUpdate,\n\t\t\t\t\t\t\t\tt.typeName as 'fuel_type',\n\t\t\t\t\t\t\t\td.amount\n\t\t\t\t\t\t\tFrom\n\t\t\t\t\t\t\t\tStarbase_Details s\n\t\t\t\t\t\t\tLeft Join\n\t\t\t\t\t\t\t\tDetails d on d.detail_id = s.detail_id\n\t\t\t\t\t\t\tLeft Join\n\t\t\t\t\t\t\t\tinvTypes t on t.typeID = d.fuel_typeID\n\t\t\t\t\t\t\tWhere\n\t\t\t\t\t\t\t\ts.starbase_id =" . $starbaseIDs[$i]; $result = mysql_query($sql, $conn) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { foreach ($row as $name => $value) { if ($name == "lastUpdate") { $starbaseUpdate[$i][$fuelCount] = $value; } if ($name == "fuel_type") { $starbaseFuelType[$i][$fuelCount] = $value; } if ($name == "amount") { $starbaseFuel[$i][$fuelCount] = $value; $fuelCount++; } } } $landlordName = "-= No Landlord =-"; $sql = "Select\n\t\t\t\t\t\t\t\tCount(user_id) as 'Residents'\n\t\t\t\t\t\t\tFrom\n\t\t\t\t\t\t\t\tStarbase_Users\n\t\t\t\t\t\t\tWhere\n\t\t\t\t\t\t\t\tisRemoved = 0\n\t\t\t\t\t\t\t\tAnd\n\t\t\t\t\t\t\t\tStarbase_id = " . $starbaseIDs[$i]; $result = mysql_query($sql, $conn) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { foreach ($row as $name => $value) { if ($name == "Residents") { $memberCount[$i] = $value; } } } $sql = "Select\n\t\t\t\t\t\t\t\tu.user_name\n\t\t\t\t\t\t\tFrom\n\t\t\t\t\t\t\t\tStarbase_Users su\n\t\t\t\t\t\t\tLeft Join\n\t\t\t\t\t\t\t\tUsers u on u.user_id = su.user_id\n\t\t\t\t\t\t\tWhere\n\t\t\t\t\t\t\t\tsu.isRemoved = 0\n\t\t\t\t\t\t\t\tAnd\n\t\t\t\t\t\t\t\tsu.isLandlord = 1\n\t\t\t\t\t\t\t\tAnd\n\t\t\t\t\t\t\t\tsu.Starbase_id = " . $starbaseIDs[$i] . "\n\t\t\t\t\t\t\tLimit 1"; $landlord[$i] = $landlordName; $result = mysql_query($sql, $conn) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { foreach ($row as $name => $value) { if ($name == "user_name") { $landlord[$i] = $value; } } } } echo "<a href = './processGetTowers.php'><input type = 'button' value = 'Refresh Towers' /></a>"; echo "<a href = './processTowerDetails.php'><input type = 'button' value = 'Refresh All Tower Details' /></a>"; echo "<br />"; echo "<br />"; echo "<form action='' method='post'/>"; echo "<fieldset>"; echo "<legend>Towers</legend>"; for ($i = 0; $i < $starbaseCount; $i++) { echo "<fieldset>"; echo "<legend><span class='DisplayBlue'>" . $moonIDs[$i] . "</span> -> <span class='DisplayYellow'>" . $typeIDs[$i] . "</span> ---> " . $states[$i] . "</legend>"; /*echo "<table class='Tower' border='' align='center' >"; echo "<tr>"; echo "<th>Type</th>"; echo "<th>Info</th>"; echo "</tr>"; echo "<tr>"; echo "<td>itemID</td>"; echo "<td>".$itemIDs[$i]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td>typeID</td>"; echo "<td>".$typeIDs[$i]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td>locationID</td>"; echo "<td>".$locationIDs[$i]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td>moonID</td>"; echo "<td>".$moonIDs[$i]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td>state</td>"; echo "<td>".$states[$i]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td>stateTime</td>"; echo "<td>".$stateTimes[$i]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td>onlineTime</td>"; echo "<td>".$onlineTimes[$i]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td>lastUpdate</td>"; echo "<td>".$lastUpdates[$i]."</td>"; echo "</tr>"; echo "</table>";*/ echo "<table class='Tower' border='' align='center' >"; echo "<tr>"; echo "<th>Type</th>"; echo "<th>Amount</th>"; echo "<th>lastUpdate</th>"; echo "</tr>"; for ($x = 0; $x < $fuelCount; $x++) { echo "<tr>"; echo "<td>" . $starbaseFuelType[$i][$x] . "</td>"; echo "<td>" . $starbaseFuel[$i][$x] . "</td>"; echo "<td>" . $starbaseUpdate[$i][$x] . "</td>"; echo "</tr>"; } echo "</table>"; if ($states[$i] == "Reinforced") { echo "<span class = 'Display'>This tower is currently Reinforced. It will exit at: " . $stateTimes[$i]; } echo "Current Number of Residents: " . $memberCount[$i]; echo "<br />"; echo "Current Landlord: " . $landlord[$i]; echo "<br />"; echo "<a href = './TDSInTowerAdvance.php?ViewStarbase=" . $starbaseIDs[$i] . "'><input type = 'button' value = 'Tower Advance View' /></a>"; echo "<a href = './processTowerDetails.php?UpdateStarbase=" . $starbaseIDs[$i] . "'><input type = 'button' value = 'Refresh Tower Details' /></a>"; echo "</fieldset>"; } echo "</fieldset>"; echo "</form>"; } else { Fail("No Active API Keys Found"); } }
} } if ($newRankPower >= $processorRankPower) { Fail("You do not have the power to Preform this act"); } else { $sql = "Select\n\t\t\t\t\t\tuser_id\n\t\t\t\t\tfrom\n\t\t\t\t\t\tUsers\n\t\t\t\t\twhere\n\t\t\t\t\t\tuser_name = '" . strtolower($targetUserName) . "'"; $result = mysql_query($sql, $conn) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { foreach ($row as $name => $value) { if ($name == "user_id") { $targetUserID = $value; } } } if ($targetUserID == -1) { Fail("Bad Data, I think??"); } else { $sql = "Call sp_UpdateUserRank(" . $targetUserID . ", " . $newRankId . ")"; $result = mysql_query($sql, $conn) or die(mysql_error()); Success(); } } } function Fail($error) { header('Location: ./TDSInError.php?Error=' . $error . ''); } function Success() { header('Location: ./TDSInAdminTools.php'); }
} } } if (!$fail) { if (!$rankFail) { //Update Old Ranks for ($i = 0; $i < $anotherOldCount; $i++) { global $oldRankIds, $oldRankNewPower; $sql = "Call sp_UpdateRankPower(" . $oldRankIds[$i] . ", " . $oldRankNewPower[$i] . ")"; $result = mysql_query($sql, $conn) or die(mysql_error()); } //Add New Ranks for ($i = 0; $i < $newRankCount; $i++) { $sql = "Call sp_AddNewRank('" . $newRankNames[$i] . "', " . $newRankPower[$i] . ")"; $result = mysql_query($sql, $conn) or die(mysql_error()); } } else { Fail("You cannot Create or Edit the Rank of a Rank with higher or Equal Power as yourself"); } Success(); } else { Fail("Bad Data"); } function Fail($error) { header('Location: ./TDSInError.php?Error=' . $error . ''); } function Success() { header('Location: ./TDSInAdminTools.php'); }
// We construct the modificator array $in['userPassword'] = $encPassword; // Modifying ... $mod = AssistedLDAPModify($ldapc, $moddn, $in); // If the modifying went OK, we send the notification e-mail to the user if ($mod) { $send = AssistedEMail("ResetPasswordDo", $mail); } // If the mailing went OK ... if ($send) { // We need to get rid of the temporary entry $del_q = sprintf("DELETE FROM ResetPassword" . " WHERE mail='%s'" . " AND uid='%s'" . " AND token='%s'", mysql_real_escape_string($mail), mysql_real_escape_string($uid), mysql_real_escape_string($token)); // Deleting the row from the table ... $del_r = AssistedMYSQLQuery($del_q); // We log the event WriteLog("ResetPasswordDo"); // Print the good news to the user Success("ResetPasswordDo"); } else { // We fail nicely, at least Fail("ResetPasswordDo"); } } } } } // Closing the connection $ldapx = AssistedLDAPClose($ldapc); // Closing the connection $mysqlx = AssistedMYSQLClose($mysqlc); require_once "./themes/{$app_theme}/footer.php";