當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::setup方法代碼示例

本文整理匯總了PHP中Model\User::setup方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::setup方法的具體用法?PHP User::setup怎麽用?PHP User::setup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Model\User的用法示例。


在下文中一共展示了User::setup方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: install

 public function install($db_type)
 {
     $f3 = \Base::instance();
     $db_type = strtoupper($db_type);
     if ($db = storage::instance()->get($db_type)) {
         $f3->set('DB', $db);
     } else {
         $f3->error(256, 'no valid DB specified');
     }
     // setup the models
     \Model\Post::setup();
     \Model\Tag::setup();
     \Model\Comment::setup();
     \Model\User::setup();
     // create demo admin user
     $user = new \Model\User();
     $user->load(array('username = ?', 'admin'));
     if ($user->dry()) {
         $user->username = 'admin';
         $user->name = 'Administrator';
         $user->password = 'fabulog';
         $user->save();
         \Flash::instance()->addMessage('Admin User created,' . ' username: admin, password: fabulog', 'success');
     }
     \Flash::instance()->addMessage('Setup complete', 'success');
 }
開發者ID:xfra35,項目名稱:fabulog,代碼行數:26,代碼來源:setup.php

示例2: install

 /**
  * Installs tables with default user
  * @param $db_type
  */
 public function install($db_type)
 {
     $f3 = \Base::instance();
     $db_type = strtoupper($db_type);
     if ($db = DBHandler::instance()->get($db_type)) {
         $f3->set('DB', $db);
     } else {
         $f3->error(256, 'no valid Database Type specified');
     }
     // setup the models
     \Model\User::setup();
     \Model\Payload::setup();
     \Model\Webot::setup();
     // create demo admin user
     $user = new \Model\User();
     $user->load(array('username = ?', 'mth3l3m3nt'));
     if ($user->dry()) {
         $user->username = 'mth3l3m3nt';
         $user->name = 'Framework Administrator';
         $user->password = 'mth3l3m3nt';
         $user->email = 'placeholder_mail@mth3l3m3nt.com';
         $user->save();
         //migrate payloads successfully
         $payload_file = $f3->ROOT . $f3->BASE . '/db_dump_optional/mth3l3m3nt_payload';
         if (file_exists($payload_file)) {
             $payload = new \Model\Payload();
             $payload_file_data = $f3->read($payload_file);
             $payloadarray = json_decode($payload_file_data, true);
             foreach ($payloadarray as $payloaddata) {
                 $payload->pName = $payloaddata['pName'];
                 $payload->pType = $payloaddata['pType'];
                 $payload->pCategory = $payloaddata['pCategory'];
                 $payload->pDescription = $payloaddata['pDescription'];
                 $payload->payload = $payloaddata['payload'];
                 $payload->save();
                 //ensures values set to null before continuing update
                 $payload->reset();
             }
             //migtate payloads
             \Flash::instance()->addMessage('Payload StarterPack: ,' . 'All Starter Pack Payloads added New database', 'success');
         } else {
             \Flash::instance()->addMessage('Payload StarterPack: ,' . 'StarterPack Database not Found no payloads installed ', 'danger');
         }
         \Flash::instance()->addMessage('Admin User created,' . ' username: mth3l3m3nt, password: mth3l3m3nt', 'success');
     }
     \Flash::instance()->addMessage('New Database Setup Completed', 'success');
 }
開發者ID:theralfbrown,項目名稱:OWASP-mth3l3m3nt-framework,代碼行數:51,代碼來源:setup.php


注:本文中的Model\User::setup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。