Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
function help[CLOSED]
#1
Thx to eveyone, solved.

this is the code:

Code:
function directoryToArray($directory, $recursive) {
    $array_items = array();
    if ($handle = opendir($directory)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                if (is_dir($directory. "/" . $file)) {
                    if($recursive) {
                        $array_items = array_merge($array_items, directoryToArray($directory. "/" . $file, $recursive));
                    }
                    $file = $directory . "/" . $file;
                    $array_items[] = preg_replace("////si", "/", $file);
                } else {
                    $file = $directory . "/" . $file;
                    $array_items[] = preg_replace("////si", "/", $file);
                }
            }
        }
        closedir($handle);
    }
    return $array_items;
}

Code:
<?php

$directory=GSDATAUPLOADPATH;
$values=(directoryToArray($directory,true));
$datanext=$_GET['datanext'];
$data=$_GET['data'];
if($data!=NULL){
echo '<img src="'.$path.$data.'" width="600px" /><img src="'.$path.$datanext.'" width="600px" />';

}
else{echo'';}

while (list($key, $value) = each($values)) {
if($value!="." && $value!=".."&& $value!=".htaccess"){
echo '<img src="'.$values[$key].'"/><br />';
echo '<a href="http://localhost/GetSimple/index.php?id=php&data='.$values[$key].'&datanext='.$values[$key+1].'"><img src="http://localhost/GetSimple/data/uploads/'.$values[$key].'" width="100px" /></a>';
}
}
?>

and this is the error:

Warning: preg_replace() [function.preg-replace]: Unknown modifier '/' in E:\internet\EasyPHP-5.3.2i\www\GetSimple\theme\MyTheme\functions.php on line 22

for every file.

I've tried this code in a blank php page and it'works.
Where's the problem.

plugin exec-php is installed and html editor off.

Ciao
Reply
#2
have you tried

Code:
$array_items[] = preg_replace("/\/\/\/s/i", "/", $file);

just a quick geuss no time to test yet
(sorry missed the ending / added that later)
Stopped developing on GS Plugins. Anybody welcome to take the projects over. Thanks for all the support all.
Reply
#3
THX.
Solved the problem about preg_replace.
Now i've a problem with the link...
GSDATAUPLOADPATH doesn't work. so I changed in

$directory="http://localhost/GetSimple/data/uploads/";

and now it retunrs another error:

Warning: opendir(http://localhost/GetSimple/data/uploads/) [function.opendir]: failed to open dir: not implemented in E:\internet\EasyPHP-5.3.2i\www\GetSimple\plugins\exec-php.php(30) : eval()'d code on line 4

any idea?
Reply
#4
$array_items[] = preg_replace("/\/\/\/s/i", "/", $file);

when i update the page become

$array_items[] = preg_replace("////si", "/", $file);

idea?
ciao
Reply




Users browsing this thread: 1 Guest(s)