<?php
defined('_JEXEC') or die('Direct Access to this location is not allowed.');

if(version_compare(PHP_VERSION, '5.1.2', '>=')){
 
	$msg  = 'Installation succeeded but an issue occured: ';
	
	if(is_writable(JPATH_SITE . '/')){
	
		if(file_exists(JPATH_SITE . '/administrator/components/com_facileforms/ff_secimage_index.php')){
			if(@copy(JPATH_SITE . '/administrator/components/com_facileforms/ff_secimage_index.php', JPATH_SITE . '/ff_secimage.php')){
				
			} else {
				echo '<b style="color:red">' . $msg. 'Could not write ff_secimage_index.php to ' . JPATH_SITE . '/ff_secimage.php!<br/><br/>Please copy the file "'.JPATH_SITE . '/administrator/components/com_facileforms/ff_secimage_index.php" to "'.JPATH_SITE . '/ff_secimage.php" manually (do not forget to rename it)!</b>';
			}
		} else {
			echo '<b style="color:red">' . $msg. JPATH_SITE . '/administrator/components/com_facileforms/ff_secimage_index.php does not exist!</b></b>';
		}
		
	} else {
		echo '<b style="color:red">' . $msg. 'Could not write ff_secimage_index.php to ' . JPATH_SITE . '/ff_secimage.php!<br/><br/>Please copy the file "'.JPATH_SITE . '/administrator/components/com_facileforms/ff_secimage_index.php" to "'.JPATH_SITE . '/ff_secimage.php" manually (do not forget to rename it)!</b>';
	}
	
	if(is_writable(JPATH_SITE . '/templates/system/')){
	
		if(file_exists(JPATH_SITE . '/administrator/components/com_facileforms/ff_secimage_template.php')){
			if(@copy(JPATH_SITE . '/administrator/components/com_facileforms/ff_secimage_template.php', JPATH_SITE . '/templates/system/ff_secimage.php')){
				
			}else {
				echo '<b style="color:red">' . $msg. 'Could not write ff_secimage_index.php to ' . JPATH_SITE . '/ff_secimage.php!<br/><br/>Please copy the file "'.JPATH_SITE . '/administrator/components/com_facileforms/ff_secimage_template.php" to "'.JPATH_SITE . '/templates/system/ff_secimage.php" manually (do not forget to rename it)!</b>';
			}
		} else {
			echo '<b style="color:red">' . $msg. JPATH_SITE . '/administrator/components/com_facileforms/ff_secimage_template.php does not exist!</b>';
		}
		
	} else {
		 echo '<b style="color:red">' . $msg. 'Could not write ff_secimage_index.php to ' . JPATH_SITE . '/ff_secimage.php!<br/><br/>Please copy the file "'.JPATH_SITE . '/administrator/components/com_facileforms/ff_secimage_template.php" to "'.JPATH_SITE . '/templates/system/ff_secimage.php" manually (do not forget to rename it)!</b>';
	}

} else {
	
	 echo '<b style="color:red">WARNING: YOU ARE RUNNING PHP VERSION "'.PHP_VERSION.'". BREEZINGFORMS WON\'T WORK WITH THIS VERSION. PLEASE UPGRADE TO AT LEAST PHP 5.1.2, SORRY BUT YOU BETTER UNINSTALL THIS COMPONENT NOW!</b>';
	
}

if (file_exists(JPATH_SITE . "/administrator/components/com_joomfish/contentelements"))
{
	@copy( JPATH_SITE . "/administrator/components/com_facileforms/joomfish/facileforms_elements.xml",JPATH_SITE . "/administrator/components/com_joomfish/contentelements/facileforms_elements.xml");
	@copy( JPATH_SITE . "/administrator/components/com_facileforms/joomfish/translationFformFilter.php", JPATH_SITE . "/administrator/components/com_joomfish/contentelements/translationFformFilter.php");
	@copy( JPATH_SITE . "/administrator/components/com_facileforms/joomfish/translationFformoptions_emptyFilter.php", JPATH_SITE . "/administrator/components/com_joomfish/contentelements/translationFformoptions_emptyFilter.php");
}
?>