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


PHP Index类代码示例

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


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

示例1: __construct

 public function __construct()
 {
     $url = isset($_GET["url"]) ? $_GET["url"] : null;
     $url = rtrim($url, "/");
     $url = explode("/", $url);
     if (empty($url[0])) {
         require "controllers/index.php";
         $controller = new Index();
         $controller->index();
         return false;
     }
     $file = "controllers/" . $url[0] . ".php";
     if (file_exists($file)) {
         require $file;
     } else {
         require "controllers/error.php";
         $controller = new Error();
         return false;
     }
     $controller = new $url[0]();
     $controller->LoadModel($url[0]);
     if (isset($url[2])) {
         if (method_exists($controller, $url[1])) {
             $controller->{$url[1]}($url[2]);
         } else {
             echo "Error ошибка";
         }
     } else {
         if (isset($url[1])) {
             $controller->{$url[1]}();
         } else {
             $controller->index();
         }
     }
 }
开发者ID:KravaDima,项目名称:mvc.local,代码行数:35,代码来源:bootstrap.php

示例2: __construct

 function __construct()
 {
     $url = filter_input(INPUT_GET, 'url');
     $url = rtrim($url, '/');
     $url = explode('/', $url);
     if (empty($url[0])) {
         require 'controllers/controllerIndex.php';
         $controller = new Index();
         $controller->index();
         return false;
     }
     $file = 'controllers/controller' . $url[0] . '.php';
     if (file_exists($file)) {
         require $file;
     } else {
         require 'controllers/controllerError.php';
         $controller = new Error();
         $controller->index($url[0]);
         return false;
     }
     $controller = new $url[0]();
     if (isset($url[1])) {
         if (method_exists($controller, $url[1])) {
             if (isset($url[2])) {
                 $controller->{$url[1]}($url[2]);
             } else {
                 $controller->{$url[1]}();
             }
         } else {
             $controller->index();
         }
     } else {
         $controller->index();
     }
 }
开发者ID:leal32b,项目名称:mvc,代码行数:35,代码来源:Bootstrap.php

示例3: add_new

 public function add_new($step = 1, $url_key = NULL)
 {
     if (isset($this->session->userdata["user_id"])) {
         $data = array();
         $user_id = $this->session->userdata["user_id"];
         $model = new Common_model();
         switch ($step) {
             case 1:
                 // meta info
                 $this->add_new_step_one($url_key);
                 break;
             case 2:
                 // regions
                 $this->add_new_step_two($url_key);
                 break;
             case 3:
                 // budgets
                 $this->add_new_step_three($url_key);
                 break;
             case 4:
                 // media
                 $this->add_new_step_four($url_key);
                 break;
         }
     } else {
         require_once APPPATH . 'controllers/index.php';
         $index_controller = new Index();
         $index_controller->login();
     }
 }
开发者ID:arp19690,项目名称:newtravel,代码行数:30,代码来源:trip.php

示例4: __construct

 function __construct()
 {
     $url = isset($_GET['url']) ? $_GET['url'] : null;
     $url = rtrim($url, '/');
     $url = explode('/', $url);
     //print_r($url);
     if (empty($url[0])) {
         require 'controllers/index.php';
         $controller = new Index();
         $controller->index();
         return false;
     }
     $file = 'controllers/' . $url[0] . '.php';
     if (file_exists($file)) {
         require $file;
     } else {
         $this->error();
     }
     $controller = new $url[0]();
     $controller->loadModel($url[0]);
     // calling methods
     if (isset($url[1])) {
         if (method_exists($controller, $url[1])) {
             if (isset($url[2])) {
                 $controller->{$url[1]}($url[2]);
             } else {
                 $controller->{$url[1]}();
             }
         } else {
             $this->error();
         }
     } else {
         $controller->index();
     }
 }
开发者ID:vraolji,项目名称:MVC-Sample,代码行数:35,代码来源:bootstrap.php

示例5: __construct

 function __construct()
 {
     $route = isset($_GET['route']) ? $_GET['route'] : null;
     $route = rtrim($route, '/');
     $route = explode('/', $route);
     if (empty($route[0])) {
         //если путь пуст, вызывает главную страницу
         require_once 'controllers/index.php';
         //вызываем вид
         $controller = new Index('index');
         $controller->Index();
         return false;
     }
     $file = 'controllers/' . $route[0] . '.php';
     //если есть страница, указанная в маршруте, подключаем ее
     if (file_exists($file)) {
         require_once $file;
     } else {
         $controller = new Error();
     }
     //вызываем обьект подключенного файла
     $controller = new $route[0]($route[0]);
     //загружаем модель
     $controller->loadModel($route[0]);
     //$controller->Index();
     if (isset($route[1])) {
         $controller->{$route[1]}();
     } else {
         $controller->Index();
     }
 }
开发者ID:VelMrnk,项目名称:LandingPages,代码行数:31,代码来源:Bootstrap.php

示例6: logOut

 function logOut()
 {
     session_destroy();
     echo "<div class='alert alert-warning' role='alert'>Je bent nu uitgelogd.</div>";
     $index = new Index();
     $index->redirect('index.php');
 }
开发者ID:emilev90,项目名称:intekenbord,代码行数:7,代码来源:login.class.php

示例7: __construct

 function __construct()
 {
     $url = isset($_GET['url']) ? $_GET['url'] : null;
     $url = rtrim($url, '/');
     $url = explode('/', $url);
     if (empty($url[0])) {
         require 'controllers/index.php';
         $controller = new Index();
         $controller->index();
         return false;
     }
     $file = 'controllers/' . $url[0] . '.php';
     if (file_exists($file)) {
         require $file;
     } else {
         throw new Exception("file doesnt exits");
     }
     $controller = new $url[0]();
     $controller->loadModel($url[0]);
     if (isset($url[2])) {
         $controller->{$url[1]}($url[2]);
     } else {
         if (isset($url[1])) {
             $controller->{$url[1]}();
         } else {
             $controller->index();
         }
     }
 }
开发者ID:bartoszl,项目名称:surveygeek,代码行数:29,代码来源:Init.php

示例8: redirect

 public function redirect()
 {
     require 'app/controllers/indexcontroller.php';
     $controller = new Index();
     $controller->index();
     return false;
 }
开发者ID:Andrew365,项目名称:PHP,代码行数:7,代码来源:authmodel.php

示例9: __construct

 function __construct()
 {
     $urlll = '';
     //$url = isset($_GET['url']) ? $_GET['url']: null;
     if (isset($_GET['url']) && is_string($_GET['url'])) {
         $url = $_GET['url'];
         // name in $_GET['url'] is ok, so you can set it
         $url = filter_var($url, FILTER_SANITIZE_URL);
         $urll = rtrim($url, '/');
         //right trim if there are more than on /
         $urlll = explode('/', $urll);
     }
     /*
      *print_r($urlll);//for debugging
      *echo '<br/>';
      */
     //when there is empty url
     if (empty($urlll[0])) {
         //echo 'bootstrap initiating Main Index page, \'controllers/Index.php\'</br>';
         require 'controllers/index.php';
         $controller = new Index();
         $controller->index();
         return false;
         //the remaining below code is not executed
     }
     $file = 'controllers/' . $urlll[0] . '.php';
     //never user controllers, instead use config.ini
     if (file_exists($file)) {
         //checking if url exists
         //incude the file
         require $file;
     } else {
         $this->error();
         return false;
         //stops the execution of code and returns
     }
     //initializes the class of the 'included' controller
     $controller = new $urlll[0]();
     //redirecting to the controller's php file
     $controller->loadModel($urlll[0]);
     if (isset($urlll[2])) {
         if (method_exists($controller, $urlll[1])) {
             $controller->{$urlll[1]}($urlll[2]);
             //function(param)
         } else {
             $this->error();
         }
     } else {
         if (isset($urlll[1])) {
             if (method_exists($controller, $urlll[1])) {
                 $controller->{$urlll[1]}();
                 //function()
             } else {
                 $this->error();
             }
         } else {
             $controller->index();
         }
     }
 }
开发者ID:saptharsh,项目名称:Project-Management-App,代码行数:60,代码来源:Bootstrap.php

示例10: error

 function error()
 {
     require 'controllers/index.php';
     $controller = new Index();
     $controller->LoadModel('index');
     $controller->loadError();
     return false;
 }
开发者ID:runningjack,项目名称:RobertJohnson,代码行数:8,代码来源:Bootstrap.php

示例11: __construct

 function __construct($http, $url, $controller, $method, $params)
 {
     if ($http == "GET") {
         if ($params = null) {
             return true;
         }
         $burl = isset($_GET['url']) ? $_GET['url'] : null;
         $burl = rtrim($burl, '/');
         $burl = explode('/', $burl);
         $url = rtrim($url, '/');
         $url = explode('/', $url);
         if (empty($burl[0])) {
             require 'app/controllers/indexcontroller.php';
             $controller = new Index();
             $controller->index();
             return false;
         } elseif ($burl[0] == 'index' || $burl[0] == "Index") {
             require 'app/controllers/indexcontroller.php';
             $controller = new Index();
             $controller->index();
             return false;
         }
         /////////////////////////////////////////////////////////////////////////////////////////////
         if ($burl == $url) {
             $file = 'app/controllers/' . $controller . '.php';
             if (file_exists($file)) {
                 require $file;
             } else {
                 $this->error();
                 return false;
             }
             $findcont = $controller;
             $class = rtrim($controller, 'controller');
             $classname = $class;
             $class = new $class();
             if (isset($params)) {
                 if (method_exists($findcont, $method)) {
                     $findcont->{$method}($params);
                 } else {
                     $this->methoderror();
                     return false;
                 }
             } else {
                 if (isset($controller)) {
                     if (method_exists($classname, $method)) {
                         $class->{$method}();
                     } else {
                         $this->methoderror();
                         return false;
                     }
                 }
             }
         }
         ///////////end of if burl = url[0]
     }
 }
开发者ID:Andrew365,项目名称:PHP,代码行数:56,代码来源:RoutesServiceProvider.php

示例12: Index

 public function Index()
 {
     $Index = new Index();
     $data = array();
     $data['html'] = $Index->index();
     $view = new View();
     $view->setData($data);
     $view->setTemplate('../view/_Index.php');
     $view->setLayout('../template/Layout.php');
     $view->render();
 }
开发者ID:AnthonyWainer,项目名称:sisacreditacion,代码行数:11,代码来源:IndexController.php

示例13: __construct

 function __construct()
 {
     $url = isset($_GET['url']) ? $_GET['url'] : null;
     $url = rtrim($url, "/");
     $url = explode("/", $url);
     if (empty($url[0])) {
         require '../controllers/index.php';
         $controller = new Index();
         $controller->index();
         return false;
     }
     // CONTROLLER
     // Only allow a controller name with dashes & alphanumeric characters
     if (preg_match('/[^0-9a-z-]/i', $url[0])) {
         require '../controllers/error.php';
         $controller = new Error("Invalid Character In Controller Name.");
         return false;
     }
     // For the script to read past this line, the controller must be alphanumeric w/ dash
     $file = '../controllers/' . $url[0] . '.php';
     if (file_exists($file)) {
         require $file;
     } else {
         // controller file not found
         // HOW CAN I LOG ERRORS HERE? PUT THEM INTO A DATABASE?
         require '../controllers/error.php';
         $controller = new Error("Controller not found: " . $url[0]);
         return false;
         //throw new Exception("The file '$file' does not exist!");
     }
     $controller = new $url[0]();
     $controller->loadModule($url[0]);
     // CALLING METHODS -------------------------------
     if (isset($url[2])) {
         // CHECK IF METHOD EXISTS
         if (method_exists($controller, $url[1])) {
             $controller->{$url[1]}($url[2]);
         } else {
             require '../controllers/error.php';
             $controller = new Error("Method not found: " . $url[1]);
         }
         return false;
     } elseif (isset($url[1])) {
         if (method_exists($controller, $url[1])) {
             $controller->{$url[1]}();
         } else {
             require '../controllers/error.php';
             $controller = new Error("Method not found: " . $url[1]);
         }
         return false;
     } else {
         $controller->index();
     }
 }
开发者ID:417solutions,项目名称:MVC-Files,代码行数:54,代码来源:libs-Bootstrap.php

示例14: Index

 function Index()
 {
     //print_r($_SESSION);
     //print_r($_COOKIE);
     /**
      * session cookie tourists
      * 
      * 1.判断是登陆,服务器是否保留session
      * 2.如果没有session可取,判断是否本地保存cookie
      * 3.如果session cookie 都没有值可取采用游客登录
      * 
      */
     if (isset($_SESSION['username']) && !empty($_SESSION['username'])) {
         //检测session
         $this->assign('username', $_SESSION['username']);
     } else {
         if (!empty($_COOKIE["username"])) {
             //检测cookie
             $userCookie = $_COOKIE["username"];
             $this->assign('username', $userCookie);
         } else {
             //游客登陆
             $tourists_id = Login::getTouristsId();
             if ($tourists_id == null) {
                 Login::setTouristsId();
             }
         }
     }
     /**
      * 获取顶部banner1数据
      * 
      */
     $index = new Index();
     $banner1 = $index->getBanner1();
     if ($banner1) {
         $this->assign('banner1', $banner1);
     }
     /**
      * 获取banner2数据
      *
      */
     $banner2 = $index->getBanner2();
     if ($banner2) {
         $this->assign('banner2', $banner2);
     }
     /**
      * 获取website数据
      *
      */
     $websites = $index->getWebsites();
     if ($websites) {
         $this->assign('websites', $websites);
     }
 }
开发者ID:koery,项目名称:Vcanbuy,代码行数:54,代码来源:IndexController.class.php

示例15: myAccount

 public function myAccount()
 {
     if (isset($this->session->userdata["user_id"])) {
         $data = array();
         $model = new Common_model();
         $user_id = $this->session->userdata["user_id"];
         $username = $this->session->userdata["user_username"];
         if ($this->input->post()) {
             $arr = $this->input->post();
             //                prd($arr);
             if (isset($arr["btn_submit"])) {
                 $user_dob = NULL;
                 if (!empty($arr['dob_dd']) && !empty($arr['dob_mm']) && !empty($arr['dob_yy'])) {
                     $user_dob = $arr['dob_yy'] . '-' . $arr['dob_mm'] . '-' . $arr['dob_dd'];
                 }
                 $location_details = get_location_details_from_google(trim($arr['user_location']));
                 $location_lat_long = getLatLonByAddress(trim($arr['user_location']));
                 $data_array = array('user_fullname' => addslashes($arr['user_fullname']), 'user_gender' => addslashes($arr['user_gender']), 'user_location' => addslashes($arr['user_location']), 'user_city' => $location_details['city'], 'user_state' => $location_details['state'], 'user_country' => $location_details['country'], 'user_location' => trim($arr['user_location']), 'user_latitude' => $location_lat_long['latitude'], 'user_longitude' => $location_lat_long['longitude'], 'user_tagline' => addslashes($arr['user_tagline']), 'user_about' => addslashes($arr['user_about']), 'user_relationship_status' => addslashes($arr['user_relationship_status']), 'user_dob' => $user_dob);
                 if (isset($arr['user_username'])) {
                     $username = trim($arr['user_username']);
                     $checkUsername = $model->is_exists("user_id", TABLE_USERS, array("username" => $username, "user_id !=" => $user_id));
                     if (!empty($checkUsername)) {
                         $this->session->set_flashdata("error", "That username is already taken. Please choose another.");
                     } else {
                         $data_array['user_username'] = $username;
                         $data_array['user_changed_username'] = '1';
                     }
                 }
                 $this->session->set_flashdata("success", "Personal details updated successfully");
                 $model->updateData(TABLE_USERS, $data_array, array("user_id" => $user_id));
                 // updating redis keys now
                 $this->redis_functions->set_user_profile_data($username);
                 @$this->session->set_userdata("user_fullname", trim($arr["user_fullname"]));
                 @$this->session->set_userdata("user_username", $username);
             }
             redirect(base_url('my-account'));
         } else {
             $record = $this->redis_functions->get_user_profile_data($username);
             $page_title = $record["user_fullname"];
             $input_arr = array(base_url() => 'Home', '#' => $page_title);
             $breadcrumbs = get_breadcrumbs($input_arr);
             $data["record"] = $record;
             $data["breadcrumbs"] = $breadcrumbs;
             $data["page_title"] = $page_title;
             $data['meta_title'] = $data["page_title"] . ' - ' . $this->redis_functions->get_site_setting('SITE_NAME');
             $this->template->write_view("content", "pages/user/my-account", $data);
             $this->template->render();
         }
     } else {
         require_once APPPATH . 'controllers/index.php';
         $index_controller = new Index();
         $index_controller->login();
     }
 }
开发者ID:arp19690,项目名称:newtravel,代码行数:54,代码来源:user.php


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