$root = strval(time()); \bbn\file\dir::create_path($path . $root); foreach ($parsed as $parserName => $link) { if ($parserName === 'general') { $r = ['url' => $link->getUrl(), 'realurl' => $link->getRealUrl(), 'title' => $link->getPageTitle(), 'desc' => $link->getDescription(), 'pictures' => []]; $img = $link->getImage(); $pictures = $link->getPictures(); if (!is_array($pictures)) { $pictures = []; } if (!empty($img)) { array_unshift($pictures, $img); } foreach ($pictures as $pic) { $saved = @file_get_contents($pic); if ($saved && strlen($saved) > 1000) { $new = \bbn\str::encode_filename(basename($pic), \bbn\str::file_ext(basename($pic))); file_put_contents($path . $root . '/' . $new, $saved); unset($saved); $img = new \bbn\file\image($path . $root . '/' . $new); if ($img->test() && ($imgs = $img->thumbs($path . $root))) { array_push($r['pictures'], array_map(function ($a) use($path) { return substr($a, strlen($path)); }, $imgs)); } } } return $r; } } }
$all = \bbn\file\dir::scan($fname, 'file'); foreach ($all as $a) { array_push($files, $a); } chdir($tmp); } } $ctrl->obj->files = []; foreach ($files as $f) { $tmp = \bbn\str::file_ext($f, 1); $fname = $tmp[0]; $ext = $tmp[1]; $res = ['name' => $f, 'size' => filesize($path . '/' . $f), 'extension' => '.' . $ext]; if (in_array($ext, $images)) { // Creating thumbnails $res['imgs'] = []; $img = new \bbn\file\image($path . '/' . $f); if ($img->test() && ($imgs = $img->thumbs($path))) { array_push($res['imgs'], array_map(function ($a) use($path) { return substr($a, strlen($path)); }, $imgs)); } $res['imgs']['length'] = count($res['imgs']); } array_push($ctrl->obj->files, $res); } } } if (!isset($ctrl->obj->success)) { $ctrl->obj->success = 0; }