<?php
///////////////////////////////////////////////////////////////////////////////////////
// PHPizabi 0.848b 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.848b 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')?die("Access restricted"):NULL);
	
	
	
	/* Initialize template engine */
	$tpl = new template;
	$tpl -> Load("add");
	
	/* Get the languages array */
	$i=0;
	foreach(explode(",", $CONF["LOCALE_SITE_LANGUAGES"]) as $lang) {
		$langLoop[$i]["language"] = $lang;
		$i++;
	}
	$tpl -> Loop("language", $langLoop);
	

	/* Handle posted horoscope data */
	if (isset($_POST["Submit"])) {

		/* Load title and body for all the languages */
		foreach ($_POST as $var => $val) {
			if (strstr($var, "_")) {
				$var = explode("_", $var);
				if ($var[0] == "body") $body[$var[1]] = $val;
			}
		}
	
		$hArr = unpk(file_get_contents("system/cache/horoscopes.dat"));
		if (!is_array($hArr)) $hArr = array();
		
		end($hArr);
		$key = key($hArr)+1;
		
		$hArr[$key]["body"] = $body;
		
		if ($handle = fopen("system/cache/horoscopes.dat", "w")) {
			fwrite($handle, pk($hArr));
			fclose($handle);
		}
	}
	
	
	
	$tpl -> Flush();