Example #1
0
function proc_items($items, $itemNum, $categoryID)
{
    $realItemNum = $itemNum > 1000 ? 976 : $itemNum;
    for ($i = 1; $i <= $realItemNum; $i += 25) {
        // get 25 from i
        $url = sprintf("//api.walmartlabs.com/v1/search?apiKey=zttbe274whhe3ghezr9ktcfu&query=\"*\"&categoryId=%s&start=%d&numItems=25", $categoryID, $i);
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = json_decode(curl_exec($ch));
        curl_close($ch);
        foreach ($response->items as $item) {
            //get each item info
            $url = sprintf("//api.walmartlabs.com/v1/items/%s?apiKey=zttbe274whhe3ghezr9ktcfu", $item->itemId);
            $ch = curl_init($url);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $response = json_decode(curl_exec($ch));
            curl_close($ch);
            insertIntoDB($response);
        }
    }
}
Example #2
0
				$studentNumbersFromDB .= $row['studentnumber']." "; //the extra space string here creates a delimiter
			}
		}
		
		//if the user signed in with a student number existing in the DB, update rather than insert.
		//also, sometimes the user might have a cookie for their information; this accounts for that
		$snForDB = isset($_SESSION['studentNumber']) ? $_SESSION['studentNumber'] : $_COOKIE['studentNumber'];
		$nameForDB = (isset($_SESSION['firstName']) ? $_SESSION['firstName'] : $_COOKIE['firstName'])." ".
			(isset($_SESSION['lastName']) ? $_SESSION['lastName'] : $_COOKIE['lastName']);
		$progForDB = isset($_SESSION['programs']) ? $_SESSION['programs'] : $_COOKIE['programs'];
		$coursesforDB = isset($_SESSION['courses']) ? $_SESSION['courses'] : $_COOKIE['courses'];
		
		if (strpos($studentNumbersFromDB, $snForDB) !== false) {
			updateDB($snForDB, $nameForDB, $progForDB, $coursesforDB);
		} else {
			insertIntoDB($snForDB, $nameForDB, $progForDB, $coursesforDB);
		}
		?>
	</body>
</html>
<?php
} else {
	header("Location: index.php");
}
function updateDB($studentnumber, $fullname, $program, $courses) {
	global $conn;
	$sql = "UPDATE `rosenich`.`students` SET fullname='$fullname', 
		program='$program', courses='$courses' 
		WHERE studentnumber='$studentnumber'";
	if (!$conn->query($sql)) {
		echo "Error: " . $sql . "<br>" . $conn->error;
Example #3
0
    if ($errFlag != 1) {
        $inputs["fName"] = scrubInput($_REQUEST["fName"]);
        $inputs["lName"] = scrubInput($_REQUEST["lName"]);
        $inputs["email"] = scrubInput($_REQUEST["email"]);
        $inputs["testRigUsername"] = scrubInput($_REQUEST["testRigUsername"]);
        $inputs["phoneNumber"] = scrubInput($_REQUEST["phoneNumber"]);
        $inputs["instName"] = scrubInput($_REQUEST["instName"]);
        $inputs["scpUsername"] = scrubInput($_REQUEST["scpUsername"]);
        $inputs["scpDstIp"] = scrubInput($_REQUEST["scpDstIp"]);
        $inputs["scpPubKey"] = scrubInput($_REQUEST["scpPubKey"]);
        $inputs["rtEmailAddress"] = scrubInput($_REQUEST["rtEmailAddress"]);
        //hash the password
        $inputs["testRigPassword"] = password_hash($_REQUEST["testRigPassword"], PASSWORD_BCRYPT);
        //echo "You entered:<hr>First Name:  ".$inputs["fName"]. "<br>Last Name:  " . $inputs["lName"]. "<br>Email:  " . $inputs["email"] . "<br>Phone:  " . $inputs["phoneNumber"] . "<br>Institution:  " . $inputs["instName"] . "<br>SCP Username:  "******"scpUsername"]. "<br>Dst IP:  " .$inputs["scpDstIp"]. "<br>Key:  " . $inputs["scpPubKey"] . "<br>" . "Password: "******"testRigPassword"] . "<br>";
        //insert this shit into the DB
        if (insertIntoDB($inputs)) {
            if (triggerNotification($inputs)) {
                echo "Your subscription request to TestRig2.0 has been received. Please allow 1 ";
                echo "business day to process the request and receive approval notification.";
            } else {
                echo "The attempt to send notification of your request failed.";
            }
        } else {
            echo "There was a problem processing your request.";
        }
    }
}
//end PHP input validation
?>