Enjoy an ad free experience by logging in. Not a member yet?
Register .
08-31-2006, 02:52 AM
PM User |
#1
New to the CF scene
Join Date: Aug 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
What do I use, for or foreach??
PHP Code:
function Build_htAccess ()
{
$result1 = $this -> DB_Query ( "select * from " . TABLE_PAGES . " where parent_id='0' order by nav_order" );
$count1 = $this -> DB_CountResult ( $result1 );
$build1 = "php_flag register_globals on\nphp_value register_globals 1\n\n<Files .htaccess>\norder allow,deny\ndeny from all\n</Files>\n\nRewriteBase /\n\n#<DEFAULT>\nDirectoryIndex index.php index.htm index.asp index.shtml\n#</DEFAULT>\n\n" ;
for( $x = 0 ; $x < $count1 ; $x ++)
{
$remove_tags = array( " " , "=" , "+" , ")" , "(" , "*" , "&" , "^" , "%" , "$" , "#" , "@" , "!" , "~" , "`" , "'" , "\"" , "\\" , "/" , "." , "," , "?" , ";" , ":" , "[" , "]" , "{" , "}" , "|" );
$id1 = $this -> DB_Result ( $result1 , $x , "id" );
$link_text1 = strtolower ( str_replace ( $remove_tags , "" , str_replace ( " " , "-" , str_replace ( " " , " " , strip_tags ( $this -> DB_Result ( $result1 , $x , "link_text" ))))));
$layout1 = $this -> DB_Result ( $result1 , $x , "layout" );
$upper_text = strtoupper ( $link_text1 );
$build2 = "#<" . $upper_text . ">\n" ;
if( $this -> Pages_HasSubPages ( $id1 ))
{
$result2 = $this -> DB_Query ( "select * from " . TABLE_PAGES . " where parent_id='" . $id1 . "' order by nav_order" );
$count2 = $this -> DB_CountResult ( $result2 );
for( $y = 0 ; $y < $count2 ; $y ++)
{
$id2 = $this -> DB_Result ( $result2 , $y , "id" );
$link_text2 = strtolower ( str_replace ( $remove_tags , "" , str_replace ( " " , "-" , str_replace ( " " , " " , strip_tags ( $this -> DB_Result ( $result2 , $y , "link_text" ))))));
$layout2 = $this -> DB_Result ( $result2 , $y , "layout" );
if( $this -> Pages_HasSubPages ( $id2 ))
{
$result3 = $this -> DB_Query ( "select * from " . TABLE_PAGES . " where parent_id='" . $id2 . "' order by nav_order" );
$count3 = $this -> DB_CountResult ( $result3 );
for( $z = 0 ; $z < $count3 ; $z ++)
{
$id3 = $this -> DB_Result ( $result3 , $z , "id" );
$link_text3 = strtolower ( str_replace ( $remove_tags , "" , str_replace ( " " , "-" , str_replace ( " " , " " , strip_tags ( $this -> DB_Result ( $result3 , $z , "link_text" ))))));
$layout3 = $this -> DB_Result ( $result3 , $z , "layout" );
$build3 = "RewriteRule ^" . $link_text1 . "/" . $link_text2 . "/" . $link_text3 . "/ index.php?id=" . $id3 . "&layout=" . $layout3 . "\nRewriteRule ^" . $link_text1 . "/" . $link_text2 . "/" . $link_text3 . "." . HTACCESS_EXT . " index.php?id=" . $id3 . "&layout=" . $layout3 . "\nRewriteRule ^" . $link_text1 . "/" . $link_text2 . "/" . $link_text3 . " index.php?id=" . $id3 . "&layout=" . $layout3 . "\n" ;
}
$this -> DB_FreeResult ( $result3 );
}
$build4 = "RewriteRule ^" . $link_text1 . "/" . $link_text2 . "/ index.php?id=" . $id2 . "&layout=" . $layout2 . "\nRewriteRule ^" . $link_text1 . "/" . $link_text2 . "." . HTACCESS_EXT . " index.php?id=" . $id2 . "&layout=" . $layout2 . "\nRewriteRule ^" . $link_text1 . "/" . $link_text2 . " index.php?id=" . $id2 . "&layout=" . $layout2 . "\n" ;
}
$this -> DB_FreeResult ( $result2 );
}
$build5 = "RewriteRule ^" . $link_text1 . "/ index.php?id=" . $id1 . "&layout=" . $layout1 . "\nRewriteRule ^" . $link_text1 . "." . HTACCESS_EXT . " index.php?id=" . $id1 . "&layout=" . $layout1 . "\nRewriteRule ^" . $link_text1 . " index.php?id=" . $id1 . "&layout=" . $layout1 . "\n" ;
}
$build6 = "#</" . $upper_text . ">\n" ;
$build = $build1 . $build2 . $build3 . $build4 . $build5 . $build6 ;
$htcheck = @ fopen ( "../.htaccess" , "w" ) or die( "INSTALL ERROR - CANNOT CREATE .HTACCESS FILE" );
@ fwrite ( $htcheck , $build ) or die( "INSTALL ERROR - CANNOT WRITE TO .HTACCESS FILE" );
@ fclose ( $htcheck );
$this -> DB_FreeResult ( $result1 );
}
builds
Code:
php_flag register_globals on
php_value register_globals 1
<Files .htaccess>
order allow,deny
deny from all
</Files>
RewriteBase /
#<DEFAULT>
DirectoryIndex index.php index.htm index.asp index.shtml
#</DEFAULT>
#<CONTACT-ME>
RewriteRule ^contact-me/2/3/ index.php?id=9&layout=1
RewriteRule ^contact-me/2/3.xt index.php?id=9&layout=1
RewriteRule ^contact-me/2/3 index.php?id=9&layout=1
RewriteRule ^contact-me/2/ index.php?id=8&layout=1
RewriteRule ^contact-me/2.xt index.php?id=8&layout=1
RewriteRule ^contact-me/2 index.php?id=8&layout=1
RewriteRule ^contact-me/ index.php?id=6&layout=1
RewriteRule ^contact-me.xt index.php?id=6&layout=1
RewriteRule ^contact-me index.php?id=6&layout=1
#</CONTACT-ME>
---- But why does it only write "CONTACT-ME" the last row pulled from the database, and no other rows before it? Am I missing something here?
Last edited by sc0ttkclark; 08-31-2006 at 03:05 AM ..
08-31-2006, 04:20 AM
PM User |
#2
New to the CF scene
Join Date: Aug 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
okay I accomplished it. How did I do it?
I moved this above the first "for":
PHP Code:
$htcheck = @ fopen ( "../.htaccess" , "w" ) or die( "INSTALL ERROR - CANNOT CREATE .HTACCESS FILE" );
and added this after each $buildNUMBER:
PHP Code:
@ fwrite ( $htcheck , $build ) or die( "INSTALL ERROR - CANNOT WRITE TO .HTACCESS FILE" );
One must remember to include the build and write function just before it's corresponding for statement ends. After the last for statement ends, close it out with
PHP Code:
@ fclose ( $htcheck );
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 09:50 PM .
Advertisement
Log in to turn off these ads.