Use Appcan client to automatically update PHP version number (full), Appcan version number _php tutorial

Source: Internet
Author: User

Automatically update PHP version number (full) with Appcan client, Appcan version number


In the project development process encountered automatic update of the app side, consult the relevant data and then the Appcan client automatically update the PHP version number of the method to collate, the specific code explained below.

Server files: update.php, version.php, Version.xml

update.php content:

Php

<?phpdefine (' CIN ', true); $oldver = $_request[' ver '];//client-passed version number $platform = $_request[' platform '];//client Platform $info = Simplexml_load_file (' Version.xml '); $iphone _filename= $info->news[' iphone_filename ']; iphone download file $android_filename= $info->news[' android_filename ']; Androiad download file $version= $info->news[' version '; Version number if ($version > $oldver) {switch ($platform) {case "0"://iphone echo "<?xml version=\" 1.0\ "encoding=\"      Utf-8\ "?>"; echo "
 
  
   
 "; echo " 
   
    i2ty 
   ";//Client name echo " 
   
    itunesurl 
   ";//Return to the client's download address echo " 
   
    0 
   ";//File Size echo "" 
   
    . $version. 
   ""; /version information echo "
  
 ";    Break      Case "1"://android echo "<?xml version=\" 1.0\ "encoding=\" utf-8\ "?>"; echo "
 
  
   
 "; echo " 
   
    i2ty 
   ";//Client name echo " 
   
    http://i2ty.com/app/". $android _filename. " 
   "; /Return to the client's download address echo " 
   
    0 
   ";//File size echo " 
   
    ". $version. 
   ""; /version information echo "
  
 ";  Break }}?>

version.php content:

Php

<?phpdefine (' CIN ', true); $result [' Vtitle ']= "Update"; $result [' Vcontent ']= ' new version is updated! ~ new features fix various errors ";p Rint_r (Json_encode ($result));? >version.xml content: Php<?xml version= "1.0" encoding= "Utf-8"?>
 
  
    
 

  
 Index.html client: Phpwindow.uexonload = function (type) {if (!type) {update (); }var Flag_sdcard = 1;var UpdateUrl = ";//download new apk file address var filepath2 ="/sdcard/";//Save to SD card var filename = ';//new version filename var platf ORM = ';//platform version function Update () {//Android version, show download Progress (step:7) Uexdownloadermgr.onstatus = function (Opid, fileSize, perc            ENT, status) {if (status = = 0) {//download ...            Log (' download percent ' + percent + '% '); Uexwindow.toast (' 1 ', ' 5 ', ' Downloading ' +localstorage.app_title+ ' new version, please later.        Progress: ' + percent + '% ', ');            } else if (status = = 1) {//download completed.            Uexwindow.closetoast (); Uexdownloadermgr.closedownloader (' 14 ');//Close Download Object Uexwidget.installapp (filepath2+filename);//install download APK file}        else {uexwindow.toast (' 1 ', ' 5 ', ' download error, please close ' +localstorage.app_title+ ' to run again. ');    }    }; Android version, create a Download object callback function (step:6) Uexdownloadermgr.cbcreatedownloader = function (Opid, dataType, data) {Log (' Uexdownloa Dermgr.cBcreatedownloader data= ' +data);  if (data = = 0) {//updateurl is put into a global variable by calling the Cbcheckupdate callback after uexdownloadermgr.download (' + ', UpdateUrl,        Filepath2+filename, ' 0 ');//Start download APK file} else if (data = = 1) {;        } else {;    }    }; Prompts to update the Modal Box button event callback function to determine whether the user chooses to update or cancel (step:5) uexwindow.cbconfirm = function (Opid, dataType, data) {Log (' UEXWINDOW.CB        Confirm '); Call the dialog prompt function if (data = = 0) {//user click the button later, do not update} else {//user click OK button to update if (                Platform = = 0) {//Apple version update, load AppStore path via browser uexwidget.loadapp (UpdateUrl, ' ', ');            Uexwidget.loadapp ("", "" ", updateurl);//The old method is no longer available. } else if (platform = = 1) {////Android update, download by creating download Object Uexdownloadermgr.createdown            Loader ("14");            } else {;    }        }    }; Called to check the update callback function, when the request succeeds, the pop-up modal box lets the user choose whether to update Now (STEP:4) uexwiDget.cbcheckupdate = function (OpCode, DataType, Jsondata) {Log (' jsondata= ' +jsondata);        var obj = eval (' (' + jsondata + ') '); if (Obj.result = = 0) {//Tips = "Update address is:" + Obj.url + "
File name: "+ Obj.name +"
File size: "+//Obj.size +"
Version number: "+ obj.version; UpdateUrl = Obj.url; FileName = obj.name+ ". apk"; Getversioncontent (); var value = "later; update"; var mycars = Value.split (";"); Uexwindow.confirm (', ' currently has a new version, update? ', mycars);//Popup prompt box, whether to determine the update} else if (Obj.result = = 1) {//Apple Alert ("Update address is:" + Obj.url + "
File name: "+ Obj.name +"
File size: "+//obj.size +"
Version number: "+ obj.version";//Tips = "Current version is up to date"; alert (tips); } else if (Obj.result = = 2) {;//tips = "Unknown error"; alert (tips); } else if (Obj.result = = 3) {;//tips = "parameter error"; alert (tips); } }; Check if the SD card's callback function (Step:3) is already present Uexfilemgr.cbisfileexistbypath = function (OpCode, dataType, data) {Log (' uexfilemgr.c Bisfileexistbypath flag_sdcard= ' +flag_sdcard+ ', Data= ' +data); if (Flag_sdcard = = 0) {if (data = = 0) {Log (' sdcard does not exist, processing according to specific circumstances '); } else {//perform check update uexwidget.checkupdate ();//initiate an HTTP request based on the check update address configured in CONFIG. Flag_sdcard = 1; } }; Get the platform version callback function to determine if the client is the client of that platform (step:2) Uexwidgetone.cbgetplatform = function (Opid, dataType, data) {Log (' UEXWIDG Etone.cbgetplatform '); Gets the system version information callback function platform = data; Log (' platform= ' +platform); if (data = = 0) {//Is IPhONe uexwidget.checkupdate ();//Call to check for updates, check that the update address is configured in CONFIG.} else if (data = = 1) {//IS and Roid flag_sdcard = 0; Uexfilemgr.isfileexistbypath ('/sdcard/');//First determine if there is an SD card, then call checkupdate to update} else {//IS platform}}; Uexwidgetone.getplatform ();//Get Platform Version (step:1)}function Log (s) {uexlog.sendlog (s);} function getversioncontent () {var url = web_url+ "version.php"; Uexxmlhttpmgr.ondata = getvsuccess; Uexxmlhttpmgr.open (777, "get", url, ""); Uexxmlhttpmgr.send (777); }function getvsuccess (Opid,status,result) {if (status = =-1) {Uexwindow.toast ("0", "5", "Connection not on network ^_^ Oh", "3000"); } if (status==1) {uexxmlhttpmgr.close (777); Uexwindow.closetoast (); if (result== "[]") {Uexwindow.toast ("0", "5", "None", "2000");} else{var con=eval (' (' + result + ') ' var value = "later; update"; var mycars = Value.split (";"); Uexwindow.confirm (Con.vtitle, con.vcontent, mycars);//pop-up Prompt box, confirm update}}}

Finally, the config update address of the application configuration file is:

http://www.i2ty.com/update.php

App-Side Update tips:

The contents of the popup window can be customized according to the contents of the version.php file.

The above is to explain the use of Appcan client automatically update the PHP version number method, I hope to help you.

http://www.bkjia.com/PHPjc/1041327.html www.bkjia.com true http://www.bkjia.com/PHPjc/1041327.html techarticle using the Appcan client to automatically update the PHP version number (full), the Appcan version number in the project development process encountered the app-side Automatic Updates, consulted the relevant information and then the Appcan client automatically updated ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.