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


PHP control函数代码示例

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


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

示例1: getVariables

 public function getVariables()
 {
     if ($_SESSION['user']['user_role'] != 1) {
         header('Location: /');
         exit;
     }
     if (isset($_GET['remove']) && trim($_GET['remove'])) {
         $this->remove($_GET['remove']);
     }
     $servers = control()->database()->search('server')->setColumns('*');
     // Get keywords for Search
     if (isset($_GET['keywords']) && !empty($_GET['keywords'])) {
         $keywords = sprintf('%s', $_GET['keywords']);
         $servers = $servers->addFilter('(server_name LIKE \'%%' . $keywords . '%%\'
             OR server_root LIKE \'%%' . $keywords . '%%\' 
             OR server_ip LIKE \'%%' . $keywords . '%%\')');
     }
     // Determine Current Page
     $page = isset($_GET['page']) ? $_GET['page'] : 1;
     // Get The Start In Query
     $start = isset($_GET['page']) && $_GET['page'] != 1 ? ($_GET['page'] - 1) * self::RANGE : 0;
     $totalServers = $servers->getRows();
     $servers = $servers->setStart($start)->setRange(self::RANGE)->getRows();
     $msg = array();
     if (isset($_SESSION['serverMsg']) && is_array($_SESSION['serverMsg']) && !empty($_SESSION['serverMsg'])) {
         $msg = $_SESSION['serverMsg'];
         unset($_SESSION['serverMsg']);
     }
     return array('serverMsg' => $msg, 'servers' => $servers, 'range' => self::RANGE, 'page' => $page, 'totalServers' => count($totalServers));
 }
开发者ID:rujealfon,项目名称:UAC,代码行数:30,代码来源:Servers.php

示例2: start

 /**
  * 运行应用
  * @access private
  */
 private static function start()
 {
     //控制器实例
     $control = control(CONTROL);
     //控制器不存在
     if (!$control) {
         //空控制器
         $control = Control("Empty");
         if (!$control) {
             _404('模块' . CONTROL . '不存在');
         }
     }
     //执行动作
     try {
         $method = new ReflectionMethod($control, METHOD);
         if ($method->isPublic()) {
             $method->invoke($control);
         } else {
             throw new ReflectionException();
         }
     } catch (ReflectionException $e) {
         $method = new ReflectionMethod($control, '__call');
         $method->invokeArgs($control, array(METHOD, ''));
     }
 }
开发者ID:sxau-web-team,项目名称:wish-web,代码行数:29,代码来源:App.class.php

示例3: start

 private static function start()
 {
     $control = control(CONTROL);
     if (!$control) {
         if (IS_GROUP and !is_dir(GROUP_PATH . GROUP_NAME)) {
             _404('应用组' . GROUP_PATH . GROUP_NAME . '不存在');
         }
         if (!is_dir(APP_PATH)) {
             _404('应用' . APP . '不存在');
         }
         $control = Control("Empty");
         if (!$control) {
             _404('模块' . CONTROL . C("CONTROL_FIX") . '不存在');
         }
     }
     try {
         $method = new ReflectionMethod($control, METHOD);
         if ($method->isPublic()) {
             $method->invoke($control);
         } else {
             throw new ReflectionException();
         }
     } catch (ReflectionException $e) {
         $method = new ReflectionMethod($control, '__call');
         $method->invokeArgs($control, array(METHOD, ''));
     }
 }
开发者ID:jyht,项目名称:v5,代码行数:27,代码来源:~boot.php

示例4: create

 /**
  * 生成静态页面
  * <code>
  * array(控制器名,方法名,表态数据,保存表态文件路径)
  * array(news,show,1,'h/b/Hd.html');表示生成news控制器中的show方法生成ID为1的文章
  * </code>
  * @param $control
  * @param $method
  * @param $data
  * @return bool
  */
 public static function create($control, $method, $data)
 {
     //创建控制器对象
     if (is_null(self::$obj)) {
         $obj = control($control);
         if (!method_exists($obj, $method)) {
             error("方法{$method}不存在,请查看HD手册", false);
         }
     }
     foreach ($data as $d) {
         //************创建GET数据****************
         $_GET = array_merge($_GET, $d);
         $htmlPath = dirname($d['html_file']);
         //生成静态目录
         if (!dir_create($htmlPath)) {
             //创建生成静态的目录
             throw_exception(L("html_create_error2"));
             return false;
         }
         ob_start();
         $obj->{$method}();
         //执行控制器方法
         $content = ob_get_clean();
         file_put_contents($d['html_file'], $content);
     }
     return true;
 }
开发者ID:sxau-web-team,项目名称:wish-web,代码行数:38,代码来源:Html.class.php

示例5: saveUser

 protected function saveUser($data, $id)
 {
     if ($id != $data['id']) {
         $_SESSION['_msg'] = array('type' => 'danger', 'msg' => 'Something went wrong!! Please try again!');
         header('Location: /user/edit/' . $id);
         exit;
     }
     $fields = array('user_first' => $data['first'], 'user_last' => $data['last'], 'user_role' => $data['role']);
     control()->database()->updateRows('user', $fields, array(array('user_id=%s', $id)));
     $_SESSION['userMsg'] = array('type' => 'success', 'msg' => 'User updated successfully');
     header('Location: /users');
     exit;
 }
开发者ID:rujealfon,项目名称:UAC,代码行数:13,代码来源:Edit.php

示例6: getServer

 protected function getServer($id)
 {
     $data = control()->database()->search('server')->addFilter('server_id=%s', $id)->getRow();
     if (empty($data)) {
         $_SESSION['serverMsg'] = array('type' => 'danger', 'msg' => 'Server not found!');
         header('Location: /servers');
         exit;
     }
     $server = array();
     foreach ($data as $k => $v) {
         $server[str_replace('server_', '', $k)] = $v;
     }
     return $server;
 }
开发者ID:rujealfon,项目名称:UAC,代码行数:14,代码来源:Edit.php

示例7: removeServer

 public function removeServer($id)
 {
     $server = control()->database()->search('server')->filterByServerId($id)->getRow();
     if (!$server) {
         return false;
     }
     //get users
     $users = control()->database()->search('dev')->addInnerJoinOn('user', 'user_id = dev_user')->filterByDevServer($id)->getRows();
     foreach ($users as $v) {
         \Mod\User::i()->setUserId($v['user_id'])->removeUser($server['server_id']);
     }
     control()->database()->deleteRows('dev', array(array('dev_server=%s', $id)));
     control()->database()->deleteRows('server', array(array('server_id=%s', $id)));
     return true;
 }
开发者ID:rujealfon,项目名称:UAC,代码行数:15,代码来源:Server.php

示例8: call

 public static function call($endpoint, $data = null)
 {
     $response = control('curl')->setUrl(self::$host . $endpoint)->setHeaders('Authorization', 'Basic ' . base64_encode(self::$token . ':'));
     if ($data) {
         $response->setPostFields(json_encode($data));
     }
     $result = $response->getJsonResponse();
     // check for errors and throw them
     if (isset($result['error'])) {
         // unexpected error
         if ($result['error']['panic']) {
             throw new Exception("something went wrong.", 1);
         }
         throw new Exception($result['error']['msg'], 1);
     }
     return $result;
 }
开发者ID:ratatxt,项目名称:php-sms,代码行数:17,代码来源:Base.php

示例9: getVariables

 public function getVariables()
 {
     if ($_SESSION['user']['user_role'] != 1) {
         header('Location: /');
         exit;
     }
     // get requested user Id
     $this->serverId = control()->registry()->get('request', 'variables', 0);
     $detail = control()->database()->search('server')->addFilter('server_id=%s', $this->serverId)->getRow();
     $user = control()->database()->search('dev')->innerJoinOn('user', 'user_id=dev_user')->filterByDevServer($this->serverId);
     // Determine Current Page
     $page = isset($_GET['page']) ? $_GET['page'] : 1;
     // Get The Start In Query
     $start = isset($_GET['page']) && $_GET['page'] != 1 ? ($_GET['page'] - 1) * self::RANGE : 0;
     $totalUsers = $user->getTotal();
     $user = $user->setStart($start)->setRange(self::RANGE)->getRows();
     return array('detail' => $detail, 'user' => $user, 'range' => self::RANGE, 'page' => $page, 'totalUsers' => $totalUsers);
 }
开发者ID:rujealfon,项目名称:UAC,代码行数:18,代码来源:Detail.php

示例10: verify

 protected function verify($data, $userId)
 {
     if (!isset($data['password']) || !trim($data['password'])) {
         $this->setVerifyMsg('Password invalid!', 'danger');
     }
     if (!isset($data['password_repeat']) || !trim($data['password_repeat'])) {
         $this->setVerifyMsg('Password did not match!', 'danger');
     }
     if ($data['password'] != $data['password_repeat']) {
         $this->setVerifyMsg('Password did not match!', 'danger');
     }
     $pass = \Mod\User::i()->encode($data['password']);
     $fields = array('user_pass' => $pass, 'user_active' => 1);
     $query = array(array('user_id=%s', $userId));
     control()->database()->updateRows('user', $fields, $query);
     $_SESSION['loginError'] = array('type' => 'success', 'msg' => 'Your account has been activated. You can now login using your username and password');
     header('Location: /login');
     exit;
 }
开发者ID:rujealfon,项目名称:UAC,代码行数:19,代码来源:Verify.php

示例11: login

 protected function login($data)
 {
     $error = array();
     if (!isset($data['email']) || !trim($data['email'])) {
         $this->loginError(array('type' => 'danger', 'msg' => 'Email Address cannot be empty!'));
     }
     if (!isset($data['password']) || !trim($data['password'])) {
         $this->loginError(array('type' => 'danger', 'msg' => 'Password is invalid!'));
     }
     $pass = \Mod\User::i()->encode($data['password']);
     $email = control()->database()->bind($data['email']);
     $account = control()->database()->search('user')->filterByUserPass($pass)->filterByUserActive(1)->addFilter('(user_email = ' . $email . ' OR user_name = ' . $email . ')')->getRow();
     if (empty($account)) {
         $this->loginError(array('type' => 'danger', 'msg' => 'Username and Password did not match'));
     }
     $_SESSION['user'] = $account;
     header('Location: /');
     exit;
 }
开发者ID:rujealfon,项目名称:UAC,代码行数:19,代码来源:Login.php

示例12: addUser

 protected function addUser($user)
 {
     // check data
     // validate email email
     if (!isset($user['email']) && !trim($user['email'])) {
         $this->setMsg('Email is invalid!', 'danger');
     }
     if (!preg_match('/^[A-Za-z0-9\\._\\-]+\\@[A-Za-z0-9\\.\\-]+\\.[A-Za-z]{2,6}$/i', $user['email'])) {
         $this->setMsg('Email is invalid!', 'danger');
     }
     $account = control()->database()->search('user')->filterByUserEmail($user['email'])->getRow();
     if (!empty($account)) {
         $this->setMsg('Email is already taken', 'danger');
     }
     // validate username
     if (!isset($user['name']) || !trim($user['name'])) {
         $this->setMsg('Username is invalid!', 'danger');
     }
     $account = control()->database()->search('user')->filterByUserName($user['name'])->getRow();
     if (!empty($account)) {
         $this->setMsg('Username is already taken', 'danger');
     }
     if (!isset($user['first']) || !trim($user['first'])) {
         $this->setMsg('Please provide a firstname', 'danger');
     }
     if (!isset($user['last']) || !trim($user['last'])) {
         $this->setMsg('Please provide a lastname', 'danger');
     }
     if (!isset($user['role']) || $user['role'] < 0 && $data['role'] > 1) {
         $this->setMsg('Invalid role!', 'danger');
     }
     $user['status'] = '0';
     $fields = array('user_email' => $user['email'], 'user_name' => $user['name'], 'user_first' => $user['first'], 'user_last' => $user['last'], 'user_role' => $user['role'], 'user_pass' => '', 'user_active' => $user['status']);
     $token = \Mod\User::i()->encode($user['email']);
     $html = '<h3>User Access Control Account Verification</h3>' . '<p>Hi ' . ucwords($user['first']) . ',</p><br>' . '<p>Please verify your account for User Access Control</p>' . '<p>To verify your account, Visit the link below and create your password.</p>' . '<p><a href="http://' . $_SERVER['HTTP_HOST'] . '/verify?token=' . $token . '">http://' . $_SERVER['HTTP_HOST'] . '/verify?token=' . $token . '</a></p>' . '<br>' . '<p>Thanks</p>' . '<p>Openovate Team</p>';
     $account = control('system')->file(control()->path('config') . '/front/accounts.php')->getData();
     control('mail')->smtp($account['host'], $account['email'], $account['pass'], $account['port'], true)->addTo($user['email'])->setSubject('Account Verification')->setBody($html, true)->send();
     control()->database()->insertRow('user', $fields);
     $this->setMsg('User ' . $user['name'] . ' has been created', 'success');
 }
开发者ID:rujealfon,项目名称:UAC,代码行数:40,代码来源:Add.php

示例13: addServer

 protected function addServer($data)
 {
     if (!isset($data['name']) || !trim($data['name'])) {
         $this->setMsg('Server name is required!', 'danger');
     }
     if (!isset($data['root']) || !trim($data['root'])) {
         $this->setMsg('Server username is invalid!', 'danger');
     }
     if (!isset($data['pass']) || !trim($data['pass'])) {
         $this->setMsg('Password is invalid', 'danger');
     }
     if (!isset($data['ip']) || !trim($data['ip'])) {
         $this->setMsg('Server IP is invalid!', 'danger');
     }
     $server = control()->database()->search('server')->filterByServerIp($data['ip'])->getRow();
     if (!empty($server)) {
         $this->setMsg('Server IP already exist!', 'danger');
     }
     $fields = array('server_name' => $data['name'], 'server_root' => $data['root'], 'server_pass' => \Mod\User::i()->encode($data['pass']), 'server_ip' => $data['ip']);
     control()->database()->insertRow('server', $fields);
     $id = control()->database()->getLastInsertedId();
     \Mod\Server::i()->setId($id)->addServer();
     $this->setMsg('Server added', 'success');
 }
开发者ID:rujealfon,项目名称:UAC,代码行数:24,代码来源:Add.php

示例14: playlist


//.........这里部分代码省略.........
    }
    // Ok, now we need to figure out where to add the stuff
    if ($_SESSION['jb-addtype'] == "current") {
        // Ok, let's split our first playlist in 2 so we can add in the middle
        //$begArr = array_slice($curList,0,$curTrack+1);
        if (is_array($curList)) {
            $begArr = array();
            $endArr = array_slice($curList, $curTrack + 1);
        } else {
            $begArr = array();
            $endArr = array();
        }
    } else {
        if ($_SESSION['jb-addtype'] == "begin") {
            $begArr = array();
            $endArr = $curList;
        } else {
            if ($_SESSION['jb-addtype'] == "end") {
                $begArr = array();
                $endArr = array();
            } else {
                if ($_SESSION['jb-addtype'] == "replace") {
                    $begArr = array();
                    $endArr = array();
                }
            }
        }
    }
    if ($restart_playback === true) {
        $myMpd->Stop();
        $myMpd->PLClear();
    } else {
        if ($_SESSION['jb-addtype'] == "current") {
            // Remove everything at the end of the playlist, since we are going to readd it all.
            for ($i = sizeof($curList); $i > $curTrack; $i--) {
                $myMpd->PLRemove($i);
            }
        }
    }
    // Now let's send the new playlist to the player
    for ($i = 0; $i < count($begArr); $i++) {
        // Now let's add this
        if ($begArr[$i] != '') {
            $myMpd->PLAdd($begArr[$i]);
        }
    }
    // Ok, Now let's add the new stuff
    $pArray = explode("\n", $playlist);
    for ($i = 0; $i < count($pArray); $i++) {
        if ($pArray[$i] != "") {
            // Now let's clean up the paths so we can add the media
            $mArr = explode("|", $media_dirs);
            $track = trim($pArray[$i]);
            for ($e = 0; $e < count($mArr); $e++) {
                if (false !== strpos($track, $mArr[$e])) {
                    $track = trim(str_replace($mArr[$e] . "/", "", $track));
                    if ($track[0] == '/') {
                        $track = substr($track, 1);
                    }
                }
            }
            $myMpd->PLAdd($track);
        }
    }
    // Now let's finish this out
    for ($i = 0; $i < count($endArr); $i++) {
        // Now let's add this
        if ($endArr[$i] != '') {
            $myMpd->PLAdd($endArr[$i]);
        }
    }
    // Now let's jump to where we need to play
    switch ($_SESSION['jb-addtype']) {
        case "current":
            if ($curTrack == 0) {
                $curTrack = -1;
            }
            $_POST['jbjumpto'] = $curTrack + 1;
            break;
        case "end":
            $_POST['jbjumpto'] = $curTrack;
            break;
        case "replace":
        case "begin":
            $_POST['jbjumpto'] = 0;
            break;
    }
    if ($restart_playback) {
        control("jumpto");
    }
    control("play");
    if (defined('NO_AJAX_JUKEBOX')) {
        ?>
		<script>
			history.back();
		</script>
		<?php 
    }
    exit;
}
开发者ID:seanfbrown,项目名称:jinzora,代码行数:101,代码来源:mpd.php

示例15: array

    //The homepage for the network
    $registry->getObject('template')->getPage()->addTag('sitename', $registry->getSetting('sitename'));
    $registry->getObject('template')->getPage()->addTag('baseurl', $registry->getSetting('baseurl'));
    $registry->getObject('template')->getPage()->addTag('siteurl', $registry->getSetting('siteurl'));
    $registry->getObject('template')->buildFromTemplate('header.php', 'main.php', 'footer.php');
    $controllers = array();
    $controllerSQL = "SELECT * FROM controllers WHERE active=1";
    $registry->getObject('db')->executeQuery($controllerSQL);
    while ($control = $registry->getObject('db')->getRows()) {
        $controllers[] = $control['controller'];
    }
    $controller = $registry->getObject('url')->getURLBit(0);
    if (in_array($controller, $controllers)) {
        control($controller, $registry);
    } else {
        control('', $registry);
    }
    if ($registry->getObject('authenticate')->isLoggedIn() == true) {
        $registry->getObject('template')->addTemplateBit('userbar', 'userbar_loggedin.php');
        $registry->getObject('template')->getPage()->addTag('username', $registry->getObject('authenticate')->getUser()->getUsername());
    } else {
        $registry->getObject('template')->addTemplateBit('userbar', 'userbar-guest.php');
    }
    $registry->getObject('template')->parseOutput();
    print $registry->getObject('template')->getPage()->getContentToPrint();
} catch (Exception $e) {
    require_once 'errorHandler.php';
    $handle = new ErrorHandler($e->getMessage());
}
function control($bit, $reg)
{
开发者ID:maxzeroedge,项目名称:social,代码行数:31,代码来源:index.php


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