GIF89a; EcchiShell v1.0
//etc/zpanel/panel/dryden/ws/

wsdataarray['content']); } } if(!ctrl_users::CheckUserIsExisted($username)){ $return_mgs = array("error" => "$username is not exists"); $return = json_encode($return_mgs); echo $return;exit; } } $this->currentmodule = new module_controller; } /** * Requests that the web service method requires that the user must be authenticated wth the server. * @author Bobby Allen (ballen@bobbyallen.me) */ public function RequireUserAuth($port = false) { global $zdbh; $authuser = $this->wsdataarray['authuser']; $authpass = $this->wsdataarray['authpass']; $ws_auth = new ctrl_auth; if($port == '2086' || $port == '2087'){ $sql_for_login="SELECT ac_passsalt_vc FROM x_accounts WHERE ac_user_vc = '$authuser' AND ac_id_pk=1 AND ac_deleted_ts IS NULL"; }else{ $sql_for_login="SELECT ac_passsalt_vc FROM x_accounts WHERE ac_user_vc = '$authuser' AND ac_id_pk<>1 AND ac_deleted_ts IS NULL"; } $sql = $zdbh->prepare($sql_for_login); $sql->execute(); $result = $sql->fetch(); if(empty($result)){ return false; } $crypto = new runtime_hash; $crypto->SetPassword($authpass); $crypto->SetSalt($result['ac_passsalt_vc']); $password = $crypto->CryptParts($crypto->Crypt())->Hash; $user = $ws_auth->Authenticate($authuser, $password); if ($user) { $this->authuserid = $user; return true; } else { return false; } } /** * Checks that the Server API given in the webservice request XML is valid and matches the one stored in the x_settings table. * @author Bobby Allen (ballen@bobbyallen.me) * @return boolean */ public function CheckServerAPIKey() { if ($this->wsdataarray['apikey'] != ctrl_options::GetSystemOption('apikey')) { runtime_hook::Execute('OnBadAPIKeyAuth'); return false; } else { runtime_hook::Execute('OnGoodAPIKeyAuth'); return true; } } /** * Will format and send a valid XMWS XML response. * @author Bobby Allen (ballen@bobbyallen.me) * @param array $responsearray Array of data to send. */ public function SendResponse($responsearray) { /* if ($responsearray['response'] == '') $responsearray['response'] = '1101'; header("Content-Type:text/xml"); echo "\n" . "\n" . "\t" . $responsearray['response'] . "\n" . "\t" . $responsearray['content'] . "\n" . ""; */ echo $responsearray;exit; } /** * Takes RAW XMWS XML request data and converts its contents into a usable data array. * @author Bobby Allen (ballen@bobbyallen.me) * @param string $xml The RAW XML content. * @return array Array containing all the request data that has been received. */ public function RawXMWSToArray($xml) { $return_dataobject = new runtime_dataobject(); $return_dataobject->addItemValue('version', runtime_haystack::GetValueBetween($xml, '', '')); $return_dataobject->addItemValue('apikey', runtime_haystack::GetValueBetween($xml, '', '')); $return_dataobject->addItemValue('request', runtime_haystack::GetValueBetween($xml, '', '')); $return_dataobject->addItemValue('response', runtime_haystack::GetValueBetween($xml, '', '')); $return_dataobject->addItemValue('authuser', runtime_haystack::GetValueBetween($xml, '', '')); $return_dataobject->addItemValue('authpass', runtime_haystack::GetValueBetween($xml, '', '')); $return_dataobject->addItemValue('content', runtime_haystack::GetValueBetween($xml, '', '')); return $return_dataobject->getDataObject(); } /** * A simple way to build an XML section for the tag, perfect for multiple data lines etc. * @author Bobby Allen (ballen@bobbyallen.me) * @param string $name The name of the section . * @param array $tags An associated array of the tag names and values to be added. * @return string A formatted XML section block which can then be used in the tag if required. */ static function NewXMLContentSection($name, $tags) { $xml = "\t<" . $name . ">\n"; foreach ($tags as $tagname => $tagval) { $xml .="\t\t<" . $tagname . ">" . $tagval . "\n"; } $xml .= "\t\n"; return $xml; } /** * A simple way to build an XML tag, for simple single line XML data. * @author Bobby Allen (ballen@bobbyallen.me) * @param string $name The name of the . * @param string $value The value of the . * @return string A formatted (single tab indented) XML line designed to be used in the tag. */ static function NewXMLTag($name, $value) { $xml = "\t<" . $name . ">" . $value . "\n"; return $xml; } /** * Takes an XML string and converts it into a usable PHP array. * @author Bobby Allen (ballen@bobbyallen.me) * @param string $contents The XML content to convert to a PHP array. * @param int $get_arrtibutes Retieve the tag attrubtes too (1 = yes, 0 =no)? * @param string $priotiry What should take priority? tag or attributes? * @return array Associated array of the XML tag data. */ function XMLDataToArray($contents, $get_attributes = 1, $priority = 'tag') { return ws_generic::XMLToArray($contents, $get_attributes, $priority); } } ?>