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


PHP SkinTemplate::makeSpecialUrlSubpage方法代码示例

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


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

示例1: execute

 function execute($par)
 {
     $request = $this->getRequest();
     $output = $this->getOutput();
     $this->setHeaders();
     if (!$this->userCanExecute($this->getUser())) {
         $this->displayRestrictionError();
         return;
     }
     global $virtualFactoryURL;
     global $virtualFactoryUser;
     global $virtualFactoryPass;
     global $virtualFactoryImages;
     if ($par === "token") {
         $token = $request->getText('id');
         $success = 0;
         $context = stream_context_create(array('http' => array('header' => array("Authorization: Basic " . base64_encode("{$virtualFactoryUser}:{$virtualFactoryPass}"), "Content-type: application/x-www-form-urlencoded"), 'method' => 'POST', 'content' => http_build_query(array('token' => $token)))));
         $response = file_get_contents("{$virtualFactoryURL}/0.1/query", false, $context);
         $data = json_decode($response)->data;
         $success = $data->status;
         if (!$success) {
             $redirect = SkinTemplate::makeSpecialUrlSubpage('DockerAccess', "token", "id={$token}");
             $this->getOutput()->redirect($redirect);
         } else {
             if (isset($_SERVER['HTTPS'])) {
                 $encrypted = 1;
                 $port = $data->host_ssl_port;
             } else {
                 $encrypted = 0;
                 $port = $data->host_port;
             }
             $host = $data->host_name;
             $password = $data->instance_password;
             $path = $data->instance_path;
             $url = "/extensions/DockerAccess/noVNC/vnc.html?resize=scale&autoconnect=1&host=" . $host . "&port=" . $port . "&password=" . $password . "&path=" . $path . "&encrypted=" . $encrypted;
             $this->getOutput()->redirect($url);
         }
     }
     if (!($par === "launch")) {
         $wikitext = "Please select an image to launch from the follwing list:\n";
         foreach ($virtualFactoryImages as $image => $readableName) {
             $wikitext .= "* <span class=\"plainlinks\">[{{fullurl:{{FULLPAGENAME}}}}/launch?image={$image} {$readableName}]<span>\n";
         }
         $output->addWikiText($wikitext);
         return;
     }
     # Check Image Parameter
     $imageID = $request->getText('image');
     if ($imageID === "") {
         $wikitext = "No image specified";
         $output->addWikiText($wikitext);
         return;
     }
     $userID = $this->getUser()->getId();
     if (!array_key_exists($imageID, $virtualFactoryImages)) {
         $wikitext = "Image {$imageID} is not in the list of authorized images. Please see [[Special:DockerAccess]]";
         $output->addWikiText($wikitext);
         return;
     }
     $data = array("user" => $userID, "image" => $imageID, "enable_cuda" => 1);
     $context = stream_context_create(array('http' => array('header' => array("Authorization: Basic " . base64_encode("{$virtualFactoryUser}:{$virtualFactoryPass}"), "Content-type: application/x-www-form-urlencoded"), 'method' => 'POST', 'content' => http_build_query($data))));
     $response = file_get_contents("{$virtualFactoryURL}/0.1/create", false, $context);
     $token = json_decode($response)->data->token;
     $success = 0;
     $data = 0;
     $redirect = SkinTemplate::makeSpecialUrlSubpage('DockerAccess', 'token', "id={$token}");
     $this->getOutput()->redirect($redirect);
     // 		$success_text = "/vnc.html";
     // 		# If $response starts with $success_text...
     // 		if (substr($response, 0, strlen($success_text)) === $success_text) {
     // 			$wikitext = "Your VNC virtual instance is ready. To access it, [".$virtualFactoryURL.$response.' please click here].';
     // 		} else {
     // 			$wikitext = "'''Internal Error!'''\n\nServer replied:\n ".$response."\nIf you believe it is a bug, please report it to [mailto:sysadmin@wikitolearn.org sysadmin@wikitolearn.org].";
     // 		}
     //
     // 		$output->addWikiText( $wikitext );
 }
开发者ID:WikiToLearn,项目名称:DockerAccess,代码行数:77,代码来源:SpecialDockerAccess.php


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