Beispiel #1
0
<?php

/*
 * Describe what it does to show you're not that dumb!
 *
 **/
/** @var $ctrl \bbn\mvc\controller */
if (isset($ctrl->files['file'], $ctrl->arguments[0]) && \bbn\str::is_integer($ctrl->arguments[0])) {
    $f =& $ctrl->files['file'];
    $path = BBN_USER_PATH . 'tmp/' . $ctrl->arguments[0];
    $new = \bbn\str::encode_filename($f['name'], \bbn\str::file_ext($f['name']));
    $file = $path . '/' . $new;
    if (\bbn\file\dir::create_path($path) && move_uploaded_file($f['tmp_name'], $file)) {
        $tmp = \bbn\str::file_ext($new, 1);
        $fname = $tmp[0];
        $ext = $tmp[1];
        $ctrl->obj->success = 1;
        $archives = ['zip', 'rar', 'tar', 'gzip', 'iso'];
        $images = ['jpg', 'gif', 'jpeg', 'png', 'svg'];
        $files = [basename($file)];
        if (in_array($ext, $archives)) {
            $archive = \wapmorgan\UnifiedArchive\UnifiedArchive::open($file);
            \bbn\file\dir::create_path($path . '/' . $fname);
            if ($num = $archive->extractNode($path . '/' . $fname, '/')) {
                $tmp = getcwd();
                chdir($path);
                $all = \bbn\file\dir::scan($fname, 'file');
                foreach ($all as $a) {
                    array_push($files, $a);
                }
                chdir($tmp);
Beispiel #2
0
    $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;
        }
    }
}
Beispiel #3
0
<?php

/*
 * Describe what it does to show you're not that dumb!
 *
 **/
/** @var $ctrl \bbn\mvc\controller */
$ctrl->obj->success = false;
if (isset($ctrl->arguments[0], $ctrl->post['fileNames'])) {
    $path = BBN_USER_PATH . 'tmp/' . $ctrl->arguments[0];
    $new = \bbn\str::encode_filename($ctrl->post['fileNames'], \bbn\str::file_ext($ctrl->post['fileNames']));
    $file = $path . '/' . $new;
    if (is_file($file)) {
        $ctrl->obj->files = $ctrl->post['fileNames'];
        $ctrl->obj->success = unlink($file);
    }
}