View Full Version : PHP Question
minnseoelite
May 21st, 2007, 11:29 PM
Does anyone know what is causing this error and how to fix it
Warning: natcasesort() [function.natcasesort]: The argument should be an array in /plugins/graphics-gallery/index.php on line 81
and would fixing that also fix this
Warning: array_values() [function.array-values]: The argument should be an array in /plugins/graphics-gallery/index.php on line 82
Greg-J
May 22nd, 2007, 12:04 AM
Both functions take arrays as arguments. Are you trying to give them a string? Can you post how you are using them in context?
minnseoelite
May 22nd, 2007, 12:10 AM
Not exactly sure I don't know that much about PHP but here is the code for that page
<?
$urlpath = "$GPATH";
$cat = "$GROOT";
$max2show = 3; //Amount you want to show per page
$numFolderColumns = 1; // Number of columns of folder names you want to show on each row
// END OF CONFIGURATION SECTION
// Do not edit below this line
// Folder support
if(isset($_GET['folder']))
{
$cat .= $_GET['folder'] . '/';
$urlpath .= $_GET['folder'] . '/';
}
$hook = opendir($cat) or die('cant open dir');
$total = 0;
if(!isset($_GET['page'])) $page = 1;
else $page = $_GET['page'];
$start = $max2show * $page - $max2show;
$end = $page * $max2show;
/* folder support */
$directories = array();
/* End folder support part */
$ext = array("jpg", "png", "jpeg", "gif");
while (false!==($file = readdir($hook))) {
$idnum = "1";
// Functionality to check folders added here
$fpath = $cat . $file;
if(is_dir($fpath))
{
//echo
if($file != '.' && $file != '..')
{
array_push($directories, $file);
}
}
// folder support ends here
for($i=0;$i<sizeof($ext);$i++)
{
if (stristr($file, ".".$ext[$i])) //NOT case sensitive
{
$files[] = $file;
$total++;
}
}
}
closedir($hook);
natcasesort($files);
$files = array_values($files);
/* Modification part to display folders */
if(count($directories) > 0)
{
$loopCounter = 1;
foreach($directories as $directory)
{
echo ' <a href="' . $_SERVER['PHP_SELF'] . '?app=graphics-gallery&page=1&folder=' . urlencode($directory) . '"><b>' . $directory . '</b></a> ~';
$loopCounter += 1;
}
;
}
if(!empty($_GET['folder']))
{
echo '</div><span>Viewing subfolder: <b>' . $_GET['folder'] . '</b></span><br /><a href="/graphics-gallery"><b>Back To Gallery Index</b></a><br />';
}
/* End modification part */
if ($end > $total) { $end = $total; }
echo '<table width="100%" border="0" cellspacing="0" cellpadding="4" border="0"><tr>';
//if ($cnt >= $start && $cnt < $end)
if(isset($_GET['page'])&&($_GET['page'] != 1)) {
$pre = $_GET['page'] - 1;
echo '<td align="left" width="38%"><a href="' . $_SERVER['PHP_SELF'] . '?app=graphics-gallery&page=' . $pre . '&folder=' . urlencode($_GET['folder']) . '"><big><b>Previous Page</b></big></a></td>';
}
$pages = $total/$max2show;
$lastpage = ceil($pages);
echo '<td></td>';
if($page < $lastpage) {
$next = $page + 1;
echo '<td align="right" width="45%"><a href="' . $_SERVER['PHP_SELF'] . '?app=graphics-gallery&page=' . $next . '&folder=' . urlencode($_GET['folder']) . '"><big><b>Next Page</b></big></a></td>';
}
echo '</tr>
</table><br />';
for ($cnt = $start; $cnt < $end; $cnt++) {
$file = $files[$cnt];
$exten = explode('.',$file);
?>
<table border="0" width="100%" align="center" cellpadding="4" cellspacing="4">
<tr>
<td valign="top" style="padding-right: 10px;" align="right"><a href="<?php echo $urlpath . $file; ?>" target="_blank" rel="lightbox" title="<?php echo $file; ?>"><img src="<?php echo $urlpath . $file; ?>" alt="<?php echo $file; ?>" width="230" height="230"></a></td>
<td valign="top" align="left">
<strong>HTML Code For All Profiles/Blogs:</strong><br />
<input onClick="this.focus();this.select()" id="postContent_<?php echo $idnum; ?>" class="input" size="20" name="file2" type="text" value="<a href="<?php echo $urlpath . $file; ?>" target="_blank"><img src="<?php echo $urlpath . $file; ?>" border="0"></a>" /><br />
<strong>Myspace Contact Table:</strong><br />
<input onClick="this.focus();this.select()" class="input" size="20" name="file" type="text" value="<style type="text/css">.contactTable {width:300px!important; height:150px!important; padding:0px!important; background-image:url("<?php echo $urlpath . $file; ?>"); background-attachment:scroll; background-position:center center; background-repeat:no-repeat; background-color:transparent;} .contactTable table, table.contactTable td {padding:0px !important; border:0px; background-color:transparent; background-image:none;} .contactTable a img {visibility:hidden; border:0px!important;} .contactTable a {display:block; height:28px; width:115px;} .contactTable .text {font-size:1px!important;}.contactTable .text, .contactTable a, .contactTable img {filter:none!important;}</style>" ><br />
<strong>Myspace Background:</strong><br />
<input onClick="this.focus();this.select()" class="input" size="20" name="file" type="text" value="<style><!--body{background: black url(<?php echo $urlpath . $file; ?>) fixed}--></style>"><br />
<strong>Myspace Online Now:</strong><br />
<input onClick="this.focus();this.select()" class="input" size="20" name="file" type="text" value="<style type="text/css">table table table td.text div img {visibility:hidden;} table table table td.text div { background-image:url('<?php echo $urlpath . $file; ?>'); background-repeat:no-repeat} table table table td.text table table div img {visibility:visible;} table table table td.text table table div { background-image:url('none');}</style>"><br />
<strong>Myspace Extended Network:</strong><br />
<input onClick="this.focus();this.select()" class="input" size="20" name="file" type="text" value="<style>table table table td {vertical-align:top ! important;}span.blacktext12 {visibility:visible !important;background-color:transparent;background-image:url(<?php echo $urlpath . $file; ?>);background-repeat:no-repeat;background-position:center center;font-size:0px; letter-spacing:-0.5px;width:435px; height:75px; display:block !important; }span.blacktext12 img {display:none;}</style>">
</td>
</tr>
</table>
<table border="0" width="100%" align="center" cellpadding="4" cellspacing="4">
<tr>
<td>
<div id="divWildfirePost_<?php echo $idnum; ?>"></div>
<SCRIPT>
var pconf_<?php echo $idnum; ?>={
defaultContent: "postContent_<?php echo $idnum; ?>",
tabTextColor: "#2B2B2B",
frameColor: "#757575",
fontType: "Arial"
};
Wildfire.initPost("ProfileCMS", "divWildfirePost_<?php echo $idnum; ?>", 450, 130, pconf_<?php echo $idnum; ?>);
</SCRIPT>
</td>
</tr>
</table>
<br />
<hr />
<?
$idnum ++;
}//for
echo '<br /><table width="100%" border="0" cellspacing="0" cellpadding="4" border="0"><tr>';
if(isset($_GET['page'])&&($_GET['page'] != 1)) {
$pre = $_GET['page'] - 1;
echo '<td align="left" width="38%"><a href="' . $_SERVER['PHP_SELF'] . '?app=graphics-gallery&page=' . $pre . '&folder=' . urlencode($_GET['folder']) . '"><big><b>Previous Page</b></big></a></td>';
}
echo '<td></td>';
if($page < $lastpage) {
$next = $page + 1;
echo '<td align="right" width="45%"><a href="' . $_SERVER['PHP_SELF'] . '?app=graphics-gallery&page=' . $next . '&folder=' . urlencode($_GET['folder']) . '"><big><b>Next Page</b></big></a></td>';
}
echo '</tr>
</table>';
?>
Greg-J
May 22nd, 2007, 12:18 AM
Do this:
On line 58 you will see this code:
closedir($hook);
natcasesort($files);
$files = array_values($files);
Change that to:
closedir($hook);
echo $files;
natcasesort($files)
$files = array_values($files);;
As long as you're not feeding those functions arrays, that should print something out. Paste it here. If that throws an error then change it to this:
closedir($hook);
echo "<pre>";
print_r($files);
echo "</pre>";
natcasesort($files);
$files = array_values($files);
And paste the output here.
Regardless of what you find it would seem to me that one of the variables needed to readdir() is not present or incorrect.
minnseoelite
May 22nd, 2007, 12:26 AM
i got it figured out......the script was set so that if the uploads folder was empty it returned that error message instead of having it echo back 0 if the file count was zero
thanks anyways Greg
vBulletin® v3.7.1, Copyright ©2000-2008, Jelsoft Enterprises Ltd.