$prefix = strtolower($pSplit[0]); $postfix = $pSplit[1]; if ($prefix == "u" || $prefix == "p") { if ($prefix == "u") { if (array_key_exists('n', $_GET)) { $name = decodeInput($_REQUEST['n']); //it is a user created location $lat = decodeInput($_REQUEST['lat']); $long = decodeInput($_REQUEST['long']); if (!is_numeric($lat) || !is_numeric($long)) { redirectIndex(); } else { $location = $lat . "," . $long; $category = new Category(); $category->setSubCategory("custom"); $poi->init($name, "Nepal", $location, $category, "NA", "NA", "NA", "", new User()); } } else { redirectIndex(); } } else { if ($prefix == "p") { if (is_numeric($postfix)) { $poiController = new PoiController(); $poi = $poiController->find($postfix); if ($poi) { } else { redirectIndex(); } } else { redirectIndex();
$name = str_replace("'", "''", $name); $address = $row[1]; $contacts = relinquishContacts($row[2]); $phone = $contacts[0]; $email = $contacts[1]; $website = $contacts[2]; $categoryLabel = $row[3]; $position = $row[4]; //create the category for the poi $category = new Category(); $category->init($parentController->getParentCategory($categoryLabel), $categoryLabel, $user); if ($id = $categoryController->add($category)) { $category->setId($id); //create the poi object $poi = new POI(); $poi->init($name, $address, $position, $category, $phone, $email, $website, "", $user); if ($poiController->add($poi)) { $insertCount++; } else { $skippedData[] = $line . "\n"; } } else { $skippedData[] = $line . "\n"; } } else { /* skip this data as it contains invalid number of data*/ $skippedData[] = $line . "\n"; } //need to execute javascript here to increment the progress bar and update the progress text send_message($insertCount, $insertCount, $insertCount); } catch (Exception $e) {
$userId = $_SESSION['userId']; if ($_SERVER['REQUEST_METHOD'] == 'POST' || $_SERVER['REQUEST_METHOD'] == 'post') { /* get all the post data from */ $poiName = decodeInput($_POST['poiName']); $poiAddress = decodeInput($_POST['poiAddress']); $poiCategory = decodeInput($_POST['poiCategory']); $poiPhone = decodeInput($_POST['poiPhone']); $poiEmail = decodeInput($_POST['poiEmail']); $poiWebsite = decodeInput($_POST['poiWebsite']); $poiLatitude = decodeInput($_POST['poiLat']); $poiLongitude = decodeInput($_POST['poiLong']); $poiPosition = $poiLatitude . "," . $poiLongitude; $poiContribution = decodeInput($_POST['poiContribution']); $userController = new UsersController(); $poiController = new PoiController(); $categoryController = new CategoryController(); $contributionController = new ContributionController(); /* since we are letting the validation of the data on the client side, we will skip the validation here and just go on with insertion */ /* so first create the poi object, also the required objects to initialize the poi */ $poi = new POI(); $poi->init($poiName, $poiAddress, $poiPosition, $categoryController->find($poiCategory), $poiPhone, $poiEmail, $poiWebsite, "", $userController->find($user->getId())); if ($poiContribution != 0) { if (is_numeric($poiContribution)) { if ($contribution = $contributionController->find($poiContribution)) { $poi->setContribution($contribution); } } } $poiController->add($poi); }
* Created by Yogesh on 11/20/2015. * */ include_once "../model/PoiController.php"; include_once "../model/UsersController.php"; include_once "../model/objects/User.php"; include_once "../model/objects/POI.php"; include_once "../model/objects/Contribution.php"; include_once "../model/objects/Category.php"; include_once "../model/objects/ParentCategory.php"; include_once "../model/CategoryController.php"; include_once "../model/ContributionController.php"; header("Content-Type: text/plain"); $cont = new ContributionController(); $data = $cont->getAll(); print_r($data); exit; $dataArray = array("Pokhara||Gandaki Zone, Kaski District, Nepal||http://en.wikipedia.org/wiki/Pokhara||city||28.2095379,83.9914028", "Hyatt Regency||Nepal||null||bus station||27.7193693,85.3541166", "Ason||Nepal||null||neighbourhood||27.7075079,85.3122521", "Lainchour Chowk Bus Stop||Nepal||null||bus station||27.7169967,85.316039", "Airport Bus Station||Nepal||null||bus station||27.7007168,85.3537173", "Dillibazaar stop||Nepal||null||bus station||27.7053698,85.3267594"); $currentUser = $userController->find(3); $poiIdDummy = 56; foreach ($dataArray as $key => $value) { $row = $value; $data = explode("||", $row); $category = new Category(); $category->setUser($currentUser); $category->setSubCategory($data[3]); $poi = new POI(); $poi->init($poiIdDummy, $data[0], $data[1], $data[4], $category, "", "", "", "", $currentUser); $contributionController->add($poi); $poiIdDummy++; }