* fetch_accounts.php : TxRTS fetch accounts php script. * * Accepts the following params: user_id (string) * * Returns a JSON blob with the account object(s) */ function fixtags($text) { $text = preg_replace("/Optional\\("/", "", $text); $text = preg_replace("/"\\)/", "", $text); return $text; } /*----------------------------------------------------------------------*/ // get values posted and remove extraneous characters $userID = htmlentities($_POST["userID"]); $userID = fixtags($userID); try { // a new MongoDB connection $conn = new MongoClient(); // connect to test database $db = $conn->test; // a new products collection object $collection = $db->accounts; // fetch all product documents $cursor = $collection->find(array('userID' => $userID)); // How many results found $num_docs = $cursor->count(); if ($num_docs > 0) { // loop over the results foreach ($cursor as $obj) { echo '_id: ' . $obj['_id'] . "\n";
* * *---------------------------------------------------------------------*/ //require("RTS_mongoDB_connect.php"); function fixtags($text) { $text = preg_replace("/Optional\\("/", "", $text); $text = preg_replace("/"\\)/", "", $text); return $text; } /*----------------------------------------------------------------------*/ // get values posted and remove extraneous characters $userID = htmlentities($_POST["userID"]); $userID = fixtags($userID); $activityID = htmlentities($_POST["activityID"]); $activityID = fixtags($activityID); try { // connect $m = new MongoClient(); // select a database $db = $m->test; $activityCollection = $db->activities; $activityQuery = array("activityID" => $activityID); $activityRet = $activityCollection->remove($activityQuery); var_dump($activityRet); $returnValue = "Success"; echo json_encode($returnValue); session_write_close(); ob_flush(); flush(); return;
* *---------------------------------------------------------------------*/ //require("RTS_mongoDB_connect.php"); function fixtags($text) { $text = preg_replace("/Optional\\("/", "", $text); $text = preg_replace("/"\\)/", "", $text); return $text; } /*----------------------------------------------------------------------*/ // get values posted and remove extraneous characters $userID = htmlentities($_POST["userID"]); $userID = fixtags($userID); echo $userID; $accountID = htmlentities($_POST["accountID"]); $accountID = fixtags($accountID); echo $accountID; try { // connect $connection = new MongoClient(); // select a database $db = $connection->test; $accountCollection = $db->accounts; $contactCollection = $db->contacts; $accountQuery = array("userID" => $userID); $accountRet = $accountCollection->remove($accountQuery); echo $accountRet['n'] . "documents deleted \n"; var_dump($accountRet); $contactQuery = array("userID" => $userID); $contactRet = $contactCollection->remove($contactQuery); echo $contactRet['n'] . "documents deleted \n";
//require("RTS_mongoDB_connect.php"); function fixtags($text) { $text = preg_replace("/Optional\\("/", "", $text); $text = preg_replace("/"\\)/", "", $text); return $text; } /*----------------------------------------------------------------------*/ // hard-wire email "jbb" for testing only.... //$email = "jbb"; //$password = "******"; // get values posted and remove extraneous characters $email = htmlentities($_POST["email"]); $email = fixtags($email); $password = htmlentities($_POST["password"]); $password = fixtags($password); $returnValue = array(); //hey // connect $m = new MongoClient(); // select a database $db = $m->RTSRegistrations; // select a collection (analogous to a relational database's table) $collection = $db->Registrations; $user = array("email" => "{$email}"); //$user = array ("email" => "$email" , "password" => "$password" ); $userDetails = $collection->find($user); // iterate through the results $registered = "false"; foreach ($userDetails as $document) { //Xecho $document["email"] . "\n";
} // get values posted and remove extraneous characters $userID = htmlentities($_POST["userID"]); $userID = fixtags($userID); $activityID = htmlentities($_POST["activityID"]); $activityID = fixtags($activityID); $accountID = htmlentities($_POST["accountID"]); $accountID = fixtags($accountID); $type = htmlentities($_POST["type"]); $type = fixtags($type); $dateCreated = htmlentities($_POST["dateCreated"]); $dateCreated = fixtags($dateCreated); $notes = htmlentities($_POST["notes"]); $notes = fixtags($notes); $inbound = htmlentities($_POST["inbound"]); $inbound = fixtags($inbound); $activityArray = array('userID' => $userID, 'activityID' => $activityID, 'accountID' => $accountID, 'type' => $type, 'dateCreated' => $dateCreated, 'notes' => $notes, 'inbound' => $inbound); try { // connect $m = new MongoClient(); // select a database $db = $m->test; // a new accounts and contact collection object $activityCollection = $db->activities; // insert the array $activityCollection->insert($activityArray); echo 'Activity inserted with ID: ' . $activityArray['_id'] . "\n"; $returnValue = "Success"; echo json_encode($returnValue); session_write_close(); ob_flush();
$companyName = htmlentities($_POST["companyName"]); $companyName = fixtags($companyName); $projectName = htmlentities($_POST["projectName"]); $projectName = fixtags($projectName); $isVIP = htmlentities($_POST["isVIP"]); $isVIP = fixtags($isVIP); $firstName = htmlentities($_POST["firstName"]); $firstName = fixtags($firstName); $lastName = htmlentities($_POST["lastName"]); $lastName = fixtags($lastName); $email = htmlentities($_POST["email"]); $email = fixtags($email); $phone = htmlentities($_POST["phone"]); $phone = fixtags($phone); $phone2 = htmlentities($_POST["phone2"]); $phone2 = fixtags($phone2); $accountArray = array('userID' => $userID, 'accountID' => $accountID, 'companyName' => $companyName, 'projectName' => $projectName, 'isVIP' => $isVIP); $contactArray = array('userID' => $userID, 'firstName' => $firstName, 'lastName' => $lastName, 'email' => $email, 'phone' => $phone, 'phone2' => $phone2); try { // connect $m = new MongoClient(); // select a database $db = $m->test; // a new accounts and contact collection object $accountCollection = $db->accounts; $contactCollection = $db->contacts; // insert the array $accountCollection->insert($accountArray); $contactCollection->insert($contactArray); echo 'Account inserted with ID: ' . $accountArray['_id'] . "\n"; echo 'Contact asdfadfinserted with ID: ' . $contactArray['_id'] . "\n";