public function create_salts() { // config without slash is the custom foolz one $this->config->set('foolz/foolframe', 'config', 'config.cookie_prefix', 'foolframe_' . Util::randomString(3) . '_'); $this->config->save('foolz/foolframe', 'config'); $this->config->set('foolz/foolframe', 'cache', 'prefix', 'foolframe_' . Util::randomString(3) . '_'); $this->config->save('foolz/foolframe', 'cache'); }
public static function installAssets(CommandEvent $event) { $options = self::getOptions($event); $rootDir = realpath(__DIR__ . '/../../'); if (!$event->getIO()->askConfirmation('Would you like to install the third-party assets? [y/N] ', false)) { return; } $event->getIO()->write('Installing third-party assets.'); foreach ($options['assets'] as $package => $path) { $pkgDir = $rootDir . '/' . $path; $webDir = $rootDir . '/' . $options['foolfuuka-web-dir'] . '/foolfuuka/' . $package; $event->getIO()->write('+ ' . $package); if (file_exists($webDir)) { Util::delete($webDir); } if (is_dir($pkgDir)) { @mkdir($webDir, 0755, true); } else { @mkdir($webDir . '/../', 0755, true); } Util::copy($pkgDir, $webDir); } $event->getIO()->write('Finished installing third-party assets.'); }
/** * @return bool */ public function radix_submit() { // adapter if (!$this->getPost()) { return $this->error(_i('You aren\'t sending the required fields for creating a new message.')); } if (!$this->checkCsrfToken()) { return $this->error(_i('The security token wasn\'t found. Try resubmitting.')); } if ($this->getPost('reply_delete')) { foreach ($this->getPost('delete') as $idx => $doc_id) { try { $comments = Board::forge($this->getContext())->getPost()->setOptions('doc_id', $doc_id)->setRadix($this->radix)->getComments(); $comment = current($comments); $comment = new Comment($this->getContext(), $comment); $comment->delete($this->getPost('delpass')); } catch (\Foolz\Foolfuuka\Model\BoardException $e) { return $this->error($e->getMessage(), 404); } catch (\Foolz\Foolfuuka\Model\CommentDeleteWrongPassException $e) { return $this->error($e->getMessage(), 404); } } $this->builder->createLayout('redirect')->getParamManager()->setParam('url', $this->uri->create([$this->radix->shortname, 'thread', $comment->comment->thread_num])); $this->builder->getProps()->addTitle(_i('Redirecting')); return new Response($this->builder->build()); } if ($this->getPost('reply_report')) { foreach ($this->getPost('delete') as $idx => $doc_id) { try { $this->getContext()->getService('foolfuuka.report_collection')->add($this->radix, $doc_id, $this->getPost('KOMENTO'), Inet::ptod($this->getRequest()->getClientIp())); } catch (\Foolz\Foolfuuka\Model\ReportException $e) { return $this->error($e->getMessage(), 404); } } $this->builder->createLayout('redirect')->getParamManager()->setParam('url', $this->uri->create($this->radix->shortname . '/thread/' . $this->getPost('parent'))); $this->builder->getProps()->addTitle(_i('Redirecting')); return new Response($this->builder->build()); } // Determine if the invalid post fields are populated by bots. if (isset($post['name']) && mb_strlen($post['name'], 'utf-8') > 0) { return $this->error(); } if (isset($post['reply']) && mb_strlen($post['reply'], 'utf-8') > 0) { return $this->error(); } if (isset($post['email']) && mb_strlen($post['email'], 'utf-8') > 0) { return $this->error(); } $data = []; $post = $this->getPost(); if (isset($post['parent'])) { $data['thread_num'] = $post['parent']; } if (isset($post['NAMAE'])) { $data['name'] = $post['NAMAE']; $this->response->headers->setCookie(new Cookie($this->getContext(), 'reply_name', $data['name'], 60 * 60 * 24 * 30)); } if (isset($post['MERU'])) { $data['email'] = $post['MERU']; $this->response->headers->setCookie(new Cookie($this->getContext(), 'reply_email', $data['email'], 60 * 60 * 24 * 30)); } if (isset($post['subject'])) { $data['title'] = $post['subject']; } if (isset($post['KOMENTO'])) { $data['comment'] = $post['KOMENTO']; } if (isset($post['delpass'])) { // get the password needed for the reply field if it's not set yet if (!$post['delpass'] || strlen($post['delpass']) < 3) { $post['delpass'] = Util::randomString(7); } $data['delpass'] = $post['delpass']; } if (isset($post['reply_spoiler'])) { $data['spoiler'] = true; } if (isset($post['reply_postas'])) { $data['capcode'] = $post['reply_postas']; } if (isset($post['recaptcha_challenge_field']) && isset($post['recaptcha_response_field'])) { $data['recaptcha_challenge'] = $post['recaptcha_challenge_field']; $data['recaptcha_response'] = $post['recaptcha_response_field']; } $media = null; if ($this->getRequest()->files->count()) { try { $media = $this->media_factory->forgeFromUpload($this->getRequest(), $this->radix); $media->spoiler = isset($data['spoiler']) && $data['spoiler']; } catch (\Foolz\Foolfuuka\Model\MediaUploadNoFileException $e) { $media = null; } catch (\Foolz\Foolfuuka\Model\MediaUploadException $e) { return $this->error($e->getMessage()); } } return $this->submit($data, $media); }
public function radix_submit() { // adapter if (!$this->getPost()) { return $this->error(_i('You aren\'t sending the required fields for creating a new message.')); } if (!$this->checkCsrfToken()) { if ($this->getRequest()->isXmlHttpRequest()) { return $this->response->setData(['error' => _i('The security token wasn\'t found. Try resubmitting.')]); } return $this->error(_i('The security token wasn\'t found. Try resubmitting.')); } // Determine if the invalid post fields are populated by bots. if (isset($post['name']) && mb_strlen($post['name'], 'utf-8') > 0) { return $this->error(); } if (isset($post['reply']) && mb_strlen($post['reply'], 'utf-8') > 0) { return $this->error(); } if (isset($post['email']) && mb_strlen($post['email'], 'utf-8') > 0) { return $this->error(); } $data = []; $post = $this->getPost(); if (isset($post['reply_numero'])) { $data['thread_num'] = $post['reply_numero']; } if (isset($post['reply_bokunonome'])) { $data['name'] = $post['reply_bokunonome']; $this->response->headers->setCookie(new Cookie($this->getContext(), 'reply_name', $data['name'], 60 * 60 * 24 * 30)); } if (isset($post['reply_elitterae'])) { $data['email'] = $post['reply_elitterae']; $this->response->headers->setCookie(new Cookie($this->getContext(), 'reply_email', $data['email'], 60 * 60 * 24 * 30)); } if (isset($post['reply_talkingde'])) { $data['title'] = $post['reply_talkingde']; } if (isset($post['reply_chennodiscursus'])) { $data['comment'] = $post['reply_chennodiscursus']; } if (isset($post['reply_nymphassword'])) { // get the password needed for the reply field if it's not set yet if (!$post['reply_nymphassword'] || strlen($post['reply_nymphassword']) < 3) { $post['reply_nymphassword'] = Util::randomString(7); } $data['delpass'] = $post['reply_nymphassword']; $this->response->headers->setCookie(new Cookie($this->getContext(), 'reply_password', $data['delpass'], 60 * 60 * 24 * 30)); } if (isset($post['reply_gattai_spoilered']) || isset($post['reply_spoiler'])) { $data['spoiler'] = true; } if (isset($post['reply_postas'])) { $data['capcode'] = $post['reply_postas']; } if (isset($post['reply_last_limit'])) { $data['last_limit'] = $post['reply_last_limit']; } if (isset($post['recaptcha_challenge_field']) && isset($post['recaptcha_response_field'])) { $data['recaptcha_challenge'] = $post['recaptcha_challenge_field']; $data['recaptcha_response'] = $post['recaptcha_response_field']; } $media = null; if ($this->getRequest()->files->count()) { try { $media = $this->media_factory->forgeFromUpload($this->getRequest(), $this->radix); $media->media->spoiler = isset($data['spoiler']) && $data['spoiler']; } catch (\Foolz\Foolfuuka\Model\MediaUploadNoFileException $e) { if ($this->getRequest()->isXmlHttpRequest()) { return $this->response->setData(['error' => $e->getMessage()]); } else { return $this->error($e->getMessage()); } } catch (\Foolz\Foolfuuka\Model\MediaUploadException $e) { if ($this->getRequest()->isXmlHttpRequest()) { return $this->response->setData(['error' => $e->getMessage()]); } else { return $this->error($e->getMessage()); } } } return $this->submit($data, $media); }
/** * Removes the release from disk and database * * @param int $id The ID of the series */ public function delete($id) { // this method is constructed so if any part fails, // executing this function again will continue the deletion process $dc = $this->dc; // we can't get around fetching the series data, we need it to delete the directory $release_bulk = $this->getById($id); $dir = DOCROOT . 'foolslide/series/' . $release_bulk->series->id . '/' . $release_bulk->release->id; if (file_exists($dir)) { Util::delete($dir); } // delete all the pages related to this chapter from the database $dc->qb()->delete($dc->p('pages'))->where('release_id = :release_id')->setParameter(':release_id', $id)->execute(); // delete the release from the database $dc->qb()->delete($dc->p('releases'))->where('id = :id')->setParameter(':id', $id)->execute(); }