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


PHP Utilities::ValidateJWTToken方法代码示例

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


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

示例1: pay

 /**
  * @method POST
  */
 function pay()
 {
     // get token
     $token = Utilities::ValidateJWTToken(apache_request_headers());
     // check if token is not null
     if ($token != NULL) {
         // parse request
         parse_str($this->request->data, $request);
         $site = Site::GetBySiteId($token->SiteId);
         $siteId = $site['SiteId'];
         $email = $site['PrimaryEmail'];
         $status = 'Active';
         $stripe_token = $request['token'];
         $plan = $request['plan'];
         // set API key
         Stripe::setApiKey(STRIPE_SECRET_KEY);
         // create a new customer and subscribe them to the plan
         $customer = Stripe_Customer::create(array("card" => $stripe_token, "plan" => $plan, "email" => $email));
         // get back the id and the end period for the plan
         $id = $customer->id;
         // get subscription information
         $subscription = $customer->subscriptions->data[0];
         $subscriptionId = $subscription->id;
         $stripe_status = $subscription->status;
         $stripe_plan = $subscription->plan->id;
         $stripe_planname = $subscription->plan->name;
         // subscribe to a plan
         Site::Subscribe($siteId, $status, $plan, 'stripe', $subscriptionId, $customerId);
         // return a json response
         return new Tonic\Response(Tonic\Response::OK);
     } else {
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:sanderdrummer,项目名称:Homepages,代码行数:37,代码来源:pay.php

示例2: get

 /**
  * @method GET
  */
 function get()
 {
     // get token
     $token = Utilities::ValidateJWTToken();
     // check if token is not null
     if ($token != NULL) {
         $list = MenuType::GetMenuTypes($token->SiteId);
         // return a json response
         $response = new Tonic\Response(Tonic\Response::OK);
         $response->contentType = 'application/json';
         $response->body = json_encode($list);
         return $response;
     } else {
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:bladep911,项目名称:respond,代码行数:19,代码来源:menuType.php

示例3: post

 /**
  * @method POST
  */
 function post()
 {
     // get token
     $token = Utilities::ValidateJWTToken();
     // check if token is not null
     if ($token != NULL) {
         // parse request
         parse_str($this->request->data, $request);
         $pageId = $request['pageId'];
         Product::RemoveForPage($pageId);
         // return a json response
         $response = new Tonic\Response(Tonic\Response::OK);
         return $response;
     } else {
         // unauthorized access
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:bladep911,项目名称:respond,代码行数:21,代码来源:product.php

示例4: post

 /**
  * @method POST
  */
 function post()
 {
     // get token
     $token = Utilities::ValidateJWTToken();
     // check if token is not null
     if ($token != NULL) {
         // parse request
         parse_str($this->request->data, $request);
         $pageId = $request['pageId'];
         $list = Version::GetVersions($pageId);
         // return a json response
         $response = new Tonic\Response(Tonic\Response::OK);
         $response->contentType = 'application/json';
         $response->body = json_encode($list);
         return $response;
     } else {
         // unauthorized access
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:bladep911,项目名称:respond,代码行数:23,代码来源:version.php

示例5: get

 /**
  * @method GET
  */
 function get()
 {
     // get token
     $token = Utilities::ValidateJWTToken(apache_request_headers());
     // check if token is not null
     if ($token != NULL) {
         $site = Site::GetBySiteId($token->SiteId);
         $directory = SITES_LOCATION . '/' . $site['FriendlyId'] . '/themes/' . $site['Theme'] . '/styles/';
         //get all image files with a .less ext
         $files = glob($directory . "*.less");
         $arr = array();
         //print each file name
         foreach ($files as $file) {
             $f_arr = explode("/", $file);
             $count = count($f_arr);
             $filename = $f_arr[$count - 1];
             $name = str_replace('.less', '', $filename);
             array_push($arr, $name);
         }
         // return a json response
         $response = new Tonic\Response(Tonic\Response::OK);
         $response->contentType = 'application/json';
         $response->body = json_encode($arr);
         return $response;
     } else {
         // return an unauthorized exception (401)
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:sanderdrummer,项目名称:Homepages,代码行数:32,代码来源:stylesheet.php

示例6: post

 /**
  * @method POST
  */
 function post()
 {
     // get token
     $token = Utilities::ValidateJWTToken(apache_request_headers());
     // check if token is not null
     if ($token != NULL) {
         parse_str($this->request->data, $request);
         // parse request
         $configurations = $request['configurations'];
         $site = Site::GetBySiteId($token->SiteId);
         // get configuration
         $configure_file = SITES_LOCATION . '/' . $site['FriendlyId'] . '/themes/' . $site['Theme'] . '/configure.json';
         // put contents
         file_put_contents($configure_file, $configurations);
         // republish css
         Publish::PublishAllCSS($site);
         // get index
         $page = Page::GetByFriendlyId('index', '-1', $token->SiteId);
         // republish home page
         Publish::PublishPage($page['PageId']);
         // return a json response
         $response = new Tonic\Response(Tonic\Response::OK);
         return $response;
     } else {
         // return an unauthorized exception (401)
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:nboss,项目名称:respond,代码行数:31,代码来源:theme.php

示例7: post

 /**
  * @method POST
  */
 function post()
 {
     // get token
     $token = Utilities::ValidateJWTToken();
     // check if token is not null
     if ($token != NULL) {
         try {
             parse_str($this->request->data, $request);
             // parse request
             $roleId = $request['roleId'];
             // remove role
             Role::Remove($roleId, $token->SiteId);
             // return a response
             $response = new Tonic\Response(Tonic\Response::OK);
             $response->contentType = 'text/html';
             $response->body = 'success';
             return $response;
         } catch (Exception $e) {
             $response = new Tonic\Response(Tonic\Response::BADREQUEST);
             $response->body = $e->getMessage();
             return $response;
         }
     } else {
         // unauthorized access
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:bladep911,项目名称:respond,代码行数:30,代码来源:role.php

示例8: post

 /**
  * @method POST
  */
 function post()
 {
     // get token
     $token = Utilities::ValidateJWTToken();
     $siteId = -1;
     parse_str($this->request->data, $request);
     // parse request
     // check if token is not null
     if ($token != NULL) {
         $siteId = $token->SiteId;
     } else {
         if (isset($request['siteId'])) {
             $siteId = $request['siteId'];
         } else {
             // return an unauthorized exception (401)
             return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
         }
     }
     // get a reference to the site
     $site = Site::GetBySiteId($siteId);
     // set directory an filename
     $dir = SITES_LOCATION . '/' . $site['FriendlyId'] . '/locales/';
     // array to store directories
     $list = array();
     if ($handle = opendir($dir)) {
         $blacklist = array('.', '..');
         while (false !== ($file = readdir($handle))) {
             if (!in_array($file, $blacklist)) {
                 array_push($list, $file);
             }
         }
         closedir($handle);
     }
     // return a json response
     $response = new Tonic\Response(Tonic\Response::OK);
     $response->contentType = 'application/json';
     $response->body = json_encode($list);
     return $response;
 }
开发者ID:bladep911,项目名称:respond,代码行数:42,代码来源:translation.php

示例9: post

 /**
  * @method POST
  */
 function post()
 {
     // get an authuser
     $token = Utilities::ValidateJWTToken(apache_request_headers());
     // check if token is not null
     if ($token != NULL) {
         parse_str($this->request->data, $request);
         // parse request
         Publish::PublishMenuJSON($token->SiteId);
         return new Tonic\Response(Tonic\Response::OK);
     } else {
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:sanderdrummer,项目名称:Homepages,代码行数:17,代码来源:menuItem.php

示例10: post

 /**
  * @method POST
  */
 function post()
 {
     // get token
     $token = Utilities::ValidateJWTToken();
     // check if token is not null
     if ($token != NULL) {
         // parse request
         parse_str($this->request->data, $request);
         $site = Site::GetBySiteId($token->SiteId);
         $siteId = $site['siteId'];
         $status = $site['status'];
         $plan = $request['plan'];
         $provider = $request['provider'];
         $subscriptionId = $request['subscriptionId'];
         $customerId = $request['customerId'];
         $userLimit = $request['userLimit'];
         $fileLimit = $request['fileLimit'];
         // subscribe to a plan
         Site::EditSubscription($siteId, $status, $plan, $provider, $subscriptionId, $customerId, $userLimit, $fileLimit);
         // return a json response
         return new Tonic\Response(Tonic\Response::OK);
     } else {
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:bladep911,项目名称:respond,代码行数:28,代码来源:site.php

示例11: get

 /**
  * @method GET
  */
 function get()
 {
     // get token
     $token = Utilities::ValidateJWTToken(apache_request_headers());
     // check if token is not null
     if ($token != NULL) {
         parse_str($this->request->data, $request);
         // parse request
         // get transactions
         $list = Transaction::GetTransactions($token->SiteId);
         // return a json response
         $response = new Tonic\Response(Tonic\Response::OK);
         $response->contentType = 'application/json';
         $response->body = json_encode($list);
         return $response;
     } else {
         // unauthorized access
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:sanderdrummer,项目名称:Homepages,代码行数:23,代码来源:transaction.php

示例12: get

 /**
  * @method GET
  */
 function get()
 {
     // get token
     $token = Utilities::ValidateJWTToken(apache_request_headers());
     // check if token is not null
     if ($token != NULL) {
         $siteId = $token->SiteId;
         // get user
         $user = User::GetByUserId($token->UserId);
         // creates an access object
         $access = Utilities::SetAccess($user);
         // get pagetype
         $list = PageType::GetPageTypes($siteId);
         // allowed
         $allowed = array();
         // create a root element in the array
         $root = array('FriendlyId' => '', 'IsSecure' => 0, 'LastModifiedBy' => NULL, 'LastModifiedDate' => NULL, 'Layout' => 'content', 'PageTypeId' => -1, 'PageTypeId' => -1, 'SiteId' => -1, 'Stylesheet' => 'content');
         // return the entire list for all access
         if ($access['CanAccess'] == 'All') {
             $allowed = $list;
             array_unshift($allowed, $root);
         } else {
             foreach ($list as $row) {
                 $pageTypeId = $row['PageTypeId'];
                 if (Utilities::CanPerformAction('root', $access['CanAccess']) != false) {
                     array_push($allowed, $root);
                 }
                 //print('$pageTypeId='.$pageTypeId.' access='.$access['CanAccess']);
                 // check permissions
                 if (Utilities::CanPerformAction($pageTypeId, $access['CanAccess']) != false) {
                     array_push($allowed, $row);
                 }
             }
         }
         // return a json response
         $response = new Tonic\Response(Tonic\Response::OK);
         $response->contentType = 'application/json';
         $response->body = json_encode($allowed);
         return $response;
     } else {
         // unauthorized access
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:nboss,项目名称:respond,代码行数:47,代码来源:pageType.php

示例13: post

 /**
  * @method POST
  */
 function post()
 {
     // get token
     $token = Utilities::ValidateJWTToken(apache_request_headers());
     // check if token is not null
     if ($token != NULL) {
         // parse request
         parse_str($this->request->data, $request);
         $site = Site::GetBySiteId($token->SiteId);
         $siteId = $site['SiteId'];
         $email = $site['PrimaryEmail'];
         $status = 'Unsubscribed';
         $plan = '';
         $provider = '';
         $subscriptionId = '';
         $customerId = $site['CustomerId'];
         // set API key
         Stripe::setApiKey(STRIPE_SECRET_KEY);
         // retrieve customer
         $customer = Stripe_Customer::retrieve($site['CustomerId']);
         // unsubscribe
         $cu->subscriptions->retrieve($site['SubscriptionId'])->cancel();
         // unsubscribe to a plan
         Site::Subscribe($siteId, $status, $plan, $provider, $subscriptionId, $customerId);
         // send success email to user
         $to = $site['PrimaryEmail'];
         $from = REPLY_TO;
         $fromName = REPLY_TO_NAME;
         $subject = BRAND . ': You have successfully unsubscribed to ' . BRAND;
         $file = APP_LOCATION . '/emails/unsubscribe-success.html';
         $replace = array('{{brand-logo}}' => '<img src="' . BRAND_LOGO . '" style="max-height:50px">', '{{brand}}' => BRAND, '{{reply-to}}' => REPLY_TO);
         // send
         Utilities::SendEmailFromFile($to, $from, $fromName, $subject, $replace, $file);
         // send details email to admin
         $to = REPLY_TO;
         $from = REPLY_TO;
         $fromName = REPLY_TO_NAME;
         $subject = BRAND . ': Unsubscribed';
         $file = APP_LOCATION . '/emails/unsubscribe-details.html';
         $replace = array('{{brand-logo}}' => '<img src="' . BRAND_LOGO . '" style="max-height:50px">', '{{brand}}' => BRAND, '{{reply-to}}' => REPLY_TO, '{{domain}}' => $domain, '{{siteid}}' => $site['SiteId'], '{{friendlyid}}' => $site['FriendlyId'], '{{provider}}' => $site['Provider'], '{{customerid}}' => $site['CustomerId']);
         // send email from file
         Utilities::SendEmailFromFile($to, $from, $fromName, $subject, $replace, $file);
         // return a json response
         return new Tonic\Response(Tonic\Response::OK);
     } else {
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:sanderdrummer,项目名称:Homepages,代码行数:51,代码来源:site.php

示例14: get

 /**
  * @method GET
  */
 function get()
 {
     // get token
     $token = Utilities::ValidateJWTToken(apache_request_headers());
     // check if token is not null
     if ($token != NULL) {
         // get users
         $list = User::GetUsersForSite($token->SiteId, true);
         $site = Site::GetBySiteId($token->SiteId);
         $updated_list = array();
         //print each file name
         foreach ($list as $user) {
             $hasPhoto = false;
             $fullPhotoUrl = '';
             if ($user['PhotoUrl'] != '' && $user['PhotoUrl'] != '') {
                 $hasPhoto = true;
                 // set images URL
                 if (FILES_ON_S3 == true) {
                     $bucket = $site['Bucket'];
                     $imagesURL = str_replace('{{bucket}}', $bucket, S3_URL);
                     $imagesURL = str_replace('{{site}}', $site['FriendlyId'], $imagesURL);
                 } else {
                     $imagesURL = $site['Domain'];
                 }
                 $fullPhotoUrl = $imagesURL . '/files/thumbs/' . $user['PhotoUrl'];
             }
             $user['HasPhoto'] = $hasPhoto;
             $user['FullPhotoUrl'] = $fullPhotoUrl;
             array_push($updated_list, $user);
         }
         // return a json response
         $response = new Tonic\Response(Tonic\Response::OK);
         $response->contentType = 'application/json';
         $response->body = json_encode($updated_list);
         return $response;
     } else {
         // unauthorized access
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:nboss,项目名称:respond,代码行数:43,代码来源:user.php

示例15: get

 /**
  * @method POST
  */
 function get()
 {
     // get token
     $token = Utilities::ValidateJWTToken(apache_request_headers());
     // check if token is not null
     if ($token != NULL) {
         // get a reference to the site, user
         $site = Site::GetBySiteId($token->SiteId);
         parse_str($this->request->data, $request);
         // parse request
         $filename = $request['filename'];
         $folder = 'files';
         if (isset($_REQUEST['folder'])) {
             $folder = $_REQUEST['folder'];
         }
         if (FILES_ON_S3 == true) {
             // remove file on S3
             S3::RemoveFile($site, $filename, $folder);
         } else {
             // remove local file
             // remove file
             $path = SITES_LOCATION . '/' . $site['FriendlyId'] . '/' . $folder . '/' . $filename;
             if (file_exists($path)) {
                 $path = unlink($path);
             }
             // remove thumb
             $path = SITES_LOCATION . '/' . $site['FriendlyId'] . '/' . $folder . '/thumbs/' . $filename;
             if (file_exists($path)) {
                 $path = unlink($path);
             }
         }
         return new Tonic\Response(Tonic\Response::OK);
     } else {
         // return an unauthorized exception (401)
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:nboss,项目名称:respond,代码行数:40,代码来源:file.php


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