本文整理汇总了PHP中app\models\Setting::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Setting::find方法的具体用法?PHP Setting::find怎么用?PHP Setting::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Setting
的用法示例。
在下文中一共展示了Setting::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionSetmail
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]);
}
}
示例2: sendEmail
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);
}
}
示例3: sendMail
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;
}
示例4: index
/**
* 显示系统消息列表
* @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'));
}
示例5: actionIndex
public function actionIndex()
{
$message = true;
$model = new mail();
if ($model->load(Yii::$app->request->post())) {
$mailaccount = Setting::find()->one();
$sendhost = $mailaccount->sendhost;
$username = $mailaccount->username;
$user = $mailaccount->user;
$password = $mailaccount->password;
error_reporting(E_ALL ^ E_WARNING);
$request = Yii::$app->request;
$body = $request->post();
$to = $model->receiver;
$subject = $model->subject;
$model->file = UploadedFile::getInstance($model, 'file');
if ($model->file != null) {
$filename = $model->file->name;
$encode = mb_detect_encoding($filename, array("ASCII", "UTF-8", "GBK", "GB2312"));
if ($encode == "EUC-CN") {
$encode = "GB2312";
}
if ($encode != "GBK") {
$filename = iconv($encode, "GBK//IGNORE", $filename);
}
echo $filename . "before save" . "</br>";
if ($model->file->saveAs('c:/sendattachment/' . $filename)) {
$mail = new sendmail();
//新建发送
$mail->setServer($sendhost, $user, $password);
$mail->setFrom($username);
$mail->setReceiver("{$to}");
$mail->setMailInfo($subject, $body['body'], 'c:/sendattachment/' . $filename);
$message = true;
if (!$mail->sendMail()) {
$message = false;
}
return $this->render('index', ['model' => $model, 'message' => $message]);
}
} else {
$mail = new sendmail();
//新建发送
$mail->setServer($sendhost, $user, $password);
$mail->setFrom($username);
$mail->setReceiver("{$to}");
$mail->setMailInfo($subject, $body['body'], "");
if (!$mail->sendMail()) {
$message = false;
}
return $this->render('index', ['model' => $model, 'message' => $message]);
}
} else {
return $this->render('index', ['model' => $model]);
}
}
示例6: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Setting::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'userCreate' => $this->userCreate, 'userUpdate' => $this->userUpdate, 'createDate' => $this->createDate, 'updateDate' => $this->updateDate]);
$query->andFilterWhere(['like', 'emailAdmin', $this->emailAdmin])->andFilterWhere(['like', 'emailSupport', $this->emailSupport])->andFilterWhere(['like', 'emailOrder', $this->emailOrder])->andFilterWhere(['like', 'sendgridUsername', $this->sendgridUsername])->andFilterWhere(['like', 'sendgridPassword', $this->sendgridPassword])->andFilterWhere(['like', 'whatsappNumber', $this->whatsappNumber])->andFilterWhere(['like', 'whatsappPassword', $this->whatsappPassword])->andFilterWhere(['like', 'facebook', $this->facebook])->andFilterWhere(['like', 'instagram', $this->instagram])->andFilterWhere(['like', 'google', $this->google])->andFilterWhere(['like', 'twitter', $this->twitter])->andFilterWhere(['like', 'privacyPolicy', $this->privacyPolicy])->andFilterWhere(['like', 'terms', $this->terms])->andFilterWhere(['like', 'legalNotice', $this->legalNotice]);
return $dataProvider;
}
示例7: putUpdate
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function putUpdate(Request $request, $id)
{
$input = $request->all();
$setting = Setting::find($id);
$setting->is_open = $input['is_open'];
if ($setting->save()) {
return redirect('setting/edit')->with('status', '系统设置成功');
} else {
return back()->withErrors('系统设置失败');
}
}
示例8: actionTest
public function actionTest()
{
$setting = \app\models\Setting::find()->where(['id' => 1])->one();
$number = $setting->whatsappNumber;
$app = 'Sintret Projects';
$password = $setting->whatsappPassword;
$w = new WhatsApp($number, $app, $password);
$message = 'this is just test again @sintret oke';
$w = new WhatsApp($number, $app, $password);
echo $w->send($phone, $message);
}
示例9: handle
/**
* Handle the event.
*
* @param Login $event
* @return void
*/
public function handle(Login $event)
{
if (!Fresh::whereXh(Auth::user()->xh)->exists()) {
if (!Profile::whereXh(Auth::user()->xh)->whereXjzt(config('constants.school.student'))->exists()) {
Auth::logout();
return back()->withInput()->withStatus('不是在校生,请不要登录系统');
}
}
session(['year' => Setting::find('XK_ND')->value, 'term' => Setting::find('XK_XQ')->value, 'campus' => Auth::user()->profile->college->pivot->xq, 'season' => Auth::user()->profile->zsjj, 'grade' => Auth::user()->profile->nj, 'major' => Auth::user()->profile->zy]);
$log = new Slog();
$log->ip = request()->ip();
$log->czlx = 'login';
$log->save();
}
示例10: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Setting::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'sms' => $this->sms, 'gcm' => $this->gcm, 'userCreate' => $this->userCreate, 'userUpdate' => $this->userUpdate, 'updateDate' => $this->updateDate, 'createDate' => $this->createDate]);
$query->andFilterWhere(['like', 'applicationName', $this->applicationName])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'sms_key', $this->sms_key])->andFilterWhere(['like', 'sms_pass', $this->sms_pass])->andFilterWhere(['like', 'gcm_api_key', $this->gcm_api_key])->andFilterWhere(['like', 'gcm_sender', $this->gcm_sender])->andFilterWhere(['like', 'emailAdmin', $this->emailAdmin])->andFilterWhere(['like', 'emailSupport', $this->emailSupport])->andFilterWhere(['like', 'emailOrder', $this->emailOrder])->andFilterWhere(['like', 'sendgridUsername', $this->sendgridUsername])->andFilterWhere(['like', 'sendgridPassword', $this->sendgridPassword])->andFilterWhere(['like', 'whatsappNumber', $this->whatsappNumber])->andFilterWhere(['like', 'whatsappPassword', $this->whatsappPassword])->andFilterWhere(['like', 'whatsappSend', $this->whatsappSend])->andFilterWhere(['like', 'facebook', $this->facebook])->andFilterWhere(['like', 'instagram', $this->instagram])->andFilterWhere(['like', 'google', $this->google])->andFilterWhere(['like', 'twitter', $this->twitter]);
return $dataProvider;
}
示例11: actionIndex
/**
* This command echoes what you have entered as the message.
* @param string $message the message to be echoed.
*/
public function actionIndex()
{
Yii::info('CronController', 'cronjob');
/**
* If cron execute it the default date and time are wrong,
* this fix it (date_default_timezone_set)
*/
$settingModel = Setting::find()->where(['name' => 'date_default_timezone'])->one();
if (isset($settingModel->data) and !empty($settingModel->data)) {
date_default_timezone_set($settingModel->data);
}
$modelCronjob = new Cronjob();
$modelCronjob->cron();
}
示例12: actionMail
public function actionMail()
{
$this->layout = 'admin';
// In @app/views/layouts
$settings = Setting::find()->where(['category' => 'smtp'])->orderBy('id')->all();
if (Model::loadMultiple($settings, Yii::$app->request->post()) && Model::validateMultiple($settings)) {
/** @var \app\models\Setting $setting */
foreach ($settings as $setting) {
$setting->save(false);
}
// Show success alert
Yii::$app->getSession()->setFlash('success', Yii::t('app', 'The smtp server settings have been successfully updated.'));
}
return $this->render('mail', ['settings' => $settings]);
}
示例13: IamReallyAthome
public static function IamReallyAthome()
{
$ip_addressen = Setting::find()->select('data')->where(['name' => 'i_am_really_at_home_ip_addressen'])->one();
$ip_addressen = HelperData::dataExplode($ip_addressen->data);
$iamathome = false;
foreach ($ip_addressen as $ip_adres) {
$command = 'sudo ping ' . $ip_adres . ' -c 2';
// -c 2 (two time on linux machine
exec(escapeshellcmd($command), $output, $return_var);
if (0 == $return_var) {
$iamathome = true;
}
}
return HelperData::dataExplode($iamathome);
}
示例14: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Setting::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'name' => $this->name, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
//$query->andFilterWhere(['like', 'name', $this->name])
$query->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'data', $this->data]);
return $dataProvider;
}
示例15: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id = 1)
{
$setting = Setting::find($id);
$cekinput = Input::file('setheader');
// Header Website
if (!empty($cekinput)) {
$oldfile = Setting::where('id_setting', $id)->first();
File::delete('upload/logo/' . $oldfile->bg_header);
$thefile = Input::file('setheader');
$lokasi_simpan = 'upload/logo';
$filename = str_random(30) . '.' . $thefile->getClientOriginalExtension();
$upload_gambar = Input::file('setheader')->move($lokasi_simpan, $filename);
$setting->bg_header = $filename;
}
if ($setting->save()) {
return redirect()->back()->with('alert', 'Data berhasil di simpan');
}
}