public static function loadSiteProcessor($siteIDs, $params) { $timeout = DEFAULT_MAX_CLIENT_REQUEST_TIMEOUT; //$siteID = reset($siteIDs); $siteID = $_REQUEST['siteID']; if (empty($siteID)) { echo 'Invalid Site ID'; } //$where = $params['where'] ? $params['where'].".php" : ''; $where = $_REQUEST['where'] ? $_REQUEST['where'] . ".php" : ''; $loadSiteVars = array(); if (isset($_REQUEST['var_0'])) { for ($i = 0; $i < 5; $i++) { if (isset($_REQUEST['var_' . $i]) && strpos($_REQUEST['var_' . $i], '__IWPVAR__') !== false) { $temp = explode('__IWPVAR__', $_REQUEST['var_' . $i]); $loadSiteVars[$temp[0]] = $temp[1]; } } } //if(!empty($params['vars']) && is_array($params['vars'])){ // $loadSiteVars = $params['vars']; // } $siteData = DB::getRow("?:sites", "*", "siteID=" . DB::realEscapeString($siteID)); if (empty($siteData)) { echo 'Invalid Site ID'; } $type = 'site'; $action = 'load'; $events = 1; $historyData = array('siteID' => $siteData['siteID'], 'actionID' => Reg::get('currentRequest.actionID'), 'userID' => $GLOBALS['userID'], 'type' => $type, 'action' => $action, 'events' => $events, 'URL' => $siteData['URL'], 'status' => 'completed', 'timeout' => $timeout); $historyAdditionalData[] = array('detailedAction' => 'loadSite', 'uniqueName' => 'loadSite', 'status' => 'success'); $historyID = addHistory($historyData, $historyAdditionalData); $signature = signData($where . $historyID, $siteData['isOpenSSLActive'], $siteData['privateKey'], $siteData['randomSignature']); $URLQueryArray = array('auto_login' => 1, 'iwp_goto' => $where, 'signature' => base64_encode($signature), 'message_id' => $historyID, 'username' => $siteData['adminUsername']); //signature urlencode will be taken care by httpBuildURLCustom() if (!empty($loadSiteVars) && is_array($loadSiteVars)) { $URLQueryArray = array_merge($URLQueryArray, $loadSiteVars); } $adminURLArray = parse_url($siteData['adminURL']); if (!empty($adminURLArray['query'])) { $parsedQuery = array(); parse_str($adminURLArray['query'], $parsedQuery); if (!empty($parsedQuery) && is_array($parsedQuery)) { $URLQueryArray = array_merge($parsedQuery, $URLQueryArray); } } $adminURLArray['query'] = $URLQueryArray; $adminURLArray['path'] .= $where ? $where : ''; $URL = httpBuildURLCustom($adminURLArray); $argSeparator = ini_get('arg_separator.output'); if ($argSeparator == "&" || $argSeparator == "&") { $URL = str_replace($argSeparator, "&", $URL); } //$URL .='&signature='.$tempSignature; //$URL = $siteData['adminURL'].$where.'?'."auto_login=1&iwp_goto=".$where."&signature=".urlencode(base64_encode($signature))."&message_id=".$historyID."&username="******"Location: " . $URL); exit; }
function getFullWPURL($siteID, $URL) { //this will add http auth if it set for the site if (is_array($URL)) { $finalURL = array(); $finalKey = ''; foreach ($URL as $key => $value) { $finalURL[$key] = $value; $siteData = getSiteData($siteID); if (!empty($siteData['httpAuth'])) { $siteHttpAuth = @unserialize($siteData['httpAuth']); if (!empty($siteHttpAuth['username'])) { $URLParts = parse_url($value); $URLParts['user'] = urlencode($siteHttpAuth['username']); $URLParts['pass'] = urlencode($siteHttpAuth['password']); $finalURL[$key] = httpBuildURLCustom($URLParts); $finalKey = $key; } } } return $finalURL[$key]; } else { $finalURL = $URL; $siteData = getSiteData($siteID); if (!empty($siteData['httpAuth'])) { $siteHttpAuth = @unserialize($siteData['httpAuth']); if (!empty($siteHttpAuth['username'])) { $URLParts = parse_url($URL); $URLParts['user'] = urlencode($siteHttpAuth['username']); $URLParts['pass'] = urlencode($siteHttpAuth['password']); $finalURL = httpBuildURLCustom($URLParts); } } return $finalURL; } }