Beispiel #1
0
 public function before()
 {
     $request = $this->getRequest();
     $this->uri = $this->getContext()->getService('uri');
     $this->mailer = $this->getContext()->getService('mailer');
     $this->notices = $this->getContext()->getService('notices');
     $this->preferences = $this->getContext()->getService('preferences');
     $this->config = $this->getContext()->getService('config');
     $this->security = $this->getContext()->getService('security');
     $theme_instance = \Foolz\Theme\Loader::forge('foolframe_admin');
     $theme_instance->addDir(VENDPATH . 'foolz/foolframe/assets/themes-admin/');
     $theme_instance->addDir(VAPPPATH . 'foolz/foolframe/themes-admin/');
     $theme_instance->setBaseUrl($this->uri->base() . 'foolframe/');
     $theme_instance->setPublicDir(DOCROOT . 'foolframe/');
     // make it possible to override the theme so other framework components can extend with their own
     $this->setupTheme($theme_instance);
     $this->builder = $this->theme->createBuilder();
     $this->param_manager = $this->builder->getParamManager();
     $this->builder->createLayout('base');
     $this->builder->getProps()->addTitle(_i('Control Panel') . ' - ' . $this->preferences->get('foolframe.gen.website_title'));
     $this->param_manager->setParams(['context' => $this->getContext(), 'notices' => $this->notices, 'uri' => $this->uri, 'request' => $request]);
     // returns the hardcoded sidebar array (can't use functions when declaring a class variable)
     $sidebar = $this->getSidebarValues();
     $sidebar_dynamic = Hook::forge('Foolz\\FoolFrame\\Controller\\Admin::before#var.sidebar')->setObject($this)->setParam('sidebar', [])->execute()->getParam('sidebar');
     // merge if there were sidebar elements added dynamically
     if (!empty($sidebar_dynamic)) {
         $sidebar = $this->mergeSidebars($sidebar, $sidebar_dynamic);
     }
     $this->builder->createPartial('navbar', 'navbar');
     $this->builder->createPartial('sidebar', 'sidebar')->getParamManager()->setParams(['sidebar' => $this->getSidebar($request, $sidebar)]);
 }
Beispiel #2
0
 /**
  * Creates a schema manager for testing if the modules are up to date
  *
  * @param  \Doctrine\DBAL\Connection  $connection        The doctrine database connection
  * @param  string                     $prefix            The prefix used for the database (will ignore any other prefix)
  * @param  array                      $prefixes_ignored  Prefix in the database that should be ignored between the ones with the selected $prefix. Do not prepend $prefix.
  *
  * @return  \Foolz\FoolFrame\Model\SchemaManager  A new SchemaManager
  */
 public static function forge(\Doctrine\DBAL\Connection $connection, $prefix = '', $prefixes_ignored = [])
 {
     $new = new static();
     $new->connection = $connection;
     $new->prefix = $prefix;
     $sm = $new->connection->getSchemaManager();
     $tables = $sm->listTables();
     // get rid of the tables that don't have the same prefix
     if ($prefix !== null) {
         foreach ($tables as $key => $table) {
             if (strpos($table->getName(), $new->prefix) !== 0) {
                 unset($tables[$key]);
             }
         }
     }
     // get more prefixes ignored
     $prefixes_ignored = Hook::forge('Foolz\\FoolFrame\\Model\\SchemaManager::forge#var.ignorePrefix')->setObject($new)->setParam('prefixes_ignored', $prefixes_ignored)->execute()->get($prefixes_ignored);
     // get rid of the ignored prefixes (in example ff_plugin_)
     if (count($prefixes_ignored)) {
         foreach ($tables as $key => $table) {
             foreach ($prefixes_ignored as $prefix_ignored) {
                 if (strpos($table->getName(), $new->prefix . $prefix_ignored) === 0) {
                     unset($tables[$key]);
                 }
             }
         }
     }
     // get more tables ignored
     $tables = Hook::forge('Foolz\\FoolFrame\\Model\\SchemaManager::forge#var.tables')->setObject($new)->setParam('tables', $tables)->execute()->get($tables);
     // create a database "how it is now"
     $new->database_schema = new \Doctrine\DBAL\Schema\Schema($tables, [], $sm->createSchemaConfig());
     // make an empty schema
     $new->coded_schema = new \Doctrine\DBAL\Schema\Schema([], [], $sm->createSchemaConfig());
     return $new;
 }
Beispiel #3
0
    public function toString()
    {
        ?>
        <nav class="index_nav clearfix">
        <h1><?php 
        echo $this->getPreferences()->get('foolfuuka.gen_index_title');
        ?>
</h1>
        <?php 
        $index_nav = array();
        if ($this->getRadixColl()->getArchives()) {
            $index_nav['archives'] = array('title' => _i('Archives'), 'elements' => array());
            foreach ($this->getRadixColl()->getArchives() as $key => $item) {
                $index_nav['archives']['elements'][] = array('href' => $this->getUri()->create($item->shortname), 'text' => '/' . $item->shortname . '/ <span class="help">' . $item->name . '</span>');
            }
        }
        if ($this->getRadixColl()->getBoards()) {
            $index_nav['boards'] = array('title' => _i('Boards'), 'elements' => array());
            foreach ($this->getRadixColl()->getBoards() as $key => $item) {
                $index_nav['boards']['elements'][] = array('href' => $this->getUri()->create($item->shortname), 'text' => '/' . $item->shortname . '/ <span class="help">' . $item->name . '</span>');
            }
        }
        $index_nav = Hook::forge('foolframe.themes.generic.index_nav_elements')->setObject($this)->setParam('nav', $index_nav)->execute()->get($index_nav);
        $index_nav = Hook::forge('foolfuuka.themes.default.index_nav_elements')->setObject($this)->setParam('nav', $index_nav)->execute()->get($index_nav);
        foreach ($index_nav as $item) {
            ?>
                <ul class="pull-left clearfix">
                    <li><h2><?php 
            echo $item['title'];
            ?>
</h2></li>
                    <li>
                        <ul>
                            <?php 
            foreach ($item['elements'] as $i) {
                ?>
                                <li><h3><a href="<?php 
                echo $i['href'];
                ?>
"><?php 
                echo $i['text'];
                ?>
</a></h3></li>
                            <?php 
            }
            ?>
                        </ul>
                    </li>
                </ul>
            <?php 
        }
        ?>
        </nav>
    <?php 
    }
Beispiel #4
0
 public static function getEnvironment(Context $context)
 {
     $environment = [];
     $environment['server'] = ['title' => _i('Server Information'), 'data' => [['title' => _i('Web Server Software'), 'value' => $_SERVER['SERVER_SOFTWARE'], 'alert' => ['type' => 'warning', 'condition' => (bool) preg_match('/nginx/i', $_SERVER['SERVER_SOFTWARE']), 'title' => 'Warning', 'string' => _i('The nginx web server has its own internal file size limit variable for uploads. It is recommended that this value be set at the same value set in the PHP configuration file.')]], ['title' => _i('PHP Version'), 'value' => PHP_VERSION, 'alert' => ['type' => 'important', 'condition' => version_compare(PHP_VERSION, '5.4.0') < 0, 'title' => _i('Please Update Immediately'), 'string' => _i('The minimum requirements to run this software is 5.4.0.')]]]];
     $environment['software'] = ['title' => _i('Software Information'), 'data' => [['title' => _i('FoolFrame Version'), 'value' => $context->getService('config')->get('foolz/foolframe', 'package', 'main.version'), 'alert' => ['type' => 'info', 'condition' => true, 'title' => _i('New Update Available'), 'string' => _i('There is a new version of the software available for download.')]]]];
     $environment['php-configuration'] = ['title' => _i('PHP Configuration'), 'data' => [['title' => _i('Config Location'), 'value' => php_ini_loaded_file(), 'description' => _i('This is the path to the location of the php.ini configuration file.')], ['title' => 'allow_url_fopen', 'value' => ini_get('allow_url_fopen') ? _i('On') : _i('Off'), 'description' => _i('This option enables the URL-aware fopen wrappers that allows access to remote files using the FTP or HTTP protocol.'), 'alert' => ['type' => 'important', 'condition' => (bool) (!ini_get('allow_url_fopen')), 'title' => _i('Critical'), 'string' => _i('The PHP configuration on the server currently has URL-aware fopen wrappers disabled. The software will be operating at limited functionality.')]], ['title' => 'max_execution_time', 'value' => ini_get('max_execution_time'), 'description' => _i('This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser.'), 'alert' => ['type' => 'warning', 'condition' => (bool) (intval(ini_get('max_execution_time')) < 60), 'title' => _i('Warning'), 'string' => _i('Your current value for maximum execution time is below the suggested value.')]], ['title' => 'file_uploads', 'value' => ini_get('file_uploads') ? _i('On') : _i('Off'), 'description' => _i('This sets whether or not to allow HTTP file uploads.'), 'alert' => ['type' => 'important', 'condition' => (bool) (!ini_get('file_uploads')), 'title' => _i('Critical'), 'string' => _i('The PHP configuration on the server currently has file uploads disabled. This option must be enabled for the software to fully function.')]], ['title' => 'post_max_size', 'value' => ini_get('post_max_size'), 'description' => _i('This sets the maximum size of POST data allowed.'), 'alert' => ['type' => 'warning', 'condition' => (bool) (intval(substr(ini_get('post_max_size'), 0, -1)) < 16), 'title' => _i('Warning'), 'string' => _i('Your current value for maximum POST data size is below the suggested value.')]], ['title' => 'upload_max_filesize', 'value' => ini_get('upload_max_filesize'), 'description' => _i('This sets the maximum size allowed to be uploaded.'), 'alert' => ['type' => 'warning', 'condition' => (bool) (intval(substr(ini_get('upload_max_filesize'), 0, -1)) < 16), 'title' => _i('Warning'), 'string' => _i('Your current value for maximum upload file size is below the suggested value.')]], ['title' => 'max_file_uploads', 'value' => ini_get('max_file_uploads'), 'description' => _i('This sets the maximum number of files allowed to be uploaded concurrently.'), 'alert' => ['type' => 'warning', 'condition' => (bool) (intval(ini_get('max_file_uploads')) < 60), 'title' => _i('Warning'), 'string' => _i('Your current value for maximum number of concurrent uploads is below the suggested value.')]]]];
     $environment['php-extensions'] = ['title' => _i('PHP Extensions'), 'data' => [['title' => 'APC', 'value' => extension_loaded('apc') ? _i('Installed') : _i('Unavailable'), 'alert' => ['type' => 'warning', 'condition' => (bool) (!extension_loaded('apc')), 'title' => _i('Warning'), 'string' => _i('Your PHP environment shows that you do not have the "%s" extension installed. This may limit the functionality of the software.', 'APC')]], ['title' => 'cURL', 'value' => extension_loaded('curl') ? _i('Installed') : _i('Unavailable'), 'alert' => ['type' => 'important', 'condition' => (bool) (!extension_loaded('curl')), 'title' => _i('Critical'), 'string' => _i('Your PHP environment shows that you do not have the "%s" extension installed. This may limit the functionality of the software.', 'cURL')]], ['title' => 'FileInfo', 'value' => extension_loaded('fileinfo') ? _i('Installed') : _i('Unavailable'), 'alert' => ['type' => 'important', 'condition' => (bool) (!extension_loaded('fileinfo')), 'title' => _i('Critical'), 'string' => _i('Your PHP environment shows that you do not have the "%s" extension installed. This may limit the functionality of the software.', 'FileInfo')]], ['title' => 'JSON', 'value' => extension_loaded('json') ? _i('Installed') : _i('Unavailable'), 'alert' => ['type' => 'important', 'condition' => (bool) (!extension_loaded('json')), 'title' => _i('Critical'), 'string' => _i('Your PHP environment shows that you do not have the "%s" extension installed. This may limit the functionality of the software.', 'JSON')]], ['title' => 'Multi-byte String', 'value' => extension_loaded('mbstring') ? _i('Installed') : _i('Unavailable'), 'alert' => ['type' => 'important', 'condition' => (bool) (!extension_loaded('mbstring')), 'title' => _i('Critical'), 'string' => _i('Your PHP environment shows that you do not have the "%s" extension installed. This may limit the functionality of the software.', 'Multi-byte String')]], ['title' => 'MySQLi', 'value' => extension_loaded('mysqli') ? _i('Installed') : _i('Unavailable'), 'alert' => ['type' => 'important', 'condition' => (bool) (!extension_loaded('mysqli')), 'title' => _i('Critical'), 'string' => _i('Your PHP environment shows that you do not have the "%s" extension installed. This may limit the functionality of the software.', 'MySQLi')]], ['title' => 'PDO MySQL', 'value' => extension_loaded('pdo_mysql') ? _i('Installed') : _i('Unavailable'), 'alert' => ['type' => 'important', 'condition' => (bool) (!extension_loaded('pdo_mysql')), 'title' => _i('Critical'), 'string' => _i('Your PHP environment shows that you do not have the "%s" extension installed. This may limit the functionality of the software.', 'PDO MySQL')]]]];
     $environment = Hook::forge('Foolz\\FoolFrame\\Model\\System::getEnvironment#var.environment')->setParam('environment', $environment)->execute()->get($environment);
     usort($environment['php-extensions']['data'], array('System', 'sortByTitle'));
     return $environment;
 }
Beispiel #5
0
 /**
  * @param bool $reload
  * @return array|mixed
  */
 public function load($reload = false)
 {
     $this->profiler->log('Preferences::load Start');
     if ($reload === true) {
         Cache::item('foolframe.model.preferences.settings')->delete();
     }
     $this->modules = $this->config->get('foolz/foolframe', 'config', 'modules.installed');
     try {
         $this->preferences = Cache::item('foolframe.model.preferences.settings')->get();
     } catch (\OutOfBoundsException $e) {
         $preferences = $this->dc->qb()->select('*')->from($this->dc->p('preferences'), 'p')->execute()->fetchAll();
         foreach ($preferences as $pref) {
             // fix the PHP issue where . is changed to _ in the $_POST array
             $this->preferences[$pref['name']] = $pref['value'];
         }
         Cache::item('foolframe.model.preferences.settings')->set($this->preferences, 3600);
     }
     $this->preferences = Hook::forge('Foolz\\FoolFrame\\Model\\Preferences::load#var.preferences')->setObject($this)->setParam('preferences', $this->preferences)->execute()->get($this->preferences);
     $this->profiler->logMem('Preferences $preferences', $this->preferences);
     $this->profiler->log('Preferences::load End');
     $this->loaded = true;
     return $this->preferences;
 }
Beispiel #6
0
 /**
  * Send the comment and attached media to database
  *
  * @param Media $media
  * @param array $data extra data
  * @throws CommentSendingDatabaseException
  * @throws CommentSendingBannedException
  * @throws CommentSendingThreadWithoutMediaException
  * @throws CommentSendingSpamException
  * @throws CommentSendingImageInGhostException
  * @throws CommentSendingNoDelPassException
  * @throws CommentSendingThreadClosedException
  * @throws CommentSendingRequestCaptchaException
  * @throws CommentSendingTimeLimitException
  * @throws CommentSendingException
  * @throws CommentSendingTooManyCharactersException
  * @throws \RuntimeException
  * @throws CommentSendingDisplaysEmptyException
  * @throws CommentSendingTooManyLinesException
  * @throws CommentSendingSameCommentException
  * @throws CommentSendingWrongCaptchaException
  * @throws CommentSendingUnallowedCapcodeException
  * @return array error key with explanation to show to user, or success and post row
  */
 public function p_insert(Media $media = null, $data = [])
 {
     if (isset($data['recaptcha_challenge'])) {
         $this->recaptcha_challenge = $data['recaptcha_challenge'];
         $this->recaptcha_response = $data['recaptcha_response'];
     }
     $this->ghost = false;
     $this->ghost_exist = false;
     $this->allow_media = true;
     // some users don't need to be limited, in here go all the ban and posting limitators
     if (!$this->getAuth()->hasAccess('comment.limitless_comment')) {
         // check if the user is banned
         if ($ban = $this->ban_factory->isBanned($this->comment->poster_ip, $this->radix)) {
             if ($ban->board_id == 0) {
                 $banned_string = _i('It looks like you were banned on all boards.');
             } else {
                 $banned_string = _i('It looks like you were banned on /' . $this->radix->shortname . '/.');
             }
             if ($ban->length) {
                 $banned_string .= ' ' . _i('This ban will last until:') . ' ' . date(DATE_COOKIE, $ban->start + $ban->length) . '.';
             } else {
                 $banned_string .= ' ' . _i('This ban will last forever.');
             }
             if ($ban->reason) {
                 $banned_string .= ' ' . _i('The reason for this ban is:') . ' «' . $ban->reason . '».';
             }
             if ($ban->appeal_status == Ban::APPEAL_NONE) {
                 $banned_string .= ' ' . _i('If you\'d like to appeal to your ban, go to the %s page.', '<a href="' . $this->uri->create($this->radix->shortname . '/appeal') . '">' . _i('Appeal') . '</a>');
             } elseif ($ban->appeal_status == Ban::APPEAL_PENDING) {
                 $banned_string .= ' ' . _i('Your appeal is pending.');
             }
             throw new CommentSendingBannedException($banned_string);
         }
     }
     // check if it's a thread and its status
     if ($this->comment->thread_num > 0) {
         try {
             $thread = Board::forge($this->getContext())->getThread($this->comment->thread_num)->setRadix($this->radix);
             $status = $thread->getThreadStatus();
         } catch (BoardException $e) {
             throw new CommentSendingException($e->getMessage());
         }
         if ($status['closed']) {
             throw new CommentSendingThreadClosedException(_i('The thread is closed.'));
         }
         $this->ghost = $status['dead'];
         $this->ghost_exist = $status['ghost_exist'];
         $this->allow_media = !$status['disable_image_upload'];
     }
     foreach (['name', 'email', 'title', 'comment', 'capcode'] as $key) {
         $this->comment->{$key} = trim((string) $this->comment->{$key});
     }
     $this->comment->setDelpass(trim((string) $this->comment->getDelPass()));
     // some users don't need to be limited, in here go all the ban and posting limitators
     if (!$this->getAuth()->hasAccess('comment.limitless_comment')) {
         if ($this->comment->thread_num < 1) {
             // one can create a new thread only once every 5 minutes
             $check_op = $this->dc->qb()->select('*')->from($this->radix->getTable(), 'r')->where('r.poster_ip = :poster_ip')->andWhere('r.timestamp > :timestamp')->andWhere('r.op = :op')->setParameters([':poster_ip' => $this->comment->poster_ip, ':timestamp' => time() - $this->radix->getValue('cooldown_new_thread'), ':op' => true])->setMaxResults(1)->execute()->fetch();
             if ($check_op) {
                 throw new CommentSendingTimeLimitException(_i('You must wait up to %d minutes to make another new thread.', ceil($this->radix->getValue('cooldown_new_thread') / 60)));
             }
         }
         // check the latest posts by the user to see if he's posting the same message or if he's posting too fast
         $check = $this->dc->qb()->select('*')->from($this->radix->getTable(), 'r')->where('poster_ip = :poster_ip')->orderBy('timestamp', 'DESC')->setMaxResults(1)->setParameter(':poster_ip', $this->comment->poster_ip)->execute()->fetch();
         if ($check) {
             if ($this->comment->comment !== null && $check['comment'] === $this->comment->comment) {
                 throw new CommentSendingSameCommentException(_i('You\'re sending the same comment as the last time'));
             }
             $check_time = $this->getRadixTime();
             if ($check_time - $check['timestamp'] < $this->radix->getValue('cooldown_new_comment') && $check_time - $check['timestamp'] > 0) {
                 throw new CommentSendingTimeLimitException(_i('You must wait up to %d seconds to post again.', $this->radix->getValue('cooldown_new_comment')));
             }
         }
         // we want to know if the comment will display empty, and in case we won't let it pass
         $comment_parsed = $this->processComment();
         if ($this->comment->comment !== '' && $comment_parsed === '') {
             throw new CommentSendingDisplaysEmptyException(_i('This comment would display empty.'));
         }
         // clean up to reset eventual auto-built entries
         $this->comment->clean();
         if ($this->recaptcha_challenge && $this->recaptcha_response && $this->preferences->get('foolframe.auth.recaptcha_public', false)) {
             $recaptcha = ReCaptcha::create($this->preferences->get('foolframe.auth.recaptcha_public'), $this->preferences->get('foolframe.auth.recaptcha_private'));
             $recaptcha_result = $recaptcha->checkAnswer(Inet::dtop($this->comment->poster_ip), $this->recaptcha_challenge, $this->recaptcha_response);
             if (!$recaptcha_result->isValid()) {
                 throw new CommentSendingWrongCaptchaException(_i('Incorrect CAPTCHA solution.'));
             }
         } elseif ($this->preferences->get('foolframe.auth.recaptcha_public')) {
             // if there wasn't a recaptcha input, let's go with heavier checks
             if (substr_count($this->comment->comment, 'http') >= $this->radix->getValue('captcha_comment_link_limit')) {
                 throw new CommentSendingRequestCaptchaException();
             }
             // bots usually fill all the fields
             if ($this->comment->comment && $this->comment->title && $this->comment->email) {
                 throw new CommentSendingRequestCaptchaException();
             }
             // bots usually try various BBC, this checks if there's unparsed BBC after parsing it
             if ($comment_parsed !== '' && substr_count($comment_parsed, '[') + substr_count($comment_parsed, ']') > 4) {
                 throw new CommentSendingRequestCaptchaException();
             }
         }
         // load the spam list and check comment, name, title and email
         $spam = array_filter(preg_split('/\\r\\n|\\r|\\n/', file_get_contents(ASSETSPATH . 'packages/anti-spam/databases/urls.dat')));
         foreach ($spam as $s) {
             if (strpos($this->comment->comment, $s) !== false || strpos($this->comment->name, $s) !== false || strpos($this->comment->title, $s) !== false || strpos($this->comment->email, $s) !== false) {
                 throw new CommentSendingSpamException(_i('Your post has undesidered content.'));
             }
         }
         // check entire length of comment
         if (mb_strlen($this->comment->comment, 'utf-8') > $this->radix->getValue('max_comment_characters_allowed')) {
             throw new CommentSendingTooManyCharactersException(_i('Your comment has too many characters'));
         }
         // check total numbers of lines in comment
         if (count(explode("\n", $this->comment->comment)) > $this->radix->getValue('max_comment_lines_allowed')) {
             throw new CommentSendingTooManyLinesException(_i('Your comment has too many lines.'));
         }
     }
     \Foolz\Plugin\Hook::forge('Foolz\\Foolslide\\Model\\CommentInsert::insert.call.after.input_checks')->setObject($this)->execute();
     // process comment name+trip
     if ($this->comment->name === '') {
         $this->comment->name = $this->radix->getValue('anonymous_default_name');
         $this->comment->trip = null;
     } else {
         $this->processName();
         if ($this->comment->trip === '') {
             $this->comment->trip = null;
         }
     }
     foreach (['email', 'title', 'comment'] as $key) {
         if ($this->comment->{$key} === '') {
             $this->comment->{$key} = null;
         }
     }
     // process comment password
     if ($this->comment->getDelpass() === '') {
         throw new CommentSendingNoDelPassException(_i('You must submit a deletion password.'));
     }
     $pass = password_hash($this->comment->getDelpass(), PASSWORD_BCRYPT, ['cost' => 10]);
     if ($this->comment->getDelpass() === false) {
         throw new \RuntimeException('Password hashing failed');
     }
     $this->comment->setDelpass($pass);
     if ($this->comment->capcode != '') {
         $allowed_capcodes = ['N'];
         if ($this->getAuth()->hasAccess('comment.mod_capcode')) {
             $allowed_capcodes[] = 'M';
         }
         if ($this->getAuth()->hasAccess('comment.admin_capcode')) {
             $allowed_capcodes[] = 'A';
         }
         if ($this->getAuth()->hasAccess('comment.dev_capcode')) {
             $allowed_capcodes[] = 'D';
         }
         if (!in_array($this->comment->capcode, $allowed_capcodes)) {
             throw new CommentSendingUnallowedCapcodeException(_i('You\'re not allowed to use this capcode.'));
         }
     } else {
         $this->comment->capcode = 'N';
     }
     $microtime = str_replace('.', '', (string) microtime(true));
     $this->comment->timestamp = substr($microtime, 0, 10);
     $this->comment->op = (bool) (!$this->comment->thread_num);
     if ($this->radix->getValue('enable_flags')) {
         $reader = new Reader($this->preferences->get('foolframe.maxmind.geoip2_db_path'));
         try {
             $record = $reader->country(Inet::dtop($this->comment->poster_ip));
             $this->comment->poster_country = strtolower($record->country->isoCode);
         } catch (AddressNotFoundException $e) {
             $this->comment->poster_country = 'xx';
         }
     }
     // process comment media
     if ($media !== null) {
         // if uploading an image with OP is prohibited
         if (!$this->comment->thread_num && $this->radix->getValue('op_image_upload_necessity') === 'never') {
             throw new CommentSendingException(_i('You can\'t start a new thread with an image.'));
         }
         if (!$this->allow_media) {
             if ($this->ghost) {
                 throw new CommentSendingImageInGhostException(_i('You can\'t post images when the thread is in ghost mode.'));
             } else {
                 throw new CommentSendingException(_i('This thread has reached its image limit.'));
             }
         }
         try {
             $media->insert($microtime, $this->comment->op);
             $this->media = $media->media;
         } catch (MediaInsertException $e) {
             throw new CommentSendingException($e->getMessage());
         }
     } else {
         // if the user is forced to upload an image when making a new thread
         if (!$this->comment->thread_num && $this->radix->getValue('op_image_upload_necessity') === 'always') {
             throw new CommentSendingThreadWithoutMediaException(_i('You can\'t start a new thread without an image.'));
         }
         // in case of no media, check comment field again for null
         if ($this->comment->comment === null) {
             throw new CommentSendingDisplaysEmptyException(_i('This comment would display empty.'));
         }
         $this->media = $this->bulk->media = new MediaData();
     }
     // 2ch-style codes, only if enabled
     if ($this->comment->thread_num && $this->radix->getValue('enable_poster_hash')) {
         $this->comment->poster_hash = substr(substr(crypt(md5($this->comment->poster_ip . 'id' . $this->comment->thread_num), 'id'), +3), 0, 8);
     }
     $this->comment->timestamp = $this->getRadixTime($this->comment->timestamp);
     \Foolz\Plugin\Hook::forge('Foolz\\Foolslide\\Model\\CommentInsert::insert.call.before.sql')->setObject($this)->execute();
     // being processing insert...
     if ($this->ghost) {
         $num = '
         (
             SELECT MAX(num) AS num
             FROM (
                 (
                     SELECT num
                     FROM ' . $this->radix->getTable() . ' xr
                     WHERE thread_num = ' . $this->dc->getConnection()->quote($this->comment->thread_num) . '
                 )
                 UNION
                 (
                     SELECT num
                     FROM ' . $this->radix->getTable('_deleted') . ' xrd
                     WHERE thread_num = ' . $this->dc->getConnection()->quote($this->comment->thread_num) . '
                 )
             ) x
         )';
         $subnum = '
         (
             SELECT MAX(subnum) + 1 AS subnum
             FROM (
                 (
                     SELECT subnum
                     FROM ' . $this->radix->getTable() . ' xxr
                     WHERE num = (
                         SELECT MAX(num)
                         FROM (
                             (
                                 SELECT num
                                 FROM ' . $this->radix->getTable() . ' xxxr
                                 WHERE thread_num = ' . $this->dc->getConnection()->quote($this->comment->thread_num) . '
                             )
                             UNION
                             (
                                 SELECT num
                                 FROM ' . $this->radix->getTable('_deleted') . ' xxxrd
                                 WHERE thread_num = ' . $this->dc->getConnection()->quote($this->comment->thread_num) . '
                             )
                         ) xxx
                     )
                 )
                 UNION
                 (
                     SELECT subnum
                     FROM ' . $this->radix->getTable('_deleted') . ' xxdr
                     WHERE num = (
                         SELECT MAX(num)
                         FROM (
                             (
                                 SELECT num
                                 FROM ' . $this->radix->getTable() . ' xxxr
                                 WHERE thread_num = ' . $this->dc->getConnection()->quote($this->comment->thread_num) . '
                             )
                             UNION
                             (
                                 SELECT num
                                 FROM ' . $this->radix->getTable('_deleted') . ' xxxdrd
                                 WHERE thread_num = ' . $this->dc->getConnection()->quote($this->comment->thread_num) . '
                             )
                         ) xxxd
                     )
                 )
             ) xx
         )';
         $thread_num = $this->comment->thread_num;
     } else {
         $num = '
         (
             SELECT MAX(num) + 1 AS num
             FROM (
                 (
                     SELECT COALESCE(MAX(num), 0) AS num
                     FROM ' . $this->radix->getTable() . ' xr
                 )
                 UNION
                 (
                     SELECT COALESCE(MAX(num), 0) AS num
                     FROM ' . $this->radix->getTable('_deleted') . ' xdr
                 )
             ) x
         )';
         $subnum = 0;
         if ($this->comment->thread_num > 0) {
             $thread_num = $this->dc->getConnection()->quote($this->comment->thread_num);
         } else {
             $thread_num = '
             (
                 SELECT MAX(thread_num) + 1 AS thread_num
                 FROM (
                     (
                         SELECT COALESCE(MAX(num), 0) as thread_num
                         FROM ' . $this->radix->getTable() . ' xxr
                     )
                     UNION
                     (
                         SELECT COALESCE(MAX(num), 0) as thread_num
                         FROM ' . $this->radix->getTable('_deleted') . ' xxdr
                     )
                 ) xx
             )';
         }
     }
     try {
         $query_fields = ['num' => $num, 'subnum' => $subnum, 'thread_num' => $thread_num];
         $fields = ['media_id' => $this->media->media_id ? $this->media->media_id : 0, 'op' => (int) $this->op, 'timestamp' => $this->comment->timestamp, 'capcode' => $this->comment->capcode, 'email' => $this->comment->email, 'name' => $this->comment->name, 'trip' => $this->comment->trip, 'title' => $this->comment->title, 'comment' => $this->comment->comment, 'delpass' => $this->comment->getDelpass(), 'spoiler' => (int) $this->media->spoiler, 'poster_ip' => $this->comment->poster_ip, 'poster_hash' => $this->comment->poster_hash, 'poster_country' => $this->comment->poster_country, 'preview_orig' => $this->media->preview_orig, 'preview_w' => $this->media->preview_w, 'preview_h' => $this->media->preview_h, 'media_filename' => $this->media->media_filename, 'media_w' => $this->media->media_w, 'media_h' => $this->media->media_h, 'media_size' => $this->media->media_size, 'media_hash' => $this->media->media_hash, 'media_orig' => $this->media->media_orig, 'exif' => $this->media->exif !== null ? @json_encode($this->media->exif) : null, 'timestamp_expired' => 0];
         foreach ($fields as $key => $item) {
             if ($item === null) {
                 $fields[$key] = 'null';
             } else {
                 $fields[$key] = $this->dc->getConnection()->quote($item);
             }
         }
         $fields = $query_fields + $fields;
         $this->dc->getConnection()->beginTransaction();
         $this->dc->getConnection()->executeUpdate('INSERT INTO ' . $this->radix->getTable() . ' (' . implode(', ', array_keys($fields)) . ') VALUES (' . implode(', ', array_values($fields)) . ')');
         $last_id = $this->dc->getConnection()->lastInsertId($this->radix->getTable('_doc_id_seq'));
         $comment = $this->dc->qb()->select('*')->from($this->radix->getTable(), 'r')->where('doc_id = :doc_id')->setParameter(':doc_id', $last_id)->execute()->fetchAll();
         $this->bulk->import($comment[0], $this->radix);
         if (!$this->radix->archive) {
             $this->insertTriggerThreads();
             $this->insertTriggerDaily();
             $this->insertTriggerUsers();
         }
         // update poster_hash for op posts
         if ($this->comment->op && $this->radix->getValue('enable_poster_hash')) {
             $this->comment->poster_hash = substr(substr(crypt(md5($this->comment->poster_ip . 'id' . $this->comment->thread_num), 'id'), 3), 0, 8);
             $this->dc->qb()->update($this->radix->getTable(), 'ph')->set('poster_hash', $this->dc->getConnection()->quote($this->comment->poster_hash))->where('doc_id = :doc_id')->setParameter(':doc_id', $this->comment->doc_id)->execute();
         }
         $this->dc->getConnection()->commit();
         // clean up some caches
         Cache::item('foolslide.model.board.getThreadComments.thread.' . md5(serialize([$this->radix->shortname, $this->comment->thread_num])))->delete();
         // clean up the 10 first pages of index and gallery that are cached
         for ($i = 1; $i <= 10; $i++) {
             Cache::item('foolslide.model.board.getLatestComments.query.' . $this->radix->shortname . '.by_post.' . $i)->delete();
             Cache::item('foolslide.model.board.getLatestComments.query.' . $this->radix->shortname . '.by_thread.' . $i)->delete();
             Cache::item('foolslide.model.board.getThreadsComments.query.' . $this->radix->shortname . '.' . $i)->delete();
         }
     } catch (\Doctrine\DBAL\DBALException $e) {
         $this->logger->error('\\Foolz\\Foolslide\\Model\\CommentInsert: ' . $e->getMessage());
         $this->dc->getConnection()->rollBack();
         throw new CommentSendingDatabaseException(_i('Something went wrong when inserting the post in the database. Try again.'));
     }
     return $this;
 }
Beispiel #7
0
 public function install($slug)
 {
     $plugin = $this->loader->get($slug);
     $plugin->install();
     $this->dc->getConnection()->insert($this->dc->p('plugins'), ['slug' => $slug, 'enabled' => 1]);
     $this->clearCache();
     // run the schema update
     $sm = \Foolz\FoolFrame\Model\SchemaManager::forge($this->dc->getConnection(), $this->dc->getPrefix() . 'plugin_');
     foreach ($this->getInstalled() as $enabled) {
         try {
             $plug = $this->loader->get($enabled['slug']);
             if (!$plug->isBootstrapped()) {
                 $plug->bootstrap();
             }
             \Foolz\Plugin\Hook::forge('Foolz\\FoolFrame\\Model\\Plugin::install#' . $plug->getConfig('name'))->setParam('context', $this->getContext())->setParam('schema', $sm->getCodedSchema())->execute();
         } catch (\OutOfBoundsException $e) {
         }
     }
     $sm->commit();
     $this->clearCache();
 }
Beispiel #8
0
    public function toString()
    {
        $backend_vars = $this->getBuilderParamManager()->getParam('backend_vars');
        $radix = $this->getBuilderParamManager()->getParam('radix');
        $user_name = $this->getBuilderParamManager()->getParam('user_name');
        $user_pass = $this->getBuilderParamManager()->getParam('user_pass');
        $user_email = $this->getBuilderParamManager()->getParam('user_email');
        $thread_id = $this->getBuilderParamManager()->getParam('thread_id', 0);
        $reply_errors = $this->getBuilderParamManager()->getParam('reply_errors', false);
        $form = $this->getForm();
        \Foolz\Plugin\Hook::forge('foolfuuka.themes.default_after_op_open')->setObject($this)->setParam('board', $radix)->execute();
        ?>

        <?php 
        echo $form->open(['enctype' => 'multipart/form-data', 'onsubmit' => 'fuel_set_csrf_token(this);', 'action' => $this->getUri()->create([$radix->shortname, 'submit'])]);
        ?>
        <?php 
        echo $form->hidden('csrf_token', $this->getSecurity()->getCsrfToken());
        ?>
        <?php 
        echo $form->hidden('reply_numero', isset($thread_id) ? $thread_id : 0, array('id' => 'reply_numero'));
        ?>
        <?php 
        echo isset($backend_vars['last_limit']) ? $form->hidden('reply_last_limit', $backend_vars['last_limit']) : '';
        ?>

        <table id="reply">
            <tbody>
            <tr>
                <td><?php 
        echo _i('Name');
        ?>
</td>
                <td><?php 
        echo $form->input(['name' => 'name', 'id' => 'reply_name_yep', 'style' => 'display:none']);
        echo $form->input(['name' => 'reply_bokunonome', 'id' => 'reply_bokunonome', 'value' => $user_name]);
        ?>
</td>
            </tr>
            <tr>
                <td><?php 
        echo _i('E-mail');
        ?>
</td>
                <td><?php 
        echo $form->input(['name' => 'email', 'id' => 'reply_email_yep', 'style' => 'display:none']);
        echo $form->input(['name' => 'reply_elitterae', 'id' => 'reply_elitterae', 'value' => $user_email]);
        ?>
</td>
            </tr>
            <tr>
                <td><?php 
        echo _i('Subject');
        ?>
</td>
                <td>
                    <?php 
        echo $form->input(['name' => 'reply_talkingde', 'id' => 'reply_talkingde']);
        ?>

                    <?php 
        $submit_array = ['data-function' => 'comment', 'name' => 'reply_gattai', 'value' => _i('Submit'), 'class' => 'btn'];
        echo $form->submit($submit_array);
        ?>

                    <?php 
        if (!$this->getBuilderParamManager()->getParam('disable_image_upload', false)) {
            ?>
                    [ <label><?php 
            echo $form->checkbox(['name' => 'reply_spoiler', 'id' => 'reply_spoiler', 'value' => 1]);
            ?>
 Spoiler Image?</label> ]
                    <?php 
        }
        ?>
                </td>
            </tr>
            <tr>
                <td><?php 
        echo _i('Comment');
        ?>
</td>
                <td><?php 
        echo $form->textarea(['name' => 'reply', 'id' => 'reply_comment_yep', 'style' => 'display:none']);
        echo $form->textarea(['name' => 'reply_chennodiscursus', 'id' => 'reply_chennodiscursus', 'placeholder' => !$radix->archive && isset($thread_dead) && $thread_dead ? _i('This thread has entered ghost mode. Your reply will be marked as a ghost post and will only affect the ghost index.') : '']);
        ?>
</td>
            </tr>

            <?php 
        if ($this->getPreferences()->get('foolframe.auth.recaptcha_public', false)) {
            ?>
            <script>
                var RecaptchaOptions = {
                    theme : 'custom',
                    custom_theme_widget: 'recaptcha_widget'
                };
            </script>
            <tr class="recaptcha_widget" style="display:none">
                <td><?php 
            echo _i('Verification');
            ?>
</td>
                <td><div><p><?php 
            echo e(_i('You might be a bot! Enter a reCAPTCHA to continue.'));
            ?>
</p></div>
                    <div id="recaptcha_image" style="background: #fff; border: 1px solid #ccc; padding: 3px 6px; margin: 4px 0;"></div>
                    <input type="text" id="recaptcha_response_field" name="recaptcha_response_field" />
                    <div class="btn-group">
                        <a class="btn btn-mini" href="javascript:Recaptcha.reload()">Get another CAPTCHA</a>
                        <a class="recaptcha_only_if_image btn btn-mini" href="javascript:Recaptcha.switch_type('audio')">Get an audio CAPTCHA</a>
                        <a class="recaptcha_only_if_audio btn btn-mini" href="javascript:Recaptcha.switch_type('image')">Get an image CAPTCHA</a>
                        <a class="btn btn-mini" href="javascript:Recaptcha.showhelp()">Help</a>
                    </div>

                    <script type="text/javascript" src="//www.google.com/recaptcha/api/challenge?k=<?php 
            echo $this->getPreferences()->get('foolframe.auth.recaptcha_public');
            ?>
"></script>
                    <noscript>
                        <iframe src="//www.google.com/recaptcha/api/noscript?k=<?php 
            echo $this->getPreferences()->get('foolframe.auth.recaptcha_public');
            ?>
" height="300" width="500" frameborder="0"></iframe><br>
                        <textarea name="recaptcha_challenge_field" rows="3" cols="40">
                        </textarea>
                        <input type="hidden" name="recaptcha_response_field"  value="manual_challenge">
                    </noscript></td>
            </tr>
                <?php 
        }
        ?>
                <?php 
        if (!$this->getBuilderParamManager()->getParam('disable_image_upload', false)) {
            ?>
            <tr>
                <td><?php 
            echo _i('File');
            ?>
</td>
                <td><?php 
            echo $form->file(['name' => 'file_image', 'id' => 'file_image']);
            ?>
</td>
            </tr>
            <tr>
                <td><?php 
            echo _i('Progress');
            ?>
</td>
                <td><div class="progress progress-info progress-striped active" style="width: 300px; margin-bottom: 2px"><div class="bar" style="width: 0%"></div></div></td>
            </tr>
                <?php 
        }
        ?>
            <tr>
                <td><?php 
        echo _i('Password');
        ?>
</td>
                <td><?php 
        echo $form->password(['name' => 'reply_nymphassword', 'id' => 'reply_nymphassword', 'value' => $user_pass, 'required' => 'required']);
        ?>
 <span style="font-size: smaller;">(Password used for file deletion)</span>
                </td>
            </tr>

                <?php 
        $postas = ['N' => _i('User')];
        if ($this->getAuth()->hasAccess('comment.mod_capcode')) {
            $postas['M'] = _i('Moderator');
        }
        if ($this->getAuth()->hasAccess('comment.admin_capcode')) {
            $postas['A'] = _i('Administrator');
        }
        if ($this->getAuth()->hasAccess('comment.dev_capcode')) {
            $postas['D'] = _i('Developer');
        }
        if (count($postas) > 1) {
            ?>
                <tr>
                    <td><?php 
            echo _i('Post as');
            ?>
</td>
                    <td><?php 
            echo $form->select('reply_postas', 'User', $postas, array('id' => 'reply_postas'));
            ?>
</td>
                </tr>
                    <?php 
        }
        ?>

                <?php 
        if ($radix->getValue('posting_rules')) {
            ?>
            <tr class="rules">
                <td></td>
                <td>
                    <?php 
            echo \Foolz\FoolFrame\Model\Markdown::parse($radix->getValue('posting_rules'));
            ?>
                </td>
            </tr>
            <tr class="rules">
                <td colspan="2">
                    <div id="reply_ajax_notices"></div>
                    <?php 
            if (isset($reply_errors)) {
                ?>
                    <span style="color: red"><?php 
                echo $reply_errors;
                ?>
</span>
                    <?php 
            }
            ?>
                </td>
            </tr>
                <?php 
        }
        ?>
            </tbody>
        </table>
        <?php 
        echo $form->close();
        ?>
    <?php 
    }
Beispiel #9
0
 /**
  * Inserts the media uploaded (static::forgeFromUpload())
  *
  * @param  string   $microtime  The time in microseconds to use for the local filename
  * @param  boolean  $is_op      True if the thumbnail sizes should be for OP, false if they should be for a reply
  *
  * @return  \Foolz\Foolfuuka\Model\Media       The current object updated with the insert data
  * @throws  MediaInsertInvalidFormatException  In case the media is not a valid format
  * @throws  MediaInsertDomainException         In case the media uploaded is in example too small or validations don't pass
  * @throws  MediaInsertRepostException         In case the media has been reposted too recently according to control panel settings
  * @throws  MediaThumbnailCreationException	   If the thumbnail fails to generate
  */
 public function p_insert($microtime, $is_op)
 {
     $file = $this->temp_file;
     $this->op = $is_op;
     $data = \Foolz\Plugin\Hook::forge('Foolz\\Foolfuuka\\Model\\Media::insert.result.media_data')->setParams(['dimensions' => getimagesize($file->getPathname()), 'file' => $file, 'name' => $file->getClientOriginalName(), 'path' => $file->getPathname(), 'hash' => base64_encode(pack("H*", md5(file_get_contents($file->getPathname())))), 'size' => $file->getClientSize(), 'time' => $microtime, 'media_orig' => $microtime . '.' . strtolower($file->getClientOriginalExtension()), 'preview_orig' => $microtime . 's.' . strtolower($file->getClientOriginalExtension())])->execute()->getParams();
     if (!($getimagesize = $data['dimensions'])) {
         throw new MediaInsertInvalidFormatException(_i('The file you uploaded is not allowed.'));
     }
     // if width and height are lower than 25 reject the image
     if ($getimagesize[0] < 25 || $getimagesize[1] < 25) {
         throw new MediaInsertDomainException(_i('The file you uploaded is too small.'));
     }
     if ($getimagesize[0] > $this->radix->getValue('max_image_size_width') || $getimagesize[1] > $this->radix->getValue('max_image_size_height')) {
         throw new MediaInsertDomainException(_i('The dimensions of the file you uploaded is too large.'));
     }
     $this->media->media_w = $getimagesize[0];
     $this->media->media_h = $getimagesize[1];
     $this->media->media_filename = $data['name'];
     $this->media->media_hash = $data['hash'];
     $this->media->media_size = $data['size'];
     $this->media->media_orig = $data['media_orig'];
     $this->media->preview_orig = $data['preview_orig'];
     $do_thumb = true;
     $do_full = true;
     try {
         $duplicate = CommentBulk::forge($this->radix, null, $this->media_factory->getByMediaHash($this->radix, $this->media->media_hash));
         $duplicate = new Media($this->getContext(), $duplicate);
         // we want the current media to work with the same filenames as previously stored
         $this->media->media_id = $duplicate->media->media_id;
         $this->media->media = $duplicate->media->media;
         $this->media->media_orig = $duplicate->media->media;
         $this->media->preview_op = $duplicate->media->preview_op;
         $this->media->preview_reply = $duplicate->media->preview_reply;
         if (!$this->getAuth()->hasAccess('comment.limitless_comment') && $this->radix->getValue('min_image_repost_time')) {
             // if it's -1 it means that image reposting is disabled, so this image shouldn't pass
             if ($this->radix->getValue('min_image_repost_time') == -1) {
                 throw new MediaInsertRepostException(_i('This image has already been posted once. This board doesn\'t allow image reposting.'));
             }
             // we don't have to worry about archives with weird timestamps, we can't post images there
             $duplicate_entry = $this->dc->qb()->select('COUNT(*) as count, MAX(timestamp) as max_timestamp')->from($this->radix->getTable(), 'r')->where('media_id = :media_id')->andWhere('timestamp > :timestamp')->setParameter('media_id', $duplicate->media->media_id)->setParameter('timestamp', time() - $this->radix->getValue('min_image_repost_time'))->setMaxResults(1)->execute()->fetch();
             if ($duplicate_entry['count']) {
                 $datetime = new \DateTime(date('Y-m-d H:i:s', $duplicate_entry['max_timestamp'] + $this->radix->getValue('min_image_repost_time')));
                 $remain = $datetime->diff(new \DateTime());
                 throw new MediaInsertRepostException(_i('This image has been posted recently. You will be able to post it again in %s.', ($remain->d > 0 ? $remain->d . ' ' . _i('day(s)') : '') . ' ' . ($remain->h > 0 ? $remain->h . ' ' . _i('hour(s)') : '') . ' ' . ($remain->i > 0 ? $remain->i . ' ' . _i('minute(s)') : '') . ' ' . ($remain->s > 0 ? $remain->s . ' ' . _i('second(s)') : '')));
             }
         }
         // if we're here, we got the media
         $duplicate_dir = $duplicate->getDir();
         if ($duplicate_dir !== null && file_exists($duplicate_dir)) {
             $do_full = false;
         }
         $duplicate->op = $is_op;
         $duplicate_dir_thumb = $duplicate->getDir(true, true);
         if ($duplicate_dir_thumb !== null && file_exists($duplicate_dir_thumb)) {
             $duplicate_dir_thumb_size = getimagesize($duplicate_dir_thumb);
             $this->media->preview_w = $duplicate_dir_thumb_size[0];
             $this->media->preview_h = $duplicate_dir_thumb_size[1];
             $do_thumb = false;
         }
     } catch (MediaNotFoundException $e) {
     }
     if ($do_thumb) {
         $thumb_width = $this->radix->getValue('thumbnail_reply_width');
         $thumb_height = $this->radix->getValue('thumbnail_reply_height');
         if ($is_op) {
             $thumb_width = $this->radix->getValue('thumbnail_op_width');
             $thumb_height = $this->radix->getValue('thumbnail_op_height');
         }
         if (!file_exists($this->pathFromFilename(true, $is_op))) {
             mkdir($this->pathFromFilename(true, $is_op), 0777, true);
         }
         $return = \Foolz\Plugin\Hook::forge('Foolz\\Foolfuuka\\Model\\Media::insert.result.create_thumbnail')->setObject($this)->setParams(['thumb_width' => $thumb_width, 'thumb_height' => $thumb_height, 'exec' => str_replace(' ', '\\ ', $this->preferences->get('foolframe.imagick.convert_path')), 'is_op' => $is_op, 'media' => $file, 'thumb' => $this->pathFromFilename(true, $is_op, true)])->execute()->get();
         if ($return instanceof \Foolz\Plugin\Void) {
             if ($this->radix->getValue('enable_animated_gif_thumbs') && strtolower($file->getClientOriginalExtension()) === 'gif') {
                 exec(str_replace(' ', '\\ ', $this->preferences->get('foolframe.imagick.convert_path')) . " " . $data['path'] . " -coalesce -treedepth 4 -colors 256 -quality 80 -background none " . "-resize \"" . $thumb_width . "x" . $thumb_height . ">\" " . $this->pathFromFilename(true, $is_op, true));
             } else {
                 exec(str_replace(' ', '\\ ', $this->preferences->get('foolframe.imagick.convert_path')) . " " . $data['path'] . "[0] -quality 80 -background none " . "-resize \"" . $thumb_width . "x" . $thumb_height . ">\" " . $this->pathFromFilename(true, $is_op, true));
             }
         }
         if (!file_exists($this->pathFromFilename(true, $is_op, true))) {
             throw new MediaThumbnailCreationException(_i('The thumbnail failed to generate.'));
         }
         $thumb_getimagesize = getimagesize($this->pathFromFilename(true, $is_op, true));
         $this->media->preview_w = $thumb_getimagesize[0];
         $this->media->preview_h = $thumb_getimagesize[1];
         if ($do_full) {
             if (!file_exists($this->pathFromFilename())) {
                 mkdir($this->pathFromFilename(), 0777, true);
             }
             copy($data['path'], $this->pathFromFilename(false, false, true));
         }
     }
     if (function_exists('exif_read_data') && in_array(strtolower($file->getClientOriginalExtension()), ['jpg', 'jpeg', 'tiff'])) {
         $exif_data = null;
         getimagesize($data['path'], $exif_data);
         if (!isset($exif_data['APP1']) || strpos($exif_data['APP1'], 'Exif') === 0) {
             $exif = exif_read_data($data['path']);
             if ($exif !== false) {
                 $this->media->exif = $exif;
             }
         }
     }
     if (!$this->media->media_id) {
         $this->dc->getConnection()->insert($this->radix->getTable('_images'), ['media_hash' => $this->media->media_hash, 'media' => $this->media->media_orig, 'preview_op' => $this->op ? $this->media->preview_orig : null, 'preview_reply' => !$this->op ? $this->media->preview_orig : null, 'total' => 1, 'banned' => 0]);
         $this->media->media_id = $this->dc->getConnection()->lastInsertId($this->radix->getTable('_images_media_id_seq'));
     } else {
         $media_sql = $this->dc->qb()->select('COUNT(*)')->from($this->radix->getTable(), 't')->where('media_id = :media_id')->setParameter(':media_id', $this->media->media_id)->getSQL();
         $query = $this->dc->qb()->update($this->radix->getTable('_images'));
         if ($this->media === null) {
             $query->set('media', ':media_orig')->setParameter(':media_orig', $this->media->preview_orig);
         }
         if ($this->op && $this->media->preview_op === null) {
             $query->set('preview_op', ':preview_orig')->setParameter(':preview_orig', $this->media->preview_orig);
         }
         if (!$this->op && $this->media->preview_reply === null) {
             $query->set('preview_reply', ':preview_orig')->setParameter(':preview_orig', $this->media->preview_orig);
         }
         $query->set('total', '(' . $media_sql . ')');
         $query->where('media_id = :media_id')->setParameter(':media_id', $this->media->media_id)->execute();
     }
     return $this;
 }
Beispiel #10
0
    public function getFooter()
    {
        ?>
    <footer id="footer">
        <a href="https://github.com/FoolCode/FoolFuuka"><?php 
        echo $this->getConfig()->get('foolz/foolfuuka', 'package', 'main.name');
        ?>
            Imageboard <?php 
        echo $this->getConfig()->get('foolz/foolfuuka', 'package', 'main.version');
        ?>
</a>
        - <a href="http://github.com/eksopl/asagi" target="_blank">Asagi Fetcher</a>

        <div class="pull-right">
            <div class="btn-group dropup pull-right">
                <a href="#" class="btn btn-inverse btn-mini dropdown-toggle" data-toggle="dropdown">
                    <?php 
        echo _i('Change Theme');
        ?>
 <span class="caret"></span>
                </a>
                <ul class="dropdown-menu">
                    <?php 
        foreach ($this->getTheme()->getLoader()->getListWithStyles() as $key => $theme) {
            if (isset($theme['object']->enabled) && $theme['object']->enabled) {
                ?>
                            <li>
                                <a href="<?php 
                echo $this->getUri()->create(array('_', 'theme', $key));
                ?>
">
                                    <?php 
                echo $theme['string'];
                ?>
                                    <?php 
                if ($theme['object'] === $this->getTheme() && $theme['style'] == $this->getBuilder()->getStyle()) {
                    ?>
                                        <i class="icon-ok"></i>
                                    <?php 
                }
                ?>
                                </a>
                            </li>
                        <?php 
            }
        }
        ?>
                </ul>
            </div>
        </div>

        <div class="pull-right">
            <div class="btn-group dropup pull-right">
                <a href="#" class="btn btn-inverse btn-mini dropdown-toggle" data-toggle="dropdown">
                    <?php 
        echo _i('Change Language');
        ?>
 <span class="caret"></span>
                </a>
                <ul class="dropdown-menu">
                    <?php 
        foreach ($this->getConfig()->get('foolz/foolframe', 'package', 'preferences.lang.available') as $key => $lang) {
            ?>
                    <li>
                        <a href="<?php 
            echo $this->getUri()->create(['_', 'language', $key]);
            ?>
">
                            <?php 
            echo $lang;
            ?>
                            <?php 
            if (!$this->getCookie('language') && $key == 'en_EN' || $key == $this->getCookie('language')) {
                ?>
                                <i class="icon-ok"></i>
                            <?php 
            }
            ?>
                        </a>
                    </li>
                    <?php 
        }
        ?>
                    <li class="divider"></li>
                    <li><a href="http://archive.foolz.us/articles/translate/"><?php 
        echo _i('Add a Translation');
        ?>
</a></li>
                </ul>
            </div>
        </div>

        <?php 
        $bottom_nav = [];
        $bottom_nav = \Foolz\Plugin\Hook::forge('foolframe.themes.generic_bottom_nav_buttons')->setObject($this)->setParam('nav', $bottom_nav)->execute()->get($bottom_nav);
        $bottom_nav = \Foolz\Plugin\Hook::forge('foolfuuka.themes.default_bottom_nav_buttons')->setObject($this)->setParam('nav', $bottom_nav)->execute()->get($bottom_nav);
        if (!empty($bottom_nav)) {
            echo '<div class="pull-right" style="margin-right: 15px;">';
            foreach ($bottom_nav as $key => $nav) {
                echo '<a href="' . $nav['href'] . '">' . $nav['text'] . '</a>';
                if ($key < count($bottom_nav) - 1) {
                    echo ' - ';
                }
            }
            echo '</div>';
        }
        if ($this->getPreferences()->get('foolframe.theme.footer_text')) {
            echo '<section class="footer_text">' . $this->getPreferences()->get('foolframe.theme.footer_text') . '</section>';
        }
        ?>
    </footer>

    <script>
        var backend_vars = <?php 
        echo json_encode($this->getBuilderParamManager()->getParam('backend_vars'));
        ?>
;
    </script>

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script>window.jQuery || document.write('<script src="<?php 
        echo $this->getUri()->base() . 'assets/js/jquery.js';
        ?>
"><\/script>')</script>
    <script defer src="<?php 
        echo $this->getTheme()->getExtended()->getAssetManager()->getAssetLink('bootstrap.min.js');
        ?>
"></script>
    <script defer src="<?php 
        echo $this->getTheme()->getExtended()->getAssetManager()->getAssetLink('plugins.js');
        ?>
"></script>
    <script defer src="<?php 
        echo $this->getTheme()->getExtended()->getAssetManager()->getAssetLink('board.js');
        ?>
"></script>

        <?php 
        if ($this->getPreferences()->get('foolframe.theme.google_analytics')) {
            ?>
    <script>
        var _gaq = [
            ['_setAccount', '<?php 
            echo $this->getPreferences()->get('foolframe.theme.google_analytics');
            ?>
'],
            ['_trackPageview'],
            ['_trackPageLoadTime']
        ];
        (function (d, t) {
            var g = d.createElement(t), s = d.getElementsByTagName(t)[0];
            g.src = ('https:' == location.protocol ? '//ssl' : '//www') + '.google-analytics.com/ga.js';
            s.parentNode.insertBefore(g, s)
        }(document, 'script'));
    </script>
        <?php 
        }
        ?>

    <!-- Prompt IE 6 users to install Chrome Frame. Remove this if you want to support IE 6.
     chromium.org/developers/how-tos/chrome-frame-getting-started -->
    <!--[if lt IE 7 ]>
    <script defer src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
    <script defer>window.attachEvent('onload', function () {
        CFInstall.check({mode:'overlay'})
    })</script>
    <![endif]-->
        <?php 
        echo $this->getPreferences()->get('foolframe.theme.footer_code');
        ?>
    </body>
    </html>
    <?php 
    }
Beispiel #11
0
    public function getFooter()
    {
        ?>
    <footer id="footer">
        <a href="https://github.com/FoolCode/FoolFuuka"><?php 
        echo $this->getConfig()->get('foolz/foolfuuka', 'package', 'main.name');
        ?>
            Imageboard <?php 
        echo $this->getConfig()->get('foolz/foolfuuka', 'package', 'main.version');
        ?>
</a>
        - <a href="http://github.com/eksopl/asagi" target="_blank">Asagi Fetcher</a>

        <div class="pull-right">
            <div class="btn-group dropup pull-right">
                <a href="#" class="btn btn-inverse btn-mini dropdown-toggle" data-toggle="dropdown">
                    <?php 
        echo _i('Change Theme');
        ?>
 <span class="caret"></span>
                </a>
                <ul class="dropdown-menu">
                    <?php 
        foreach ($this->getTheme()->getLoader()->getListWithStyles() as $key => $theme) {
            if (isset($theme['object']->enabled) && $theme['object']->enabled) {
                ?>
                        <li>
                            <a href="<?php 
                echo $this->getUri()->create(array('_', 'theme', $key));
                ?>
">
                                <?php 
                echo $theme['string'];
                ?>
                                <?php 
                if ($theme['object'] === $this->getTheme() && $theme['style'] == $this->getBuilder()->getStyle()) {
                    ?>
                                    <i class="icon-ok"></i>
                                <?php 
                }
                ?>
                            </a>
                        </li>
                        <?php 
            }
        }
        ?>
                </ul>
            </div>
        </div>

        <div class="pull-right">
            <div class="btn-group dropup pull-right">
                <a href="#" class="btn btn-inverse btn-mini dropdown-toggle" data-toggle="dropdown">
                    <?php 
        echo _i('Change Language');
        ?>
 <span class="caret"></span>
                </a>
                <ul class="dropdown-menu">
                    <?php 
        foreach ($this->getConfig()->get('foolz/foolframe', 'package', 'preferences.lang.available') as $key => $lang) {
            ?>
                    <li>
                        <a href="<?php 
            echo $this->getUri()->create(array('_', 'language', $key));
            ?>
">
                            <?php 
            echo $lang;
            ?>
                            <?php 
            if (!$this->getCookie('language') && $key == 'en_EN' || $key == $this->getCookie('language')) {
                ?>
                                <i class="icon-ok"></i>
                            <?php 
            }
            ?>
                        </a>
                    </li>
                    <?php 
        }
        ?>
                    <li class="divider"></li>
                    <li><a href="//archive.foolz.us/_/articles/translate/"><?php 
        echo _i('Add a Translation');
        ?>
</a></li>
                </ul>
            </div>
        </div>

        <?php 
        $radix = $this->getBuilderParamManager()->getParam('radix');
        $bottom_nav = array();
        $bottom_nav = \Foolz\Plugin\Hook::forge('foolframe.themes.generic_bottom_nav_buttons')->setObject($this)->setParam('nav', $bottom_nav)->execute()->get($bottom_nav);
        $bottom_nav = \Foolz\Plugin\Hook::forge('foolfuuka.themes.default_bottom_nav_buttons')->setObject($this)->setParam('nav', $bottom_nav)->execute()->get($bottom_nav);
        if (!empty($bottom_nav)) {
            echo '<div class="pull-right" style="margin-right: 15px;">';
            foreach ($bottom_nav as $key => $nav) {
                echo '<a href="' . $nav['href'] . '">' . $nav['text'] . '</a>';
                if ($key < count($bottom_nav) - 1) {
                    echo ' - ';
                }
            }
            echo '</div>';
        }
        if ($this->getPreferences()->get('foolframe.theme.footer_text')) {
            echo '<section class="footer_text">' . $this->getPreferences()->get('foolframe.theme.footer_text') . '</section>';
        }
        ?>
    </footer>

    <?php 
        if ($radix) {
            ?>
<div id="totop" title="Top of page"><a href="#"><img src="/static-assets/totop.png" alt="Top of page"></a></div><?php 
        }
        ?>

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script>
        window.jQuery || document.write('<script src="<?php 
        echo $this->getAssetManager()->getAssetLink('assets/js/jquery.js');
        ?>
"><\/script>');
        hljs.configure({
            tableReplace: '  '
        });
        $('pre,code').each(function(i, block) {
            hljs.highlightBlock(block);
        });

        var backend_vars = <?php 
        echo json_encode($this->getBuilderParamManager()->getParam('backend_vars'));
        ?>
;

        <?php 
        if ($this->getPreferences()->get('foolframe.theme.google_analytics')) {
            ?>
        var _gaq = [
            ['_setAccount', '<?php 
            echo $this->getPreferences()->get('foolframe.theme.google_analytics');
            ?>
'],
            ['_setCustomVar', 1, 'HTTPS', ('https:' == location.protocol ? 'Yes' : 'No'), 1],
            ['_trackPageview'],
            ['_trackPageLoadTime']
        ];
        (function (d, t) {
            var g = d.createElement(t), s = d.getElementsByTagName(t)[0];
            g.src = ('https:' == location.protocol ? '//ssl' : '//www') + '.google-analytics.com/ga.js';
            s.parentNode.insertBefore(g, s)
        }(document, 'script'));
        <?php 
        }
        ?>
    </script>
    <script src="<?php 
        echo $this->getAssetManager()->getAssetLink('bootstrap.min.js');
        ?>
"></script>
    <script src="<?php 
        echo $this->getAssetManager()->getAssetLink('board.js');
        ?>
"></script>
    <script src="<?php 
        echo $this->getAssetManager()->getAssetLink('plugins.js');
        ?>
"></script>
    <script src="/static-assets/nyafuu-plugins.js"></script>

    <!--[if lt IE 7 ]>
        <script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
        <script>window.attachEvent('onload', function () { CFInstall.check({mode:'overlay'}) })</script>
    <![endif]-->

    <?php 
        echo $this->getPreferences()->get('foolframe.theme.footer_code');
        ?>

    <?php 
        if ($this->getConfig()->get('foolz/foolfuuka', 'config', 'profiler.enabled') && $this->getBuilder()->isStreaming() && $this->getAuth()->hasAccess('maccess.admin')) {
            $profiler = $this->getContext()->getService('profiler');
            $profiler->log('Generating profiler HTML in streamed response');
            echo $profiler->getHtml();
        }
        ?>
</body>
</html>
    <?php 
    }
Beispiel #12
0
 /**
  * Puts the table in readily available variables
  */
 public function preload()
 {
     $this->profiler->log('Radix::preload Start');
     try {
         $result = Cache::item('foolfuuka.model.radix.preload')->get();
     } catch (\OutOfBoundsException $e) {
         $result = $this->dc->qb()->select('*')->from($this->dc->p('boards'), 'b')->orderBy('shortname', 'ASC')->execute()->fetchAll();
         Cache::item('foolfuuka.model.radix.preload')->set($result, 900);
     }
     if (!is_array($result) || empty($result)) {
         $this->preloaded_radixes = [];
         return false;
     }
     $result_object = [];
     foreach ($result as $item) {
         // don't process hidden boards
         if (!$this->getAuth()->hasAccess('boards.see_hidden') && $item['hidden'] == 1) {
             continue;
         }
         $structure = $this->structure($item);
         $result_object[$item['id']] = new Radix($this->getContext(), $this);
         // set the plain database data as keys
         foreach ($item as $k => $i) {
             $result_object[$item['id']]->{$k} = $i;
             // we set it also in the values so we can just use it from there as commodity
             $result_object[$item['id']]->setValue($k, $i);
         }
         // url values for commodity
         $result_object[$item['id']]->setValue('formatted_title', $item['name'] ? '/' . $item['shortname'] . '/ - ' . $item['name'] : '/' . $item['shortname'] . '/');
         // load the basic value of the preferences
         foreach ($structure as $key => $arr) {
             if (!isset($result_object[$item['id']]->{$key}) && isset($arr['boards_preferences'])) {
                 $result_object[$item['id']]->setValue($key, $this->config->get('foolz/foolfuuka', 'package', 'preferences.radix.' . $key, false));
             }
             foreach (['sub', 'sub_inverse'] as $sub) {
                 if (isset($arr[$sub])) {
                     foreach ($arr[$sub] as $k => $a) {
                         if (!isset($result_object[$item['id']]->{$k}) && isset($a['boards_preferences'])) {
                             $result_object[$item['id']]->setValue($k, $this->config->get('foolz/foolfuuka', 'package', 'preferences.radix.' . $k, false));
                         }
                     }
                 }
             }
         }
     }
     // load the preferences from the board_preferences table
     $this->profiler->log('Radix::load_preferences Start');
     try {
         $preferences = Cache::item('foolfuuka.model.radix.load_preferences')->get();
     } catch (\OutOfBoundsException $e) {
         $preferences = $this->dc->qb()->select('*')->from($this->dc->p('boards_preferences'), 'p')->execute()->fetchAll();
         Cache::item('foolfuuka.model.radix.load_preferences')->set($preferences, 900);
     }
     foreach ($preferences as $value) {
         // in case of leftover values, it would try instantiating a new stdClass and that would trigger error
         if (isset($result_object[$value['board_id']])) {
             $result_object[$value['board_id']]->setValue($value['name'], $value['value']);
         }
     }
     $this->preloaded_radixes = $result_object;
     $this->profiler->logMem('Radix $this->preloaded_radixes', $this->preloaded_radixes);
     $this->profiler->log('Radix::load_preferences End');
     // take them all and then filter/do whatever (we use this to split the boards through various subdomains)
     // only public is affected! admins and mods will see all boards at all the time
     $this->preloaded_radixes = \Foolz\Plugin\Hook::forge('Foolz\\Foolfuuka\\Model\\Radix::preload.result.public')->setObject($this)->setParam('preloaded_radixes', $this->preloaded_radixes)->execute()->get($this->preloaded_radixes);
     $this->profiler->log('Radix::preload End');
     $this->profiler->logMem('Radix $this->preloaded_radixes w/ preferences', $this->preloaded_radixes);
 }
Beispiel #13
0
 /**
  * @param ReleaseBulk $release_bulk
  * @param UploadedFile[] $files A flat array of UploadedFile objects
  * @throws PageUploadInvalidException
  * @throws PageUploadInvalidFormatException
  * @throws PageUploadNoFileException
  */
 public function addFromFileArray(ReleaseBulk $release_bulk, array $files)
 {
     $config = Hook::forge('Foolz\\Foolslide\\Model\\PageFactory::upload.config')->setParams(['ext_whitelist' => ['jpg', 'jpeg', 'gif', 'png'], 'mime_whitelist' => ['image/jpeg', 'image/png', 'image/gif']])->execute()->getParams();
     if (!$files) {
         throw new PageUploadNoFileException(_i('You must upload an image or your image was too large.'));
     }
     foreach ($files as $file) {
         if (!$file->isValid()) {
             if ($file->getError() === UPLOAD_ERR_INI_SIZE) {
                 throw new PageUploadInvalidException(_i('The server is misconfigured: the Foolslide upload size should be lower than PHP\'s upload limit.'));
             }
             if ($file->getError() === UPLOAD_ERR_PARTIAL) {
                 throw new PageUploadInvalidException(_i('You uploaded the file partially.'));
             }
             if ($file->getError() === UPLOAD_ERR_CANT_WRITE) {
                 throw new PageUploadInvalidException(_i('The image couldn\'t be saved on the disk.'));
             }
             if ($file->getError() === UPLOAD_ERR_EXTENSION) {
                 throw new PageUploadInvalidException(_i('A PHP extension broke and made processing the image impossible.'));
             }
             throw new PageUploadInvalidException(_i('Unexpected upload error.'));
         }
         if (mb_strlen($file->getFilename(), 'utf-8') > 64) {
             throw new PageUploadInvalidException(_i('You uploaded a file with a too long filename.'));
         }
         if (!in_array(strtolower($file->getClientOriginalExtension()), $config['ext_whitelist'])) {
             throw new PageUploadInvalidException(_i('You uploaded a file with an invalid extension.'));
         }
         if (!in_array(strtolower($file->getMimeType()), $config['mime_whitelist'])) {
             throw new PageUploadInvalidException(_i('You uploaded a file with an invalid mime type.'));
         }
         /*
          * Disabled max size
          *
         if ($file->getClientSize() > $max_size && !$this->getAuth()->hasAccess('media.limitless_media')) {
             throw new PageUploadInvalidException(
                 _i('You uploaded a too big file. The maxmimum allowed filesize is %s',
                     $radix->getValue('max_image_size_kilobytes')));
         }
         */
     }
     $dc = $this->dc;
     foreach ($files as $file) {
         $page_data = new PageData();
         $page_data->release_id = $release_bulk->release->id;
         $page_data->filename = $file->getClientOriginalName();
         $page_data->extension = $file->getClientOriginalExtension();
         $page_data->filesize = $file->getSize();
         $imagesize = getimagesize($file->getPathname());
         if (!$imagesize) {
             throw new PageUploadInvalidFormatException(_i('The file you uploaded is not allowed.'));
         }
         $page_data->width = $imagesize[0];
         $page_data->height = $imagesize[1];
         $page_data->hash = sha1_file($file->getPathname());
         $dc->getConnection()->insert($dc->p('pages'), $page_data->export());
         $id = $dc->getConnection()->lastInsertId();
         $dir = DOCROOT . 'foolslide/series/' . $release_bulk->series->id . '/' . $release_bulk->release->id . '/';
         if (!file_exists($dir)) {
             mkdir($dir, 0655, true);
         }
         $file->move($dir, $id . '.' . $page_data->extension);
     }
 }
Beispiel #14
0
 /**
  * A callback function for preg_replace_callback for external links (>>>//)
  * Notice: this function generates some class variables
  *
  * @param array $matches the matches sent by preg_replace_callback
  * @return string the complete anchor
  */
 public function processExternalLinks($matches)
 {
     // create $data object with all results from $matches
     $data = new \stdClass();
     $data->link = $matches[2];
     $data->shortname = $matches[3];
     $data->board = $this->radix_coll->getByShortname($data->shortname);
     $data->query = $matches[4];
     $build_href = ['tags' => ['open' => '', 'close' => ''], 'short_link' => '//boards.4chan.org/' . $data->shortname . '/', 'query_link' => '//boards.4chan.org/' . $data->shortname . '/res/' . $data->query, 'attributes' => '', 'backlink_attr' => ' class="backlink" data-function="highlight" data-backlink="true" data-board="' . ($data->board ? $data->board->shortname : $data->shortname) . '" data-post="' . $data->query . '"'];
     $build_href = Hook::forge('Foolz\\FoolFuuka\\Model\\Comment::processExternalLinks#var.link')->setObject($this)->setParam('data', $data)->setParam('build_href', $build_href)->execute()->get($build_href);
     if (!$data->board) {
         if ($data->query) {
             return implode('<a href="' . $build_href['query_link'] . '"' . $build_href['attributes'] . '>&gt;&gt;&gt;' . $data->link . '</a>', $build_href['tags']);
         }
         return implode('<a href="' . $build_href['short_link'] . '">&gt;&gt;&gt;' . $data->link . '</a>', $build_href['tags']);
     }
     if ($data->query) {
         return implode('<a href="' . $this->uri->create([$data->board->shortname, 'post', $data->query]) . '"' . $build_href['attributes'] . $build_href['backlink_attr'] . '>&gt;&gt;&gt;' . $data->link . '</a>', $build_href['tags']);
     }
     return implode('<a href="' . $this->uri->create($data->board->shortname) . '">&gt;&gt;&gt;' . $data->link . '</a>', $build_href['tags']);
 }
Beispiel #15
0
 /**
  * Takes an uploaded file and makes an object. It doesn't do the ->insert()
  *
  * @param  Radix $radix  The Radix where this Media belongs
  *
  * @return  \Foolz\Foolfuuka\Model\Media            A new Media object with the upload data
  * @throws  MediaUploadNoFileException              If there's no file uploaded
  * @throws  MediaUploadMultipleNotAllowedException  If there's multiple uploads
  * @throws  MediaUploadInvalidException             If the file format is not allowed
  */
 protected function p_forgeFromUpload(Request $request, Radix $radix)
 {
     $config = Hook::forge('Foolz\\Foolfuuka\\Model\\Media::upload.config')->setParams(['ext_whitelist' => ['jpg', 'jpeg', 'gif', 'png'], 'mime_whitelist' => ['image/jpeg', 'image/png', 'image/gif']])->execute()->getParams();
     if (!$request->files->count()) {
         throw new MediaUploadNoFileException(_i('You must upload an image or your image was too large.'));
     }
     if ($request->files->count() !== 1) {
         throw new MediaUploadMultipleNotAllowedException(_i('You can\'t upload multiple images.'));
     }
     /** @var UploadedFile[] $files */
     $files = $request->files->all();
     $max_size = $radix->getValue('max_image_size_kilobytes') * 1024;
     foreach ($files as $file) {
         if (!$file->isValid()) {
             if ($file->getError() === UPLOAD_ERR_INI_SIZE) {
                 throw new MediaUploadInvalidException(_i('The server is misconfigured: the FoolFuuka upload size should be lower than PHP\'s upload limit.'));
             }
             if ($file->getError() === UPLOAD_ERR_PARTIAL) {
                 throw new MediaUploadInvalidException(_i('You uploaded the file partially.'));
             }
             if ($file->getError() === UPLOAD_ERR_CANT_WRITE) {
                 throw new MediaUploadInvalidException(_i('The image couldn\'t be saved on the disk.'));
             }
             if ($file->getError() === UPLOAD_ERR_EXTENSION) {
                 throw new MediaUploadInvalidException(_i('A PHP extension broke and made processing the image impossible.'));
             }
             throw new MediaUploadInvalidException(_i('Unexpected upload error.'));
         }
         if (mb_strlen($file->getFilename(), 'utf-8') > 64) {
             throw new MediaUploadInvalidException(_i('You uploaded a file with a too long filename.'));
         }
         if (!in_array(strtolower($file->getClientOriginalExtension()), $config['ext_whitelist'])) {
             throw new MediaUploadInvalidException(_i('You uploaded a file with an invalid extension.'));
         }
         if (!in_array(strtolower($file->getMimeType()), $config['mime_whitelist'])) {
             throw new MediaUploadInvalidException(_i('You uploaded a file with an invalid mime type.'));
         }
         if ($file->getClientSize() > $max_size && !$this->getAuth()->hasAccess('media.limitless_media')) {
             throw new MediaUploadInvalidException(_i('You uploaded a too big file. The maxmimum allowed filesize is %s', $radix->getValue('max_image_size_kilobytes')));
         }
     }
     $media = new Media($this->getContext());
     $media->setTempFile($radix, $files['file_image']);
     return $media;
 }
Beispiel #16
0
 public function handleConsole()
 {
     $application = new Application();
     Hook::forge('Foolz\\FoolFrame\\Model\\Context::handleConsole#obj.app')->setObject($this)->setParam('application', $application)->execute();
     //$application->add(new \Your\Class\Command\Console()); // that extends Command
     $application->run();
 }
Beispiel #17
0
    public function toString()
    {
        $board = $this->getParamManager()->getParam('board');
        $controller_method = $this->getBuilderParamManager()->getParam('controller_method', 'thread');
        $thread_id = $this->getBuilderParamManager()->getParam('thread_id', 0);
        foreach ($board as $key => $post) {
            if (isset($post['op'])) {
                $op_bulk = $post['op'];
                $op = new Comment($this->getContext(), $op_bulk);
                $op->setControllerMethod($controller_method);
                if ($op_bulk->media !== null) {
                    $op_media = new Media($this->getContext(), $op_bulk);
                } else {
                    $op_media = null;
                }
                $num = $op->num . ($op->subnum ? '_' . $op->subnum : '');
                ?>
        <?php 
                if ($thread_id === 0) {
                    ?>
        <div class="thread stub stub_doc_id_<?php 
                    echo $op->doc_id;
                    ?>
">
            <button class="btn-toggle-post" data-function="showThread" data-board="<?php 
                    echo $op->radix->shortname;
                    ?>
" data-doc-id="<?php 
                    echo $op->doc_id;
                    ?>
" data-thread-num="<?php 
                    echo $op->thread_num;
                    ?>
"><i class="icon-plus"></i></button>
            <?php 
                    if ($op->email && $op->email !== 'noko') {
                        ?>
<a href="mailto:<?php 
                        echo rawurlencode($op->email);
                        ?>
"><?php 
                    }
                    ?>
<span class="post_author"><?php 
                    echo $op->getNameProcessed();
                    ?>
</span><?php 
                    echo $op->getNameProcessed() && $op->getTripProcessed() ? ' ' : '';
                    ?>
<span class="post_tripcode"><?php 
                    echo $op->getTripProcessed();
                    ?>
</span><?php 
                    if ($op->email && $op->email !== 'noko') {
                        ?>
</a><?php 
                    }
                    ?>
            (<?php 
                    echo $post['omitted'] + 5 . ' ' . _i('replies');
                    ?>
)
        </div>
        <?php 
                }
                ?>
        <article id="<?php 
                echo $num;
                ?>
" class="clearfix thread doc_id_<?php 
                echo $op->doc_id;
                ?>
 board_<?php 
                echo $op->radix->shortname;
                ?>
" data-doc-id="<?php 
                echo $op->doc_id;
                ?>
" data-thread-num="<?php 
                echo $op->thread_num;
                ?>
">
                <?php 
                if ($thread_id === 0) {
                    ?>
                <div class="stub pull-left">
                    <button class="btn-toggle-post" data-function="hideThread" data-board="<?php 
                    echo $op->radix->shortname;
                    ?>
" data-doc-id="<?php 
                    echo $op->doc_id;
                    ?>
"><i class="icon-minus"></i></button>
                </div>
                <?php 
                }
                ?>
                <?php 
                \Foolz\Plugin\Hook::forge('foolfuuka.themes.default_after_op_open')->setObject($this)->setParam('board', $op->radix)->execute();
                ?>
                <?php 
                if ($op_media !== null) {
                    ?>
                <div class="thread_image_box">
                    <?php 
                    if ($op_media->getMediaStatus($this->getRequest()) === 'banned') {
                        ?>
                    <img src="<?php 
                        echo $this->getAssetManager()->getAssetLink('images/banned-image.png');
                        ?>
" width="150" height="150" />
                    <?php 
                    } elseif ($op_media->getMediaStatus($this->getRequest()) !== 'normal') {
                        ?>
                    <a href="<?php 
                        echo $op_media->getMediaLink($this->getRequest()) ? $op_media->getMediaLink($this->getRequest()) : $op_media->getRemoteMediaLink($this->getRequest());
                        ?>
" target="_blank" rel="noreferrer" class="thread_image_link">
                        <img src="<?php 
                        echo $this->getAssetManager()->getAssetLink('images/missing-image.jpg');
                        ?>
" width="150" height="150" />
                    </a>
                    <?php 
                    } else {
                        ?>
                    <a href="<?php 
                        echo $op_media->getMediaLink($this->getRequest()) ? $op_media->getMediaLink($this->getRequest()) : $op_media->getRemoteMediaLink($this->getRequest());
                        ?>
" target="_blank" rel="noreferrer" class="thread_image_link">
                        <?php 
                        if (!$this->getAuth()->hasAccess('maccess.mod') && !$op->radix->getValue('transparent_spoiler') && $op_media->spoiler) {
                            ?>
                        <div class="spoiler_box"><span class="spoiler_box_text"><?php 
                            echo _i('Spoiler');
                            ?>
<span class="spoiler_box_text_help"><?php 
                            echo _i('Click to view');
                            ?>
</span></div>
                        <?php 
                        } else {
                            ?>
                        <img src="<?php 
                            echo $op_media->getThumbLink($this->getRequest());
                            ?>
" width="<?php 
                            echo $op_media->preview_w;
                            ?>
" height="<?php 
                            echo $op_media->preview_h;
                            ?>
" class="thread_image<?php 
                            echo $op_media->spoiler ? ' is_spoiler_image' : '';
                            ?>
" data-md5="<?php 
                            echo $op_media->media_hash;
                            ?>
" />
                        <?php 
                        }
                        ?>
                    </a>
                    <?php 
                    }
                    ?>
                    <?php 
                    if ($op_media->getMediaStatus($this->getRequest()) !== 'banned') {
                        ?>
                    <div class="post_file" style="padding-left: 2px;<?php 
                        if ($op_media->preview_w > 149) {
                            echo 'max-width:' . $op_media->preview_w . 'px;';
                        }
                        ?>
">
                        <?php 
                        echo ByteSize::formatBinary($op_media->media_size, 0) . ', ' . $op_media->media_w . 'x' . $op_media->media_h . ', ';
                        ?>
<a class="post_file_filename" href="<?php 
                        echo $op_media->getMediaLink($this->getRequest()) ? $op_media->getMediaLink($this->getRequest()) : $op_media->getRemoteMediaLink($this->getRequest());
                        ?>
" target="_blank"><?php 
                        echo $op_media->getMediaFilenameProcessed();
                        ?>
</a>
                    </div>
                    <?php 
                    }
                    ?>
                    <div class="post_file_controls">
                        <?php 
                    if ($op_media->getMediaStatus($this->getRequest()) !== 'banned' || $this->getAuth()->hasAccess('media.see_banned')) {
                        ?>
                        <?php 
                        if (!$op->radix->hide_thumbnails || $this->getAuth()->hasAccess('maccess.mod')) {
                            ?>
                            <a href="<?php 
                            echo $this->getUri()->create($op->radix->shortname . '/search/image/' . $op_media->getSafeMediaHash());
                            ?>
" class="btnr parent"><?php 
                            echo _i('View Same');
                            ?>
</a><a
                                href="http://google.com/searchbyimage?image_url=<?php 
                            echo $op_media->getThumbLink($this->getRequest());
                            ?>
" target="_blank"
                                class="btnr parent">Google</a><a
                                href="http://iqdb.org/?url=<?php 
                            echo $op_media->getThumbLink($this->getRequest());
                            ?>
" target="_blank"
                                class="btnr parent">iqdb</a><a
                                href="http://saucenao.com/search.php?url=<?php 
                            echo $op_media->getThumbLink($this->getRequest());
                            ?>
" target="_blank"
                                class="btnr parent">SauceNAO</a><?php 
                            if (!$op->radix->archive || $op->radix->getValue('archive_full_images')) {
                                ?>
<a
                                href="<?php 
                                echo $op_media->getMediaDownloadLink($this->getRequest());
                                ?>
" download="<?php 
                                echo $op_media->getMediaFilenameProcessed();
                                ?>
"
                                class="btnr parent"><i class="icon-download-alt"></i></a><?php 
                            }
                            ?>
                            <?php 
                        }
                        ?>
                        <?php 
                    }
                    ?>
                    </div>
                </div>
                <?php 
                }
                ?>
                <header>
                    <div class="post_data">
                        <?php 
                if ($op->getTitleProcessed() !== '') {
                    ?>
<h2 class="post_title"><?php 
                    echo $op->getTitleProcessed();
                    ?>
</h2><?php 
                }
                ?>
                        <span class="post_poster_data">
                            <?php 
                if ($op->email && $op->email !== 'noko') {
                    ?>
<a href="mailto:<?php 
                    echo rawurlencode($op->email);
                    ?>
"><?php 
                }
                ?>
<span class="post_author"><?php 
                echo $op->getNameProcessed();
                ?>
</span><?php 
                echo $op->getNameProcessed() && $op->getTripProcessed() ? ' ' : '';
                ?>
<span class="post_tripcode"><?php 
                echo $op->getTripProcessed();
                ?>
</span><?php 
                if ($op->email && $op->email !== 'noko') {
                    ?>
</a><?php 
                }
                ?>

                            <?php 
                if ($op->getPosterHashProcessed()) {
                    ?>
<span class="poster_hash">ID:<?php 
                    echo $op->getPosterHashProcessed();
                    ?>
</span><?php 
                }
                ?>
                            <?php 
                if ($op->capcode !== 'N') {
                    ?>
                            <?php 
                    if ($op->capcode === 'M') {
                        ?>
<span class="post_level post_level_moderator">## <?php 
                        echo _i('Mod');
                        ?>
</span><?php 
                    }
                    ?>
                            <?php 
                    if ($op->capcode === 'A') {
                        ?>
<span class="post_level post_level_administrator">## <?php 
                        echo _i('Admin');
                        ?>
</span><?php 
                    }
                    ?>
                            <?php 
                    if ($op->capcode === 'D') {
                        ?>
<span class="post_level post_level_developer">## <?php 
                        echo _i('Developer');
                        ?>
</span><?php 
                    }
                    ?>
                            <?php 
                }
                ?>
                        </span>
                        <span class="time_wrap">
                            <time datetime="<?php 
                echo gmdate(DATE_W3C, $op->timestamp);
                ?>
" class="show_time" <?php 
                if ($op->radix->archive) {
                    ?>
 title="<?php 
                    echo _i('4chan Time') . ': ' . $op->getFourchanDate();
                    ?>
"<?php 
                }
                ?>
><?php 
                echo gmdate('D d M H:i:s Y', $op->timestamp);
                ?>
</time>
                        </span>
                        <a href="<?php 
                echo $this->getUri()->create(array($op->radix->shortname, $controller_method, $op->thread_num)) . '#' . $num;
                ?>
" data-post="<?php 
                echo $num;
                ?>
" data-function="highlight">No.</a><a href="<?php 
                echo $this->getUri()->create(array($op->radix->shortname, $controller_method, $op->thread_num)) . '#q' . $num;
                ?>
" data-post="<?php 
                echo $num;
                ?>
" data-function="quote"><?php 
                echo $num;
                ?>
</a>

                        <span class="post_type">
                            <?php 
                if ($op->poster_country !== null) {
                    ?>
<span title="<?php 
                    echo e($op->poster_country_name);
                    ?>
" class="flag flag-<?php 
                    echo strtolower($op->poster_country);
                    ?>
"></span><?php 
                }
                ?>
                            <?php 
                if (isset($op_media) && $op_media->spoiler) {
                    ?>
<i class="icon-eye-close" title="<?php 
                    echo htmlspecialchars(_i('The image in this post has been marked spoiler.'));
                    ?>
"></i><?php 
                }
                ?>
                            <?php 
                if ($op->deleted && !$op->timestamp_expired) {
                    ?>
<i class="icon-trash" title="<?php 
                    echo htmlspecialchars(_i('This thread was prematurely deleted.'));
                    ?>
"></i><?php 
                }
                ?>
                            <?php 
                if ($op->deleted && $op->timestamp_expired) {
                    ?>
<i class="icon-trash" title="<?php 
                    echo htmlspecialchars(_i('This thread was deleted on %s.', gmdate('M d, Y \\a\\t H:i:s e', $op->timestamp_expired)));
                    ?>
"></i><?php 
                }
                ?>
                            <?php 
                if ($op->sticky) {
                    ?>
<i class="icon-pushpin" title="<?php 
                    echo _i('This thread has been stickied.');
                    ?>
"></i><?php 
                }
                ?>
                            <?php 
                if ($op->locked) {
                    ?>
<i class="icon-lock" title="<?php 
                    echo _i('This thread has been locked.');
                    ?>
"></i><?php 
                }
                ?>
                        </span>

                        <span class="post_controls">
                <a href="<?php 
                echo $this->getUri()->create(array($op->radix->shortname, 'thread', $num));
                ?>
" class="btnr parent"><?php 
                echo _i('View');
                ?>
</a><a href="<?php 
                echo $this->getUri()->create(array($op->radix->shortname, $controller_method, $num)) . '#reply';
                ?>
" class="btnr parent"><?php 
                echo _i('Reply');
                ?>
</a><?php 
                echo isset($post['omitted']) && $post['omitted'] > 50 ? '<a href="' . $this->getUri()->create($op->radix->shortname . '/last/50/' . $num) . '" class="btnr parent">' . _i('Last 50') . '</a>' : '';
                echo $op->radix->archive ? '<a href="//boards.4chan.org/' . $op->radix->shortname . '/thread/' . $num . '" class="btnr parent">' . _i('Original') . '</a>' : '';
                ?>
<a href="#" class="btnr parent" data-post="<?php 
                echo $op->doc_id;
                ?>
" data-post-id="<?php 
                echo $num;
                ?>
" data-board="<?php 
                echo htmlspecialchars($op->radix->shortname);
                ?>
" data-controls-modal="post_tools_modal" data-backdrop="true" data-keyboard="true" data-function="report"><?php 
                echo _i('Report');
                ?>
</a><?php 
                if ($this->getAuth()->hasAccess('maccess.mod') || !$op->radix->archive) {
                    ?>
<a href="#" class="btnr parent" data-post="<?php 
                    echo $op->doc_id;
                    ?>
" data-post-id="<?php 
                    echo $num;
                    ?>
" data-board="<?php 
                    echo htmlspecialchars($op->radix->shortname);
                    ?>
" data-controls-modal="post_tools_modal" data-backdrop="true" data-keyboard="true" data-function="delete"><?php 
                    echo _i('Delete');
                    ?>
</a><?php 
                }
                ?>
            </span>

                        <div class="backlink_list"<?php 
                echo $op->getBacklinks() ? ' style="display:block"' : '';
                ?>
>
                            <?php 
                echo _i('Quoted By:');
                ?>
 <span class="post_backlink" data-post="<?php 
                echo $num;
                ?>
"><?php 
                echo $op->getBacklinks() ? implode(' ', $op->getBacklinks()) : '';
                ?>
</span>
                        </div>

                        <?php 
                if ($this->getAuth()->hasAccess('maccess.mod')) {
                    ?>
                        <div class="btn-group" style="clear:both; padding:5px 0 0 0;">
                            <button class="btn btn-mini" data-function="activateModeration"><?php 
                    echo _i('Mod');
                    if ($op->poster_ip) {
                        echo ' ' . Inet::dtop($op->poster_ip);
                    }
                    ?>
</button>
                        </div>
                        <div class="btn-group post_mod_controls" style="clear:both; padding:5px 0 0 0;">
                            <button class="btn btn-mini" data-function="mod" data-board="<?php 
                    echo $op->radix->shortname;
                    ?>
" data-id="<?php 
                    echo $op->doc_id;
                    ?>
" data-action="delete_post"><?php 
                    echo _i('Delete Thread');
                    ?>
</button>
                            <?php 
                    if (!is_null($op_media)) {
                        ?>
                            <button class="btn btn-mini" data-function="mod" data-board="<?php 
                        echo $op->radix->shortname;
                        ?>
" data-id="<?php 
                        echo $op_media->media_id;
                        ?>
" data-doc-id="<?php 
                        echo $op->doc_id;
                        ?>
" data-action="delete_image"><?php 
                        echo _i('Delete Image');
                        ?>
</button>
                            <button class="btn btn-mini" data-function="mod" data-board="<?php 
                        echo $op->radix->shortname;
                        ?>
" data-id="<?php 
                        echo $op_media->media_id;
                        ?>
" data-doc-id="<?php 
                        echo $op->doc_id;
                        ?>
" data-action="ban_image_local"><?php 
                        echo _i('Ban Image');
                        ?>
</button>
                            <button class="btn btn-mini" data-function="mod" data-board="<?php 
                        echo $op->radix->shortname;
                        ?>
" data-id="<?php 
                        echo $op_media->media_id;
                        ?>
" data-doc-id="<?php 
                        echo $op->doc_id;
                        ?>
" data-action="ban_image_global"><?php 
                        echo _i('Ban Image Globally');
                        ?>
</button>
                            <?php 
                    }
                    ?>
                            <?php 
                    if ($op->poster_ip) {
                        ?>
                            <button class="btn btn-mini" data-function="ban" data-controls-modal="post_tools_modal" data-backdrop="true" data-keyboard="true" data-board="<?php 
                        echo $op->radix->shortname;
                        ?>
" data-ip="<?php 
                        echo Inet::dtop($op->poster_ip);
                        ?>
" data-action="ban_user"><?php 
                        echo _i('Ban IP:') . ' ' . Inet::dtop($op->poster_ip);
                        ?>
</button>
                            <button class="btn btn-mini" data-function="searchUser" data-board="<?php 
                        echo $op->radix->shortname;
                        ?>
" data-board-url="<?php 
                        echo $this->getUri()->create(array($op->radix->shortname));
                        ?>
" data-id="<?php 
                        echo $op->doc_id;
                        ?>
" data-poster-ip="<?php 
                        echo Inet::dtop($op->poster_ip);
                        ?>
"><?php 
                        echo _i('Search IP');
                        ?>
</button>
                            <?php 
                        if ($this->getPreferences()->get('foolfuuka.sphinx.global')) {
                            ?>
                                <button class="btn btn-mini" data-function="searchUserGlobal" data-board="<?php 
                            echo $op->radix->shortname;
                            ?>
" data-board-url="<?php 
                            echo $this->getUri()->create(array($op->radix->shortname));
                            ?>
" data-id="<?php 
                            echo $op->doc_id;
                            ?>
" data-poster-ip="<?php 
                            echo Inet::dtop($op->poster_ip);
                            ?>
"><?php 
                            echo _i('Search IP Globally');
                            ?>
</button>
                                <?php 
                        }
                        ?>
                            <?php 
                    }
                    ?>
                        </div>
                        <?php 
                }
                ?>
                    </div>
                </header>

                <div class="text<?php 
                if (preg_match('/[\\x{4E00}-\\x{9FBF}\\x{3040}-\\x{309F}\\x{30A0}-\\x{30FF}]/u', $op->getCommentProcessed())) {
                    echo ' shift-jis';
                }
                ?>
">
                    <?php 
                echo $op->getCommentProcessed();
                ?>
                </div>
                <div class="thread_tools_bottom">
                    <?php 
                if (isset($post['omitted']) && $post['omitted'] > 0) {
                    ?>
        <span class="omitted">
            <a style="display:inline-block" href="<?php 
                    echo $this->getUri()->create(array($op->radix->shortname, $controller_method, $op->thread_num));
                    ?>
" data-function="expandThread" data-thread-num="<?php 
                    echo $op->thread_num;
                    ?>
"><i class="icon icon-resize-full"></i></a>
                    <span class="omitted_text">
                <span class="omitted_posts"><?php 
                    echo $post['omitted'];
                    ?>
</span> <?php 
                    echo _n('post', 'posts', $post['omitted']);
                    ?>
                        <?php 
                    if (isset($post['images_omitted']) && $post['images_omitted'] > 0) {
                        ?>
                        <?php 
                        echo _i('and');
                        ?>
 <span class="omitted_images"><?php 
                        echo $post['images_omitted'];
                        ?>
</span> <?php 
                        echo _n('image', 'images', $post['images_omitted']);
                        ?>
                        <?php 
                    }
                    ?>
                        <?php 
                    echo _n('omitted', 'omitted', $post['omitted'] + $post['images_omitted']);
                    ?>
        </span>
                    <?php 
                }
                ?>
                </div>

                <?php 
                if ($op->getReports()) {
                    ?>
                <?php 
                    foreach ($op->getReports() as $report) {
                        ?>
                    <div class="report_reason"><?php 
                        echo '<strong>' . _i('Reported Reason:') . '</strong> ' . $report->getReasonProcessed();
                        ?>
                        <br/>
                        <div class="ip_reporter">
                            <strong><?php 
                        echo _i('Info:');
                        ?>
</strong>
                            <?php 
                        echo Inet::dtop($report->ip_reporter);
                        ?>
, <?php 
                        echo _i('Type:');
                        ?>
 <?php 
                        echo $report->media_id !== null ? _i('media') : _i('post');
                        ?>
, <?php 
                        echo _i('Time:');
                        ?>
 <?php 
                        echo gmdate('D M d H:i:s Y', $report->created);
                        ?>
                            <button class="btn btn-mini" data-function="mod" data-id="<?php 
                        echo $report->id;
                        ?>
" data-board="<?php 
                        echo htmlspecialchars($op->radix->shortname);
                        ?>
" data-action="delete_report"><?php 
                        echo _i('Delete Report');
                        ?>
</button>
                        </div>
                    </div>
                    <?php 
                    }
                    ?>
                <?php 
                }
                ?>
                <?php 
            } elseif (isset($post['posts'])) {
                ?>
        <article class="clearfix thread">
                    <?php 
                \Foolz\Plugin\Hook::forge('foolfuuka.themes.default_after_headless_open')->setObject($this)->setParam('board', array(isset($radix) ? $radix : null))->execute();
                ?>
                <?php 
            }
            ?>

            <aside class="posts">
                <?php 
            if (isset($post['posts'])) {
                $post_counter = 0;
                $image_counter = 0;
                $board_comment_view = $this->getBuilder()->createPartial('post', 'board_comment');
                // reusable Comment object not to create one every loop
                $comment = new Comment($this->getContext());
                $comment->setControllerMethod($controller_method);
                $media_obj = new Media($this->getContext());
                $search = array('/\\>[^\\S ]+/s', '/[^\\S ]+\\</s', '/(\\s)+/s');
                $replace = array('>', '<', '\\1');
                foreach ($post['posts'] as $p) {
                    /** @var CommentBulk $p */
                    $post_counter++;
                    if ($p->media !== null) {
                        $image_counter++;
                    }
                    if ($image_counter == 150) {
                        $modifiers['lazyload'] = true;
                    }
                    $comment->setBulk($p);
                    // set the $media to null and leave the Media object in existence
                    if ($p->media !== null) {
                        $media_obj->setBulk($p);
                        $media = $media_obj;
                    } else {
                        $media = null;
                    }
                    $board_comment_view->getParamManager()->setParams(['p' => $comment, 'p_media' => $media, 'modifiers' => $this->getBuilderParamManager()->getParam('modifiers', false), 'post_counter' => $post_counter, 'image_counter' => $image_counter]);
                    // refreshes the string
                    $board_comment_view->doBuild();
                    echo preg_replace($search, $replace, $board_comment_view->build());
                    // remove extra strings from the objects
                    $board_comment_view->clearBuilt();
                    $p->comment->clean();
                    if ($p->media !== null) {
                        $p->media->clean();
                    }
                    $this->flush();
                }
            }
            ?>
            </aside>

            <?php 
            if ($thread_id !== 0) {
                ?>
            <div class="js_hook_realtimethread"></div>
            <?php 
                echo $this->getBuilder()->isPartial('tools_reply_box') ? $this->getBuilder()->getPartial('tools_reply_box')->build() : '';
                ?>
            <?php 
            }
            ?>
            <?php 
            if (isset($post['op']) || isset($post['posts'])) {
                ?>
        </article>
        <?php 
            }
            ?>
            <?php 
        }
        ?>
        <article class="clearfix thread backlink_container">
            <div id="backlink" style="position: absolute; top: 0; left: 0; z-index: 5;"></div>
        </article>
        <?php 
    }
Beispiel #18
0
    public function getFooter()
    {
        $disable_headers = $this->getBuilderParamManager()->getParam('disable_headers', false);
        ?>
        <?php 
        if ($disable_headers !== true) {
            ?>
            <div style="float: right;">
                <?php 
            $bottom_nav = array();
            $bottom_nav = \Foolz\Plugin\Hook::forge('foolframe.themes.generic_bottom_nav_buttons')->setObject($this)->setParam('nav', $bottom_nav)->execute()->get($bottom_nav);
            $bottom_nav = \Foolz\Plugin\Hook::forge('foolfuuka.themes.fuuka_bottom_nav_buttons')->setObject($this)->setParam('nav', $bottom_nav)->execute()->get($bottom_nav);
            if (!empty($bottom_nav)) {
                echo '[ ';
                foreach ($bottom_nav as $key => $nav) {
                    echo '<a href="' . $nav['href'] . '">' . $nav['text'] . '</a>';
                    if ($key < count($bottom_nav) - 1) {
                        echo ' / ';
                    }
                }
                echo ' ]';
            }
            ?>

                <?php 
            $theme_links = array();
            foreach ($this->getTheme()->getLoader()->getListWithStyles() as $key => $theme) {
                if (isset($theme['object']->enabled) && $theme['object']->enabled) {
                    $theme_links[] = '<a href="' . $this->getUri()->create(array('_', 'theme', $key)) . '">' . $theme['string'] . '</a>';
                }
            }
            echo 'Theme [ ' . implode(' / ', $theme_links) . ' ]';
            ?>
            </div>
        <?php 
        }
        ?>

        <?php 
        if ($this->getPreferences()->get('foolframe.theme.footer_text')) {
            echo '<div style="clear: both;">' . $this->getPreferences()->get('foolframe.theme.footer_text') . '</div>';
        }
        ?>

        <script>
            var backend_vars = <?php 
        echo json_encode($this->getBuilderParamManager()->getParam('backend_vars'));
        ?>
;
        </script>

        <?php 
        if ($this->getPreferences()->get('foolframe.theme.google_analytics')) {
            ?>
            <script>
                var _gaq = [
                    ['_setAccount','<?php 
            echo $this->getPreferences()->get('foolframe.theme.google_analytics');
            ?>
'],
                    ['_setCustomVar', 1, 'HTTPS', ('https:' == location.protocol ? 'Yes' : 'No'), 1],
                    ['_trackPageview'],
                    ['_trackPageLoadTime']
                ];
                (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
                    g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
                    s.parentNode.insertBefore(g,s)}(document,'script'));
            </script>
        <?php 
        }
        ?>

        <?php 
        echo $this->getPreferences()->get('foolframe.theme.footer_code');
        ?>
    </body>
</html>
    <?php 
    }
Beispiel #19
0
 public function loadRoutes(RouteCollection $route_collection)
 {
     Hook::forge('Foolz\\Foolslide\\Model\\Context.loadRoutes.before')->setObject($this)->setParam('route_collection', $route_collection)->execute();
     $route_collection->add('foolslide.root', new Route('/', ['_controller' => '\\Foolz\\Foolslide\\Controller\\Reader::index']));
     $route_collection->add('404', new Route('', ['_controller' => '\\Foolz\\Foolslide\\Controller\\Chan::404']));
     $route = \Foolz\Plugin\Hook::forge('Foolz\\Foolslide\\Model\\Content::routes.collection')->setParams(['default_suffix' => 'page', 'suffix' => 'page', 'controller' => '\\Foolz\\Foolslide\\Controller\\Chan::*'])->execute();
     /** @var Radix[] $radix_all */
     $radix_all = $this->context->getService('foolslide.radix_collection')->getAll();
     foreach ($radix_all as $radix) {
         $route_collection->add('foolslide.chan.radix.' . $radix->shortname, new Route('/' . $radix->shortname . '/{_suffix}', ['_default_suffix' => $route->getParam('default_suffix'), '_suffix' => $route->getParam('suffix'), '_controller' => $route->getParam('controller'), 'radix_shortname' => $radix->shortname], ['_suffix' => '.*']));
     }
     $route_collection->add('foolslide.chan.api', new Route('/_/api/chan/{_suffix}', ['_suffix' => '', '_controller' => '\\Foolz\\Foolslide\\Controller\\Api\\Chan::*'], ['_suffix' => '.*']));
     $route_collection->add('foolslide.chan._', new Route('/_/{_suffix}', ['_suffix' => '', '_controller' => '\\Foolz\\Foolslide\\Controller\\Chan::*'], ['_suffix' => '.*']));
     foreach (['reader', 'boards', 'moderation'] as $location) {
         $route_collection->add('foolslide.admin.' . $location, new Route('/admin/' . $location . '/{_suffix}', ['_suffix' => '', '_controller' => '\\Foolz\\Foolslide\\Controller\\Admin\\' . ucfirst($location) . '::*'], ['_suffix' => '.*']));
     }
     Hook::forge('Foolz\\Foolslide\\Model\\Context.loadRoutes.after')->setObject($this)->setParam('route_collection', $route_collection)->execute();
 }