What Mod rewrite do I use?
- Shawn
- Student


- Joined: Mar 28, 2004
- Posts: 65
- Status: Offline
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
May 14th, 2004, 11:16 am
- Axe
- Genius


- Joined: Jan 07, 2004
- Posts: 5744
- Loc: Sub-level 28
- Status: Offline
Code: [ Select ]
RewriteRule ^([0-9]+).html$ index.php?c=$1& [L]
That would turn 2.html into index.php?c=2, so that when somebody entered 2.html into their browser it would send them to the correct page.
How to turn index.php?c=2 into 2.html, well that's between you and your script. Your script will have to send out the modified URLs. .htaccess can't do that for you, it can only forward from the fake URL to the real URL.
- Shawn
- Student


- Joined: Mar 28, 2004
- Posts: 65
- Status: Offline
- Axe
- Genius


- Joined: Jan 07, 2004
- Posts: 5744
- Loc: Sub-level 28
- Status: Offline
Already answered that one
That has nothing to do with mod_rewrite. That is purely based on the URLs your script outputs. It's impossible to say what you'd need to do without knowing what PHP scripts you use, or seeing the code.
Axe wrote:
How to turn index.php?c=2 into 2.html, well that's between you and your script. Your script will have to send out the modified URLs. .htaccess can't do that for you, it can only forward from the fake URL to the real URL.
That has nothing to do with mod_rewrite. That is purely based on the URLs your script outputs. It's impossible to say what you'd need to do without knowing what PHP scripts you use, or seeing the code.
- Shawn
- Student


- Joined: Mar 28, 2004
- Posts: 65
- Status: Offline
Sorry, Im a moron. Ok, here's the code for the c=variable part, what do you think I should change?
Thanks,
Shawn
Code: [ Select ]
<?
include ("config.php");
include ("include.php");
include ("lang.php");
session_start();
$c *= 1;
if ($c == 0) { $c = 1; };
$sql = mysql_query("SELECT name, title, description, pages, ref FROM {$prefix}categories WHERE id = $c");
$current_category = mysql_fetch_array($sql, MYSQL_ASSOC);
if (($c > 1) & !$current_category["name"]){
header("Location: {$dir}index.php");
};
include ("config.php");
include ("include.php");
include ("lang.php");
session_start();
$c *= 1;
if ($c == 0) { $c = 1; };
$sql = mysql_query("SELECT name, title, description, pages, ref FROM {$prefix}categories WHERE id = $c");
$current_category = mysql_fetch_array($sql, MYSQL_ASSOC);
if (($c > 1) & !$current_category["name"]){
header("Location: {$dir}index.php");
};
- <?
- include ("config.php");
- include ("include.php");
- include ("lang.php");
- session_start();
- $c *= 1;
- if ($c == 0) { $c = 1; };
- $sql = mysql_query("SELECT name, title, description, pages, ref FROM {$prefix}categories WHERE id = $c");
- $current_category = mysql_fetch_array($sql, MYSQL_ASSOC);
- if (($c > 1) & !$current_category["name"]){
- header("Location: {$dir}index.php");
- };
Thanks,
Shawn
- Axe
- Genius


- Joined: Jan 07, 2004
- Posts: 5744
- Loc: Sub-level 28
- Status: Offline
that's the index.php?
does your site use any kind of theme/template (like PostNuke)?
Basically, what you'd need to do is look at the PHP functions for handling the output buffer...
ob_start(); (to start capturing the output buffer)
ob_get_contents(); (you'd store what's in this function in a variable)
ob_end_clean(); (to stop capturing the output buffer and clear it)
Now, let's say you did...
What would happen is, instead of sending that text out down to the browser, it gets stored in the $somvar variable instead.
You will have to write a function to basically search & replace certain text for certain other text. For example, searching for index.php?c=somenumber, and replacing it with somenumber.html. You'd call this funtion and pass the contents of $somevar to it. The function would process the contents, search and replace the appropriate URLs, and then return it back...
At which point, you'd simply echo my_search_and_replace_function($somevar); and it would get sent out to the browser (as you're no longer capturing the output buffer), with your replaced URLs (that .htaccess is already prepared to accept).
So, basically, in your index.php, right at the top, you want your ob_start(); function. Then at the bottom of your index.php, store the buffer contents in a variable, quit capturing the output buffer, process the variable, and echo out the results.
does your site use any kind of theme/template (like PostNuke)?
Basically, what you'd need to do is look at the PHP functions for handling the output buffer...
ob_start(); (to start capturing the output buffer)
ob_get_contents(); (you'd store what's in this function in a variable)
ob_end_clean(); (to stop capturing the output buffer and clear it)
Now, let's say you did...
PHP Code: [ Select ]
<?php
ob_start();
echo '<html><head><title>Test</title></head><body>This is some text!</body></html>';
$somevar = ob_get_contents();
ob_end_clean();
?>
ob_start();
echo '<html><head><title>Test</title></head><body>This is some text!</body></html>';
$somevar = ob_get_contents();
ob_end_clean();
?>
- <?php
- ob_start();
- echo '<html><head><title>Test</title></head><body>This is some text!</body></html>';
- $somevar = ob_get_contents();
- ob_end_clean();
- ?>
What would happen is, instead of sending that text out down to the browser, it gets stored in the $somvar variable instead.
You will have to write a function to basically search & replace certain text for certain other text. For example, searching for index.php?c=somenumber, and replacing it with somenumber.html. You'd call this funtion and pass the contents of $somevar to it. The function would process the contents, search and replace the appropriate URLs, and then return it back...
At which point, you'd simply echo my_search_and_replace_function($somevar); and it would get sent out to the browser (as you're no longer capturing the output buffer), with your replaced URLs (that .htaccess is already prepared to accept).
So, basically, in your index.php, right at the top, you want your ob_start(); function. Then at the bottom of your index.php, store the buffer contents in a variable, quit capturing the output buffer, process the variable, and echo out the results.
- Axe
- Genius


- Joined: Jan 07, 2004
- Posts: 5744
- Loc: Sub-level 28
- Status: Offline
- Shawn
- Student


- Joined: Mar 28, 2004
- Posts: 65
- Status: Offline
Ok..your too advanced for me. I kinda new to php..html I know but php baffles me. but here is what I gathered I should use:
However it doesnt work. What do you suggest?
Thanks again,
Shawn
Code: [ Select ]
{
ob_start();
function replace_for_mod_rewrite(&$s)
{
$urlin =
array(
"'(?<!/)index.php\?p=([0-9]*)'",
);
$urlout = array(
"([0-9]+).html",
);
$s = preg_replace($urlin, $urlout, $s);
return $s;
}
}
ob_start();
function replace_for_mod_rewrite(&$s)
{
$urlin =
array(
"'(?<!/)index.php\?p=([0-9]*)'",
);
$urlout = array(
"([0-9]+).html",
);
$s = preg_replace($urlin, $urlout, $s);
return $s;
}
}
- {
- ob_start();
- function replace_for_mod_rewrite(&$s)
- {
- $urlin =
- array(
- "'(?<!/)index.php\?p=([0-9]*)'",
- );
- $urlout = array(
- "([0-9]+).html",
- );
- $s = preg_replace($urlin, $urlout, $s);
- return $s;
- }
- }
However it doesnt work. What do you suggest?
Thanks again,
Shawn
- Axe
- Genius


- Joined: Jan 07, 2004
- Posts: 5744
- Loc: Sub-level 28
- Status: Offline
Close, but not quite, it'd be more like......
PHP Code: [ Select ]
<?php
function replace_for_mod_rewrite(&$s) {
$urlin =
array(
'"index.php\?p=([0-9]+)"'
);
$urlout = array(
'"([0-9]+).html"'
);
$s = preg_replace($urlin, $urlout, $s);
return $s;
}
// This is where we start capturing the output buffer...
ob_start();
// Anything outside of php tags is normally just sent right out to the browser. Here, we're capturing it to the output buffer instead.
// Below here is where your page normally performs its regular functions.
?>
<html><head><title>This is your title</title></head><body>
Here's all your content
</body></html>
<?php
// Now we add all this lot to the end of the file after the regular script processes.
// Here we put the contents of the output buffer into $somevar
$somevar = ob_get_contents();
// And here we empty the output buffer and stop capturing it.
ob_end_clean();
// Here's where we send the contents of the $somvar variable to the replacement function, and echo the result down to the browser (Remember, we're no longer capturing the output buffer, so down it goes).
echo replace_for_mod_rewrite($somevar);
?>
function replace_for_mod_rewrite(&$s) {
$urlin =
array(
'"index.php\?p=([0-9]+)"'
);
$urlout = array(
'"([0-9]+).html"'
);
$s = preg_replace($urlin, $urlout, $s);
return $s;
}
// This is where we start capturing the output buffer...
ob_start();
// Anything outside of php tags is normally just sent right out to the browser. Here, we're capturing it to the output buffer instead.
// Below here is where your page normally performs its regular functions.
?>
<html><head><title>This is your title</title></head><body>
Here's all your content
</body></html>
<?php
// Now we add all this lot to the end of the file after the regular script processes.
// Here we put the contents of the output buffer into $somevar
$somevar = ob_get_contents();
// And here we empty the output buffer and stop capturing it.
ob_end_clean();
// Here's where we send the contents of the $somvar variable to the replacement function, and echo the result down to the browser (Remember, we're no longer capturing the output buffer, so down it goes).
echo replace_for_mod_rewrite($somevar);
?>
- <?php
- function replace_for_mod_rewrite(&$s) {
- $urlin =
- array(
- '"index.php\?p=([0-9]+)"'
- );
- $urlout = array(
- '"([0-9]+).html"'
- );
- $s = preg_replace($urlin, $urlout, $s);
- return $s;
- }
- // This is where we start capturing the output buffer...
- ob_start();
- // Anything outside of php tags is normally just sent right out to the browser. Here, we're capturing it to the output buffer instead.
- // Below here is where your page normally performs its regular functions.
- ?>
- <html><head><title>This is your title</title></head><body>
- Here's all your content
- </body></html>
- <?php
- // Now we add all this lot to the end of the file after the regular script processes.
- // Here we put the contents of the output buffer into $somevar
- $somevar = ob_get_contents();
- // And here we empty the output buffer and stop capturing it.
- ob_end_clean();
- // Here's where we send the contents of the $somvar variable to the replacement function, and echo the result down to the browser (Remember, we're no longer capturing the output buffer, so down it goes).
- echo replace_for_mod_rewrite($somevar);
- ?>
- Shawn
- Student


- Joined: Mar 28, 2004
- Posts: 65
- Status: Offline
Ok, I tried that and like 4 different variations with no luck. Here is my index file. I dont really know what sections of it would need modifying to make static urls. Any ideas?
Thanks,
Shawn
Thanks,
Shawn
Code: [ Select ]
<?
include ("config.php");
include ("include.php");
include ("lang.php");
session_start();
$c *= 1;
if ($c == 0) { $c = 1; };
$sql = mysql_query("SELECT name, title, description, pages, ref FROM {$prefix}categories WHERE id = $c");
$current_category = mysql_fetch_array($sql, MYSQL_ASSOC);
if (($c > 1) & !$current_category["name"]){
header("Location: {$dir}index.php");
};
if (!$current_category["name"]) { $current_category["name"] = "Directory Search"; };
if (!$current_category["title"]) { $current_category["title"] = $current_category["name"]; };
if (!$current_category["description"]) { $current_category["description"] = $current_category["name"]." ".$current_category["title"]; };
$last_category = false;
$ref = $c;
while(!$last_category){
$n_parent_categories += 1;
$sql = mysql_query("SELECT id, name, ref FROM {$prefix}categories WHERE id = $ref");
$parent_categories[$n_parent_categories-1] = mysql_fetch_array($sql, MYSQL_ASSOC);
if ($parent_categories[$n_parent_categories-1]["ref"] == 0){
$last_category = true;
}else{
$ref = $parent_categories[$n_parent_categories-1]["ref"];
};
};
$sql = mysql_query("SELECT {$prefix}categories.id, {$prefix}categories.name, COUNT({$prefix}pages.id) AS pages FROM {$prefix}categories LEFT JOIN {$prefix}pages ON {$prefix}pages.category = {$prefix}categories.id AND {$prefix}pages.accepted = 'y' WHERE ref = $c GROUP BY {$prefix}categories.id ORDER BY {$prefix}categories.name");
$n_subcategories = mysql_num_rows($sql);
for ($x = 0; $x < $n_subcategories; $x++){
$subcategories[$x] = mysql_fetch_array($sql, MYSQL_ASSOC);
};
$sql = mysql_query("SELECT {$prefix}categories.id, {$prefix}categories.name, COUNT({$prefix}subcategories.id) AS subcategories FROM {$prefix}categories LEFT JOIN {$prefix}categories AS {$prefix}subcategories ON {$prefix}subcategories.ref = {$prefix}categories.id WHERE {$prefix}categories.ref = $c GROUP BY {$prefix}categories.id ORDER BY {$prefix}categories.name");
for ($x = 0; $x < $n_subcategories; $x++){
$subcategories[$x]["subcategories"] = mysql_result($sql, $x, "subcategories");
};
if ($current_category["pages"] == "y"){
if ($s == 0) { $s = 1; };
$n = 10;
$sql = mysql_query("SELECT COUNT(*) AS total_pages FROM {$prefix}pages WHERE category = $c AND accepted = 'y'");
$total_pages = mysql_result($sql,0,"total_pages");
if ($total_pages > 0){
$sql = mysql_query("SELECT id, url, title, description FROM {$prefix}pages WHERE category = $c AND accepted = 'y' ORDER BY title LIMIT ".($s-1).",$n");
$n_pages = mysql_num_rows($sql);
for ($x = 0; $x < $n_pages; $x++){
$pages[$x] = mysql_fetch_array($sql, MYSQL_ASSOC);
};
};
};
$e = min($s + $n - 1, $s + $n_pages - 1);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Wedding Vendors : <? echo $current_category["name"]; if ($current_category["title"] != $current_category["name"]){ echo " - ".$current_category["title"]; };?></TITLE>
<META NAME="description" CONTENT="<? echo $current_category["description"]?>">
<META NAME="keywords" CONTENT="<? echo $current_category["name"]." ".$current_category["description"]?>">
<SCRIPT TYPE="text/javascript" SRC="style.js"></SCRIPT>
</HEAD>
<BODY>
<?
include ("starting_html.php");
?>
<DIV CLASS="main">
<A HREF="http://vlib.org"> <IMG ALT="logo" SRC="VL.gif"> </A>
<CENTER> <H1>The World Wide Web Virtual Library: Weddings</H1> </CENTER>
<DIV CLASS="heading">
<H1><? echo $current_category["name"]?></H1>
<?
if ($c != 1){
echo '<DIV CLASS="heading_path">'."\r\n";
for ($x = $n_parent_categories-1; $x >= 1; $x--){
if ($x != $n_parent_categories-1) { echo " > "; };
if ($parent_categories[$x]["id"] == 1){
echo '<A HREF="'.$dir.'index.php">'.$parent_categories[$x]["name"].'</A>';
}else{
echo '<A HREF="'.$dir.'index.php?c='.$parent_categories[$x]["id"].'">'.$parent_categories[$x]["name"].'</A>';
};
};
echo ' > '.$current_category["name"];
echo "</DIV>\r\n";
};
?>
</DIV>
<DIV CLASS="search">
<FORM METHOD="get" ACTION="search.php">
<DIV CLASS="search_controls">
<INPUT TYPE="text" NAME="q" MAXLENGTH=100 CLASS="search_controls_text">
<INPUT TYPE="submit" VALUE="<? echo $t02?>" CLASS="search_controls_button">
</DIV>
<?
if ($current_category["pages"] == "y" || $HTTP_SESSION_VARS['admin']){
echo '<DIV CLASS="search_add">'."\r\n";
if($current_category["pages"] == "y"){
echo '<A HREF="'.$dir.'add_url.php?c='.$c.'">'.$t03.'</A>'."\r\n";
};
if($HTTP_SESSION_VARS['admin']){
echo '<A HREF="'.$dir.'admin_edit.php?c='.$c.'">'.$t04.'</A>'."\r\n";
};
echo "</DIV>\r\n";
};
?>
</FORM>
</DIV>
<?
if ($n_subcategories > 0){
echo '<DIV CLASS="categories">'."\r\n";
echo '<DIV CLASS="categories_text">'.$t01.' "'.$current_category["name"].'":</DIV>'."\r\n";
$t = ceil($n_subcategories/2);
echo '<DIV CLASS="categories_blocks">'."\r\n";
echo '<DIV CLASS="categories_blocks_left">'."\r\n";
for ($x = 0; $x < $t; $x++){
echo '<DIV CLASS="categories_category"><font size=3>» <DIV CLASS="categories_category_title"><A HREF="'.$dir.'index.php?c='.$subcategories[$x]["id"].'">'.$subcategories[$x]["name"].'</A></font> </DIV></DIV>'."\r\n";
};
echo "</DIV>\r\n";
echo '<DIV CLASS="categories_blocks_right">'."\r\n";
if ($n_subcategories > 1){
for ($x = $t; $x < $n_subcategories; $x++){
echo '<DIV CLASS="categories_category"><font size=3>» <DIV CLASS="categories_category_title"><A HREF="'.$dir.'index.php?c='.$subcategories[$x]["id"].'">'.$subcategories[$x]["name"].'</A></font> </DIV></DIV>'."\r\n";
};
}else{
echo " \r\n";
};
echo "</DIV>\r\n";
echo "</DIV>\r\n";
echo "</DIV>\r\n";
};
if ($current_category["pages"] == "y"){
if ($n_pages > 0){
echo '<DIV CLASS="pages">'."\r\n";
echo '<DIV CLASS="pages_results">'.$t05a.' '.$s.' - '.$e.' '.$t05b.' '.$total_pages.' '.$t05c.' "'.$current_category["name"].'":</DIV>'."\r\n";
for ($x = 0; $x < $n_pages; $x++){
echo '<DIV CLASS="pages_page">'."\r\n";
echo '<DIV CLASS="pages_page_title"><A HREF="'.$pages[$x]["url"].'">'.$pages[$x]["title"].'</A></DIV>'."\r\n";
echo '<DIV CLASS="pages_page_description">'.$pages[$x]["description"].'</DIV>'."\r\n";
echo '<DIV CLASS="pages_page_url">'.$pages[$x]["url"].'</DIV>'."\r\n";
echo "</DIV>\r\n";
};
echo "</DIV>\r\n";
}else{
echo '<DIV CLASS="pages">'."\r\n";
echo '<DIV CLASS="pages_results">'.$t06.' "'.$current_category["name"].'"</DIV>'."\r\n";
echo "</DIV>\r\n";
};
if ($s != 1 || $e != $total_pages){
function query($s){
global $c;
if ($c != 1) { $query = "?c=$c"; };
if (($c != 1) & $s != 1){
$query .= "&s=$s";
}elseif ($s != 1){
$query = "?s=$s";
};
return $query;
};
echo '<DIV CLASS="options">'."\r\n";
if ($s != 1){
$previous = $s - $n;
echo '<A HREF="'.$dir.'index.php'.query($previous).'">'.$t07.'</A>'."\r\n";
};
for ($x = 1; $x <= ceil($total_pages/$n); $x++){
$current = ($x-1) * $n + 1;
if ($current == $s){
echo $x."\r\n";
}else{
echo '<A HREF="'.$dir.'index.php'.query($current).'">'.$x.'</A>'."\r\n";
};
};
if ($e < $total_pages){
$next = $s + $n;
echo '<A HREF="'.$dir.'index.php'.query($next).'">'.$t08.'</A>'."\r\n";
};
echo "</DIV>\r\n";
};
};
include ("links.php");
?>
</DIV>
<?
include ("ending_html.php");
?>
</BODY>
</HTML>
include ("config.php");
include ("include.php");
include ("lang.php");
session_start();
$c *= 1;
if ($c == 0) { $c = 1; };
$sql = mysql_query("SELECT name, title, description, pages, ref FROM {$prefix}categories WHERE id = $c");
$current_category = mysql_fetch_array($sql, MYSQL_ASSOC);
if (($c > 1) & !$current_category["name"]){
header("Location: {$dir}index.php");
};
if (!$current_category["name"]) { $current_category["name"] = "Directory Search"; };
if (!$current_category["title"]) { $current_category["title"] = $current_category["name"]; };
if (!$current_category["description"]) { $current_category["description"] = $current_category["name"]." ".$current_category["title"]; };
$last_category = false;
$ref = $c;
while(!$last_category){
$n_parent_categories += 1;
$sql = mysql_query("SELECT id, name, ref FROM {$prefix}categories WHERE id = $ref");
$parent_categories[$n_parent_categories-1] = mysql_fetch_array($sql, MYSQL_ASSOC);
if ($parent_categories[$n_parent_categories-1]["ref"] == 0){
$last_category = true;
}else{
$ref = $parent_categories[$n_parent_categories-1]["ref"];
};
};
$sql = mysql_query("SELECT {$prefix}categories.id, {$prefix}categories.name, COUNT({$prefix}pages.id) AS pages FROM {$prefix}categories LEFT JOIN {$prefix}pages ON {$prefix}pages.category = {$prefix}categories.id AND {$prefix}pages.accepted = 'y' WHERE ref = $c GROUP BY {$prefix}categories.id ORDER BY {$prefix}categories.name");
$n_subcategories = mysql_num_rows($sql);
for ($x = 0; $x < $n_subcategories; $x++){
$subcategories[$x] = mysql_fetch_array($sql, MYSQL_ASSOC);
};
$sql = mysql_query("SELECT {$prefix}categories.id, {$prefix}categories.name, COUNT({$prefix}subcategories.id) AS subcategories FROM {$prefix}categories LEFT JOIN {$prefix}categories AS {$prefix}subcategories ON {$prefix}subcategories.ref = {$prefix}categories.id WHERE {$prefix}categories.ref = $c GROUP BY {$prefix}categories.id ORDER BY {$prefix}categories.name");
for ($x = 0; $x < $n_subcategories; $x++){
$subcategories[$x]["subcategories"] = mysql_result($sql, $x, "subcategories");
};
if ($current_category["pages"] == "y"){
if ($s == 0) { $s = 1; };
$n = 10;
$sql = mysql_query("SELECT COUNT(*) AS total_pages FROM {$prefix}pages WHERE category = $c AND accepted = 'y'");
$total_pages = mysql_result($sql,0,"total_pages");
if ($total_pages > 0){
$sql = mysql_query("SELECT id, url, title, description FROM {$prefix}pages WHERE category = $c AND accepted = 'y' ORDER BY title LIMIT ".($s-1).",$n");
$n_pages = mysql_num_rows($sql);
for ($x = 0; $x < $n_pages; $x++){
$pages[$x] = mysql_fetch_array($sql, MYSQL_ASSOC);
};
};
};
$e = min($s + $n - 1, $s + $n_pages - 1);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Wedding Vendors : <? echo $current_category["name"]; if ($current_category["title"] != $current_category["name"]){ echo " - ".$current_category["title"]; };?></TITLE>
<META NAME="description" CONTENT="<? echo $current_category["description"]?>">
<META NAME="keywords" CONTENT="<? echo $current_category["name"]." ".$current_category["description"]?>">
<SCRIPT TYPE="text/javascript" SRC="style.js"></SCRIPT>
</HEAD>
<BODY>
<?
include ("starting_html.php");
?>
<DIV CLASS="main">
<A HREF="http://vlib.org"> <IMG ALT="logo" SRC="VL.gif"> </A>
<CENTER> <H1>The World Wide Web Virtual Library: Weddings</H1> </CENTER>
<DIV CLASS="heading">
<H1><? echo $current_category["name"]?></H1>
<?
if ($c != 1){
echo '<DIV CLASS="heading_path">'."\r\n";
for ($x = $n_parent_categories-1; $x >= 1; $x--){
if ($x != $n_parent_categories-1) { echo " > "; };
if ($parent_categories[$x]["id"] == 1){
echo '<A HREF="'.$dir.'index.php">'.$parent_categories[$x]["name"].'</A>';
}else{
echo '<A HREF="'.$dir.'index.php?c='.$parent_categories[$x]["id"].'">'.$parent_categories[$x]["name"].'</A>';
};
};
echo ' > '.$current_category["name"];
echo "</DIV>\r\n";
};
?>
</DIV>
<DIV CLASS="search">
<FORM METHOD="get" ACTION="search.php">
<DIV CLASS="search_controls">
<INPUT TYPE="text" NAME="q" MAXLENGTH=100 CLASS="search_controls_text">
<INPUT TYPE="submit" VALUE="<? echo $t02?>" CLASS="search_controls_button">
</DIV>
<?
if ($current_category["pages"] == "y" || $HTTP_SESSION_VARS['admin']){
echo '<DIV CLASS="search_add">'."\r\n";
if($current_category["pages"] == "y"){
echo '<A HREF="'.$dir.'add_url.php?c='.$c.'">'.$t03.'</A>'."\r\n";
};
if($HTTP_SESSION_VARS['admin']){
echo '<A HREF="'.$dir.'admin_edit.php?c='.$c.'">'.$t04.'</A>'."\r\n";
};
echo "</DIV>\r\n";
};
?>
</FORM>
</DIV>
<?
if ($n_subcategories > 0){
echo '<DIV CLASS="categories">'."\r\n";
echo '<DIV CLASS="categories_text">'.$t01.' "'.$current_category["name"].'":</DIV>'."\r\n";
$t = ceil($n_subcategories/2);
echo '<DIV CLASS="categories_blocks">'."\r\n";
echo '<DIV CLASS="categories_blocks_left">'."\r\n";
for ($x = 0; $x < $t; $x++){
echo '<DIV CLASS="categories_category"><font size=3>» <DIV CLASS="categories_category_title"><A HREF="'.$dir.'index.php?c='.$subcategories[$x]["id"].'">'.$subcategories[$x]["name"].'</A></font> </DIV></DIV>'."\r\n";
};
echo "</DIV>\r\n";
echo '<DIV CLASS="categories_blocks_right">'."\r\n";
if ($n_subcategories > 1){
for ($x = $t; $x < $n_subcategories; $x++){
echo '<DIV CLASS="categories_category"><font size=3>» <DIV CLASS="categories_category_title"><A HREF="'.$dir.'index.php?c='.$subcategories[$x]["id"].'">'.$subcategories[$x]["name"].'</A></font> </DIV></DIV>'."\r\n";
};
}else{
echo " \r\n";
};
echo "</DIV>\r\n";
echo "</DIV>\r\n";
echo "</DIV>\r\n";
};
if ($current_category["pages"] == "y"){
if ($n_pages > 0){
echo '<DIV CLASS="pages">'."\r\n";
echo '<DIV CLASS="pages_results">'.$t05a.' '.$s.' - '.$e.' '.$t05b.' '.$total_pages.' '.$t05c.' "'.$current_category["name"].'":</DIV>'."\r\n";
for ($x = 0; $x < $n_pages; $x++){
echo '<DIV CLASS="pages_page">'."\r\n";
echo '<DIV CLASS="pages_page_title"><A HREF="'.$pages[$x]["url"].'">'.$pages[$x]["title"].'</A></DIV>'."\r\n";
echo '<DIV CLASS="pages_page_description">'.$pages[$x]["description"].'</DIV>'."\r\n";
echo '<DIV CLASS="pages_page_url">'.$pages[$x]["url"].'</DIV>'."\r\n";
echo "</DIV>\r\n";
};
echo "</DIV>\r\n";
}else{
echo '<DIV CLASS="pages">'."\r\n";
echo '<DIV CLASS="pages_results">'.$t06.' "'.$current_category["name"].'"</DIV>'."\r\n";
echo "</DIV>\r\n";
};
if ($s != 1 || $e != $total_pages){
function query($s){
global $c;
if ($c != 1) { $query = "?c=$c"; };
if (($c != 1) & $s != 1){
$query .= "&s=$s";
}elseif ($s != 1){
$query = "?s=$s";
};
return $query;
};
echo '<DIV CLASS="options">'."\r\n";
if ($s != 1){
$previous = $s - $n;
echo '<A HREF="'.$dir.'index.php'.query($previous).'">'.$t07.'</A>'."\r\n";
};
for ($x = 1; $x <= ceil($total_pages/$n); $x++){
$current = ($x-1) * $n + 1;
if ($current == $s){
echo $x."\r\n";
}else{
echo '<A HREF="'.$dir.'index.php'.query($current).'">'.$x.'</A>'."\r\n";
};
};
if ($e < $total_pages){
$next = $s + $n;
echo '<A HREF="'.$dir.'index.php'.query($next).'">'.$t08.'</A>'."\r\n";
};
echo "</DIV>\r\n";
};
};
include ("links.php");
?>
</DIV>
<?
include ("ending_html.php");
?>
</BODY>
</HTML>
- <?
- include ("config.php");
- include ("include.php");
- include ("lang.php");
- session_start();
- $c *= 1;
- if ($c == 0) { $c = 1; };
- $sql = mysql_query("SELECT name, title, description, pages, ref FROM {$prefix}categories WHERE id = $c");
- $current_category = mysql_fetch_array($sql, MYSQL_ASSOC);
- if (($c > 1) & !$current_category["name"]){
- header("Location: {$dir}index.php");
- };
- if (!$current_category["name"]) { $current_category["name"] = "Directory Search"; };
- if (!$current_category["title"]) { $current_category["title"] = $current_category["name"]; };
- if (!$current_category["description"]) { $current_category["description"] = $current_category["name"]." ".$current_category["title"]; };
- $last_category = false;
- $ref = $c;
- while(!$last_category){
- $n_parent_categories += 1;
- $sql = mysql_query("SELECT id, name, ref FROM {$prefix}categories WHERE id = $ref");
- $parent_categories[$n_parent_categories-1] = mysql_fetch_array($sql, MYSQL_ASSOC);
- if ($parent_categories[$n_parent_categories-1]["ref"] == 0){
- $last_category = true;
- }else{
- $ref = $parent_categories[$n_parent_categories-1]["ref"];
- };
- };
- $sql = mysql_query("SELECT {$prefix}categories.id, {$prefix}categories.name, COUNT({$prefix}pages.id) AS pages FROM {$prefix}categories LEFT JOIN {$prefix}pages ON {$prefix}pages.category = {$prefix}categories.id AND {$prefix}pages.accepted = 'y' WHERE ref = $c GROUP BY {$prefix}categories.id ORDER BY {$prefix}categories.name");
- $n_subcategories = mysql_num_rows($sql);
- for ($x = 0; $x < $n_subcategories; $x++){
- $subcategories[$x] = mysql_fetch_array($sql, MYSQL_ASSOC);
- };
- $sql = mysql_query("SELECT {$prefix}categories.id, {$prefix}categories.name, COUNT({$prefix}subcategories.id) AS subcategories FROM {$prefix}categories LEFT JOIN {$prefix}categories AS {$prefix}subcategories ON {$prefix}subcategories.ref = {$prefix}categories.id WHERE {$prefix}categories.ref = $c GROUP BY {$prefix}categories.id ORDER BY {$prefix}categories.name");
- for ($x = 0; $x < $n_subcategories; $x++){
- $subcategories[$x]["subcategories"] = mysql_result($sql, $x, "subcategories");
- };
- if ($current_category["pages"] == "y"){
- if ($s == 0) { $s = 1; };
- $n = 10;
- $sql = mysql_query("SELECT COUNT(*) AS total_pages FROM {$prefix}pages WHERE category = $c AND accepted = 'y'");
- $total_pages = mysql_result($sql,0,"total_pages");
- if ($total_pages > 0){
- $sql = mysql_query("SELECT id, url, title, description FROM {$prefix}pages WHERE category = $c AND accepted = 'y' ORDER BY title LIMIT ".($s-1).",$n");
- $n_pages = mysql_num_rows($sql);
- for ($x = 0; $x < $n_pages; $x++){
- $pages[$x] = mysql_fetch_array($sql, MYSQL_ASSOC);
- };
- };
- };
- $e = min($s + $n - 1, $s + $n_pages - 1);
- ?>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <HTML>
- <HEAD>
- <TITLE>Wedding Vendors : <? echo $current_category["name"]; if ($current_category["title"] != $current_category["name"]){ echo " - ".$current_category["title"]; };?></TITLE>
- <META NAME="description" CONTENT="<? echo $current_category["description"]?>">
- <META NAME="keywords" CONTENT="<? echo $current_category["name"]." ".$current_category["description"]?>">
- <SCRIPT TYPE="text/javascript" SRC="style.js"></SCRIPT>
- </HEAD>
- <BODY>
- <?
- include ("starting_html.php");
- ?>
- <DIV CLASS="main">
- <A HREF="http://vlib.org"> <IMG ALT="logo" SRC="VL.gif"> </A>
- <CENTER> <H1>The World Wide Web Virtual Library: Weddings</H1> </CENTER>
- <DIV CLASS="heading">
- <H1><? echo $current_category["name"]?></H1>
- <?
- if ($c != 1){
- echo '<DIV CLASS="heading_path">'."\r\n";
- for ($x = $n_parent_categories-1; $x >= 1; $x--){
- if ($x != $n_parent_categories-1) { echo " > "; };
- if ($parent_categories[$x]["id"] == 1){
- echo '<A HREF="'.$dir.'index.php">'.$parent_categories[$x]["name"].'</A>';
- }else{
- echo '<A HREF="'.$dir.'index.php?c='.$parent_categories[$x]["id"].'">'.$parent_categories[$x]["name"].'</A>';
- };
- };
- echo ' > '.$current_category["name"];
- echo "</DIV>\r\n";
- };
- ?>
- </DIV>
- <DIV CLASS="search">
- <FORM METHOD="get" ACTION="search.php">
- <DIV CLASS="search_controls">
- <INPUT TYPE="text" NAME="q" MAXLENGTH=100 CLASS="search_controls_text">
- <INPUT TYPE="submit" VALUE="<? echo $t02?>" CLASS="search_controls_button">
- </DIV>
- <?
- if ($current_category["pages"] == "y" || $HTTP_SESSION_VARS['admin']){
- echo '<DIV CLASS="search_add">'."\r\n";
- if($current_category["pages"] == "y"){
- echo '<A HREF="'.$dir.'add_url.php?c='.$c.'">'.$t03.'</A>'."\r\n";
- };
- if($HTTP_SESSION_VARS['admin']){
- echo '<A HREF="'.$dir.'admin_edit.php?c='.$c.'">'.$t04.'</A>'."\r\n";
- };
- echo "</DIV>\r\n";
- };
- ?>
- </FORM>
- </DIV>
- <?
- if ($n_subcategories > 0){
- echo '<DIV CLASS="categories">'."\r\n";
- echo '<DIV CLASS="categories_text">'.$t01.' "'.$current_category["name"].'":</DIV>'."\r\n";
- $t = ceil($n_subcategories/2);
- echo '<DIV CLASS="categories_blocks">'."\r\n";
- echo '<DIV CLASS="categories_blocks_left">'."\r\n";
- for ($x = 0; $x < $t; $x++){
- echo '<DIV CLASS="categories_category"><font size=3>» <DIV CLASS="categories_category_title"><A HREF="'.$dir.'index.php?c='.$subcategories[$x]["id"].'">'.$subcategories[$x]["name"].'</A></font> </DIV></DIV>'."\r\n";
- };
- echo "</DIV>\r\n";
- echo '<DIV CLASS="categories_blocks_right">'."\r\n";
- if ($n_subcategories > 1){
- for ($x = $t; $x < $n_subcategories; $x++){
- echo '<DIV CLASS="categories_category"><font size=3>» <DIV CLASS="categories_category_title"><A HREF="'.$dir.'index.php?c='.$subcategories[$x]["id"].'">'.$subcategories[$x]["name"].'</A></font> </DIV></DIV>'."\r\n";
- };
- }else{
- echo " \r\n";
- };
- echo "</DIV>\r\n";
- echo "</DIV>\r\n";
- echo "</DIV>\r\n";
- };
- if ($current_category["pages"] == "y"){
- if ($n_pages > 0){
- echo '<DIV CLASS="pages">'."\r\n";
- echo '<DIV CLASS="pages_results">'.$t05a.' '.$s.' - '.$e.' '.$t05b.' '.$total_pages.' '.$t05c.' "'.$current_category["name"].'":</DIV>'."\r\n";
- for ($x = 0; $x < $n_pages; $x++){
- echo '<DIV CLASS="pages_page">'."\r\n";
- echo '<DIV CLASS="pages_page_title"><A HREF="'.$pages[$x]["url"].'">'.$pages[$x]["title"].'</A></DIV>'."\r\n";
- echo '<DIV CLASS="pages_page_description">'.$pages[$x]["description"].'</DIV>'."\r\n";
- echo '<DIV CLASS="pages_page_url">'.$pages[$x]["url"].'</DIV>'."\r\n";
- echo "</DIV>\r\n";
- };
- echo "</DIV>\r\n";
- }else{
- echo '<DIV CLASS="pages">'."\r\n";
- echo '<DIV CLASS="pages_results">'.$t06.' "'.$current_category["name"].'"</DIV>'."\r\n";
- echo "</DIV>\r\n";
- };
- if ($s != 1 || $e != $total_pages){
- function query($s){
- global $c;
- if ($c != 1) { $query = "?c=$c"; };
- if (($c != 1) & $s != 1){
- $query .= "&s=$s";
- }elseif ($s != 1){
- $query = "?s=$s";
- };
- return $query;
- };
- echo '<DIV CLASS="options">'."\r\n";
- if ($s != 1){
- $previous = $s - $n;
- echo '<A HREF="'.$dir.'index.php'.query($previous).'">'.$t07.'</A>'."\r\n";
- };
- for ($x = 1; $x <= ceil($total_pages/$n); $x++){
- $current = ($x-1) * $n + 1;
- if ($current == $s){
- echo $x."\r\n";
- }else{
- echo '<A HREF="'.$dir.'index.php'.query($current).'">'.$x.'</A>'."\r\n";
- };
- };
- if ($e < $total_pages){
- $next = $s + $n;
- echo '<A HREF="'.$dir.'index.php'.query($next).'">'.$t08.'</A>'."\r\n";
- };
- echo "</DIV>\r\n";
- };
- };
- include ("links.php");
- ?>
- </DIV>
- <?
- include ("ending_html.php");
- ?>
- </BODY>
- </HTML>
Page 1 of 1
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 10 posts
- Users browsing this forum: No registered users and 209 guests
- You cannot post new topics in this forum
- You cannot reply to topics in this forum
- You cannot edit your posts in this forum
- You cannot delete your posts in this forum
- You cannot post attachments in this forum
