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


PHP Utils::secure方法代码示例

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


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

示例1: create

 public function create($request)
 {
     $data = $request->getParameters();
     if (isset($data['submitLogin']) && !Session::isActive()) {
         $is_admin = isset($data['is_admin']) && $data['is_admin'] == 1;
         $username = Utils::secure($data['username']);
         $password = Utils::secure($data['pass']);
         if (User::find_by_username($username)) {
             $user = User::find_by_username($username);
             $current_log_fail = $user->getLogFails();
             if (!$user->isAllowedToAttemptLogin()) {
                 $next_timestamp = $current_log_fail['next_try'];
                 $last_try_timestamp = $current_log_fail['last_try'];
                 $nb_try = $current_log_fail['nb_try'];
                 $next_try_tps = $next_timestamp - Utils::tps();
                 $next_try_min = floor($next_try_tps / 60);
                 $next_try_sec = round($next_try_tps - $next_try_min * 60);
                 $next_try_str = "{$next_try_min} m et {$next_try_sec} s";
                 $data = isset($data['redirect']) ? ['redirect' => $data['redirect']] : [];
                 $data['currentPageTitle'] = 'Connexion';
                 $response = !$is_admin ? new ViewResponse('login/login', $data) : new ViewResponse('admin/login/login', $data, true, 'layouts/admin_login.php', 401);
                 $response->addMessage(ViewMessage::error($nb_try . " tentatives de connexions à la suite pour ce compte. Veuillez patienter {$next_try_str}"));
                 return $response;
             }
             $realPass = User::find_by_username($username)->getPassword();
             if (password_verify($password, $realPass)) {
                 User::connect($username, 1);
                 $user->resetLogFails();
                 return new RedirectResponse($data['redirect'] ? urldecode($data['redirect']) : WEBROOT);
             } else {
                 if (sha1($password) == $realPass) {
                     $user->resetLogFails();
                     User::connect($username, 1)->setPassword(password_hash($password, PASSWORD_BCRYPT));
                     return new RedirectResponse($data['redirect'] ? urldecode($data['redirect']) : WEBROOT);
                 }
                 if (!$user->isIntervalBetweenTwoLogAttemptElapsed() || !$current_log_fail) {
                     $user->addLogFail();
                 } else {
                     $user->resetLogFails();
                     $user->addLogFail();
                 }
                 $data = isset($data['redirect']) ? ['redirect' => $data['redirect']] : [];
                 $data['currentPageTitle'] = 'Connexion';
                 $response = !$is_admin ? new ViewResponse('login/login', $data) : new ViewResponse('admin/login/login', $data, true, 'layouts/admin_login.php', 401);
                 $response->addMessage(ViewMessage::error('Mot de passe incorrect'));
                 return $response;
             }
         } else {
             $data = isset($data['redirect']) ? ['redirect' => $data['redirect']] : [];
             $data['currentPageTitle'] = 'Connexion';
             $response = !$is_admin ? new ViewResponse('login/login', $data) : new ViewResponse('admin/login/login', $data, true, 'layouts/admin_login.php', 401);
             $response->addMessage(ViewMessage::error('Ce nom d\'utilisateur n\'existe pas'));
             return $response;
         }
     }
 }
开发者ID:boulama,项目名称:DreamVids,代码行数:56,代码来源:login_controller.php

示例2: create

 public function create($request)
 {
     $req = $request->getParameters();
     if (isset($req['post-message-submit'], $req['channel'], $req['post-content']) && Session::isActive()) {
         $channelId = $req['channel'];
         $channel = UserChannel::exists($channelId) ? UserChannel::find($channelId) : UserChannel::find_by_name($channelId);
         if (is_object($channel) && $channel->belongToUser(Session::get()->id)) {
             $postContent = $req['post-content'];
             $postContent = trim($postContent);
             if (!empty($postContent)) {
                 $post = $channel->postMessage($postContent);
                 $postData = array('id' => $post->id, 'channel_id' => $post->channel_id, 'content' => Utils::secure($post->content), 'timestamp' => $post->timestamp);
                 return new JsonResponse($postData);
             }
         }
     }
     return new Response(500);
 }
开发者ID:boulama,项目名称:DreamVids,代码行数:18,代码来源:channel_post_controller.php

示例3: create

 public function create($request)
 {
     $req = $request->getParameters();
     $data = $req;
     $data['current'] = 'channels';
     $name = @Utils::secure($req['name']);
     $descr = @Utils::secure($req['description']);
     if (isset($req['createChannelSubmit']) && Session::isActive()) {
         $data = array();
         $data['currentPageTitle'] = 'Créer une chaine';
         if (isset($req['name'], $req['description'])) {
             if (strlen($name) >= 3 && strlen($name) <= 40) {
                 if (preg_match("#^[a-zA-Z0-9\\_\\-\\.]+\$#", $name)) {
                     if (UserChannel::isNameFree($name)) {
                         UserChannel::addNew($name, $descr, $req['_FILES_']['avatar'], $req['_FILES_']['background']);
                         $data['channels'] = Session::get()->getOwnedChannels();
                         $data['currentPageTitle'] = 'Mes chaines';
                         $response = new ViewResponse('account/channels', $data);
                         $response->addMessage(ViewMessage::success('Votre nouvelle chaîne a bien été créée ! Faites-en bon usage !'));
                         return $response;
                     } else {
                         $response = new ViewResponse('channel/create', $data);
                         $response->addMessage(ViewMessage::error('Ce nom de chaine est déjà utilisé.'));
                         return $response;
                     }
                 } else {
                     $response = new ViewResponse('channel/create', $data);
                     $response->addMessage(ViewMessage::error('Le nom de la chaîne doit contenir uniquement des lettres (majuscules et minuscules), des traits-d\'union, des _ et des points.'));
                     return $response;
                 }
             } else {
                 $response = new ViewResponse('channel/create', $data);
                 $response->addMessage(ViewMessage::error('Le nom de la chaîne doit être compris entre 3 et 40 caractères.'));
                 return $response;
             }
         } else {
             $response = new ViewResponse('channel/create', $data);
             $response->addMessage(ViewMessage::error('Tous les champs doivent être remplis.'));
             return $response;
         }
     }
     $response = new ViewResponse('channel/create', $data);
     return $response;
 }
开发者ID:boulama,项目名称:DreamVids,代码行数:44,代码来源:channel_controller.php

示例4: create

 public function create($request)
 {
     $params = $request->getParameters();
     if (Session::isActive()) {
         if (isset($params['channel-id']) && UserChannel::exists(Utils::secure($params['channel-id']))) {
             $channel = UserChannel::find(Utils::secure($params['channel-id']));
             if (!$channel->hasLiveAccess() && $channel->belongToUser(Session::get()->id)) {
                 $access = LiveAccess::create(array('channel_id' => $channel->id, 'user_id' => Session::get()->id, 'key' => hash_hmac('sha256', mt_rand(), mt_rand()), 'timestamp' => time()));
                 return new RedirectResponse(WEBROOT . 'lives');
                 exit;
                 //return new JsonResponse(array('key' => $access->key, 'channel' => $channel->name, 'id' => $access->id));
             } else {
                 return new Response(500);
             }
         } else {
             return new Response(500);
         }
     } else {
         return Utils::getUnauthorizedResponse();
     }
 }
开发者ID:boulama,项目名称:DreamVids,代码行数:21,代码来源:live_controller.php

示例5: create

 public function create($request)
 {
     if (Session::isActive()) {
         $req = $request->getParameters();
         Session::get()->last_visit = Utils::tps();
         Session::get()->save();
         if (isset($req['sender'], $req['conversation'], $req['content']) && !empty($req['conversation']) && !empty($req['sender']) && !empty($req['content'])) {
             $sender = Utils::secure($req['sender']);
             $conversation = Utils::secure($req['conversation']);
             $content = Utils::secure($req['content']);
             $channel = UserChannel::exists($sender) ? UserChannel::find($sender) : false;
             if ($channel && $channel->belongToUser(Session::get()->id) && ($conv = Conversation::find($conversation))) {
                 if (!$conv->containsChannel($channel)) {
                     return Utils::getUnauthorizedResponse();
                 }
                 $message = Message::sendNew($sender, $conversation, $content);
                 $messageData = array('id' => $message->id, 'avatar' => $channel->getAvatar(), 'pseudo' => $channel->name, 'text' => $content, 'mine' => 'true');
                 return new JsonResponse($messageData);
             }
         }
     }
     return new Response(500);
 }
开发者ID:boulama,项目名称:DreamVids,代码行数:23,代码来源:message_controller.php

示例6: create

 public function create($request)
 {
     $req = $request->getParameters();
     if (isset($req['commentSubmit'], $req['from-channel'], $req['video-id']) && Session::isActive()) {
         $channelId = Utils::secure($req['from-channel']);
         $min_timestamp = Utils::tps() - Config::getValue_("time_between_comments");
         if (Comment::exists(array('conditions' => array("poster_id=? AND timestamp > ?", $channelId, $min_timestamp)))) {
             return new Response(500);
         }
         if (UserChannel::exists($channelId) && UserChannel::find($channelId)->belongToUser(Session::get()->id)) {
             $content = Utils::secure($req['comment-content']);
             $content = trim($content);
             $parent = isset($req['parent']) ? Utils::secure($req['parent']) : '';
             if (!empty($content)) {
                 $vidId = Utils::secure($req['video-id']);
                 $comment = Comment::postNew($channelId, $vidId, $content, $parent);
                 $commentData = array('id' => $comment->id, 'author' => UserChannel::find($comment->poster_id)->name, 'video_id' => $vidId, 'comment' => $content, 'relativeTime' => Utils::relative_time($comment->timestamp), 'likes' => $comment->likes, 'dislikes' => $comment->dislikes);
                 return new JsonResponse($commentData);
             }
         }
     }
     return new Response(500);
 }
开发者ID:boulama,项目名称:DreamVids,代码行数:23,代码来源:comment_controller.php

示例7:

<div class="row">
	<h1>Dashboard</h1>
  <div class="col-lg-3 col-sm-6 col-xs-12">
    <div class="thumbnail">
      <img src="<?php 
echo StaffContact::getImageName(Session::get());
?>
" alt="Avatar">
      <div class="caption">
        <h3><?php 
echo Utils::secure(StaffContact::getShownName(Session::get()));
?>
</h3>
        
        <p><?php 
echo Utils::secure(StaffContact::getDescription(Session::get()));
?>
            <a href="<?php 
echo WEBROOT . 'admin/staffContactDetails/edit_public_infos/';
?>
" class="btn btn-primary" role="button">Changer mes infos officielles</a>
        </p>
        <p>
        </p>
      </div>
    </div>
  </div>
	<div class="col-lg-6 col-sm-6 col-xs-12">
<?php 
foreach ($storage_server as $srv) {
    ?>
开发者ID:boulama,项目名称:DreamVids,代码行数:31,代码来源:index.php

示例8: foreach

include VIEW . 'layouts/messages_bootstrap.php';
?>
    <form action="<?php 
echo WEBROOT;
?>
admin/ticketlevels/edit_users" method="post">
        <input type="hidden" name="_method" value="PUT">
    <?php 
foreach ($users as $user) {
    $lvls_id = $user->getAssignedLevelsIds();
    ?>
            <div class="col-md-3">
                <div class="well">
                    <div class="form-group">
                        <label><?php 
    echo Utils::secure(StaffContact::getShownName($user));
    ?>
</label>
                        <?php 
    foreach ($levels as $level) {
        $checked = in_array($level->id, $lvls_id) ? 'checked' : '';
        ?>
                        <div class="checkbox">
                            <label>
                            <input name="<?php 
        echo $level->id . '_' . $user->id;
        ?>
" type="checkbox" <?php 
        echo $checked;
        ?>
><?php 
开发者ID:boulama,项目名称:DreamVids,代码行数:31,代码来源:edit_users.php

示例9: displayComments

function displayComments($video, $parent, $i)
{
    $comments = $video->getComments($parent);
    if (empty($comments)) {
        ?>
					<p>Aucun commentaire à propos de cette video</p>
				<?php 
    }
    foreach ($comments as $comment) {
        $comment->comment = Utils::makeLinks(Utils::secure($comment->comment));
        $margin = $i * 8;
        ?>
					<div style="width: <?php 
        echo 100 - $margin;
        ?>
%; margin-left:<?php 
        echo $margin;
        ?>
%" class="comment" id="c-<?php 
        echo $comment->id;
        ?>
">
						<div class="comment-head">
							<div class="user">
								<img src="<?php 
        echo UserChannel::find($comment->poster_id)->getAvatar();
        ?>
" alt="[Avatar]">
								<a href="<?php 
        echo WEBROOT . 'channel/' . UserChannel::find($comment->poster_id)->name;
        ?>
"><?php 
        echo UserChannel::getNameById($comment->poster_id);
        ?>
</a>
							</div>
							<div class="date">
								<p><?php 
        echo Utils::relative_time($comment->timestamp);
        echo $comment->last_updated_timestamp ? ' (Edité ' . Utils::relative_time($comment->last_updated_timestamp) . ')' : '';
        ?>
</p>
							</div>
						</div>
						<div class="comment-text">
							<p style="word-wrap:break-word"><?php 
        echo $comment->comment;
        ?>
</p>
						</div>
						<div class="comment-notation">
							<ul>
								<li class="plus" id="plus-<?php 
        echo $comment->id;
        ?>
" onclick="likeComment('<?php 
        echo $comment->id;
        ?>
')">+<?php 
        echo $comment->likes;
        ?>
</li>
								<li class="moins" id="moins-<?php 
        echo $comment->id;
        ?>
" onclick="dislikeComment('<?php 
        echo $comment->id;
        ?>
')">-<?php 
        echo $comment->dislikes;
        ?>
</li>
								<li onclick="reportComment('<?php 
        echo $comment->id;
        ?>
', this)" style="cursor:pointer">Signaler</li>
								<li onclick="document.location.href='#comments';document.getElementById('response').innerHTML='<b>Répondre à <?php 
        echo UserChannel::getNameById($comment->poster_id);
        ?>
 :</b>';document.getElementById('textarea-comment').focus();document.getElementById('parent-comment').value='<?php 
        echo $comment->id;
        ?>
';" style="cursor:pointer">Répondre</li>
								<?php 
        if (Session::isActive() && (Session::get()->isModerator() || Session::get()->isAdmin() || $comment->getAuthor()->belongToUser(Session::get()->id))) {
            ?>
								
								<li onclick="editComment('<?php 
            echo $comment->id;
            ?>
', this)" style="cursor:pointer">Editer</li>
								<?php 
        }
        ?>
								<?php 
        if (Session::isActive() && (Session::get()->isModerator() || Session::get()->isAdmin() || $video->getAuthor()->belongToUser(Session::get()->id) || $comment->getAuthor()->belongToUser(Session::get()->id))) {
            ?>
								<li onclick="deleteComment('<?php 
            echo $comment->id;
            ?>
//.........这里部分代码省略.........
开发者ID:boulama,项目名称:DreamVids,代码行数:101,代码来源:video.php

示例10:

    echo $k % 2 != 0 ? 'class="timeline-inverted"' : '';
    ?>
>
                                    
                                    <?php 
    echo $new->getBadge();
    ?>

                                    <div class="timeline-panel">
                                        <div class="timeline-heading">
                                            <h4 class="timeline-title"><?php 
    echo $new->title;
    ?>
</h4>
                                            <p><small class="text-muted"><i class="fa fa-clock-o"></i> <?php 
    echo Utils::relative_time($new->timestamp) . " par " . Utils::secure(StaffContact::getShownName($new->user));
    ?>
</small>
                                            </p>
                                        </div>
                                        <div class="timeline-body">
                                            <p><?php 
    echo $new->content;
    ?>
</p>
                                            <?php 
    if ($new->belongsToUser(Session::get())) {
        ?>
                                            <div id="modal_<?php 
        echo $new->id;
        ?>
开发者ID:agiza,项目名称:DreamVids,代码行数:31,代码来源:home.php

示例11: mail

 private function mail($ticket, $message)
 {
     if ($ticket->user_id !== '0') {
         $username = User::exists(array('id' => $ticket->user_id)) ? ' ' . User::find($ticket->user_id)->username : '';
         $to = User::exists(array('id' => $ticket->user_id)) ? User::find($ticket->user_id)->email : $ticket->user_id;
         $subject = '[DreamVids] Avancement de votre demande d\'assistance #' . $ticket->id;
         $message = str_replace('{{tech}}', Utils::secure(StaffContact::getShownName(Session::get())), $message);
         $message = "Bonjour{$username},\r\n\r\n{$message}\r\n\r\nCordialement,\r\nL'équipe DreamVids.";
         $headers = 'From: DreamVids <assistance@dreamvids.fr>';
         mail($to, $subject, utf8_decode($message), $headers);
     }
 }
开发者ID:agiza,项目名称:DreamVids,代码行数:12,代码来源:tickets_controller.php

示例12: update

 public function update($id, $request)
 {
     if (!Session::isActive()) {
         return new RedirectResponse(Utils::generateLoginURL());
     }
     $req = $request->getParameters();
     $data = $req;
     $data['current'] = 'account';
     $data['email'] = Session::get()->email;
     $data['currentPageTitle'] = 'Mon compte';
     if ($id == 'infos') {
         if (isset($req['profileSubmit']) && Session::isActive()) {
             $user = Session::get();
             $currentMail = Session::get()->email;
             $currentUsername = Session::get()->username;
             if (isset($req['email']) && $req['email'] != $currentMail) {
                 $newMail = Utils::secure($req['email']);
                 if (Utils::validateMail($newMail)) {
                     $user->email = $newMail;
                     $user->save();
                     $data['email'] = $newMail;
                 } else {
                     $response = new ViewResponse('account/profile', $data);
                     $response->addMessage(ViewMessage::error('L\'adresse E-Mail n\'est pas valide'));
                     return $response;
                 }
             }
             if (isset($req['username']) && $req['username'] != $currentUsername) {
                 $newUsername = Utils::secure($req['username']);
                 if (Utils::validateUsername($newUsername) && !User::exists(array('username' => $newUsername)) && !UserChannel::exists(['name' => $newUsername])) {
                     $channel = Session::get()->getMainChannel();
                     $user->username = $newUsername;
                     $user->save();
                     $channel->name = $newUsername;
                     $channel->save();
                     $data['username'] = $newUsername;
                 } else {
                     $response = new ViewResponse('account/profile', $data);
                     $response->addMessage(ViewMessage::error('Le nom d\'utilisateur doit être disponible, contenir uniquement des lettres, des chiffres, des points, des traits d\'union et des _ et doit être compris entre 3 et 40 caractères.'));
                     return $response;
                 }
             }
             $response = new ViewResponse('account/profile', $data);
             $response->addMessage(ViewMessage::success('Préférences enregistrées !'));
             return $response;
         }
     }
     if ($id == 'password') {
         if (isset($req['passwordSubmit']) && Session::isActive()) {
             if (isset($req['newPass']) && isset($req['newPassConfirm']) && isset($req['currentPass'])) {
                 if ($req['newPass'] == $req['newPassConfirm']) {
                     $currentPass = $req['currentPass'];
                     $newPass = $req['newPass'];
                     $data = $req;
                     $data['current'] = 'password';
                     if (password_verify($currentPass, Session::get()->pass)) {
                         Session::get()->setPassword(password_hash($newPass, PASSWORD_BCRYPT));
                         $response = new ViewResponse('account/password', $data);
                         $response->addMessage(ViewMessage::success('Préférences enregistrées !'));
                         return $response;
                     } else {
                         $response = new ViewResponse('account/password', $data);
                         $response->addMessage(ViewMessage::error('Le mot de passe actuel est erroné'));
                         return $response;
                     }
                 } else {
                     $response = new ViewResponse('account/password', $data);
                     $response->addMessage(ViewMessage::error('Les mots de passe ne sont pas identiques'));
                     return $response;
                 }
             }
         }
     }
     if ($id == 'volume') {
         $data = $req;
         Session::get()->setSoundSetting($data["volume"]);
         return new Response(200);
     }
     if ($id == 'definition') {
         $data = $req;
         Session::get()->setDefinitionSetting($data["definition"]);
         return new Response(200);
     }
     if ($id == 'notifications') {
         $data = $request->getParameters();
         $data['current'] = 'notifications';
         Session::get()->setNotificationSettings($data);
         $data = array_merge($data, Session::get()->getNotificationSettings());
         $response = new ViewResponse('account/notifications', $data);
         $response->addMessage(ViewMessage::success("Paramètres de notifications sauvegardés"));
         return $response;
     }
     if ($id == 'language') {
         $data['currentPageTitle'] = "Paramètre de langues";
         $data['current'] = 'language';
         Session::get()->setLanguageSetting($req['language']);
         $data['settings'] = Session::get()->getSettings();
         $data['avaiable_languages'] = Translator::getLanguagesList();
         $data['lang_setting'] = Session::get()->getLanguageSetting();
         return new RedirectResponse('account/language', $data);
//.........这里部分代码省略.........
开发者ID:boulama,项目名称:DreamVids,代码行数:101,代码来源:account_controller.php

示例13: executeAction

 private function executeAction($request, $controller, $uriParameters)
 {
     $is_admin = false;
     if (isset($uriParameters[0]) && $uriParameters[0] == "admin") {
         unset($uriParameters[0]);
         $is_admin = true;
         $uriParameters = array_values($uriParameters);
     }
     switch ($request->getMethod()) {
         case Method::GET:
             // Example: /posts/
             if (count($uriParameters) < 1 || $is_admin && count($uriParameters) < 2) {
                 if ($controller->isActionAllowed(Action::INDEX)) {
                     $response = call_user_func_array(array($controller, 'index'), array($request));
                     Utils::sendResponse($response);
                 } else {
                     Utils::getForbiddenResponse()->send();
                 }
             } else {
                 if (count($uriParameters) == 2) {
                     // Example: /posts/latest --> calls the 'latest' method from controller
                     if (method_exists($controller, $uriParameters[1]) || $is_admin) {
                         if (!$this->isCallableAsAction($uriParameters[1])) {
                             $response = Utils::getForbiddenResponse();
                         } else {
                             unset($uriParameters[0]);
                             $response = call_user_func_array(array($controller, $uriParameters[1]), array($request));
                         }
                         Utils::sendResponse($response);
                     } else {
                         if ($controller->isActionAllowed(Action::GET)) {
                             $response = call_user_func_array(array($controller, 'get'), array($uriParameters[1], $request));
                             Utils::sendResponse($response);
                         } else {
                             Utils::getForbiddenResponse()->send();
                         }
                     }
                 } else {
                     if (count($uriParameters) > 2) {
                         // Example: /posts/recents/4 --> calls recents(4) from PostsController, to retrive the 4 most recent posts
                         if (method_exists($controller, $uriParameters[1]) || $is_admin) {
                             $methodName = $uriParameters[1];
                             unset($uriParameters[0]);
                             unset($uriParameters[1]);
                             if (!$this->isCallableAsAction($methodName)) {
                                 $response = Utils::getForbiddenResponse();
                             } else {
                                 $response = call_user_func_array(array($controller, $methodName), array_merge($uriParameters, array($request)));
                             }
                             Utils::sendResponse($response);
                         } else {
                             $methodName = $uriParameters[2];
                             if (method_exists($controller, $methodName)) {
                                 unset($uriParameters[0]);
                                 unset($uriParameters[2]);
                                 if (!$this->isCallableAsAction($methodName)) {
                                     $response = Utils::getForbiddenResponse();
                                 } else {
                                     $response = call_user_func_array(array($controller, $methodName), array(Utils::secureArray($uriParameters), $request));
                                 }
                                 Utils::sendResponse($response);
                             } else {
                                 Utils::getNotFoundResponse()->send();
                             }
                         }
                     }
                 }
             }
             break;
         case Method::POST:
             if ($controller->isActionAllowed(Action::CREATE)) {
                 $request->setParameters(array_merge($_POST, array('_FILES_' => $_FILES)));
                 $response = call_user_func_array(array($controller, 'create'), array($request));
                 Utils::sendResponse($response);
             } else {
                 Utils::getForbiddenResponse()->send();
             }
             break;
         case Method::PUT:
             if (count($uriParameters) == 2) {
                 if ($controller->isActionAllowed(Action::UPDATE)) {
                     $parameters = array();
                     parse_str(file_get_contents('php://input'), $parameters);
                     $request->setParameters($parameters);
                     if (empty($parameters) && !empty($_POST)) {
                         // If the request is not a real PUT request but needs to be handled like one (html form)
                         $request->setParameters(array_merge($_POST, array('_FILES_' => $_FILES)));
                     }
                     $response = call_user_func_array(array($controller, 'update'), array(Utils::secure($uriParameters[1]), $request));
                     Utils::sendResponse($response);
                 } else {
                     Utils::getForbiddenResponse()->send();
                 }
             }
             break;
         case Method::DELETE:
             if (count($uriParameters) == 2) {
                 if ($controller->isActionAllowed(Action::DESTROY)) {
                     $parameters = array();
                     parse_str(file_get_contents('php://input'), $parameters);
//.........这里部分代码省略.........
开发者ID:boulama,项目名称:DreamVids,代码行数:101,代码来源:router.php

示例14: secureArray

 public static function secureArray($array)
 {
     $secureArray = array();
     foreach ($array as $key => $value) {
         if (is_string($value)) {
             $secureArray[$key] = Utils::secure($value);
         }
     }
     return $secureArray;
 }
开发者ID:boulama,项目名称:DreamVids,代码行数:10,代码来源:utils.php

示例15: create

 public function create($request)
 {
     if (Session::isActive()) {
         $req = $request->getParameters();
         if (isset($req['members'], $req['creator'], $req['subject']) && !empty($req['members']) && !empty($req['creator'])) {
             $membersStr = Utils::secure($req['members']);
             $creator = Utils::secure($req['creator']);
             $subject = Utils::secure($req['subject']);
             $subject = !empty($subject) ? $subject : 'Sans titre';
             if ($sender = UserChannel::find($creator)) {
                 if (Utils::stringStartsWith($membersStr, ';')) {
                     $membersStr = substr_replace($membersStr, '', 0, 1);
                 }
                 if (Utils::stringEndsWith($membersStr, ';')) {
                     $membersStr = substr_replace($membersStr, '', -1);
                 }
                 $membersStr = preg_replace('/\\s+/', '', $membersStr);
                 $membersIdsFinal = ';';
                 if (strpos($membersStr, ';')) {
                     foreach (explode(';', $membersStr) as $destId) {
                         if ($dest = UserChannel::find_by_name($destId)) {
                             $membersIdsFinal .= $dest->id . ';';
                         } else {
                             $response = new Response(500);
                             $response->setBody('Error: Le destinataire <' . $destId . '> n\'existe pas !');
                             return $response;
                         }
                     }
                 } else {
                     if ($chann = UserChannel::find_by_name($membersStr)) {
                         $membersIdsFinal .= $chann->id . ';';
                     } else {
                         $response = new Response(500);
                         $response->setBody('Error: les destinataires doivent être séparés par un \';\' !');
                         return $response;
                     }
                 }
                 if ($membersIdsFinal != ';') {
                     $membersIdsFinal .= $sender->id . ';';
                     Conversation::createNew($subject, $sender, $membersIdsFinal);
                     return new Response(200);
                 }
             }
         }
     }
     return new Response(500);
 }
开发者ID:boulama,项目名称:DreamVids,代码行数:47,代码来源:conversation_controller.php


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