Your IP : 216.73.216.55


Current Path : /home/giteleslfp/www/administrator/components/com_templateck/interfaces/
Upload File :
Current File : /home/giteleslfp/www/administrator/components/com_templateck/interfaces/ajaxsavefavorite.php

<?php

/**
 * @name		Template Creator CK
 * @copyright	Copyright (C) since 2011. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 * @author		Cedric Keiflin - http://www.template-creator.com - http://www.joomlack.fr
 */
// No direct access to this file
defined('TCK_LOADED') or die();

$blocs = $this->input->get('favorite', null, null);
$id = $this->input->get('id', -1, 'int');
$path = TEMPLATECREATORCK_PATH . '/favorites';
$error = 0;

if (is_numeric($id) && (int) $id > -1) {
	$i = (int) $id;
} else {
	$i = count(TCK_Folder::files($path, '.fck3'));
	$j = 0;
	$error = 0;
	while (file_exists(TEMPLATECREATORCK_PATH . '/favorites/favorite'.$i.'.fck3') && $j < 1000) {
		$i++;
		$j++;
	}
	if ($j >= 1000) {
		echo 'ERROR reach loop of 1000 files';
		$error = 1;
	}
}

$exportfiledest = TEMPLATECREATORCK_PATH . '/favorites/favorite'.$i.'.fck3';
$exportfiletext = $blocs;

if (!TCK_File::write($exportfiledest, $exportfiletext) || $error == 1) {
	$msg = TCK_Text::_('CK_ERROR_CREATING_FAVORITEFILE');
	$status = 0;
} else {
	$msg = $i;
	$status = 1;
}
echo '{"status": "' . $status . '", "msg": "' . $msg . '"}';
exit();