/** * @Route("/", methods="POST") * @Route("/{id}", methods="POST", requirements={"id"="\d+"}) * @Request({"submission": "array", "id": "int", "g-recaptcha-response": "string"}, csrf=true) */ public function saveAction($data, $id = 0, $gRecaptchaResponse = '') { if (!($submission = Submission::find($id))) { $submission = Submission::create(); unset($data['id']); $submission->form_id = $data['form_id']; $submission->created = new \DateTime(); $submission->ip = App::request()->getClientIp(); } unset($data['created']); if (!($form = Form::find($submission->form_id))) { App::abort(404, 'Form not found.'); } $submission->form = $form; if ($form->get('recaptcha') && $id == 0) { $resp = (new ReCaptcha(App::module('formmaker')->config('recaptha_secret_key')))->verify($gRecaptchaResponse, App::request()->server->get('REMOTE_ADDR')); if (!$resp->isSuccess()) { $errors = $resp->getErrorCodes(); App::abort(403, $errors[0]); } } $submission->save($data); $submission->email = $submission->getUserEmail(); if ($id == 0 && $submission->email) { try { (new MailHelper($submission))->sendMail(); $submission->save(); } catch (Exception $e) { App::abort(400, $e->getMessage()); } } return ['message' => 'Submission successfull', 'submission' => $submission]; }
/** * @Route("/", methods="GET") * @Request({"filter": "array", "page":"int"}) */ public function indexAction($filter = [], $page = 0) { $query = Post::query(); $filter = array_merge(array_fill_keys(['status', 'search', 'author', 'order', 'limit'], ''), $filter); extract($filter, EXTR_SKIP); if (!App::user()->hasAccess('blog: manage all posts')) { $author = App::user()->id; } if (is_numeric($status)) { $query->where(['status' => (int) $status]); } if ($search) { $query->where(function ($query) use($search) { $query->orWhere(['title LIKE :search', 'slug LIKE :search'], ['search' => "%{$search}%"]); }); } if ($author) { $query->where(function ($query) use($author) { $query->orWhere(['user_id' => (int) $author]); }); } if (!preg_match('/^(date|title|comment_count)\\s(asc|desc)$/i', $order, $order)) { $order = [1 => 'date', 2 => 'desc']; } $limit = (int) $limit ?: App::module('blog')->config('posts.posts_per_page'); $count = $query->count(); $pages = ceil($count / $limit); $page = max(0, min($pages - 1, $page)); $posts = array_values($query->offset($page * $limit)->related('user', 'comments')->limit($limit)->orderBy($order[1], $order[2])->get()); return compact('posts', 'pages', 'count'); }
/** * @Route("/", methods="GET") * @Request({"filter": "array", "page":"int"}) */ public function indexAction($filter = [], $page = 0) { $query = File::query()->select('f.*')->from('@download_file f'); $filter = array_merge(array_fill_keys(['status', 'category_id', 'search', 'order', 'limit'], ''), $filter); extract($filter, EXTR_SKIP); if ($search) { $query->where(function ($query) use($search) { $query->orWhere(['title LIKE :search'], ['search' => "%{$search}%"]); }); } if (is_numeric($status)) { $query->where(['status' => (int) $status]); } if (is_numeric($category_id)) { $query->select('x.catordering')->innerJoin('@download_files_categories x', 'x.file_id = f.id')->where(['x.category_id' => (int) $category_id]); } if (!preg_match('/^(date|downloads|title)\\s(asc|desc)$/i', $order, $order)) { $order = [1 => 'date', 2 => 'desc']; } $limit = (int) $limit ?: App::module('bixie/download')->config('files_per_page'); $count = $query->count(); $pages = ceil($count / $limit); $page = max(0, min($pages - 1, $page)); $files = array_values($query->related('categories')->offset($page * $limit)->limit($limit)->orderBy($order[1], $order[2])->get()); return compact('files', 'pages', 'count'); }
protected static function getFormat($format) { $intl = App::module('system/intl'); $formats = $intl->getFormats($intl->getLocale()); $moment_format = isset($formats['DATETIME_FORMATS'][$format]) ? $formats['DATETIME_FORMATS'][$format] : $format; return strtr($moment_format, static::$intl2php); }
public function __construct() { $config = App::module('shoutzor')->config(); $this->enabled = $config['acoustid']['enabled'] == 1; $this->appKey = $config['acoustid']['appKey']; $this->requirementDir = realpath($config['root_path'] . '/../shoutzor-requirements/acoustid'); }
public function getRandomTrack($autoForce = true, $forced = false) { if ($forced === true) { return Media::query()->orderBy('rand()')->first(); } else { $list = array(); } $config = App::module('shoutzor')->config('shoutzor'); $requestHistoryTime = (new DateTime())->sub(new DateInterval('PT' . $config['mediaRequestDelay'] . 'M'))->format('Y-m-d H:i:s'); $artistHistoryTime = (new DateTime())->sub(new DateInterval('PT' . $config['artistRequestDelay'] . 'M'))->format('Y-m-d H:i:s'); //Build a list of media id's that are available to play, next, randomly pick one $q = Media::query()->select('DISTINCT m.*')->from('@shoutzor_media m')->leftJoin('@shoutzor_requestlist q', 'q.media_id = m.id')->where('q.media_id IS NULL')->where('m.id NOT IN ( SELECT h.media_id FROM @shoutzor_history h LEFT JOIN @shoutzor_requestlist tq ON tq.media_id = h.media_id WHERE h.played_at > :maxTime )', ['maxTime' => $requestHistoryTime])->where('m.id NOT IN ( SELECT tma.media_id FROM @shoutzor_media_artist tma WHERE tma.artist_id IN ( SELECT ma.artist_id FROM @shoutzor_media_artist ma WHERE ma.media_id IN ( SELECT th.media_id FROM @shoutzor_history th LEFT JOIN @shoutzor_requestlist tq ON tq.media_id = th.media_id WHERE th.played_at > :maxTime ) ) )', ['maxTime' => $artistHistoryTime])->groupBy('m.id')->orderBy('rand(' . microtime(true) . ')'); if ($q->count() === 0) { return $autoForce === true ? $this->getRandomTrack(true, true) : false; } return $q->first(); }
public function __construct() { $config = App::module('shoutzor')->config('lastfm'); $this->enabled = $config['enabled'] == 1; $this->appKey = $config['apikey']; $this->secret = $config['secret']; }
/** * @Route("/", name="index") */ public function indexAction() { $config = App::module('shoutzor')->config('liquidsoap'); $liquidsoapManager = new LiquidsoapManager(); $wrapperActive = $liquidsoapManager->isUp('wrapper'); $shoutzorActive = $liquidsoapManager->isUp('shoutzor'); $form = new FormGenerator('', 'POST', 'uk-form uk-form-horizontal'); $form->addField(new DivField("Permission Check", $config['logDirectoryPath'] . (is_writable($config['logDirectoryPath']) ? " is writable" : " is not writable! chown manually to www-data:www-data"), "", is_writable($config['logDirectoryPath']) ? "uk-alert uk-alert-success" : "uk-alert uk-alert-danger")); //Usually the log directory and the socket directory will be the same //Thus, showing twice that the same directory is (not) writable has no use if ($config['logDirectoryPath'] != $config['socketPath']) { $form->addField(new DivField("Permission Check", $config['socketPath'] . (is_writable($config['socketPath']) ? " is writable" : " is not writable! chown manually to www-data:www-data"), "", is_writable($config['socketPath']) ? "uk-alert uk-alert-success" : "uk-alert uk-alert-danger")); } $form->addField(new DivField("Permission Check", $liquidsoapManager->getPidFileDirectory() . (is_writable($liquidsoapManager->getPidFileDirectory()) ? " is writable" : " is not writable! chown manually to liquidsoap:www-data"), "", is_writable($liquidsoapManager->getPidFileDirectory()) ? "uk-alert uk-alert-success" : "uk-alert uk-alert-danger")); $form->addField(new DividerField()); $form->addField(new InputField("wrapperToggle", "wrapperToggle", $wrapperActive ? "Deactivate Wrapper" : "Activate Wrapper", "button", $wrapperActive ? "Deactivate Wrapper" : "Activate Wrapper", "(De)activates the wrapper liquidsoap script", $wrapperActive ? "uk-button uk-button-danger" : "uk-button uk-button-primary", 'data-status="' . ($wrapperActive ? 'started' : 'stopped') . '"'))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); if ($wrapperActive === false) { $form->setError("The wrapper script is not activated!"); } else { $form->setSuccess("The wrapper script is up and running!"); } $form->addField(new InputField("shoutzorToggle", "shoutzorToggle", $shoutzorActive ? "Deactivate Shoutzor" : "Activate Shoutzor", "button", $shoutzorActive ? "Deactivate Shoutzor" : "Activate Shoutzor", "(De)activates the shoutzor liquidsoap script", $shoutzorActive ? "uk-button uk-button-danger" : "uk-button uk-button-primary", 'data-status="' . ($wrapperActive ? 'started' : 'stopped') . '"'))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY)); if ($shoutzorActive === false) { if ($wrapperActive === false) { $form->setError("The wrapper script needs to be activated first!"); } else { $form->setError("The shoutzor script is not activated!"); } } else { $form->setSuccess("The shoutzor script is up and running!"); } $content = $form->render(); return ['$view' => ['title' => __('Shoutzor System'), 'name' => 'shoutzor:views/admin/system.php'], 'form' => $content]; }
/** * @Route("/edit") * @Request({"id"}) */ public function editAction($id = '') { /** @var \Bixie\Formmaker\FormmakerModule $formmaker */ $formmaker = App::module('bixie/formmaker'); if (is_numeric($id)) { $field = Field::find($id); } else { $field = Field::create(); $field->setFieldType($id); } if (!$field) { App::abort(404, __('Field not found.')); } if (!($type = $formmaker->getFieldType($field->type))) { App::abort(404, __('Type not found.')); } //default values $fixedFields = ['multiple', 'required']; if (!$field->id) { foreach ($type->getConfig() as $key => $value) { if (!in_array($key, $fixedFields)) { $field->set($key, $value); } } } //check fixed value foreach ($fixedFields as $key) { if ($type[$key] != -1) { $field->set($key, $type[$key]); } } return ['field' => $field, 'type' => $type, 'roles' => array_values(Role::findAll())]; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { if (!in_array($this->option('db-driver'), ['mysql', 'sqlite'])) { $this->error("Unsupported db driver."); exit; } $this->line("Setting up Pagekit installation..."); $app = $this->container; App::module('session')->config['storage'] = 'array'; $app->boot(); $app['module']->load('installer'); $installer = new Installer($app); $dbDriver = $this->option('db-driver'); $config = ['locale' => $this->option('locale'), 'database' => ['default' => $dbDriver, 'connections' => [$dbDriver => ['dbname' => $this->option('db-name'), 'host' => $this->option('db-host'), 'user' => $this->option('db-user'), 'password' => $this->option('db-pass'), 'prefix' => $this->option('db-prefix')]]]]; $user = ['username' => $this->option('username'), 'password' => $this->option('password'), 'email' => $this->option('mail')]; $options = ['system' => ['site' => ['locale' => $this->option('locale')], 'admin' => ['locale' => $this->option('locale')]], 'system/site' => ['title' => $this->option('title')]]; $result = $installer->install($config, $options, $user); $status = $result['status']; $message = $result['message']; if ($status == 'success') { $this->line("Done"); } else { $this->error($message); } }
/** * @Request({"email": "string"}) */ public function requestAction($email) { try { if (App::user()->isAuthenticated()) { return App::redirect(); } if (!App::csrf()->validate()) { throw new Exception(__('Invalid token. Please try again.')); } if (empty($email)) { throw new Exception(__('Enter a valid email address.')); } if (!($user = User::findByEmail($email))) { throw new Exception(__('Unknown email address.')); } if ($user->isBlocked()) { throw new Exception(__('Your account has not been activated or is blocked.')); } $user->activation = App::get('auth.random')->generateString(32); $url = App::url('@user/resetpassword/confirm', ['user' => $user->username, 'key' => $user->activation], 0); try { $mail = App::mailer()->create(); $mail->setTo($user->email)->setSubject(__('Reset password for %site%.', ['%site%' => App::module('system/site')->config('title')]))->setBody(App::view('system/user:mails/reset.php', compact('user', 'url', 'mail')), 'text/html')->send(); } catch (\Exception $e) { throw new Exception(__('Unable to send confirmation link.')); } $user->save(); return ['message' => __('Check your email for the confirmation link.')]; } catch (Exception $e) { App::abort(400, $e->getMessage()); } }
/** * Registers node routes */ public function onRequest() { $site = App::module('system/site'); $frontpage = $site->config('frontpage'); $nodes = Node::findAll(true); uasort($nodes, function ($a, $b) { return strcmp(substr_count($a->path, '/'), substr_count($b->path, '/')) * -1; }); foreach ($nodes as $node) { if ($node->status !== 1 || !($type = $site->getType($node->type))) { continue; } $type = array_replace(['alias' => '', 'redirect' => '', 'controller' => ''], $type); $type['defaults'] = array_merge(isset($type['defaults']) ? $type['defaults'] : [], $node->get('defaults', []), ['_node' => $node->id]); $type['path'] = $node->path; $route = null; if ($node->get('alias')) { App::routes()->alias($node->path, $node->link, $type['defaults']); } elseif ($node->get('redirect')) { App::routes()->redirect($node->path, $node->get('redirect'), $type['defaults']); } elseif ($type['controller']) { App::routes()->add($type); } if (!$frontpage && isset($type['frontpage']) && $type['frontpage']) { $frontpage = $node->id; } } if ($frontpage && isset($nodes[$frontpage])) { App::routes()->alias('/', $nodes[$frontpage]->link); } else { App::routes()->get('/', function () { return __('No Frontpage assigned.'); }); } }
/** * @return \Bixie\Framework\FieldType\FieldTypeBase */ public function getFieldType() { if (!isset($this->fieldType)) { $this->fieldType = App::module('bixie/framework')->getFieldType($this->field->type); } return $this->fieldType; }
/** * @Saving */ public static function saving($event, Field $field) { $userprofile = App::module('bixie/userprofile'); if (!($type = $userprofile->getFieldType($field->type))) { throw new Exception(__('Field type not found.')); } foreach (['multiple', 'required'] as $key) { if ($type[$key] != -1) { //check fixed value if ($type[$key] != $field->get($key)) { throw new Exception(__('Invalid value for ' . $key . ' option.')); } } } //slug $i = 2; $id = $field->id; if (!$field->slug) { $field->slug = $field->label; } while (self::where(['slug = ?'], [$field->slug])->where(function ($query) use($id) { if ($id) { $query->where('id <> ?', [$id]); } })->first()) { $field->slug = preg_replace('/-\\d+$/', '', $field->slug) . '-' . $i++; } if (!$field->id) { $next = self::getConnection()->fetchColumn('SELECT MAX(priority) + 1 FROM @userprofile_field'); $field->priority = $next ?: 0; } }
/** * @return array */ public function getFieldTypes($extension = null) { //todo cache this if (!$this->fieldTypes) { $this->fieldTypes = []; /** @noinspection PhpUnusedLocalVariableInspection */ $app = App::getInstance(); //available for index.php files $paths = []; foreach (App::module() as $module) { if ($module->get('fieldtypes')) { $paths = array_merge($paths, glob(sprintf('%s/%s/*/index.php', $module->path, $module->get('fieldtypes')), GLOB_NOSORT) ?: []); } } foreach ($paths as $p) { $package = array_merge(['id' => '', 'path' => dirname($p), 'main' => '', 'extensions' => $this->fieldExtensions, 'class' => '\\Bixie\\Framework\\FieldType\\FieldType', 'resource' => 'bixie/framework:app/bundle', 'config' => ['hasOptions' => 0, 'readonlyOptions' => 0, 'required' => 0, 'multiple' => 0], 'dependancies' => [], 'styles' => [], 'getOptions' => '', 'prepareValue' => '', 'formatValue' => ''], include $p); $this->registerFieldType($package); } } if ($extension) { return array_filter($this->fieldTypes, function ($fieldType) use($extension) { /** @var FieldTypeBase $fieldType */ return in_array($extension, $fieldType->getExtensions()); }); } return $this->fieldTypes; }
/** * @Route("/", methods="GET") * @Request({"filter": "array", "page":"int", "limit":"int"}) */ public function indexAction($filter = [], $page = 0, $limit = 0) { $query = User::query(); $filter = array_merge(array_fill_keys(['status', 'search', 'role', 'order', 'access'], ''), $filter); extract($filter, EXTR_SKIP); if (is_numeric($status)) { $query->where(['status' => (int) $status]); if ($status) { $query->where('access IS NOT NULL'); } } elseif ('new' == $status) { $query->where(['status' => User::STATUS_ACTIVE, 'access IS NULL']); } if ($search) { $query->where(function ($query) use($search) { $query->orWhere(['username LIKE :search', 'name LIKE :search', 'email LIKE :search'], ['search' => "%{$search}%"]); }); } if ($role) { $query->whereInSet('roles', $role); } if ($access) { $query->where('access > ?', [date('Y-m-d H:i:s', time() - max(0, (int) $access))]); } if (!preg_match('/^(username|name|email)\\s(asc|desc)$/i', $order, $order)) { $order = [1 => 'username', 2 => 'asc']; } $default = App::module('system/user')->config('users_per_page'); $limit = min(max(0, $limit), $default) ?: $default; $count = $query->count(); $pages = ceil($count / $limit); $page = max(0, min($pages - 1, $page)); $users = array_values($query->offset($page * $limit)->limit($limit)->orderBy($order[1], $order[2])->get()); return compact('users', 'pages', 'count'); }
/** * @param File $file * @return mixed */ public static function getNext($file) { $module = App::module('bixie/download'); return self::where(['title < ?', 'status = ?'], [$file->title, '1'])->where(function ($query) { return $query->where('roles IS NULL')->whereInSet('roles', App::user()->roles, false, 'OR'); })->orderBy($module->config('ordering'), $module->config('ordering_dir'))->first(); }
/** * @Route("/", methods="GET") * @Request({"filter": "array", "post":"int", "page":"int", "limit":"int"}) */ public function indexAction($filter = [], $post = 0, $page = 0, $limit = 0) { $query = Comment::query(); $filter = array_merge(array_fill_keys(['status', 'search', 'order'], ''), $filter); extract($filter, EXTR_SKIP); if ($post) { $query->where(['post_id = ?'], [$post]); } elseif (!$this->user->hasAccess('blog: manage comments')) { App::abort(403, __('Insufficient user rights.')); } if (!$this->user->hasAccess('blog: manage comments')) { $query->where(['status = ?'], [Comment::STATUS_APPROVED]); if ($this->user->isAuthenticated()) { $query->orWhere(function ($query) { $query->where(['status = ?', 'user_id = ?'], [Comment::STATUS_PENDING, App::user()->id]); }); } } elseif (is_numeric($status)) { $query->where(['status = ?'], [(int) $status]); } else { $query->where(function ($query) { $query->orWhere(['status = ?', 'status = ?'], [Comment::STATUS_APPROVED, Comment::STATUS_PENDING]); }); } if ($search) { $query->where(function ($query) use($search) { $query->orWhere(['author LIKE ?', 'email LIKE ?', 'url LIKE ?', 'ip LIKE ?', 'content LIKE ?'], array_fill(0, 5, "%{$search}%")); }); } $count = $query->count(); $pages = ceil($count / ($limit ?: PHP_INT_MAX)); $page = max(0, min($pages - 1, $page)); if ($limit) { $query->offset($page * $limit)->limit($limit); } if (preg_match('/^(created)\\s(asc|desc)$/i', $order, $match)) { $order = $match; } else { $order = [1 => 'created', 2 => App::module('blog')->config('comments.order')]; } $comments = $query->related(['post' => function ($query) { return $query->related('comments'); }])->related('user')->orderBy($order[1], $order[2])->get(); $posts = []; foreach ($comments as $i => $comment) { $p = $comment->post; if ($post && (!$p || !$p->hasAccess($this->user) || !($p->isPublished() || $this->user->hasAccess('blog: manage comments')))) { App::abort(403, __('Post not found.')); } $comment->content = App::content()->applyPlugins($comment->content, ['comment' => true]); $posts[$p->id] = $p; $comment->special = count(array_diff($comment->user ? $comment->user->roles : [], [0, 1, 2])); $comment->post = null; $comment->user = null; } $comments = array_values($comments); $posts = array_values($posts); return compact('comments', 'posts', 'pages', 'count'); }
/** * @Route("/uploadmanager", name="uploadmanager", methods="GET") */ public function uploadManagerAction() { if ($this->requireLogin()) { return App::response()->redirect('@user/login'); } $uploads = Media::where(['uploader_id = :uploader AND status != :finished'], ['uploader' => App::user()->id, 'finished' => Media::STATUS_FINISHED])->orderBy('created', 'DESC')->related(['artist', 'user'])->get(); return ['$view' => ['title' => __('Upload Manager'), 'name' => 'shoutzor:views/uploadmanager.php'], 'uploads' => $uploads, 'maxFileSize' => $this->formatBytes($this->file_upload_max_size()), 'maxDuration' => App::module('shoutzor')->config('shoutzor')['uploadDurationLimit']]; }
/** * Fieldsubmission constructor. * @param FieldBase $field * @param array $data */ public function __construct(FieldBase $field, $data) { parent::__construct($field, $data); if (!$this->fieldType) { //default text field for inactive/deleted fieldtypes $this->fieldType = App::module('bixie/framework')->getFieldType('text'); } }
/** * Prepare default value before displaying form * @return array */ public function prepareValue() { $value = $this->get('value'); $type = App::module('formmaker')->getType($this->type); if (is_callable($type['prepareValue'])) { return call_user_func($type['prepareValue'], $this, $value); } return $value; }
/** * registration override page * @Route("/registration") */ public function registrationAction() { $user = App::user(); $userprofile = App::module('bixie/userprofile'); if ($user->isAuthenticated()) { return App::redirect('@userprofile'); } return ['$view' => ['title' => __('User registration'), 'name' => 'bixie/userprofile/registration.php'], '$data' => ['config' => $userprofile->config(), 'user' => ['id' => null, 'username' => '', 'name' => '', 'email' => '']]]; }
/** * @Access("userprofile: view profiles") * @Route("/{id}", methods="GET", name="id") * @Request({"id": "int"}) */ public function detailsAction($id) { if (!($user = App::auth()->getUserProvider()->find((int) $id)) or !($profileUser = ProfileUser::load($user))) { App::abort(404, __('User not found.')); } if ($breadcrumbs = App::module('bixie/breadcrumbs')) { $breadcrumbs->addUrl(['title' => $user->name, 'url' => '']); } return ['$view' => ['title' => __('User Profile'), 'name' => 'bixie/userprofile/profile-details.php'], '$data' => [], 'config' => App::module('bixie/userprofile')->config(), 'profileUser' => $profileUser, 'node' => App::node()]; }
/** * @Route(defaults={"_maintenance"=true}) * @Request({"redirect"}) */ public function loginAction($redirect = '') { if (App::user()->isAuthenticated()) { $module = App::module('system/user'); $url = App::url($module->config['login_redirect']); return App::redirect($url); } return self::loginView(['last_username' => App::session()->get(Auth::LAST_USERNAME), 'redirect' => $redirect]); return ['$view' => ['title' => __('Login'), 'name' => 'system/user/login.php'], 'last_username' => App::session()->get(Auth::LAST_USERNAME), 'redirect' => $redirect]; }
/** * {@inheritdoc} */ public function main(App $app) { if (!in_array('bixie/framework', App::system()->config('extensions'))) { throw new \RuntimeException('Bixie Framework required for Formmaker'); } $app->on('boot', function () { $this->framework = App::module('bixie/framework'); }); $app->subscribe(new FormmakerPlugin()); }
/** * @Route("/edit", name="edit") * @Request({"id": "int"}) */ public function editAction($id = 0) { $formmaker = App::module('formmaker'); if (!($form = Form::find($id))) { $form = Form::create(); } if (!$form) { throw new NotFoundException(__('Form not found.')); } return ['$view' => ['title' => __('Form'), 'name' => 'formmaker:views/admin/edit.php'], '$data' => ['config' => $formmaker->config(), 'types' => $formmaker->getTypes(), 'formitem' => $form]]; }
/** * Note: If the mailer is accessed prior to this controller action, this will possibly test the wrong mailer * * @Request({"option": "array"}, csrf=true) */ public function emailAction($option = []) { try { $config = Arr::merge(App::module('system/mail')->config(), $option); $response['success'] = (bool) App::mailer()->create(__('Test email!'), __('Testemail'), $config['from_address'])->send(); $response['message'] = $response['success'] ? __('Mail successfully sent!') : __('Mail delivery failed!'); } catch (\Exception $e) { $response = ['success' => false, 'message' => sprintf(__('Mail delivery failed! (%s)'), $e->getMessage())]; } return $response; }
/** * @Route("/{id}", name="view", requirements={"id"="\d+"}) */ public function viewAction($id) { $artist = Artist::query()->where('id = ?', [$id])->related('album')->first(); $request = App::request(); if (is_null($artist)) { $request->getSession()->getFlashBag()->add('error', __('Tried to view an non-existing Artist')); return App::response()->redirect('@shoutzor/artist/index'); } $topTracks = $artist->getTopMedia(); return ['$view' => ['title' => 'Artist: ' . $artist->name, 'name' => 'shoutzor:views/artist/view.php'], 'image' => is_null($artist->image) || empty($artist->image) ? App::url()->getStatic('shoutzor:assets/images/profile-placeholder.png') : App::url()->getStatic('shoutzor:' . App::module('shoutzor')->config('shoutzor')['imageDir'] . '/' . $artist->image), 'summary' => empty($artist->summary) ? __('No summary for this artist is available') : $artist->summary, 'artist' => $artist, 'topTracks' => $topTracks, 'albums' => $artist->getAlbums()]; }
/** * @Request({"token": "string", "amount": "integer", "description": "string"}, csrf=true) */ public function chargeCardAction($token, $amount, $desciption) { $module = App::module('tipbutton'); $config = $module->config; \Stripe\Stripe::setApiKey($config["stripe_settings"]["private_key"]); try { $charge = \Stripe\Charge::create(array("amount" => $amount, "currency" => "eur", "source" => $token, "description" => $desciption)); } catch (\Stripe\Error\Card $e) { // The card has been declined } }
/** * @Route("/", name="index") */ public function indexAction() { $config = App::module('shoutzor')->config('liquidsoap'); $liquidsoapManager = new LiquidsoapManager(); $wrapperActive = $liquidsoapManager->isUp('wrapper'); $shoutzorActive = $liquidsoapManager->isUp('shoutzor'); $form = new FormGenerator('', 'POST', 'uk-form uk-form-horizontal'); $form->addField(new InputField("skipTrack", "skipTrack", "Skip Track", "button", "Skip Track", "Sends the "skip track" command", "uk-button uk-button-primary")); $content = $form->render(); return ['$view' => ['title' => __('Shoutzor Controls'), 'name' => 'shoutzor:views/admin/controls.php'], 'form' => $content]; }