Jump to content

Recommended Posts

Have this site: web.sarunicamp.com. If you go to the

Your Photos link error messages are printed:

Warning: Wrong parameter count for fgets() in /home/web/saruni/func.php on line 351

 

Warning: Wrong parameter count for fgets() in /home/web/saruni/func.php on line 351

 

Warning: Wrong parameter count for fgets() in /home/web/saruni/func.php on line 351

 

Warning: Wrong parameter count for fgets() in /home/web/saruni/func.php on line 351

 

 

In Our Photos link, the browser actually hangs.

 

The suspect code is as below:

<?php 
define("perpage",15);
//=====================================================================
		/* Function To Get The Directory Entities*/

//=====================================================================
function imagerdel2($dirname)
{ 
$dh = opendir( $dirname );
   while (  $file = readdir( $dh ))
{ 

if ( !is_dir( "$dirname/$file" ) )
{

$im[]=$file;
}
//===============================================
//======================================================
}
return @$im;
}
function imagerdel($dirname)
{ 
$dh = opendir( $dirname );
   while (  $file = readdir( $dh ))
{ 

if ( !is_dir( "$dirname/$file" ) )
{
if($file!="description.txt")
{
$im[]=$file;
}

}

}
return @$im;
}
//=====================================================================
		/* Function To Get The Directory */

//=====================================================================
function imager($dirname)
{ 
$dh = opendir( $dirname );
   while (  $file = readdir( $dh ))
{ 

if (is_dir( "$dirname/$file" ) )
{
if($file!="." && $file!="..")
{
$im[]=$file;
}
}

}
return $im;
}
function description($gr_edits)
{
$fd = fopen ("saruni_gallary/$gr_edits/description.txt", "r");
while (!feof ($fd)) {
    $buffer[]= fgets($fd); 
}
list($descfun1,$descfun)=explode(":",$buffer[0]);
fclose ($fd);
return $descfun;
}
//============================================================

//============================================================

function tables($d,$nab=0)
{
@$n=getnum("saruni_gallary/".$d."/thumbnail");

echo "<table width=\"423\" height=\"24\" border=\"0\"><tr>";
if($nab==0)
{
$buffer=imager_geter($d);
$add=1;
}
else
{
$buffer=imager_geter2($nab);
$add=0;
}
$num=sizeof($buffer);
$i=0;
if($n[$i]!="")
{
do
{
@list($descfun1,$descfun)=split(":",$buffer[$add+$i]);
$filename = "saruni_gallary/".$d."/".$descfun1;
$fd = fopen ($filename, "r");
$dis = fread ($fd, filesize ($filename));
@list($name,$diss)=split(",",$dis);
@$i++;
if($descfun1!="")
{
echo    "<td width=\"141\"><div align=\"center\"><a href=\"#\" onClick=\"MM_openBrWindow('imager.php?gr=$d&p=".rawurlencode("$descfun1.jpg")."&disc=".rawurlencode("$descfun")."','image','scrollbars=yes,resizable=yes,width=465,height=535')\"><img src=\"saruni_gallary/$d/thumbnail/$descfun1.jpg\"></a><br>$name</div></td>";
}

if($i%3 ==0)
{
echo "</tr>";
}

}
  while($i<$num);
  if($i%3 !=0)
{
echo "<td width=\"141\"> </td></tr>";
}
echo "</table>";
}
  else
{
echo "<table width=\"423\" height=\"24\" border=\"0\"><tr>";
echo    "<td width=\"141\"><p><strong>No image</strong></p></td>";
echo "</tr>";
echo "</table>";
}
}

//=============================================================================
function tablesroot($d)
{
@$n=getnum("../saruni_gallary/".$d."/thumbnail");
$num=sizeof($n);
echo "<table width=\"423\" height=\"24\" border=\"0\"><tr>";
$buffer=imager_geteroot($d);
$i=0;
if($n[$i]!="")
{
do
{

list($descfun1,$descfun)=split(":",$buffer[2+$i]);
$i++;
echo    "<td width=\"141\"><a href=\"?show=414&gr=$d&p=".rawurlencode("$descfun1.jpg")."&disc=".rawurlencode("$descfun")."\"><img src=\"../saruni_gallary/$d/thumbnail/$descfun1.jpg\"></a></td>";


if($i%3 ==0)
{
echo "</tr>";
}

}
  while($i<$num);
  if($i%3 !=0)
{
echo "<td width=\"141\"> </td></tr>";
}
echo "</table>";
}
  else
{
echo "<table width=\"423\" height=\"24\" border=\"0\"><tr>";
echo    "<td width=\"141\"><p><strong>No image</strong></p></td>";
echo "</tr>";
echo "</table>";
}
}

//=============================================================================
//=================================================================================

			/*  Get Image Number */

//===================================================================================
function getnum($dq)
{
$dh = opendir($dq);
   while (  $file = readdir( $dh ))
{ 
if(!is_dir($file))
{
$n[]=$file;
}
}
return $n;
}
//=========================================

//========================================  
  function imager_geter($gr_edits2)
{
$fd = fopen ("saruni_gallary/$gr_edits2/description.txt", "r");
while (!feof ($fd)) {
    $buffer2[]= fgets($fd); 

}
fclose ($fd);
$buffer2_rev=array_reverse($buffer2);
$buffer2_rev=array_reverse($buffer2);
$lop=sizeof($buffer2_rev)-2;
for($pr=0;$pr<$lop;$pr++)
{
$buffer3[]=$buffer2_rev[$pr];
}
return $buffer3;
}
//============================================
function imager_geteroot($gr_edits2)
{
$fd = fopen ("../saruni_gallary/$gr_edits2/description.txt", "r");
while (!feof ($fd)) {
    $buffer2[]= fgets($fd); 
}
fclose ($fd);
return $buffer2;
}

//===========================
//=====================
//============================
function itable($dir)
{
$rd=imagerdel2("saruni_gallary/$dir/thumbnail/");
$rnd=rand(0,sizeof($rd)-1);
$t=rawurlencode($rd[$rnd]);
return $t;
}
function tables_set()
{
$n=imager("saruni_gallary/");
$num=sizeof($n);
echo "<table width=\"423\" height=\"24\" border=\"0\"><tr>";
$i=0;
if($n[$i]!="")
{
do
{
echo    "<td width=\"141\"><div align=center><a href=\"photos.php?show=$n[$i]\"><img src=\"saruni_gallary/$n[$i]/thumbnail/".itable($n[$i])."\"><br><span>".description($n[$i])."</span></a></div></td>";

$i++;
if($i%3 ==0)
{
echo "</tr>";
}

}
  while($i<$num);
  if($i%3 !=0)
{
echo "<td width=\"141\"> </td></tr>";
}
echo "</table>";
}
  else
{
echo "<table width=\"423\" height=\"24\" border=\"0\"><tr>";
echo    "<td width=\"141\"><p><strong>No image</strong></p></td>";
echo "</tr>";
echo "</table>";
}
}
//===========================================================================
//===============================================================================


  function imager_geter2($yy)
{

$fd = fopen ("saruni_gallary/Your Photos/description.txt", "r");
while (!feof ($fd)) {

    $buffer2[]= fgets($fd); 


}
fclose ($fd);
$buffer2_rev=array_reverse($buffer2);
$lop=sizeof($buffer2_rev)-2;
for($pr=0;$pr<$lop;$pr++)
{
$buffer3[]=$buffer2_rev[$pr];
}

$size=sizeof($buffer3);
$slit=($size/perpage);
$slit=ceil($slit);
$x=(perpage*$yy);
if($yy==1)
{
$y=0;
}
else
{
$y=(perpage*($yy-1));
}

for($i=$y;$i<$x;$i++)
{
$n[]=@$buffer3[$i+1];
}
return $n;
}

function navi($n)
{
$fd = fopen ("saruni_gallary/Your Photos/description.txt", "r");
while (!feof ($fd)) {
    $buffer2[]= fgets($fd); 


}
fclose ($fd);
$lop=sizeof($buffer2)-3;
for($pr=0;$pr<$lop;$pr++)
{
$buffer3[]=$buffer2[$pr];
}
$size=sizeof($buffer3);
  $slit=($size/perpage);
$slit=ceil($slit);
$pev=$n-2;
$nav="<table width=328 height=35 align=\"center\">
  <tr>
    <td width=82 height=29><div align=center><a href=photos.php?show=Your%20Photos&page=1>First</a></div></td>";
    if($pev != 1)
{
if($pev != 0)
{
$nav.="<td width=82><div align=center><a href=photos.php?show=Your%20Photos&page=".$pev.">Previous</a> </div></td>";
}
}
if($n<=$slit)
{
    $nav.="<td width=82><div align=center><a href=photos.php?show=Your%20Photos&page=$n>Next</a></div></td>";
}
    $nav.="<td width=82><div align=center><a href=photos.php?show=Your%20Photos&page=$slit>last</a></div></td>
  </tr>
</table>";
echo  $nav."<br>";
}
//===============================================================


function arraysize()
{

$fd = fopen ("saruni_gallary/Your Photos/description.txt", "rw");
while (!feof ($fd)) {

    $buffer2[]= fgets($fd); 


}
fclose ($fd);
$buffer2_rev=array_reverse($buffer2);
$lop=sizeof($buffer2_rev)-2;
for($pr=0;$pr<$lop;$pr++)
{
$buffer3[]=$buffer2_rev[$pr];
}
$size=sizeof($buffer3);
return $size;
}
//=====================================
function tabless($d)
{
@$n=getnum("saruni_gallary/".$d."/thumbnail");
$num=sizeof($n)-1;
echo "<table width=\"423\" height=\"24\" border=\"0\"><tr>";
$buffer=imager_geters($d);
$i=0;
if($n[$i]!="")
{
do
{
list($descfun1,$descfun)=split(":",$buffer[1+$i]);


echo    "<td width=\"141\"><div align=\"center\"><a href=\"#\" onClick=\"MM_openBrWindow('imager.php?gr=$d&p=".rawurlencode("$descfun1.jpg")."&disc=".rawurlencode("$descfun")."','image','scrollbars=yes,resizable=yes,width=465,height=535')\"><img src=\"saruni_gallary/$d/thumbnail/$descfun1.jpg\"></a></div></td>";

$i++;
if($i%3 ==0)
{
echo "</tr>";
}

}
  while($i<$num);
  if($i%3 !=0)
{
echo "<td width=\"141\"> </td></tr>";
}
echo "</table>";
}
  else
{
echo "<table width=\"423\" height=\"24\" border=\"0\"><tr>";
echo    "<td width=\"141\"><p><strong>No image</strong></p></td>";
echo "</tr>";
echo "</table>";
}
}
///======================================================

function imager_geters($gr_edits2)
{
$fd = fopen ("saruni_gallary/$gr_edits2/description.txt", "r");
while (!feof ($fd)) {
    $buffer2[]= fgets($fd); 

}
$buffer2_rev=array_reverse($buffer2);
fclose ($fd);
return $buffer2_rev;
}
?>

 

 

Any help??

Link to comment
https://forums.phpfreaks.com/topic/71135-error-in-phpmysql-code/
Share on other sites

The file your trying to open doesn't exist at the path you've given, so feof is never going to return true and you're code gets caught in an infinite loop. You should test that a file exists before trying to open it this way using file_exists();

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.