<?php
/*
* Created on Aug 29, 2008
* 2.0
*/
ini_set("session.gc_maxlifetime","10800");
require_once 'include/IPage.php';
class AddItemsOnServerPage implements IPage
{
private $path, $hidden;
function GetHead(& $title)
{
if (false == USER_IS_ADMIN)
return;
global $DB, $URLP, $G, $P;
$path = trim(@$G['path']);
if (false !== strpos($path, '..') or '/' == $path)
$path = '';
$this->path = $path;
if (isset($P['fileNames']))
{
require_once 'include/ItemAdder.php';
$IA = new ItemAdder();
$hidden = (int)$P['hidden'];
if (!USER_IS_ADMIN)
$max = 2;
else
$max = 3;
if ($hidden > $max or $hidden < 0)
$hidden = 0;
$location = $DB->FilterString($P['loc']);
if (empty($location))
$location = 'unknown location';
$location = trim($location);
$tags = trim($DB->FilterString($P['tags']));
$date = $IA->ReplaceBadDate($P['date']);
$path = PICS_PATH.$path;
if ($IA->MakePath($path))
{
foreach ($P['fileNames'] as $name)
{
$IA->AddItem($path, $name, $location, $tags, $date, $hidden);
}
}
}
$title = 'Add Items Already On Server: /'.$this->path;
return '<script type="text/javascript" language="javascript" SRC="ajax/scriptaculous/prototype.js"></script>'.
'<script type="text/javascript" language="javascript" src="ajax/scriptaculous/scriptaculous.js"></script>'.
'<link href="styles/edit.css" rel="stylesheet" type="text/css" />';
}
function ShowBody()
{
if (false == USER_IS_ADMIN)
return;
global $URLP, $DB, $G;
$pathURL = $URLP->GetExtendedURL().'p=AddItemsOnServer&path=';
$path = $this->path;
if ($dh = @opendir(PICS_PATH.$path))
{
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;
}
sort($files);
}
else
$files = array();
$parents = explode('/', $path);
$parentPathHtml = substr(PICS_PATH, 0, strrpos(PICS_PATH, '/', -2)+1).'<a href="'.$URLP->GetExtendedURL().'p=AddItemsOnServer">'.substr(PICS_PATH, strrpos(PICS_PATH, '/', -2)+1).'</a>';
$parentPaths = '';
foreach ($parents as $parent)
{
if ($parent)
{
$parentPaths .= $parent.'/';
$parentPathHtml .= "<a href='$pathURL$parentPaths'>$parent/</a>";
}
}
$location = @$G['loc'];
$tags = @$G['tags'];
if (!$date = @$G['date'])
$date = date('Y-m-d');
require 'AddItemsOnServerPage.html.php';
}
}
?>