andre 7 сар өмнө
parent
commit
c542b17839
1 өөрчлөгдсөн 112 нэмэгдсэн , 0 устгасан
  1. 112 0
      siteBuilder.php

+ 112 - 0
siteBuilder.php

@@ -653,6 +653,62 @@ function siteBuilder_delSite($params) {
 	if($response['status'] != '200') {
 		return 'Error: ' . $response['response'];
 	}
+	// remove builder session
+	$api = new SiteProApiClient('https://builder.thurdata.ch/api/', 'apikey0', '993yVHwC05TLsx2JI2XFlAhkkPUxR6JbQUYbI.a5HiRtmNV9');
+	// use this for enterprise licenses and change 'your-bulder-domain.com' to your builder domain
+	//$api = new SiteProApiClient('http://your-bulder-domain.com/api/', 'your_api_username', 'your_api_password');
+
+	try {
+		// this call is used to open builder, so you need to set correct parameters to represent users website you want to open
+		// this data usually comes from your user/hosting manager system
+		$res = $api->remoteCall('requestLogin', array(
+			'type' => 'internal',				// (required) 'internal'
+			'domain' => $site,			// (required) domain of the user website you want to edit
+			'lang' => 'de',						// (optional) 2-letter language code, set language code you whant builder to open in
+			'apiUrl' => getSiteBuilderApiURL($params) . 'deploy/' . $params['username'] . '/' . $site, // (required) API endpoint URL
+			'resellerClientAccountId' => $params['serviceid'],	// (required) ID of website/user in your system
+			'username' => $params['serverusername'],	// (optional) authorization username to be used with API endpoint
+			'password' => 'your-secure-password', // (optional) authorization password to be used with API endpoint
+		));
+		if (!$res || !is_object($res)) {
+			logModuleCall(
+				'siteBuilder',
+				__FUNCTION__,
+				$params,
+				'Error: Response format error',
+				$res
+				);
+			return 'Error: Response format error';
+		} else if (isset($res->url) && $res->url) {
+			logModuleCall(
+				'siteBuilder',
+				__FUNCTION__,
+				$params,
+				'Debug',
+				$res
+				);
+			// on success 
+			return 'success';
+		} else {
+			logModuleCall(
+				'siteBuilder',
+				__FUNCTION__,
+				$params,
+				'Error: Unknown error',
+				$res
+				);
+			return 'Error: Unknown error';
+		}
+	}  catch (\Exception $e) {
+		logModuleCall(
+			'siteBuilder',
+			__FUNCTION__,
+			$params,
+			'Error: Request error',
+			$e->getMessage()
+			);
+		return 'Error: Request error';
+	}
 	// update DB
 	try {
 		Capsule::table('sitePro_site')
@@ -709,6 +765,62 @@ function siteBuilder_revSite($params) {
 	if($response['status'] != '200') {
 		return 'Error: ' . $response['response'];
 	}
+		// remove builder session
+		$api = new SiteProApiClient('https://builder.thurdata.ch/api/', 'apikey0', '993yVHwC05TLsx2JI2XFlAhkkPUxR6JbQUYbI.a5HiRtmNV9');
+		// use this for enterprise licenses and change 'your-bulder-domain.com' to your builder domain
+		//$api = new SiteProApiClient('http://your-bulder-domain.com/api/', 'your_api_username', 'your_api_password');
+	
+		try {
+			// this call is used to open builder, so you need to set correct parameters to represent users website you want to open
+			// this data usually comes from your user/hosting manager system
+			$res = $api->remoteCall('requestLogin', array(
+				'type' => 'internal',				// (required) 'internal'
+				'domain' => $site,			// (required) domain of the user website you want to edit
+				'lang' => 'de',						// (optional) 2-letter language code, set language code you whant builder to open in
+				'apiUrl' => getSiteBuilderApiURL($params) . 'deploy/' . $params['username'] . '/' . $site, // (required) API endpoint URL
+				'resellerClientAccountId' => $params['serviceid'],	// (required) ID of website/user in your system
+				'username' => $params['serverusername'],	// (optional) authorization username to be used with API endpoint
+				'password' => 'your-secure-password', // (optional) authorization password to be used with API endpoint
+			));
+			if (!$res || !is_object($res)) {
+				logModuleCall(
+					'siteBuilder',
+					__FUNCTION__,
+					$params,
+					'Error: Response format error',
+					$res
+					);
+				return 'Error: Response format error';
+			} else if (isset($res->url) && $res->url) {
+				logModuleCall(
+					'siteBuilder',
+					__FUNCTION__,
+					$params,
+					'Debug',
+					$res
+					);
+				// on success 
+				return 'success';
+			} else {
+				logModuleCall(
+					'siteBuilder',
+					__FUNCTION__,
+					$params,
+					'Error: Unknown error',
+					$res
+					);
+				return 'Error: Unknown error';
+			}
+		}  catch (\Exception $e) {
+			logModuleCall(
+				'siteBuilder',
+				__FUNCTION__,
+				$params,
+				'Error: Request error',
+				$e->getMessage()
+				);
+			return 'Error: Request error';
+		}
 	return 'success';
 }