sabret00the
02-09-2006, 04:33 PM
i've written this function (below), it takes
{TEXT1}
dfhdfkldfds;hdsfjsdfsdkfsdjkfhdsfsdjkfhdfjkdsfdsjk hd
{TEXT2}
fdkfdhfsldkfhdsfjlkhfdkjlfhdjkfldslkjfhsdhfldsfjhd sf
and converts the swirly brackets to lists, however it works perfectly on my localhost and on my test site, but on server for the production site, it refuses to work. any suggestions?
function get_thumbs_with_text($text, $picture_directory)
{
$titles = array();
foreach(explode("\n", $text) as $title)
{
if (!preg_match("/\{([^\}]+)\}(.+)/", $title, $regs))
{
continue;
}
$titles[$regs[1]] = $regs[2];
}
$thumbs_directory = $picture_directory . "/thumbs/";
foreach($titles AS $key => $value)
{
if ($handle = opendir($picture_directory))
{
while (false !== ($file = readdir($handle)))
{
if (!in_array($file, array(".", "..")) AND in_array(substr($file, -4), array('.jpg', 'jpeg', '.gif', '.png')))
{
$haystack = $file;
$needle = strtolower($key);
$pos = strpos($haystack, $needle);
if (!($pos === FALSE))
{
$img_dimentions = getimagesize($thumbs_directory . '/' . $file);
$picture_list .= '<li><a href="showpic.php?gallery=' . substr($picture_directory, 4) . '&file=' . $file . '" target="_blank"><img src="' . $thumbs_directory . '/' . $file . '" width="' . $img_dimentions['0'] . '" height="' . $img_dimentions['1'] . '" alt="' . $file . '" class="thumbs" /></a>';
unset($img_dimentions);
}
}
}
closedir($handle);
}
$picture_list = (!$picture_list) ? "<li><img src=\"img/picturenotfound.gif\" /></li>" : $picture_list;
$list2[$key] = "<ul id=\"picturelist2\">" . $picture_list . "</ul>";
$picture_list = "";
$text = str_replace("{" . strtoupper($key) . "}", $list2[$key], $text);
}
$text = str_replace(
array(
"\r",
"<ul><br />",
"<li><br />",
"</li><br />",
"</ul><br />",
"</h3><br />",
"</h4><br />",
"method=\"post\"><br />",
"\"><br />",
"</div><br />"
),
array(
"<br />",
"<ul>",
"<li>",
"</li>",
"</ul>",
"</h3>",
"</h4>",
"method=\"post\">",
"\">",
"</div>"
),
$text);
return $text;
}
i originally thought about the php version, but since the production site is now on 5.0.5 and my localhost is 5.0.4, though i have a 4.3.3 that ran it fine, so it can't be that.
register_globals is set the same on all servers.
{TEXT1}
dfhdfkldfds;hdsfjsdfsdkfsdjkfhdsfsdjkfhdfjkdsfdsjk hd
{TEXT2}
fdkfdhfsldkfhdsfjlkhfdkjlfhdjkfldslkjfhsdhfldsfjhd sf
and converts the swirly brackets to lists, however it works perfectly on my localhost and on my test site, but on server for the production site, it refuses to work. any suggestions?
function get_thumbs_with_text($text, $picture_directory)
{
$titles = array();
foreach(explode("\n", $text) as $title)
{
if (!preg_match("/\{([^\}]+)\}(.+)/", $title, $regs))
{
continue;
}
$titles[$regs[1]] = $regs[2];
}
$thumbs_directory = $picture_directory . "/thumbs/";
foreach($titles AS $key => $value)
{
if ($handle = opendir($picture_directory))
{
while (false !== ($file = readdir($handle)))
{
if (!in_array($file, array(".", "..")) AND in_array(substr($file, -4), array('.jpg', 'jpeg', '.gif', '.png')))
{
$haystack = $file;
$needle = strtolower($key);
$pos = strpos($haystack, $needle);
if (!($pos === FALSE))
{
$img_dimentions = getimagesize($thumbs_directory . '/' . $file);
$picture_list .= '<li><a href="showpic.php?gallery=' . substr($picture_directory, 4) . '&file=' . $file . '" target="_blank"><img src="' . $thumbs_directory . '/' . $file . '" width="' . $img_dimentions['0'] . '" height="' . $img_dimentions['1'] . '" alt="' . $file . '" class="thumbs" /></a>';
unset($img_dimentions);
}
}
}
closedir($handle);
}
$picture_list = (!$picture_list) ? "<li><img src=\"img/picturenotfound.gif\" /></li>" : $picture_list;
$list2[$key] = "<ul id=\"picturelist2\">" . $picture_list . "</ul>";
$picture_list = "";
$text = str_replace("{" . strtoupper($key) . "}", $list2[$key], $text);
}
$text = str_replace(
array(
"\r",
"<ul><br />",
"<li><br />",
"</li><br />",
"</ul><br />",
"</h3><br />",
"</h4><br />",
"method=\"post\"><br />",
"\"><br />",
"</div><br />"
),
array(
"<br />",
"<ul>",
"<li>",
"</li>",
"</ul>",
"</h3>",
"</h4>",
"method=\"post\">",
"\">",
"</div>"
),
$text);
return $text;
}
i originally thought about the php version, but since the production site is now on 5.0.5 and my localhost is 5.0.4, though i have a 4.3.3 that ran it fine, so it can't be that.
register_globals is set the same on all servers.