Author: rado
Date: Wed May 30 10:48:29 2007
New Revision: 462
URL: http://svn.gna.org/viewcvs/phplinker?rev=462&view=rev
Log:
#130
- generate .htaccess if not exist
- create new lib htaccess.php
- regenerete .htaccess on add or change category
Added:
trunk/www/lib/htaccess.php
Modified:
trunk/www/includes/start.php
trunk/www/index.php
trunk/www/lib/category.php
Modified: trunk/www/includes/start.php
URL:
http://svn.gna.org/viewcvs/phplinker/trunk/www/includes/start.php?rev=462&r1=461&r2=462&view=diff
==============================================================================
--- trunk/www/includes/start.php (original)
+++ trunk/www/includes/start.php Wed May 30 10:48:29 2007
@@ -37,6 +37,7 @@
require(dirname(__FILE__)."/../lib/category.php");
require(dirname(__FILE__)."/../lib/url.php");
require(dirname(__FILE__)."/../lib/log.php");
+require(dirname(__FILE__)."/../lib/htaccess.php");
require(dirname(__FILE__)."/../lib/sql_config.php");
require(dirname(__FILE__)."/../lib/xajax/xajax.inc.php");
require(dirname(__FILE__)."/../lib/tag_xajax.php");
Modified: trunk/www/index.php
URL:
http://svn.gna.org/viewcvs/phplinker/trunk/www/index.php?rev=462&r1=461&r2=462&view=diff
==============================================================================
--- trunk/www/index.php (original)
+++ trunk/www/index.php Wed May 30 10:48:29 2007
@@ -24,6 +24,10 @@
$server_name = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REDIRECT_URL'];
else
$server_name = "http://".$_SERVER['SERVER_NAME']."/";
+
+if (!file_exists(".htaccess")){
+ linker_create_htaccess();
+ }
$urls='';
$categories='';
$navbars='';
Modified: trunk/www/lib/category.php
URL:
http://svn.gna.org/viewcvs/phplinker/trunk/www/lib/category.php?rev=462&r1=461&r2=462&view=diff
==============================================================================
--- trunk/www/lib/category.php (original)
+++ trunk/www/lib/category.php Wed May 30 10:48:29 2007
@@ -168,7 +168,7 @@
$id=mysql_insert_id();
linker_log("[".$_SESSION['login'] ."]Add category $name");
- require('../admin/htaccess.php');
+ linker_regenerate_htaccess();
$objResponse->addScriptCall("addCateg_step2", $id, $name);
}
else
@@ -193,8 +193,7 @@
$qry = sql_query('die',__FILE__,__LINE__,__FUNCTION__,$qry);
linker_log("[".$_SESSION['login'] ."]Update category $id set id_parent as
$id_parent,<br>set id_ad_tag as $id_ad_tag,<br>set name as $name $visibilite2");
- require('../admin/htaccess.php');
-
+ linker_regenerate_htaccess();
// }
// if ($last === 'true')
// $objResponse->addAlert("Modifications enregistrées");
Added: trunk/www/lib/htaccess.php
URL:
http://svn.gna.org/viewcvs/phplinker/trunk/www/lib/htaccess.php?rev=462&view=auto
==============================================================================
--- trunk/www/lib/htaccess.php (added)
+++ trunk/www/lib/htaccess.php Wed May 30 10:48:29 2007
@@ -1,0 +1,41 @@
+<?
+function linker_create_htaccess(){
+ $htaccess = fopen(".htaccess", "w");
+ fwrite($htaccess,"Options +MultiViews\n");
+ fwrite($htaccess,"php_flag register_globals off\n");
+ fwrite($htaccess,"AddDefaultCharset off\n\n");
+ fwrite($htaccess,"RewriteEngine On\n\n");
+
+ $values = linker_get_category_tree(0,'','0','',true);
+
+ for ($i=1, $n=sizeof($values); $i<$n; $i++) {
+ $char = linker_htaccess($values[$i]['id']);
+ $char = linker_remove_accents($char);
+ $real_link = "index.php?cat=".$values[$i]['id'];
+ fwrite($htaccess,"RewriteRule ^$char$ $real_link [last]\n");
+ }
+ fclose($htaccess);
+}
+
+function linker_regenerate_htaccess(){
+if (!$htaccess = fopen(dirname(__FILE__)."/../.htaccess", "w"))
+ exit(1);
+
+ fwrite($htaccess,"Options +MultiViews\n");
+ fwrite($htaccess,"php_flag register_globals off\n");
+ fwrite($htaccess,"#php_value error_reporting 2037\n");
+ fwrite($htaccess,"AddDefaultCharset off\n\n");
+ fwrite($htaccess,"RewriteEngine On\n\n");
+
+$values = linker_get_category_tree(0,'','0','',true);
+
+for ($i=1, $n=sizeof($values); $i<$n; $i++) {
+ $char = linker_htaccess($values[$i]['id']);
+ $char = linker_remove_accents($char);
+ $real_link = "index.php?cat=".$values[$i]['id'];
+ fwrite($htaccess,"RewriteRule ^$char$ $real_link [last]\n");
+}
+fclose($htaccess);
+
+}
+?>
_______________________________________________
PHPLinker-commits mailing list
[email protected]
https://mail.gna.org/listinfo/phplinker-commits