<?php

/**

* @version $Id: install.php 2120 2007-09-11 07:21:34Z Radek Suski $

* @package: Sigsiu Online Business Index 2

* ===================================================

* @author

* Name: Sigrid & Radek Suski, Sigsiu.NET

* Email: sobi@sigsiu.net

* Url: http://www.sigsiu.net

* ===================================================

* @copyright Copyright (C) 2007 Sigsiu.NET (http://www.sigsiu.net). All rights reserved.

* @license see http://www.gnu.org/copyleft/gpl.html GNU/GPL.

* SOBI2 is free software; you can redistribute it and/or modify

* it under the terms of the GNU General Public License as published by

* the Free Software Foundation.

*/

/*

 * $backendPath

 */

	defined( '_SOBI2_' ) || ( trigger_error("Restricted access", E_USER_ERROR) && exit() );

	if(defined("_SOBI_ADM_PATH")) {

		$config =& adminConfig::getInstance();

		$installPath = _SOBI_ADM_PATH.DS."includes".DS."install".DS."reviews";

		$config->sobiMakePath($frontPath.DS."images");

		$config->sobiMakePath($frontPath.DS."images".DS."Star-Rating");

		$frontPath = _SOBI_FE_PATH.DS."plugins".DS."reviews";

		if(!(file_exists($frontPath.DS."images".DS."Star-Rating")))

		{

			$config->logSobiError("Review Plugin Installer: could not create '".DS."images".DS."Star-Rating");

		}

		$imgPath = $frontPath.DS."images";

		$stars = opendir($installPath.DS."Star-Rating");

		while ($file = readdir($stars)) {

			if($file != "." && $file != "..")

				if(!@copy( $installPath.DS."Star-Rating".DS.$file, $imgPath.DS."Star-Rating".DS.$file) )

					$config->logSobiError("Review Plugin Installer: could not copy {$file} in '{$imgPath}".DS."Star-Rating".DS."{$file}'");

		}

		@copy($installPath.DS."progress.gif",$imgPath.DS."progress.gif");

	}

	else {

		$url = "index2.php?option=com_sobi2&task=pluginsManager&mosmsg=".urlencode("The Reviews and Ratings plugin requires at least SOBI2 RC 2.8.0. Please uninstall this plugin and update your SOBI2 version");

		@ob_end_clean();

		header( 'HTTP/1.1 301 Moved Permanently' );

		header( "Location: ". $url );

		exit();

	}

?>

