Beispiel #1
0
<?php

/*
 * Describe what it does or you're a pussy
 *
 **/
/** @var $model \bbn\mvc\model*/
if (isset($model->data['url'], $model->data['ref']) && \bbn\str::is_url($model->data['url'])) {
    $linkPreview = new \LinkPreview\LinkPreview($model->data['url']);
    $parsed = $linkPreview->getParsed();
    $path = BBN_USER_PATH . 'tmp/' . $model->data['ref'] . '/';
    $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);
Beispiel #2
0
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);
            }
        }
        $ctrl->obj->files = [];
        foreach ($files as $f) {
            $tmp = \bbn\str::file_ext($f, 1);
            $fname = $tmp[0];
            $ext = $tmp[1];