mod rewrite that makes links in html format

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    mod rewrite that makes links in html format

    below the script full code,how can mod rewrite it that indexpc.php?dir= and filepc.php?file= will be replaced and link will be in .html
    PHP Code:
    <?php
    $mt=microtime(1);
    require 'configpc.php';
    require 'funcpc.php';
    if($zip)
    {include('zip.php');}
    
    //Sorting and preview:
    
    $p=intval($_GET['p']);
    $sort=intval($_GET['sort']);
    if($sort>1 OR $sort<0)
    {$sort=1;}
    $p=1;
    $sort=1;
    //Folder:
    $dir=htmlspecialchars($_GET['dir']);
    
    while(substr($dir,0,1)=='/')
    {$dir=substr($dir,1,strlen($dir));}
    
    if(strstr($dir,'..') OR !is_dir('load/'.$dir) OR strstr($dir,'://'))
    {$dir=null;}
    
    $opis = false;
    
    //HATS
    print $top;
    
    print '<center>';
    require 'ads/headad.php';
    print '<br>';
    require 'ads/headad2.php';
    print '</center><div id="content">'; 
    require 'category.php';
    require 'update.php';
    print '<div id="center">';
    if(!$dir)
    {print '<h1>Downloads menu</h1><br/>';}
    else
    {
    $dir_exp=explode('/',$dir);
    print '<h1>'.transdir($dir_exp[count($dir_exp)-1]).'</h1>';
    }
    
    
    
    print '<table class="main"><tr><td><div id="list_wrapper">';
    //Subfolders
    $glob_dir=glob('load/'.$dir.'/*',GLOB_ONLYDIR);
    if($glob_dir)
    {
    $count=sizeof($glob_dir);
    $countstr=ceil($count/$dirstr);
    $page=intval($_GET['page']);
    if($sort)
    {usort($glob_dir, 'sortnew');}
    $start = $page * $dirstr;
    if($start>=$count OR $start<0)
    {$start=0;}
    $end = $start + $dirstr;
    if($end>=$count)
    {$end = $count;}
    for($i=$start; $i<$end; $i++)
    {
    $dirt=str_replace('load/',null,$glob_dir[$i]);
    $dir_exp=explode('/',$dirt);
    $count=countf($dirt);
    
    //if($p and file_exists('load'.$dir.'folder.png'))
    if($p and file_exists('load'.$dirt.'/folder.png'))
    $ico= '<img src="load'.$dirt.'/folder.png" width="50" height="70" alt="" class="glass" />'; 
    else $ico= '<img src="img/Erotic.png" width="60" height="80" alt="" class="glass"/>';
    if($p and file_exists('load/'.$dirt.'/folder.png'))
    $ico= '<img src="load/'.$dirt.'/folder.png" width="50" height="70" alt="" class="glass" /'; 
    else $ico= '<img src="img/Erotic.png" width="60" height="80" alt="" class="glass"/>';
    //$tx=urlencode($name); 
    print '<div class="a">'.$ico.' <br><a href="indexpc.php?dir='.$dirt.'">'.transdir($dir_exp[count($dir_exp)-1]).'</a></div>';
    }
    }
    $glob_file=glob("load/$dir/*.{{$allfile}}",GLOB_BRACE);
    if($glob_file) //FILES
    {
    if($sort)
    {usort($glob_file, 'sortnew');}
    $count=sizeof($glob_file);
    $countstr=ceil($count/$filestr);
    $page=intval($_GET['page']);
    $start = $page * $filestr;
    if($start>=$count OR $start<0)
    {$start=0;}
    $end = $start + $filestr;
    if($end>=$count)
    {$end = $count;}
    for($i=$start; $i<$end; $i++)
    {
    $name=translit($glob_file[$i]);
    $filesize=filesize($glob_file[$i]);
    if($filesize>1048576)
    {$filesize=round($filesize/1024/1024, 2).' Mb';}
    else
    {$filesize.=' kb';}
    if(r($glob_file[$i])=='txt')
    {
    $text=file($glob_file[$i]);
    $name=$text[0];
    $opis=$text[1].$text[2].$text[3].$text[4];
    }
    
    $basename=basename($glob_file[$i]);
    ///////////
    if(r($glob_file[$i])=='jar') $dthumb= '<img src="ext/jar.png" alt="" class="glass">';
    if(r($glob_file[$i])=='3gp') $dthumb= '<img src="ext/3gp.png" alt="" class="glass">';
    if(r($glob_file[$i])=='mp4') $dthumb= '<img src="ext/mp4.png" alt="" class="glass">';
    if(r($glob_file[$i])=='zip') $dthumb= '<img src="ext/zip.png" alt="" class="glass">';
    if(r($glob_file[$i])=='sis') $dthumb= '<img src="ext/sis.png" alt="" class="glass">';
    if(r($glob_file[$i])=='sisx') $dthumb= '<img src="ext/sisx.png" alt="" class="glass">';
    if(r($glob_file[$i])=='apk') $dthumb= '<img src="ext/apk.png" alt="" class="glass">';
    if(r($glob_file[$i])=='nth') $dthumb= '<img src="ext/nth.png" alt="" class="glass">';
    if(r($glob_file[$i])=='thm') $dthumb= '<img src="ext/thm.png" alt="" class="glass">';
    if(r($glob_file[$i])=='mp3') $dthumb= '<img src="ext/mp3.png" alt="" class="glass">';
    if(r($glob_file[$i])=='wav') $dthumb= '<img src="ext/wav.png" alt="" class="glass">';
    if(r($glob_file[$i])=='mid') $dthumb= '<img src="ext/mid.png" alt="" class="glass">';
    if(r($glob_file[$i])=='exe') $dthumb= '<img src="ext/exe.png" alt="" class="glass">';
    //Screenshot
    if($p and file_exists('skrin/'.$basename.'.gif'))
    $thumb= '<img src="skrin/'.$basename.'.gif" width="90" height="100" alt="Screen" class="glass"/>';
    else $thumb=$dthumb;
    if($p and file_exists('skrin/'.$basename.'.jpg'))
    {print '<img src="pic.php?file=skrin/'.$basename.'.jpg" alt="Screen" />';}
    if($p and file_exists('skrin/'.$basename.'.png'))
    {print '<img src="pic.php?file=skrin/'.$basename.'.png" alt="Screen" />';}
    if((r($glob_file[$i])=='jpg' or r($glob_file[$i])=='gif' or r($glob_file[$i])=='png') and $p)
    $thumb= '<img src="pic.php?file='.$glob_file[$i].'" alt="Screen" class="glass" />';
    
    //print '<strong>'.$name.'</strong><br/>';
    
    if(file_exists('opis/'.$basename.'.txt'))
    {$opis=htmlspecialchars(file_get_contents('opis/'.$basename.'.txt'));}
    
    if($opis)
    {print nl2br(htmlspecialchars($opis)).'<br />';}
    $opis = false;
    //$tx=urlencode($name);
    if(r($glob_file[$i])=='jar')
    {
    print '<div>'.$thumb.'<br><a href="'.$glob_file[$i].'">'.$name.' </a><br>('.$filesize.')';
    print '<br><a href="jad.php?file='.$glob_file[$i].'">Download JAD</a></div>';
    }
    elseif(r($glob_file[$i])=='txt')
    {print '<a href="txt.php?p='.$p.'&amp;file='.$glob_file[$i].'&amp;sort='.$sort.'">Read</a><br />';}
    else
    print '<div>'.$thumb.'<br><a href="filepc.php?file='.$glob_file[$i].'">'.$name.' </a><br>('.$filesize.')</div>';
    
    
    //Counts the number of Recent entries
    
    }
    }
    print '</div></div></td></tr></table><span color="#770101">';
    //Pagination:
    if($countstr>1)
    {print nav_page($countstr,$page,$dir,'indexpc');}
    //Return to level up:
    $dir_exp=explode('/',$dir);
    if($dir)
    {print 'Back :';}
    if(($countj=count(explode('/',$dir)))>1)
    {
    $j=explode('/',$dir);
    for($i=0; $i<=$countj; $i++)
    {
    $u=$j[count($j)-2];
    if($u)
    {
    unset($j[count($j)-1]);
    $g[$i]= '<a href="indexpc.php?dir='.join('/', $j).'">'.transdir($u).'</a>';
    }
    }
    for($i=count($g)-1; $i>=0; $i--)
    {print $g[$i];}
    
    print '';
    }
    if($dir)
    {print ' </span><h1>Home :<a href="indexpc.php?dir='.$dir.'">Downloads</a></h1>';}
    print '</div></div></div>';
                        
    print '<center>';
    
    print '</center>';                                                                    
    print '<div id="footer">';require 'toplist.php';
    print $foot;
    ?>
    Last edited by arnage; 30.04.12, 10:16. Reason: please use [ PHP ] YOUR CODE [ / PHP ] tags when posting codes

    #2
    RewriteEngine on
    RewriteRule ^file-([a-zA-Z0-9._-]*)\.html$ filepc.php?file=$1

    http://localhost/write/file-test.php.html will be http://localhost/write/filepc.php?file=test.php

    Make sure that you validate the user input.
    And in php script just edit the links.
    <?php unlink('World/Europe/Romania.country'); ?>

    Comment

    Working...
    X