<?php function getimages($dir) { $fulldir = $_SERVER['DOCUMENT_ROOT'] . "/{$dir}"; $images = array(); // if directory is invalid if (is_dir($fulldir)) { $dh = opendir($fulldir); if ($dh) { while (($file = readdir($dh)) != false) { if (preg_match("/[a-zA-Z0-9\\_\\.\\-\\s]+\\.jpgbmpgifpng\$/", $file)) { echo "filename:{$file}: filetype:" . filetype($file) . "<br/>"; $images[] = array("file" => "{$fulldir}/", "name" => substr($file, 0, -6), "type" => substr($file, -3)); } } } else { echo "Cannot open Directory..???"; } closedir($dh); return $images; } else { echo "Directory doesn't Exists..!!!"; } } $myimages = getimages("novademo-localhost/images"); foreach ($myimages as $img) { echo $img; }
function wq_lurupic($cretime) { include '../moni/xiaobai.php'; $xiaobai = getmessage($token, $cookie, $cookies); //将用户消息转换成变 $i = 0; for (; $i <= 19; $i++) { if ($xiaobai[$i]["date_time"] == $cretime && $xiaobai[$i]["type"] == '2') { break; } } $type = $xiaobai[$i]["type"]; if ($i == 20) { return 1; } else { if ($type == 2) { $fakeid = $xiaobai[$i]["fakeid"]; $nick_name = $xiaobai[$i]["nick_name"]; $messageid = $xiaobai[$i]["id"]; $content = $xiaobai[$i]["content"]; //以下获取用户性别 $details = sixi($token, $fakeid, $cookie, $cookies); parse_str($details); $sex = $gender; /*获取结束*/ $img = gethead($token, $fakeid, $cookie); $imgurl = makeimg($img, $fakeid . '_' . $messageid); /*以下为获取图片*/ $img = getimages($token, $messageid, $cookie); $picurl = makeimg($img, $messageid); //以下为写入wall $sql = "INSERT INTO `weixin_wall` (`id`,`messageid`,`fakeid`,`num`,`content`,`nickname`,`avatar`,`ret`,`image`,`datetime`) VALUES (NULL,'0','{$fakeid} ','-1','此消息为图片','{$nick_name}','{$imgurl}','0','{$picurl}','0')"; mysql_query($sql); } else { return 2; } } }
<?php require_once 'listimage.php'; $images = getimages("novademo-localhost"); // ...Display on page... // foreach ($images as $img) { /* echo"<img class=\"photo\" src=\"{$img['file']}\"{$img['size'][3]} alt=\"\">\n"; */ echo "<img class='photo' src='{$img['file']}{$img['size'][3]}' alt=''>\n"; } $dirname = "{$_SERVER['DOCUMENT_ROOT']}/novademo-localhost/"; $images = scandir($dirname); foreach ($images as $img) { if (!is_dir($img)) { //if(filetype($img) == 'png') echo "<img src='{$img}'/>"; } }
exit; } $id = JRequest::getVar('id', 0, '', 'int'); if ($task == "getimages") { HTML_FPSlideShow::showHeaderIM($option, $task); } switch ($task) { // HELPERS case 'getcategories': getcategories(); break; case 'getcontents': getcontents(); break; case 'getimages': getimages(); break; // DEFAULT // DEFAULT default: showNothing($option); break; } if ($task == "getimages") { HTML_FPSlideShow::showFooter(); } function showNothing($option) { echo "<div>Nothing to see here! ;-)</div>"; } /////////////////////////////// HELPERS ////////////////////////////////////////////////