50 lines
1013 B
PHP
50 lines
1013 B
PHP
<?php
|
|
|
|
include 'php/classes/page.php';
|
|
include 'functions/func_xml.php';
|
|
|
|
$page = new Page();
|
|
|
|
$page->attr('title','Links and Numbers');
|
|
$linksandnumbers = xml_get_from_file($FILES['linksandnumbers']);
|
|
$items = $linksandnumbers->xpath('item');
|
|
|
|
if(isset($_GET['id']))
|
|
{
|
|
$itemIdx = FindItemById($items,$_GET['id'],true);
|
|
|
|
if(!is_null($itemIdx))
|
|
{
|
|
$page->data('item',$items[$itemIdx]);
|
|
$page->content('linksandnumbers.subpage.php');
|
|
}
|
|
else
|
|
{
|
|
$page->addError('Links and numbers item does not exist.');
|
|
$page->content('linksandnumbers.php');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$page->data('items',$items);
|
|
$page->content('linksandnumbers.php');
|
|
}
|
|
|
|
$page->process();
|
|
|
|
################################################################# FindItemById #
|
|
function FindItemById($items, $itemId, $returnIdx = false)
|
|
{
|
|
for($c = 0; $c < count($items); $c++)
|
|
{
|
|
if((int)$items[$c]['id'] === (int)$itemId)
|
|
if($returnIdx)
|
|
return $c;
|
|
else
|
|
return $items[$c];
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
?>
|