Thought:
Modify the portal page Call of the webpage.class.inc.php, in here to add what we want to the button ah, picture ah, the form AH
The form parameters are passed to the script that modifies the language
When done, automatically jumps to the portal page
Attachment:
Icon element: Chinese flag logo, American flag logo
Vim main.php
Vim conf.php
Download icon elements to Itop's images:
[Email protected]:/home/itsm# cd/var/www/html/images/wget Http://php.chinaunix.net/images/flags/usa.pngwget http:/ /PHP.CHINAUNIX.NET/IMAGES/FLAGS/CHN.PNGMV chn.png CHINESE.JPGMV usa.png english.jpg
Modify webpage.class.inc.php
[email protected]:/var/www/html/images# cd /application/[email protected]:/var/www/html/application# cp webpage.class.inc.php webpage.class.inc.php.0418[email protected]:/var/www/html/application# vim webpage.class.inc.php[email protected]:/var/www/html/portal/language# vim conf.php modifying Itop url if (class_exists (' Metamodel ') && metamodel::getconfig ()) { echo "<link rel=\" shortcut icon\ " href=\" ". Utils::getabsoluteurlapproot ()." Images/favicon.ico?itopversion= ". Itop_version. " \ " />\n"; } $myUserID = userrights::getuserid(); if (dict::getuserlanguage () = = "EN US") {$mylanguage = "ZH"; $lanuage _logo = ". /images/chinese.jpg "; $title =" Switch to Chinese ";} if (dict::getuserlanguage () = = "Zh cn") {$mylanguage = "EN"; $lanuage _logo = ". /images/english.jpg "; $title =" Switch to english ";} echo "
The PHP script that was called
[Email protected]:/var/www/html/itop.new/portal/language# vim conf.php <?php//itop Webseervice interface define ("URL", " Https://itsmtest.logo.cn:11443/itop.new/webservices/rest.php "); #define (" URL "," https://itsm-uat.logo.cn/ Webservices/rest.php "); #define (" URL "," https://itsm.logo.cn/webservices/rest.php "); $aConfig = Array (' Itop_ User ' = ' admin ', ' itop_pass ' = ' password ',);? >
Main program:
[Email protected]:/var/www/html/itop.new/portal/language# vim main.php <?phpfunction request_post ($url, $param) { if (Empty ($url) | | empty ($param)) return false; $postUrl = $url; $curlPost = $param; $ch = curl_init (); //Initialize curl curl_setopt ($ch, curlopt_ssl_verifypeer, false); curl_setopt ($ch, curlopt_ssl_verifyhost, false); curl_setopt ($ch, curlopt_url,$ PostURL) //Crawl The specified page curl_setopt ($ch, &NBSP;CURLOPT_HEADER,&NBSP;0); // Set Header curl_setopt ($ch, curlopt_returNTRANSFER,&NBSP;1) //requires the result to be a string and output to the on-screen curl_setopt ($ch, curlopt_ POST,&NBSP;1); // Post Submission Method curl_setopt ($ch, curlopt_postfields, $curlPost); $data = Curl_exec ($ch); //running Curl curl_close ($ch); return json_decode ($data, True); //convert the returned data into JSON format}//check if communication with Itop is normal function check_ itop_network () { $url = URL; $get 1 = Request_post ($url, "test"); $get = $get 1[' message ']; if (!STRSTR ($ Get, "Missing parameter" )) { echo "and itop Connection failed! \ n "; exit; }}//itop 's webservice interface, Data model can be itop in accordance with the Function action_update ($class, $key, $fields) { global $ aconfig; $url = URL; $post _data[' version '] = ' 1.0 '; $post _data[' auth_user ']= $aConfig [' Itop_user ']; $post _data[' auth_pwd '] = $ aconfig[' Itop_pass ']; $post _data[' json_data ']= "{ \" operation\ ": \ "core/update\", \ "class\": \ "{$class}\", \ "key\": $key, \ "output_fields\": \ "*\", \ "Fields\": { $fields } , \ "comment\": \ "\"   return request_post ($url, $post _daTA);} #********************************************************************************# main#********************************************************************************require "conf.php";//check with Itop contact status check_itop_network (); $ldap _id = $_post[' user_id ']; $ldap _ lang = $_post[' lang '];if ($ldap _lang == "EN") {$fields = "\" language\ ": \" En us\ ";} if ($ldap _lang == "ZH") {$fields = "\" language\ ": \" zh cn\ "";} Action_update (' Userldap ', $ldap _id, $fields) ;header ("LOCATION:&NBSP;.. /index.php ");? >
Access test: https://itsm.logo.cn/portal/index.php
This article is from the "Soul Bucket" blog, please be sure to keep this source http://990487026.blog.51cto.com/10133282/1765427
Itop Portal page Add Chinese and English toggle buttons