beh9am
شنبه 09 آبان 1394, 13:18 عصر
سلام و خسته نباشید
یک اسکریپت دارم اما الان کار نمیکنه دسترسی به نویسنده اسکریپت هم ندارم
سایت به صورت user.site.ir درست کار میکنه اما میخوام تغییرش بدم به صورت site.ir/user باز بشه
یعنی مثلا http://hasan.site.ir بشه http://site.ir/hasan
این کد index.php
<?php
ob_start();
include 'dataload.php';
/********/
ini_set("display_errors","0");
ini_set("register_globals","0");
/********/
$pageid = isset($_GET['pageid'])?intval($_GET['pageid']):'1';
$servername = strtolower($_SERVER['SERVER_NAME']);
$servername = (substr($servername,0,4) == 'www.')?substr($servername,4):$servername;
/*
//visit
$res=mysql_query("update `amar` set `count`=count+1 where `date`='".date("Y-m-d")."' limit 1;");
if(mysql_affected_rows()!=1){
mysql_query("INSERT INTO `amar` (`id`, `date`, `count`, `click`) VALUES (NULL, '".date("Y-m-d")."', '1', '0');");
}
*/
#------
if(preg_match('#([a-z0-9-]+?)\.site\.ir#i', $servername, $blogname)){
if(isset($_GET['id']) ){
$res=mysql_query("select id,username from `feeds` where `id`=(select fid from `news_tmp` where `id`=$_GET[id]) limit 1");
if(mysql_num_rows($res)>0){
list($id,$username)=mysql_fetch_array($res);
if($blogname[1]!=$username){
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://$username.site.ir/index-$_GET[id]" );
exit;
}
}
}
$username=$blogname[1];
$q=mysql_query("select id,title from `feeds` where `username`='{$blogname[1]}'");
$row = mysql_fetch_array($q);
$blogtitle = $row['title'];
$res=mysql_query("select id,title from `feeds` where `username`='{$blogname[1]}'");
if(mysql_num_rows($res)>0){
list($id,$title)=mysql_fetch_array($res);
$res=mysql_query("select `title`,`text`,`date`,`keywords`,`url`,`id` from `news_tmp` where `fid`=$id ".(isset($_GET['id'])?"and `id`=$_GET[id] ":'')." /*order by `date` DESC*/");
while($row=mysql_fetch_assoc($res)){
if($row['title'] == ''){$row['title'] = 'بدون عنوان';}
if(isset($_GET['id']))$title=$row['title'];
?>
<div class="post-content">
<?php if($row['title'] == ''){$row['title'] = 'بدون عنوان';}?>
<h1 class="title"><?php echo "<a href=\"index-$row[id]\">$row[title]</a>";?></h1>
<?=$row['text'];?>
<br>
</div>
<?
}
}else{
echo 'user not found in feed.';
}
}
else
{
if(isset($_GET['id']) ){
$res=mysql_query("select id,username from `feeds` where `id`=(select fid from `news_tmp` where `id`=$_GET[id]) limit 1");
if(mysql_num_rows($res)>0){
list($id,$username)=mysql_fetch_array($res);
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://$username.site.ir/index-$_GET[id]" );
exit;
}
}
$res=mysql_query("select `title`,`id` from `news_tmp` order by `id` DESC limit 200");
if(mysql_num_rows($res)>0){
echo '
<div class="index-p"> <h2 class="title">آخرین مطالب</h2><ul>';
while($row=mysql_fetch_assoc($res)){
if($row['title'] == ''){$row['title'] = 'بدون عنوان';}
echo "<li><a href=\"index-$row[id]\" target=\"_blank\">$row[title]</a></li>\n";
}
echo '</ul> </div> ';
}
else{
echo 'user not found in feed.';
}
}
$out_html=ob_get_clean();
include 'tmp.php';
?>
اینم کد htaccess
RewriteEngine On
#RewriteBase /
RewriteRule index-([0-9]*) ./index.php?id=$1 [L]
RewriteRule ^post/(.*)-([0-9]*)$ ./search.php?key=$1&start=$2 [L]
RewriteRule ^post/(.*)$ ./search.php?key=$1 [L]
Rewriterule ^rss.xml ./rss/rss.php
### EXPIRES
# month A2592000, week A604800, day A86400, hour A3600,15 min A900
ExpiresActive On
ExpiresDefault A86400
ExpiresByType image/x-icon A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType text/css A2592000
ExpiresByType image/gif A604800
ExpiresByType image/png A604800
ExpiresByType image/jpeg A604800
ExpiresByType text/plain A604800
ExpiresByType application/x-shockwave-flash A604800
ExpiresByType video/x-flv A604800
ExpiresByType application/pdf A604800
ExpiresByType text/html A900
ممنون میشم راهنمایی کنید
تشکر
یک اسکریپت دارم اما الان کار نمیکنه دسترسی به نویسنده اسکریپت هم ندارم
سایت به صورت user.site.ir درست کار میکنه اما میخوام تغییرش بدم به صورت site.ir/user باز بشه
یعنی مثلا http://hasan.site.ir بشه http://site.ir/hasan
این کد index.php
<?php
ob_start();
include 'dataload.php';
/********/
ini_set("display_errors","0");
ini_set("register_globals","0");
/********/
$pageid = isset($_GET['pageid'])?intval($_GET['pageid']):'1';
$servername = strtolower($_SERVER['SERVER_NAME']);
$servername = (substr($servername,0,4) == 'www.')?substr($servername,4):$servername;
/*
//visit
$res=mysql_query("update `amar` set `count`=count+1 where `date`='".date("Y-m-d")."' limit 1;");
if(mysql_affected_rows()!=1){
mysql_query("INSERT INTO `amar` (`id`, `date`, `count`, `click`) VALUES (NULL, '".date("Y-m-d")."', '1', '0');");
}
*/
#------
if(preg_match('#([a-z0-9-]+?)\.site\.ir#i', $servername, $blogname)){
if(isset($_GET['id']) ){
$res=mysql_query("select id,username from `feeds` where `id`=(select fid from `news_tmp` where `id`=$_GET[id]) limit 1");
if(mysql_num_rows($res)>0){
list($id,$username)=mysql_fetch_array($res);
if($blogname[1]!=$username){
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://$username.site.ir/index-$_GET[id]" );
exit;
}
}
}
$username=$blogname[1];
$q=mysql_query("select id,title from `feeds` where `username`='{$blogname[1]}'");
$row = mysql_fetch_array($q);
$blogtitle = $row['title'];
$res=mysql_query("select id,title from `feeds` where `username`='{$blogname[1]}'");
if(mysql_num_rows($res)>0){
list($id,$title)=mysql_fetch_array($res);
$res=mysql_query("select `title`,`text`,`date`,`keywords`,`url`,`id` from `news_tmp` where `fid`=$id ".(isset($_GET['id'])?"and `id`=$_GET[id] ":'')." /*order by `date` DESC*/");
while($row=mysql_fetch_assoc($res)){
if($row['title'] == ''){$row['title'] = 'بدون عنوان';}
if(isset($_GET['id']))$title=$row['title'];
?>
<div class="post-content">
<?php if($row['title'] == ''){$row['title'] = 'بدون عنوان';}?>
<h1 class="title"><?php echo "<a href=\"index-$row[id]\">$row[title]</a>";?></h1>
<?=$row['text'];?>
<br>
</div>
<?
}
}else{
echo 'user not found in feed.';
}
}
else
{
if(isset($_GET['id']) ){
$res=mysql_query("select id,username from `feeds` where `id`=(select fid from `news_tmp` where `id`=$_GET[id]) limit 1");
if(mysql_num_rows($res)>0){
list($id,$username)=mysql_fetch_array($res);
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://$username.site.ir/index-$_GET[id]" );
exit;
}
}
$res=mysql_query("select `title`,`id` from `news_tmp` order by `id` DESC limit 200");
if(mysql_num_rows($res)>0){
echo '
<div class="index-p"> <h2 class="title">آخرین مطالب</h2><ul>';
while($row=mysql_fetch_assoc($res)){
if($row['title'] == ''){$row['title'] = 'بدون عنوان';}
echo "<li><a href=\"index-$row[id]\" target=\"_blank\">$row[title]</a></li>\n";
}
echo '</ul> </div> ';
}
else{
echo 'user not found in feed.';
}
}
$out_html=ob_get_clean();
include 'tmp.php';
?>
اینم کد htaccess
RewriteEngine On
#RewriteBase /
RewriteRule index-([0-9]*) ./index.php?id=$1 [L]
RewriteRule ^post/(.*)-([0-9]*)$ ./search.php?key=$1&start=$2 [L]
RewriteRule ^post/(.*)$ ./search.php?key=$1 [L]
Rewriterule ^rss.xml ./rss/rss.php
### EXPIRES
# month A2592000, week A604800, day A86400, hour A3600,15 min A900
ExpiresActive On
ExpiresDefault A86400
ExpiresByType image/x-icon A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType text/css A2592000
ExpiresByType image/gif A604800
ExpiresByType image/png A604800
ExpiresByType image/jpeg A604800
ExpiresByType text/plain A604800
ExpiresByType application/x-shockwave-flash A604800
ExpiresByType video/x-flv A604800
ExpiresByType application/pdf A604800
ExpiresByType text/html A900
ممنون میشم راهنمایی کنید
تشکر