MontefuckeR
Registered
Трябва ми код за странициране обаче без БД !
защото файловете който искам да се страницират са записани в папка
защото файловете който искам да се страницират са записани в папка
Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
това е от файл а аз искам от папкаhrischo каза:http://web-tourist.net/login/login/view.php?st=1619
<?php
//колко резултата на страница
$pp = "25";
//колко резултата на страница
//задаваме папката
$dir = "./";
//задаваме папката
$page=$_GET['page'];
if(!$_GET['page'])
{
$page="1";
}
$limit = ($pp*$page)-$pp;
$dh = opendir($dir);
while (false !== ($filename = readdir($dh)))
{
if ($filename!="." && $filename!=".." && $filename!="Thumb.db")
{
if(is_dir($dir.$filename))
{
$files[] = "[DIR] ".$filename;
}
else
{
$files[] = "[FILE] <a href='".$dir.$filename."'>".$filename."</a>";
}
}
}
$count = count($files);
for($i=$limit; $i<=($limit+$pp); $i++)
{
echo $files[$i]."<br>";
}
echo "<br>";
//от тук започва кода за показването на страниците
$total=ceil($count/$pp);
for($i=1 ; $i<=$total ; $i++)
{
if(($page)==$i)
{
echo "[".$i."] ";
}
else
{
echo "<a href=\"?page=".$i."\">".$i."</a> ";
}
}
?>
MontefuckeR каза:кода работи но можеш ли да ми кажеш към кой файл да го допълня,защото съм създал дизайн ?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
</head>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
<tr>
<form action="upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<input name="ufile" type="file" id="ufile" size="60" /></td>
</tr>
<tr>
<input type="submit" name="Submit" value="Качи" />
</tr>
</table>
</td>
</form>
</tr>
</table>
</sup></small>
</center>
</sup></small>
</center>
</center>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Search</title>
</head>
<body>
<center>
<td><strong>Search Engine</strong></td>
<form action="search.php" method="post">
<input type="text" name="searched">
<input type="submit" value="Търси !">
</form>
</html>
<?
$dir = "upload/"; // Избираме директорията, от която ще индексираме файловете
if(!is_dir($dir))
{
mkdir($dir); // Проверяваме дали директорията съществува, ако не я създаваме
}
$dh = opendir($dir); // Подготвяме за четене (отваряме) директорията
print "<h3>Files в $dir</h3><table width=\"90%\" align=\"center\" border=\"1\"><tr><td style=\"text-align:center\">Име на file:</td></tr>";
while($file = readdir($dh)) // Четем файловете от директорията (този цикъл помага да индексираме всички файлове)
{
if($file != "." and $file != "..") // Не индексираме "." и ".."
{
$lower = strtolower($file);
if(!eregi(".ht",$file)) // Така можете да не индексирате дадени файлове
{
print "<tr><td><a href=\"$dir$file\">$file</a></td></tr>"; // Когато поставяте линк не забравяйте да добавите и променливата $dir
}
}
}
print "</table>";
?>
<?php
session_start();
?>
<?
//файловете ще се съхраняват в папката upload
//$HTTP_POST_FILES['ufile']['name']; = качва името на файла
//за пример качваме файл на име picture.gif . $path то ще бъде качено - /picture.gif
$path= "upload/".$HTTP_POST_FILES['ufile']['name'];
if($ufile !=none)
{
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
echo "<b>File бе качен успешно !<BR/>";
//$HTTP_POST_FILES['ufile']['name'] = името на файла
//$HTTP_POST_FILES['ufile']['size'] = големината на файла
//$HTTP_POST_FILES['ufile']['type'] = мястото на файла
echo "Име:".$HTTP_POST_FILES['ufile']['name']."<BR/>";
echo "Тип:".$HTTP_POST_FILES['ufile']['type']."<BR/>";
}
else
{
echo "<b><font color=red>Бе открита грешка</b></font>";
}
}
?>
<?php
$flag=0;
$dir="upload/";
if(isset($_POST['searched'])) {
foreach(glob($dir."*") as $file) {
if(@eregi($_POST['searched'], str_replace($dir, "", $file))) {
echo("<a href='".$file."' target=_blank>".str_replace($dir, "", $file)."</a><br />\n");
$flag+=1;
}
}
if($flag==false) {
echo("Няма намерени файлове.");
}
}
?>
</center>
</body>
</html>
<form action="" method="GET">
<input type="text" name="search" value="<?php echo htmlspecialchars(stripslashes($_GET['search']));?>">
<input type="submit" value="Търси">
</form>
<?php
$flag=0;
$dir="images/";
$search = $_GET['search'];
$broinastranica = 2;
function searching($unset = "")
{
global $dir,$search,$broinastranica;
$each = array();
$i = 0;
$k = 1;
foreach(glob($dir."*") as $file)
{
$file = str_replace($dir,'',$file);
if(eregi($search,$file))
{
if($i == $broinastranica)
{
$i = 0;
$k++;
}
$i++;
$each[][$k] = strtolower($file);
}
}
return $each;
}
function pager($vararray)
{
global $search,$_GET,$_SERVER;
$page_set = array();
$paginator = '';
foreach($vararray as $b=>$stranici)
{
list($stranici) = @each($stranici);
if ( empty($page_set[$stranici]) )
{
$page_set[$stranici] = 1;
$paginator .= ($_GET['page'] == $stranici) ? '<b>'.$stranici.'</b>' : '<a href="'. $_SERVER['PHP_SELF'] .'?page='.$stranici.'&search='.htmlspecialchars($search).'">'.$stranici.'</a> ';
}
}
return $paginator;
}
$page = (intval($_GET['page']) > 0 ) ? intval($_GET['page']) : 1;
if($search)
{
$files = searching();
for($i = 0; $i<count($files);$i++)
{
echo $files[$i][$page].'<BR>';
}
echo pager($files);
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
</head>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
<tr>
<form action="upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<input name="ufile" type="file" id="ufile" size="60" /></td>
</tr>
<tr>
<input type="submit" name="Submit" value="Качи" />
</tr>
</table>
</td>
</form>
</tr>
</table>
</sup></small>
</center>
</sup></small>
</center>
</center>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Search</title>
</head>
<body>
<center>
<td><strong>Search Engine</strong></td>
<form action="search.php" method="GET">
<input type="text" name="search">
<input type="submit" value="Търси !">
</form>
</html>
<?php
$dir="images/";
$search = $_GET['search'];
$broinastranica = 2;
function searching()
{
global $dir,$search,$broinastranica;
$each = array();
$i = 0;
$k = 1;
foreach(glob($dir."*") as $file)
{
$file = str_replace($dir,'',$file);
if(eregi($search,$file))
{
if($i == $broinastranica)
{
$i = 0;
$k++;
}
$i++;
$each[][$k] = strtolower($file);
}
}
return $each;
}
function pager($vararray)
{
global $search,$_GET,$_SERVER;
$page_set = array();
$paginator = '';
foreach($vararray as $b=>$stranici)
{
list($stranici) = @each($stranici);
if ( empty($page_set[$stranici]) )
{
$page_set[$stranici] = 1;
$paginator .= ($_GET['page'] == $stranici) ? '<b>'.$stranici.'</b>' : '<a href="'. $_SERVER['PHP_SELF'] .'?page='.$stranici.'&search='.htmlspecialchars($search).'">'.$stranici.'</a> ';
}
}
return $paginator;
}
if(!is_dir($dir))
{
mkdir($dir); // Проверяваме дали директорията съществува, ако не я създаваме
}
$page = (intval($_GET['page']) > 0 ) ? intval($_GET['page']) : 1;
print "<h3>Files в $dir</h3><table width=\"90%\" align=\"center\" border=\"1\"><tr><td style=\"text-align:center\">Име на file:</td></tr>";
if($search)
{
$files = searching();
$var = array();
for($i = 0; $i<count($files);$i++)
{
if(!empty($files[$i][$page]))
{
echo "<tr><td><a href=\"".$dir . $files[$i][$page] ."\">". $files[$i][$page] ."</a></td></tr>";
}
}
echo pager($files);
}
print "</table>";