浏览代码

loginlink

andre 3 年之前
父节点
当前提交
d7f5124906
共有 2 个文件被更改,包括 18 次插入4 次删除
  1. 10 1
      api/cwp7/Admin.php
  2. 8 3
      cwp7.php

+ 10 - 1
api/cwp7/Admin.php

@@ -315,7 +315,16 @@ class cwp7_Admin {
         $data = array();
         return $this->doRequest('typeserver', 'list', $data);
     }
-
+	/**
+	 * getLoginLink
+	 * 
+	 * @return array status or error
+	 */
+    public function getLoginLink($user, $timer=5)
+	{
+        $data = array('user' => $user, 'timer' => $timer);
+        return $this->doRequest('user_session', 'list', $data);
+    }
     /**
      * doRequest
      * 

+ 8 - 3
cwp7.php

@@ -202,9 +202,14 @@ function cwp7_LoginLink($params) {
 	$arry=(json_decode($answer,true)); //die;F
 	$link=$arry['msj']['details'];
 	$linkautologin=$link[0]['url'];
-	logModuleCall('cwpwhmcs','cwp7_LoginLink','https://' . $params["serverhostname"] . ':2304/v1/user_session'.$postdata,$answer);
-
-	echo "<a href=\"{$linkautologin}\" target=\"_blank\" style=\"color:#cc0000\">Control Panel</a>"; */
+	logModuleCall('cwpwhmcs','cwp7_LoginLink','https://' . $params["serverhostname"] . ':2304/v1/user_session'.$postdata,$answer); */
+	$cwp7 = new cwp7_Admin($params['serverhostname'], $params['serveraccesshash']);
+	$response = $cwp7->getLoginLink($params['username']);
+	if($response['status'] == 'OK') {
+		$link=$response['msj']['details'];
+		$linkautologin=$link[0]['url'];		
+		echo "<a href=\"{$linkautologin}\" target=\"_blank\" style=\"color:#cc0000\">Control Panel</a>";
+	}
 }
 
 function cwp7_ChangePassword($params){