%%image-save-writer-html%%
$Date: 2003/02/26 21:51:19 $

%%preprocess%%
$posto= $GLOBALS[HTTP_POST_VARS];

foreach ($posto AS $property=>$value) {
 $value= htmlentities(substr($value,0,255));
 $this->propertiesList.= "posted <b>$property</b>= $value<br>";
 }

if ($this->source=="" && $this->defaultsource ) $this->source= $this->defaultsource;

// check somewhere if members are allowed to create before you do this.
if ($session->canSave['image'] || $session->canSave['all']) {
	if ($GLOBALS['sitemember']->role=="member") {
		$session->insertstatus= "posted";
		$session->insertpublic= 1;
		$session->publicwhere= "";
		$session->updatestatus= "posted";
		$session->updatepublic= "1";
		$session->updaterank= "100";
		$GLOBALS[session]= $session;
		}
	}
else {
	berror("Current policy does not allow you to save images.",0);
	ext;
	}

if (trim($this->name)=="") {
	// generate a title-based unique name
	if (trim($this->title)=="") {
		$filename= $_FILES['imagefile']['name'];
		$dotpos= strrpos($filename,".");
		if ($dotpos) {
			$filename= substr($filename,0,$dotpos);
			}
		$this->name= $filename.".".substr(uniqid(""),-4);
		}
	else {
		$this->name= urlencode(strtolower(str_replace(" ","_",$this->title)));
		berror("Before preg_repace, document name is $this->name.",2);
		$this->name= preg_replace("/\%\S\S/","",$this->name);
		$this->name= substr($this->name,0,12)."_".substr(uniqid(""),-4);
		$this->name= str_replace(".","",$this->name);
		}
	}
berror("Image Name is $this->name.",1);

// generate automagic keywords for searching later...
$ignorewords= " the , of , and , a , to , in , is , you , that , it , he , she , for , was , on , are , as , with , his , her , they , at , be , this , from , i , have , or , by , one , had , not , but , all , were , there , can , an , your , which , their , said , if , do , so , these , has , than , did , those , 1 , 2 , 3 , 4 , 5 , 6 ";
$igwordsarray= explode(",", $ignorewords);
$ignorepunctuation= ".,?,!,:,;,[,]";
$igpuncarray= explode(",", $ignorepunctuation);
$igpuncarray[]= ",";
$this->keywords= str_replace($igwordsarray, " ", str_replace($igpuncarray, " ", strtolower($this->description)));
$this->keywords= str_replace("  ", " ", $this->keywords);


%%header%%


%%css%%


%%template%%
<table width='90%' border='0' cellspacing='20' cellpadding='5' align='center'>
<tr> <td> <p><b>UPDATED! $this->objtype object id#$this->id ($this->name):</b></p>
<p>$this->propertiesList</p>
</td>
</tr>
</table>


%%listrow%%


%%nullobject%%


%%footer%%


%%postprocess%%
$GLOBALS['session']->applyPolicy();
$this->getBaseUrl();
$redirect="Location: ".$this->baseUrl."?method=view".$session->cgi; 
if ($GLOBALS[debug]) {
 print "<a href='$this->baseurl?method=view$session->cgi'>Click here to continue.</a>";
 }
else {
 header($redirect); 
 exit;
 }


%%end of context%%
