当前位置: 首页>>代码示例>>PHP>>正文


PHP Storage::instance方法代码示例

本文整理汇总了PHP中Storage::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::instance方法的具体用法?PHP Storage::instance怎么用?PHP Storage::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Storage的用法示例。


在下文中一共展示了Storage::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getInstance

 public static function getInstance($config)
 {
     if (self::$instance instanceof self) {
         return self::$instance;
     }
     return self::$instance = new self($config);
 }
开发者ID:yszar,项目名称:linuxwp,代码行数:7,代码来源:alioss.class.php

示例2: getInstance

 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new MySqlStorage();
     }
     return self::$instance;
 }
开发者ID:huluwa,项目名称:grr,代码行数:7,代码来源:Core.php

示例3: read_menu

function read_menu($parent_id = 0, $lang = null)
{
    $sql = "SELECT id,name,short_name FROM menu WHERE parent_id = :parent_id";
    $statement = Storage::instance()->db->prepare($sql);
    $statement->execute(array(':parent_id' => $parent_id));
    return $statement->fetchAll();
}
开发者ID:JumpStartGeorgia,项目名称:OpenTaps,代码行数:7,代码来源:functions.php

示例4: getInstance

 public static function getInstance()
 {
     if (null == self::$instance) {
         self::$instance = new Storage();
     }
     return self::$instance;
 }
开发者ID:vberzsin,项目名称:2014,代码行数:7,代码来源:Storage.php

示例5: action_fupload

 public function action_fupload()
 {
     if (!empty($_FILES['file'])) {
         $user_id = Auth::instance()->get_user()->id;
         $storage_id = Storage::instance()->add($_FILES['file'], $user_id);
         if ($storage_id) {
             $image = ORM::factory('Storage', $storage_id);
             $fname = URL::media($image->file_path);
             // displaying file
             $array = array('filelink' => $fname, 'filename' => $image->name);
             echo stripslashes(json_encode($array));
             exit;
         } else {
             throw new HTTP_Exception_404('Ошибка при сохранении');
         }
     } else {
         throw new HTTP_Exception_404('Не верный формат картинки');
     }
     ////////////////////
     /*
     $dir = APPPATH . '../media/upload/';
     $fname = substr(md5(time()), 0, 8) . '_' . $_FILES['file']['name'];
     move_uploaded_file($_FILES['file']['tmp_name'], $dir . $fname);
     
     $array = array(
         'filelink' => Url::site('/media/upload/').'/'.  $fname,
         'filename' => $_FILES['file']['name']
     );
     
     echo stripslashes(json_encode($array));
     exit;
     */
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:33,代码来源:Filemanager.php

示例6: instance

 public static function instance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
开发者ID:CraigChilds94,项目名称:scaffold,代码行数:7,代码来源:storage.php

示例7: getInstance

 public static function getInstance()
 {
     if (null === self::$instance) {
         self::$instance = new self();
         self::$instance->setHandler();
     }
     return self::$instance;
 }
开发者ID:ArtuhovichVladislav,项目名称:PHP-Blog,代码行数:8,代码来源:Storage.php

示例8: getInstance

 public static function getInstance()
 {
     if (NULL == self::$instance) {
         self::$instance = new self();
         self::$instance->DBConnection = new MySQLConnection();
     }
     return self::$instance;
 }
开发者ID:virtuellyworld,项目名称:WIN-V2,代码行数:8,代码来源:Storage.php

示例9: action_upload

 public function action_upload()
 {
     if ($this->request->method() == "POST") {
         $user_id = Arr::get($_POST, 'user_id', 0);
         $photogalery = Arr::get($_POST, 'photogalery', 0);
         echo Storage::instance()->add($_FILES['Filedata'], $user_id, $photogalery);
     }
     exit;
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:9,代码来源:Storage.php

示例10: getInstance

 public static function getInstance()
 {
     if (null === self::$instance) {
         self::$instance = new self();
         $storage_type = Config::getProperty('storage_type');
         switch ($storage_type) {
             case 'text':
                 self::$instance->setHandler(new Storage_text());
                 break;
             case 'json':
                 self::$instance->setHandler(new Storage_json());
                 break;
             case 'mysql':
                 self::$instance->setHandler(new Storage_mysql());
                 break;
             default:
                 self::$instance->setHandler(new Storage_json());
         }
     }
     return self::$instance;
 }
开发者ID:vladkanash,项目名称:PHP-Blog,代码行数:21,代码来源:Storage.php

示例11: unset

unset($max_file_size);
if ($_FILES['file']['error'] != UPLOAD_ERR_OK) {
    $Page->json(['jsonrpc' => '2.0', 'error' => ['code' => 500, 'message' => '500 Internal Server Error'], 'id' => 'id']);
    return;
}
/**
 * Only registered users allowed
 */
if (!$User->user()) {
    $Page->json(['jsonrpc' => '2.0', 'error' => ['code' => 403, 'message' => '403 Forbidden'], 'id' => 'id']);
    return;
}
/**
 * Getting instances of storage and database
 */
$storage = Storage::instance()->{$module_data->storage('files')};
$cdb = DB::instance()->{$module_data->db('files')}();
if (!$storage || !$cdb) {
    $Page->json(['jsonrpc' => '2.0', 'error' => ['code' => 500, 'message' => '500 Internal Server Error'], 'id' => 'id']);
    return;
}
/**
 * Moving file into storage
 */
if (!$module_data->directory_created) {
    $storage->mkdir('Plupload');
    $module_data->directory_created = 1;
}
$destination_file = 'Plupload/' . date('Y-m-d');
if (!$storage->file_exists($destination_file)) {
    $storage->mkdir($destination_file);
开发者ID:hypnomez,项目名称:opir.org,代码行数:31,代码来源:index.php

示例12:

</ul>

                <div class='search'>
                    <form method='GET' action=''>
                        <input class='search' type='text' value='Search...' onfocus='this.value=""' onblur='if(this.value=="")
                            this.value="Search..."' name='' />
                        <input class='submit' type='submit' value='' />
                    </form>
                </div>
            </div>

            <div id="map" class="middle">
            </div>

            <?php 
echo Storage::instance()->content;
?>

            <hr class='bottom' id='myhr' />

            <div class='bottom'>
                © 2011 OPEN TAPS. &nbsp;&nbsp; Designed and developed by <a href='http://jumpstart.ge/'>Jumpstart Georgia</a>
            </div>
            <div class='bottom1'>Donate | About Us | Report</div>
            <div class='bottom2'>GEORGIAN WATER PROJECT </div>
            <div class='bottom3'><img src='<?php 
echo URL;
?>
images/connect_fb.jpg' /> &nbsp;CONNECT HERE&nbsp; <img src='<?php 
echo URL;
?>
开发者ID:JumpStartGeorgia,项目名称:OpenTaps,代码行数:31,代码来源:layout.php

示例13: action_register

 public function action_register()
 {
     $post = $this->post;
     $username = Security::xss_clean(Arr::get($post, 'login', ''));
     $email = Security::xss_clean(Arr::get($post, 'email', ''));
     $password = Security::xss_clean(Arr::get($post, 'password', ''));
     $password_confirm = Security::xss_clean(Arr::get($post, 'password', ''));
     $social_token = Security::xss_clean(Arr::get($post, 'token', ''));
     if (!Auth::instance()->logged_in()) {
         if (!empty($post) || $social_token != '') {
             if ($social_token != '') {
                 $s = file_get_contents('http://ulogin.ru/token.php?token=' . $social_token . '&host=' . $_SERVER['HTTP_HOST']);
                 /* узнать как будет выглядеть массив от клиента с данными из соц сети */
                 $ulogin = json_decode($s, true);
                 //var_dump($ulogin);
                 //$ulogin = Security::xss_clean(Arr::get($post, 'ulogin', ''));
                 $identity = $ulogin['network'] . '_' . $ulogin['uid'];
                 $user = ORM::factory('user')->where('username', '=', $identity)->or_where('email', 'LIKE', '%' . Arr::get($ulogin, 'email', '1NrJH43ksWlrn'))->find();
                 if (!$user->loaded()) {
                     $pass = strtotime(date("Y-m-d H:i:s")) . $social_token;
                     $role = ORM::factory('Role', 1);
                     $user = ORM::factory('User')->values(array('username' => $identity, 'password' => $pass, 'password_confirm' => $pass, 'email' => $ulogin['network'] . '_' . $ulogin['uid'] . '_' . Arr::get($ulogin, 'email', $identity . '@test.kz'), 'network_reg' => 1))->save();
                     $user->add('roles', $role);
                     if ($ulogin['network'] != "yandex") {
                         $photo = Storage::instance()->save_social_photo(Arr::get($ulogin, 'photo', ''), $user->pk());
                     } else {
                         $photo = 0;
                     }
                     ORM::factory('User_Profile')->values(array('user_id' => $user->pk(), 'first_name' => Arr::get($ulogin, 'first_name', ''), 'last_name' => Arr::get($ulogin, 'last_name', ''), 'photo' => $photo, 'phone' => Arr::get($ulogin, 'phone', ''), 'email' => Arr::get($ulogin, 'email', ''), 'location_id' => 0))->save();
                     //Auth::instance()->force_login($identity);
                     //успешная регистрация
                     $this->data['socialReg'] = true;
                 } else {
                     $this->data['error'] = 'Social user is already registered';
                     //Auth::instance()->force_login($user->username);
                     //Пользоатель уже существует
                 }
             } else {
                 $findusername = ORM::factory('User')->where('username', '=', $username)->find_all()->count();
                 if ($findusername == 0) {
                     $findemail = ORM::factory('User')->where('email', '=', $email)->find_all()->count();
                     if ($findemail == 0) {
                         $date = date("Y-m-d H:i:s");
                         $code = md5($date . $password);
                         $user = ORM::factory('User')->values(array('username' => $username, 'email' => $email, 'password' => $password, 'password_confirm' => $password_confirm, 'network_reg' => 0, 'link_activate' => $code));
                         $user->save();
                         Email::connect();
                         Email::View('activate');
                         Email::set(array('username' => $username, 'id' => $code, 'url' => URL::site('/', true)));
                         Email::send($email, array('no-reply@e-history.kz', 'e-history.kz'), "Подтверждение регистрации на сайте E-history.kz", '', true);
                         $this->data[] = true;
                         //Успешная простая регистрация
                     } else {
                         $this->data['error'] = 'Email is already registered';
                         //такой ящик уже есть
                     }
                 } else {
                     $this->data['error'] = 'Login is already registered';
                 }
                 //Message::success('На указанный email отправлено письмо со ссылкой на подтверждение регистрации.');
             }
         }
     }
     $this->response->body(json_encode($this->data));
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:65,代码来源:Auth.php

示例14: action_register

 public function action_register()
 {
     $username = Security::xss_clean(Arr::get($_POST, 'username', ''));
     $email = Security::xss_clean(Arr::get($_POST, 'email', ''));
     $class = Security::xss_clean(Arr::get($_POST, 'class', ''));
     $vuz = Security::xss_clean(Arr::get($_POST, 'vuz', ''));
     $radio = Security::xss_clean(Arr::get($_POST, 'radio', ''));
     $password = Security::xss_clean(Arr::get($_POST, 'password', ''));
     $password_confirm = Security::xss_clean(Arr::get($_POST, 'password_confirm', ''));
     $errors = NULL;
     $res = Session::instance()->get('return');
     if (!empty($res)) {
         $return = $res;
     } else {
         $return = "/";
     }
     if (!Auth::instance()->logged_in()) {
         if ($this->request->post()) {
             if (!empty($_POST['token'])) {
                 $s = file_get_contents('http://ulogin.ru/token.php?token=' . $_POST['token'] . '&host=' . $_SERVER['HTTP_HOST']);
                 $ulogin = json_decode($s, true);
                 $ulogin['token'] = md5($ulogin['identity'] . 'hdhHgth');
                 $identity = $ulogin['network'] . '_' . $ulogin['uid'];
                 $user = ORM::factory('user')->where('username', '=', $identity)->or_where('email', 'LIKE', '%' . Arr::get($ulogin, 'email', '1NrJH43ksWlrn'))->find();
                 if (!$user->loaded()) {
                     $pass = strtotime(date("Y-m-d H:i:s")) . $ulogin['token'];
                     $role = ORM::factory('role', 1);
                     $user = ORM::factory('user')->values(array('username' => $identity, 'password' => $pass, 'password_confirm' => $pass, 'email' => $ulogin['network'] . '_' . $ulogin['uid'] . '_' . Arr::get($ulogin, 'email', $identity . '@test.kz'), 'network_reg' => 1))->save();
                     $user->add('roles', $role);
                     $photo = Storage::instance()->save_social_photo(Arr::get($ulogin, 'photo', ''), $user->pk());
                     ORM::factory('User_Profile')->values(array('user_id' => $user->pk(), 'first_name' => Arr::get($ulogin, 'first_name', ''), 'last_name' => Arr::get($ulogin, 'last_name', ''), 'photo' => $photo, 'phone' => Arr::get($ulogin, 'phone', ''), 'email' => Arr::get($ulogin, 'email', ''), 'location_id' => 0))->save();
                     Auth::instance()->force_login($identity);
                 } else {
                     Auth::instance()->force_login($user->username);
                 }
                 //запомнить токен для соц сети
                 $this->redirect($return, 301);
             } else {
                 if (Captcha::valid($_POST['captcha'])) {
                     try {
                         //$role = ORM::factory('Role', 1);
                         $date = date("Y-m-d H:i:s");
                         $code = md5($date . $password);
                         $user = ORM::factory('User')->values(array('username' => $username, 'email' => $email, 'class' => $class, 'vuz' => $vuz, 'role' => $radio, 'password' => $password, 'password_confirm' => $password_confirm, 'network_reg' => 0, 'link_activate' => $code));
                         $extra_rules = Validation::factory($_POST)->rule('password_confirm', 'matches', array(':validation', ':field', 'password'));
                         if ($extra_rules->check()) {
                             //                                die($password);
                             $user->save();
                             Email::connect();
                             Email::View('activate');
                             Email::set(array('username' => $username, 'id' => $code, 'url' => str_replace('/auth/register', '', URL::current(true))));
                             Email::send($email, array('no-reply@e-history.kz', 'e-history.kz'), "Подтверждение регистрации на сайте shkolkovo.kz", '', true);
                             Message::success('На указанный email отправлено письмо со ссылкой на подтверждение регистрации.');
                             $this->redirect('/', 301);
                         } else {
                             $errors = $extra_rules->errors('validation');
                         }
                     } catch (ORM_Validation_Exception $e) {
                         $errors = $e->errors($e->alias());
                     }
                 } else {
                     $errors['captcha'] = I18n::get("Неправильно ввели код подтверждения.");
                 }
             }
         }
     }
     $this->set('username', $username)->set('email', $email)->set('url', 'http://' . $_SERVER['SERVER_NAME'] . '/' . Request::$initial->uri())->set('errors', $errors)->set('return', $return);
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:68,代码来源:Auth.php

示例15: action_enter

 public function action_enter()
 {
     $username = Security::xss_clean(Arr::get($_POST, 'username', ''));
     $password = Security::xss_clean(Arr::get($_POST, 'password', ''));
     $remember = (bool) Arr::get($_POST, 'remember', false);
     $error = false;
     $template = View::factory('enter');
     $config = Kohana::$config->load('login');
     $captcha = false;
     if (!Auth::instance()->logged_in()) {
         if ($this->request->method() == Request::POST) {
             if (!empty($_POST['token']) && $config['type'] == 'social') {
                 $s = file_get_contents('http://ulogin.ru/token.php?token=' . $_POST['token'] . '&host=' . $_SERVER['HTTP_HOST']);
                 $ulogin = json_decode($s, true);
                 $ulogin['token'] = md5($ulogin['identity'] . 'hdhHgth');
                 $identity = $ulogin['network'] . '_' . $ulogin['uid'];
                 $user = ORM::factory('user')->where('username', '=', $identity)->or_where('email', 'LIKE', '%' . Arr::get($ulogin, 'email', '1NrJH60ksWlrn'))->find();
                 if (!$user->loaded()) {
                     $pass = strtotime(date("Y-m-d H:i:s")) . $ulogin['token'];
                     $role = ORM::factory('Role', 1);
                     $user = ORM::factory('User')->values(array('username' => $identity, 'password' => $pass, 'password_confirm' => $pass, 'email' => $ulogin['network'] . '_' . $ulogin['uid'] . '_' . Arr::get($ulogin, 'email', $identity . '@test.kz'), 'network_reg' => 1))->save();
                     $user->add('roles', $role);
                     $photo = Storage::instance()->save_social_photo(Arr::get($ulogin, 'photo', ''), $user->pk());
                     ORM::factory('User_Profile')->values(array('user_id' => $user->pk(), 'first_name' => Arr::get($ulogin, 'first_name', ''), 'last_name' => Arr::get($ulogin, 'last_name', ''), 'photo' => $photo, 'email' => Arr::get($ulogin, 'email', '')))->save();
                     Auth::instance()->force_login($identity);
                 } else {
                     Auth::instance()->force_login($user->username);
                 }
                 $this->redirect('/');
             } else {
                 $flag = true;
                 if (isset($_POST['captcha'])) {
                     if (!Captcha::valid($_POST['captcha'])) {
                         $flag = false;
                         $captcha = true;
                         $error = true;
                     }
                 }
                 if ($flag) {
                     //$token = Arr::get($_POST, 'token_auth', false);
                     //if (Security::token() === $token && Auth::instance()->login($username, $password, $remember)) {
                     if (Auth::instance()->login($username, $password, $remember)) {
                         $brute = ORM::factory('User_Bruteforce')->where('user_id', '=', Auth::instance()->get_user()->id)->find();
                         if ($brute->loaded()) {
                             ORM::factory('User_Bruteforce', $brute->id)->delete();
                         }
                         $this->redirect('/');
                     } else {
                         $user = ORM::factory('user')->where('username', '=', $username)->or_where('email', '=', $username)->find();
                         if ($user->loaded()) {
                             $bruteforce = ORM::factory('User_Bruteforce')->where('user_id', '=', $user->id)->find();
                             if ($bruteforce->loaded()) {
                                 if ($bruteforce->attempt >= 1) {
                                     $captcha = true;
                                 } else {
                                     $brute = ORM::factory('User_Bruteforce', $bruteforce->id);
                                     $brute->attempt = $bruteforce->attempt + 1;
                                     $brute->save();
                                 }
                             } else {
                                 ORM::factory('User_Bruteforce')->values(array('user_id' => $user->id))->save();
                             }
                         }
                         $error = true;
                     }
                 }
             }
         }
     } else {
         $this->redirect('/');
     }
     $template->set('username', $username)->set('remember', $remember ? 'checked' : '')->set('url', 'http://' . $_SERVER['SERVER_NAME'] . '/' . Request::$initial->uri())->set('error', $error)->set('captcha', $captcha)->set('return', '/')->render();
     $this->response->body($template->render());
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:74,代码来源:Login.php


注:本文中的Storage::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。