08-26-2014, 01:26 PM
Ребят помогите пж разобрать с чпу в движке
сейчас ссылка вот такого вида сайт/index.php?do=sitedetails&id=11
а очень хочется что бы вид ссылки был вот такой сайт/info/11
Пробовал гуглить ответ, но при любой смене кода все падает.
сейчас ссылка вот такого вида сайт/index.php?do=sitedetails&id=11
а очень хочется что бы вид ссылки был вот такой сайт/info/11
Пробовал гуглить ответ, но при любой смене кода все падает.
код
PHP код:
<?php
// +------------------------------------------------------------------+
require "./admin_common.php";
$usr->checkperm('',"isadmin");
if($usr->checkperm('',"isadmin",1) == true )
$site['title'] = "SES Module";
class SES
{
function SES()
{
global $root;
$this->file = $root.'.htaccess';
}
function mainpage()
{
global $admin,$settings;
if ($settings['useses'] == 1)
{
if ($_POST['edit'])
{
$admin->write_file($this->file,$_POST['content']);
}
$html .= $admin->warning ("This module requires mod_rewrite in order to work. Please ensure your web hosting provider supports this feature.");
$html .= '<hr size="1" width="85%" />';
// create
if ( !file_exists( $this->file ) )
{
$this->create(0);
if ( !file_exists( $this->file ) )
{
$html .= $admin->warning('UNABLE TO WRITE .HTACCESS, Please insure that you have chmodded the root folder to 777 or created a blank .htaccess file with 666 permission.'.$admin->link_button('Try Again',$_SERVER['PHP_SELF']));
}
else
{
$html .= $admin->note('.htaccess file created.');
}
}
else
{
$html .= $admin->note('.htaccess exists. Please use the Create/Recreate button to rewrite a new one.');
}
$html .= '<br /><hr size="1" width="85%" /><div style="float:right">';
$html .= $admin->link_button("Create/Recreate",$_SERVER['PHP_SELF'].'?do=create') .' ';
if ( file_exists($this->file) )
{
$html .= $admin->link_button("Edit",$_SERVER['PHP_SELF'].'?do=edit').' ';
}
$html .= $admin->button_confirm('Delete',$_SERVER['PHP_SELF'].'?do=delete');
$html .= '</div>';
}
else
{
$html .= $admin->warning ("Please make sure you have enabled <a href=\"settings.php?group=search_engine_safe_ses\">SES in settings.</a>");
}
return $html;
}
function create($redirect=1)
{
global $admin,$settings;
/*$content = "
RewriteEngine On
RewriteRule ^cat_([0-9]+).html <<path>>index.php?do=cat&cid=$1 [L]
RewriteRule ^p_([0-9]+).html <<path>>index.php?p=$1 [L]
RewriteRule ^archive_([0-9]+)_([0-9]+).html <<path>>index.php?m=$1&y=$2 [L]
RewriteRule ^day_([0-9]+)_([0-9]+)_([0-9]+).html <<path>>index.php?d=$1&m=$2&y=$3 [L]
RewriteRule ^gcat_([0-9]+).html <<path>>gallery.php?do=cat&cid=$1 [L]
RewriteRule ^image_([0-9]+).html <<path>>gallery.php?do=viewimage&id=$1 [L]
RewriteRule ^viewimage_([0-9]+).html <<path>>gallery.php?do=image&id=$1 [L]
";*/
$content = $settings['ses_template'];
$content = preg_replace("'([\n])[\s]+'","\\1",$content);
//replace path
$path = str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$content = str_replace("<<path>>",str_replace("admin/",'',$path),$content);
$admin->write_file($this->file,$content);
if ($redirect)
{
$html .= "File Created. You will be forwarded back to the main page";
$html .= $admin->redirect($_SERVER['PHP_SELF']);
return $html;
}
}
function edit()
{
global $admin;
$html .= $admin->form_start("",$_SERVER['PHP_SELF']);
$table .= $admin->add_spacer("Edit");
$table .= $admin->add_row("Content",'<textarea name="content" style="width:95%" rows="20">'.$admin->get_file($this->file).'</textarea>');
$table .= $admin->form_submit("edit");
$html .= $admin->add_table($table,"90%");
return $html;
}
function delete()
{
global $admin;
@unlink($this->file);
$html .= $admin->warning( "Please disable the <b>Enable Search-Engine-Safe URL? (requires mod_rewrite)</b> if you are planning not to use the SES Feature or re-create file if you still want to use the SES feature");
$html .= "You are being redirected to the main page";
$html .= $admin->redirect($_SERVER['PHP_SELF']);
return $html;
}
}
$ses = new SES;
switch ($_GET['do'])
{
case "write":
$content = $ses->write();
break;
case "create":
$content = $ses->create();
break;
case "edit":
$content = $ses->edit();
break;
case "delete":
$content = $ses->delete();
break;
default;
$content = $ses->mainpage();
}
/* + ------------------------------------------------------------------------- + */
// SPIT IT OUT . Generate the file i mean..
/* + ------------------------------------------------------------------------- + */
eval("echo(\"".$tpl->gettemplate("main",1)."\");");
/* + ------------------------------------------------------------------------- + */
?>