Embed this on the web:
Embed this on artician:
loadHTML(file_get_contents('http://.../fbtest2/gettoken.php'));
$grabToken = new DOMXPath($tokenMachine);
$tokenGrabber = $grabToken->query('//span[@id="token"]');
foreach ($tokenGrabber as $tokenGrab) {
return $tokenGrab->nodeValue;
}
}
$_SESSION['token'] = generateToken();
/**
* @name listProjects
* @return Array of student project records.
*/
function listProjects() {
$listMachine = new DOMDocument();
$listMachine->loadHTML(file_get_contents('http://.../fbtest2/list.php?token='.$_SESSION['token']));
$getList = new DOMXPath($listMachine);
$listGrabber1 = $getList->query('//table[@id="mytable"]/tbody/tr/td[1]'); // For student IDs.
$listGrabber2 = $getList->query('//table[@id="mytable"]/tbody/tr/td[2]'); // For project titles.
$outputArray = array();
$outputArray1 = array();
$outputArray2 = array();
foreach ($listGrabber1 as $listGrabbed1) {
array_push($outputArray1, strtolower(str_ireplace(' ', '', $listGrabbed1->nodeValue)));
}
unset($listGrabbed1);
foreach ($listGrabber2 as $listGrabbed2) {
array_push($outputArray2, htmlspecialchars_decode($listGrabbed2->nodeValue));
}
unset($listGrabbed2);
$outputArray = array_combine($outputArray2, $outputArray1);
$resultArray = array();
foreach(array_keys($outputArray) as $key) {
if(array_key_exists($outputArray[$key],$resultArray)) {
$resultArray[$outputArray[$key]] = array_merge((array)$resultArray[$outputArray[$key]], (array)$key);
} else {
$resultArray[$outputArray[$key]] = $key;
}
}
return $resultArray;
}
/**
* HTML output starts here. If this was the real world, the PHP code above would have been stored in the model and controller layer,
* and the following in the view layer.
*/
?>
Report
|