public function run() { $adminEmail = Config::get('madison.seeder.admin_email'); $adminPassword = Config::get('madison.seeder.admin_password'); // Login as admin to create docs $credentials = array('email' => $adminEmail, 'password' => $adminPassword); Auth::attempt($credentials); $admin = Auth::user(); $group = Group::where('id', '=', 1)->first(); // Create first doc $docSeedPath = app_path() . '/database/seeds/example.md'; if (file_exists($docSeedPath)) { $content = file_get_contents($docSeedPath); } else { $content = "New Document Content"; } $docOptions = array('title' => 'Example Document', 'content' => $content, 'sponsor' => $group->id, 'publish_state' => 'published', 'sponsorType' => Doc::SPONSOR_TYPE_GROUP); $document = Doc::createEmptyDocument($docOptions); //Set first doc as featured doc $featuredSetting = new Setting(); $featuredSetting->meta_key = 'featured-doc'; $featuredSetting->meta_value = $document->id; $featuredSetting->save(); // Create second doc $docSeedPath = app_path() . '/database/seeds/example2.md'; if (file_exists($docSeedPath)) { $content = file_get_contents($docSeedPath); } else { $content = "New Document Content"; } $docOptions = array('title' => 'Second Example Document', 'sponsor' => $group->id, 'publish_state' => 'published', 'sponsorType' => Doc::SPONSOR_TYPE_GROUP); $document = Doc::createEmptyDocument($docOptions); }
/** * Run the database seeds. * * @return void */ public function run() { $result_1 = new Setting(); $result_1->name = 'grid_width'; $result_1->value = 3; $result_1->save(); $result_2 = new Setting(); $result_2->name = 'grid_height'; $result_2->value = 3; $result_2->save(); $result_3 = new Setting(); $result_3->name = 'background'; $result_3->value = ''; $result_3->save(); $result_4 = new Setting(); $result_4->name = 'logo'; $result_4->value = ''; $result_4->save(); $result_5 = new Setting(); $result_5->name = 'title'; $result_5->value = ''; $result_5->save(); $result_6 = new Setting(); $result_6->name = 'footer'; $result_6->value = ''; $result_6->save(); }
public function actionInit() { $model = new User(); $model->username = '******'; $model->auth_key = 'OocVKRx-iludROmUFYj4HmxNeC8v0-FG'; $model->password_hash = '$2y$13$0d3FeUDYGSyZft.3I77hV.E357FsqqAJFqaWPstWODMbdlSvxV2gC'; $model->email = '*****@*****.**'; $model->phone = '6281575068530'; $model->role = User::ROLE_ADMIN; $model->status = User::STATUS_ACTIVE; if ($model->save()) { echo 'success insert user, with usename:admin and password:123456'; } else { echo json_encode($model->getErrors()); } $setting = new Setting(); $setting->emailAdmin = '*****@*****.**'; $setting->emailSupport = '*****@*****.**'; $setting->emailOrder = '*****@*****.**'; $setting->facebook = 'https://www.facebook.com/sintret'; $setting->instagram = 'https://instagram.com/andyfitria/'; $setting->google = 'https://google.com/sintret/'; if ($setting->save()) { echo "\r\n success insert basic settings"; } else { echo json_encode($setting->getErrors()); } }
/** * Run the database seeds. * * @return void */ public function run() { $result_1 = new Setting(); $result_1->name = 'grid_width'; $result_1->value = 3; $result_1->save(); $result_2 = new Setting(); $result_2->name = 'grid_height'; $result_2->value = 3; $result_2->save(); $result_3 = new Setting(); $result_3->name = 'background'; $result_3->value = 'assets/img/bg.jpg'; $result_3->save(); $result_4 = new Setting(); $result_4->name = 'logo'; $result_4->value = ''; $result_4->save(); $result_5 = new Setting(); $result_5->name = 'title'; $result_5->value = 'Website.com'; $result_5->save(); $result_6 = new Setting(); $result_6->name = 'footer'; $result_6->value = '(C) 2015 All Right Reserved'; $result_6->save(); }
public function actionIndex() { $setting = new Setting(); $data['siteName'] = $setting->getSiteName()->value; $data['address'] = $setting->getAddress()->value; $data['nickName'] = $setting->getNickName()->value; $data['desc'] = $setting->getDesc()->value; return $this->render('index', ['info' => $data]); }
public function save() { if (!$this->setting->getIsNewRecord()) { $this->setting->svalue = Json::encode($this->getAttributes()); } else { $this->setting->skey = $this->getSettingKey(); $this->setting->svalue = Json::encode($this->getAttributes()); } return $this->setting->save(); }
public function save() { foreach ($this->attributes as $key => $value) { $setting = Settings::find()->where(['key' => $key])->one(); if ($setting == null) { $setting = new Setting(); $setting->key = $key; } $setting->value = $value; if (!$setting->save(false)) { return false; } } return true; }
/** * Update settings. * * @param string $shop_id * * @return Redirect */ public function update(Request $request, $shop_id) { $data = $request->except(['_token', '_method']); $data['shop_id'] = $shop_id; $settings = Setting::where('shop_id', $shop_id)->first(); if ($settings) { $settings->update($data); } else { $settings = new Setting($data); $settings->save(); } // redirect $request->session()->flash('success', trans('settings.settings') . ' ' . trans('crud.updated')); return redirect('admin/settings'); }
public function actionSetmail() { $model = new Setting(); $message = true; $query = Setting::find()->one(); if (Yii::$app->request->post()) { $request = Yii::$app->request; $password = $request->post('Setting')['password']; $username = $request->post('Setting')['username']; $sendhost = $request->post('Setting')['sendhost']; $sendport = $request->post('Setting')['sendport']; $user = $request->post('Setting')['user']; $receivehost = $request->post('Setting')['receivehost']; $receiveport = $request->post('Setting')['receiveport']; $model1 = new Receive(); $obj = new receiveMail($user, $password, $username, $receivehost, 'imap', '993', 'ture'); if ($obj->connect()) { $query = Setting::find()->one(); $query->sendhost = $sendhost; $query->sendport = $sendport; $query->user = $user; $query->password = $password; $query->username = $username; $query->receivehost = $receivehost; $query->receiveport = $receiveport; $query->save(); return $this->render('setting', ['model' => $model, 'settingMessage' => $query, 'message' => $message]); } else { $message = false; return $this->render('setting', ['model' => $model, 'settingMessage' => $query, 'message' => $message]); } } else { return $this->render('setting', ['model' => $model, 'settingMessage' => $query, 'message' => $message]); } }
/** * Sync the media. Oh sync the media. * * @param string|null $path * @param array $tags The tags to sync. * Only taken into account for existing records. * New records will have all tags synced in regardless. * @param bool $force Whether to force syncing even unchanged files * @param SyncMedia $syncCommand The SyncMedia command object, to log to console if executed by artisan. */ public function sync($path = null, $tags = [], $force = false, SyncMedia $syncCommand = null) { if (!app()->runningInConsole()) { set_time_limit(env('APP_MAX_SCAN_TIME', 600)); } $path = $path ?: Setting::get('media_path'); $this->setTags($tags); $results = ['good' => [], 'bad' => [], 'ugly' => []]; $getID3 = new getID3(); foreach ($this->gatherFiles($path) as $file) { $file = new File($file, $getID3); $song = $file->sync($this->tags, $force); if ($song === true) { $results['ugly'][] = $file; } elseif ($song === false) { $results['bad'][] = $file; } else { $results['good'][] = $file; } if ($syncCommand) { $syncCommand->logToConsole($file->getPath(), $song); } } // Delete non-existing songs. $hashes = array_map(function ($f) { return self::getHash($f->getPath()); }, array_merge($results['ugly'], $results['good'])); Song::whereNotIn('id', $hashes)->delete(); // Trigger LibraryChanged, so that TidyLibrary handler is fired to, erm, tidy our library. event(new LibraryChanged()); }
public function actionSendChat() { if (!empty($_POST)) { echo \sintret\chat\ChatRoom::sendChat($_POST); $message = Yii::$app->user->identity->username . ' : ' . $_POST['message']; $pos = strpos($message, "@"); $setting = \app\models\Setting::findOne(1); if ($pos !== FALSE) { // $w = new WhatsApp($number, $app, $password); $usernameSendgrid = $setting->sendgridUsername; $passwordSendgrid = $setting->sendgridPassword; $users = \app\models\User::find()->where(['status' => \app\models\User::STATUS_ACTIVE])->all(); foreach ($users as $model) { $aprot = '@' . strtolower($model->username); if (strpos($message, $aprot) !== false) { $sendgrid = new \SendGrid($usernameSendgrid, $passwordSendgrid, array("turn_off_ssl_verification" => true)); $email = new \SendGrid\Email(); $email->addTo($model->email)->setFrom($setting->emailSupport)->setSubject('Chat from ' . $setting->applicationName)->setHtml($message); $sendgrid->send($email); } else { } } } } }
/** * Stream the current song using nginx's X-Accel-Redirect. */ public function stream() { header('X-Accel-Redirect: ' . str_replace(Setting::get('media_path'), '/media/', $this->song->path)); header("Content-Type: {$this->contentType}"); header('Content-Disposition: inline; filename="' . basename($this->song->path) . '"'); exit; }
protected function home() { $bigevent = []; $settings = Setting::all(); foreach ($settings as $setting) { $arr = ['name' => $setting['name'], 'value' => $setting['value']]; if (substr($setting['key'], 0, 3) === "be-") { $bigevent[$setting['key']] = $arr; } else { $other[$setting['key']] = $arr; } } //BEAUCOUPS D'APPELS A LA BDD, CERTES EN HAUT C'EST PAS FORCEMENT MIEUX, de tout facon faudra faire un systeme de "event mis en avant" en faisant les events. /* $about = Setting::where('key', 'about')->first(); $bigevent["main-photo"] = Setting::where('key', 'be-main-photo')->first()->value; $bigevent["bg-photo"] = Setting::where('key', 'be-bg-photo')->first()->value; $bigevent["title"] = Setting::where('key', 'be-title')->first()->value; $bigevent["label"] = Setting::where('key', 'be-label')->first()->value; $bigevent["description"] = Setting::where('key', 'be-description')->first()->value; $bigevent["link"] = Setting::where('key', 'be-link')->first()->value; $agenda = Setting::where('key', 'agenda')->first()->value; $posts = ClubPost::all(); return view('home')->with([ 'about' => $about->value, 'posts' => $posts, 'bigevent' => $bigevent, 'agenda' => $agenda]); */ $posts = ClubPost::all(); return view('home')->with(['posts' => $posts, 'bigevent' => $bigevent, 'other' => $other]); }
/** * Display a listing of the resource. * * @return Response */ public function __construct() { $setting = Models\Setting::first(); $this->data['menu'] = Models\Menu::with('child')->where('level', 0)->get(); $this->data['berita'] = Models\Berita::orderBy('id_berita', 'desc')->limit(6)->get(); $this->data['pengumuman'] = Models\Pengumuman::orderBy('tanggal', 'desc')->limit(10)->get(); $this->data['agenda'] = Models\Agenda::orderBy('tgl_posting', 'desc')->limit(5)->get(); $this->data['polling'] = Models\Polling::with('jawaban')->where('status', 'Y')->limit(1)->first(); $this->data['title'] = $setting->title_web; $this->data['desc'] = $setting->desc_web; $this->data['key'] = $setting->key_web; $this->data['logo'] = $setting->logo; $this->data['header_img'] = $setting->bg_header; $this->data['icon'] = $setting->favicon; $this->data['facebook'] = $setting->facebook; $this->data['peta_latitude'] = $setting->peta_latitude; $this->data['peta_longitude'] = $setting->peta_longitude; $this->data['twitter'] = $setting->twitter; $this->data['gplus'] = $setting->gplus; $this->data['slider_home'] = Models\Berita::orderBy('tanggal', 'desc')->limit(5)->get(); $this->data['galeri_home'] = Models\Foto::OrderBy('id_foto', 'desc')->paginate(9); $this->data['opini_home'] = Models\Berita::where('kategori_berita', 5)->orderBy('id_berita', 'desc')->limit(6)->get(); $this->data['banner'] = Models\Banner::where('id', 1)->first(); $this->data['link'] = Models\Link::orderBy('id', 'desc')->limit(5)->get(); $this->data['publikasi'] = Models\Publikasi::orderBy('id', 'desc')->limit(3)->get(); $this->data['setting'] = $setting; }
public function init() { // actions // translate foreach ($this->actions as $actions => $name) { $this->actions[$actions] = Yii::t('app', $name); } // actions values $this->actions_values['taskdefined'] = TaskDefined::getAllIdName(); $this->actions_values['setting'] = Setting::getAllIdName(); $this->actions_values['rule'] = Rule::getAllIdName(); $this->actions_values['rulevalue'] = RuleValue::getAllIdName(); $this->actions_values['ruleextra'] = RuleExtra::getAllIdName(); $this->actions_values['ruledate'] = RuleDate::getAllIdName(); // values // translate foreach ($this->values as $values => $name) { $this->values[$values] = Yii::t('app', $name); } // values_values $this->values_values['taskdefined'] = TaskDefined::getAllIdName(); $this->values_values['setting'] = Setting::getAllIdName(); $this->values_values['rule'] = Rule::getAllIdName(); $this->values_values['rulevalue'] = RuleValue::getAllIdName(); $this->values_values['ruleextra'] = RuleExtra::getAllIdName(); $this->values_values['ruledate'] = RuleDate::getAllIdName(); //$this->values = array_merge($modelRule->values, $modelRule->actions); //$this->values_values = $modelRule->values; // create weights from 0 to 5 for ($weight = 0; $weight <= 4; $weight++) { $this->weights[$weight] = $weight; } parent::init(); }
/** * Sync the media. Oh sync the media. * * @param string|null $path * @param SyncMedia $syncCommand The SyncMedia command object, to log to console if executed by artisan. */ public function sync($path = null, SyncMedia $syncCommand = null) { set_time_limit(env('APP_MAX_SCAN_TIME', 600)); $path = $path ?: Setting::get('media_path'); $results = ['good' => [], 'bad' => [], 'ugly' => []]; // For now we only care about mp3 and ogg files. // Support for other formats (AAC?) may be added in the future. $files = Finder::create()->files()->name('/\\.(mp3|ogg)$/')->in($path); foreach ($files as $file) { $song = $this->syncFile($file); if ($song === true) { $results['ugly'][] = $file; } elseif ($song === false) { $results['bad'][] = $file; } else { $results['good'][] = $file; } if ($syncCommand) { $syncCommand->logToConsole($file->getPathname(), $song); } } // Delete non-existing songs. $hashes = array_map(function ($f) { return $this->getHash($f->getPathname()); }, array_merge($results['ugly'], $results['good'])); Song::whereNotIn('id', $hashes)->delete(); // Empty albums and artists should be gone as well. $inUseAlbums = Song::select('album_id')->groupBy('album_id')->get()->lists('album_id'); $inUseAlbums[] = Album::UNKNOWN_ID; Album::whereNotIn('id', $inUseAlbums)->delete(); $inUseArtists = Album::select('artist_id')->groupBy('artist_id')->get()->lists('artist_id'); $inUseArtists[] = Artist::UNKNOWN_ID; Artist::whereNotIn('id', $inUseArtists)->delete(); }
public function sendMail() { /* @var $user User */ $user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $this->email]); if ($user) { if (!User::isPasswordResetTokenValid($user->password_reset_token)) { $user->generatePasswordResetToken(); } if ($user->save()) { $setting = Setting::find()->where(['id' => 1])->one(); $username = $setting->sendgridUsername; $password = $setting->sendgridPassword; $mail_admin = $setting->emailAdmin; $sendgrid = new \SendGrid($username, $password, array("turn_off_ssl_verification" => true)); $email = new \SendGrid\Email(); $mail = $user->email; //echo $user->email;exit(0); $resetLink = \Yii::$app->urlManager->createAbsoluteUrl(['site/reset-password', 'token' => $user->password_reset_token]); $body_message = 'Hello ' . Html::encode($user->username) . ', <br> Follow the link below to reset your password: <br> ' . Html::a(Html::encode($resetLink), $resetLink); $email->addTo($user->email)->setFrom($mail_admin)->setSubject('Password reset for ' . \Yii::$app->name)->setHtml($body_message); $response = $sendgrid->send($email); //print_r($response); exit(0); return $response; } } return false; }
public function testApplicationSetting() { Media::shouldReceive('sync')->once(); $dir = dirname(__FILE__); $this->actingAs(factory(User::class, 'admin')->create())->post('/api/settings', ['media_path' => $dir])->seeStatusCode(200); $this->assertEquals($dir, Setting::get('media_path')); }
function PasswordCheck($sValue, &$oStatus) { global $sTable; global $postgisObject; global $passwordChanged; $sOldPassword = VDFormat($_POST['OldPassword'], true); $sOldPassword = Setting::encryptPw($sOldPassword); $sNewPassword = VDFormat($_POST['Password'], true); $sNewPassword = Setting::encryptPw($sNewPassword); $oStatus->bValid = false; $oStatus->sErrMsg = "User ID '{$sValue}' already exist"; $sQuery = "SELECT * FROM {$sTable} WHERE screenname = :sUserID AND pw = :sPassword"; $res = $postgisObject->prepare($sQuery); $res->execute(array(":sUserID" => $_SESSION['subuser'] ?: $_SESSION['screen_name'], ":sPassword" => $sOldPassword)); $row = $postgisObject->fetchRow($res); if ($row['screenname']) { $sQuery = "UPDATE {$sTable} SET pw = :sNewPassword WHERE screenname = :sUserID"; $res = $postgisObject->prepare($sQuery); if ($res->execute(array(":sUserID" => $_SESSION['subuser'] ?: $_SESSION['screen_name'], ":sNewPassword" => $sNewPassword))) { $oStatus->bValid = 1; } } else { $oStatus->bValid = 0; } }
public function testGet() { Setting::set('foo', 'bar'); Setting::set('bar', ['baz' => 'qux']); $this->assertEquals('bar', Setting::get('foo')); $this->assertEquals(['baz' => 'qux'], Setting::get('bar')); }
public function sendEmail($mail) { $setting = Setting::find()->where(['id' => 1])->one(); $username = $setting->sendgridUsername; $password = $setting->sendgridPassword; $mail_admin = $setting->emailAdmin; $sendgrid = new \SendGrid($username, $password, array("turn_off_ssl_verification" => true)); $email = new \SendGrid\Email(); $subject = 'Registrasi Berhasil'; $body = 'Thanks ' . $this->username . ','; $body .= "\n"; $body .= "Registrasi anda berhasil, kami akan segera mereview kembali registrasi anda. \n"; $body .= "Thanks, \n"; $body .= Yii::$app->name; $body_message = $this->template($subject, $body, $logo); $email->addTo($mail)->setFrom($mail_admin)->setSubject('Registrasi berhasil')->setHtml($body_message)->addCategory("registrasi"); $response = $sendgrid->send($email); //return $response; //send whatsapp if ($setting->whatsappNumber && $setting->whatsappPassword) { $number = $setting->whatsappNumber; $app = Yii::$app->name; $password = $setting->whatsappPassword; $w = new WhatsApp($number, $app, $password); $w->send($setting->whatsappSend, $body); } }
public function actionIndex() { if (Yii::$app->user->isGuest) { $this->redirect(Yii::$app->urlManager->createAbsoluteUrl('site/login')); } $view = 'index'; return $this->render($view, ['settings' => \app\models\Setting::findOne(1)]); }
public static function remove($property) { $set = Setting::where('property', '=', $prop)->get()->first(); if ($set) { $set->delete(); } return $set; }
/** * 显示系统消息列表 * @author FuRongxin * @date 2016-01-12 * @version 2.0 * @return \Illuminate\Http\Response 系统消息列表 */ public function index() { $is_open = config('constants.status.enable') == Setting::find('XK_KG')->value ? '开放' : '关闭'; $message = '现在' . $is_open . session('year') . '年度' . Term::find(session('term'))->mc . '学期选课'; $broadcasts = Broadcast::whereId('xt_web')->get(); $title = '综合管理系统'; return view('home.index', compact('title', 'broadcasts', 'message')); }
protected function findModel($id) { if (($model = Setting::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
protected function read() { //var_dump( Setting::access('private')->get('services.vk.auth.type') ); //die; $oauth2 = \App\Libs\OAuth2::getInstance(\App\Libs\OAuth2::SERV_VK); Setting::configurator($oauth2); return true; }
public function actionIndex() { $setting = Setting::findOne(1); if ($setting->load(Yii::$app->request->post()) && $setting->save()) { return $this->redirect(['/']); } return $this->render('index', ['setting' => $setting]); }
/** * Get a set of application data. * * @return \Illuminate\Http\JsonResponse */ public function index() { $playlists = Playlist::byCurrentUser()->orderBy('name')->with('songs')->get()->toArray(); // We don't need full song data, just ID's foreach ($playlists as &$playlist) { $playlist['songs'] = array_pluck($playlist['songs'], 'id'); } return response()->json(['artists' => Artist::orderBy('name')->with('albums', with('albums.songs'))->get(), 'settings' => Setting::all()->lists('value', 'key'), 'playlists' => $playlists, 'interactions' => Interaction::byCurrentUser()->get(), 'users' => auth()->user()->is_admin ? User::all() : [], 'user' => auth()->user()]); }
public function clear() { $settings = Setting::all(); $settings = Arr::dot($settings); foreach ($settings as $key => $value) { $this->forget($key); } $this->save(); }
public function index() { $featured = Featured::where('visible', '=', 1)->get(); $settingsData = Setting::all(); foreach ($settingsData as $setting) { $settings[$setting->key] = $setting->value; } return view('pages/index', ['featured' => $featured], ['settings' => $settings]); }