<?php
///////////////////////////////////////////////////////////////////////////////////////
// PHPizabi 0.844b C1 [ALICIA]                               http://www.phpizabi.net //
///////////////////////////////////////////////////////////////////////////////////////
// Please read the license.txt file before using / modifying this software           //
// Original author:         Claude Desjardins, R - feedback@realitymedias.com        //
// Last modification date:  August 13th 2006                                         //
// Version:                 PHPizabi 0.844b C1                                       //
//                                                                                   //
// (C) 2005, 2006 Real!ty Medias / PHPizabi - All rights reserved                    //
///////////////////////////////////////////////////////////////////////////////////////

	/* Check Structure Availability */
	if (!defined("CORE_STRAP")) die("Out of structure call");
	/* Administrative restriction */
	(!me('is_administrator')&&!me('is_superadministrator')?throwerror("Access restricted"):NULL);

	$tpl = new template;
	$tpl -> Load("datlist");
	
//get suqgestions

function getdats($folder=""){

	$file_list = array();

$path = "system/cache/". $folder;

	if ($handle  = opendir($path)) {

		while (false !== ($file = readdir($handle))) {

			if ($file != "." && $file != ".." && !is_dir($file) && substr($file,-3) == "dat") {

				if(strlen($folder) > 0) {$file_list[$file] = $path . '/' . $file; } else $file_list[$file] = $path . $file;
			}
		}

		closedir($handle);
	}
	
return $file_list; 

}


//get questions

$questionnaires_list = getdats('questionnaires');

if(count($questionnaires_list) > 0){

$tpl->Zone('questionnaires','enabled');

$i = 0;

foreach($questionnaires_list as $key => $val){

$questionnaires_array[$i]["questionnaires.name"] = base64_decode(substr($key,0,strpos($key,'.')));

$questionnaires_array[$i]["questionnaires.file"] = $val;

$questionnaires_array[$i]["questionnaires.size"] = round(filesize($val) / 1024, 2);

$i++;
}

$tpl->Loop('questionnaires_list',$questionnaires_array);

} else $tpl->Zone('questionnaires','disabled');


//get other

$other_list = getdats('');

if(count($other_list) > 0){

$tpl->Zone('other','enabled');


$i = 0;

foreach($other_list as $key => $val){

$other_array[$i]["other.name"] = substr($key,0,strpos($key,'.'));

$other_array[$i]["other.file"] = $val;

$other_array[$i]["other.size"] = round(filesize($val) / 1024, 2);

$i++;
}

$tpl->Loop('other_list',$other_array);

} else $tpl->Zone('other','disabled');

	
	// TEMPLATE REPROCESS & FLUSH ////////////////////////////////////////////////////
	//$tpl -> CleanZones();

	/* Get the frame templates, flush the TPL result into it */
	$frame = new template;
	$frame -> Load("!theme/{$GLOBALS["THEME"]}/templates/admin/frame.tpl");
	$frame -> AssignArray(array(
		"jump" => $tpl->Flush(1)
	));
	
	/* Assign Location Value */
	$locationArray = @explode(".", $_GET["L"]);
	for ($i=0; $i<count($locationArray); $i++) {
		$locationAppendResult[] = $locationArray[$i];
		if ($i > 0) $location[] = "<a href=\"?L=".implode(".", $locationAppendResult)."\">{$locationArray[$i]}</a>";
	}
	$frame -> AssignArray(array("location" => implode(" &raquo; ", $location)));
	
	/* Set the forced chromeless mode, flush the template */
	$GLOBALS["CHROMELESS_MODE"] = 1;
	$frame -> Flush();
	