php - Porting lighttpd server to Android -


i trying port lighttpd android uses can execute php script there android device hitting localhost:port broswser script not working properly

here runtime java code

public class runtimeprovider { boolean isloaded = false;

processbuilder mysqlbuilder = new processbuilder(new string[] {         "/data/data/com.punk.qs/mysqld",         "--defaults-file=/data/data/com.punk.qs/my.ini",         "--user=root",         "--language=/data/data/com.punk.qs/share/mysql/english" });  processbuilder phpbuilder = new processbuilder(new string[] {         "/data/data/com.punk.qs/php-cgi-ext", "-c",         "data/data/com.punk.qs/php.ini" }); processbuilder lighttpdbuilder = new processbuilder(new string[] {         "/data/data/com.punk.qs/lighttpd", "-f",         "data/data/com.punk.qs/lighttpd.conf" });  public void execute() {     file fphp = new file("/data/data/com.punk.qs/php-cgi-ext");     file flighttp = new file("/data/data/com.punk.qs/lighttpd");     file fmysql = new file("/data/data/com.punk.qs/mysqld");     if (fphp.exists() && flighttp.exists() && fmysql.exists()) {          try {             runtime.getruntime().exec(                     "chmod 777 /data/data/com.punk.qs/lighttpd");             lighttpdbuilder.start();              //nativeapp(                     "/data/data/com.punk.qs/lighttpd -f data/data/com.punk.qs/lighttpd.conf",                     "lighttpd");              log.w("lighttpd started ", "lighttpd started");         } catch (ioexception e) {              log.w("lighttpd startup failed ", e);             new errorlogger("lighttpd", e.tostring());         }         try {             runtime.getruntime().exec(                     "chmod 777 /data/data/com.punk.qs/mysqld");             mysqlbuilder.start();             //nativeapp(                     "/data/data/com.punk.qs/mysqld --defaults-file=/data/data/com.punk.qs/my.ini --user=root --language=/data/data/com.punk.qs/share/mysql/english",                     "mysql");             log.d("mysql started ", "mysql started");         } catch (ioexception e) {             log.w("mysql startup failed ", e);             new errorlogger("mysql", e.tostring());         }         try {             runtime.getruntime().exec(                     "chmod 777 /data/data/com.punk.qs/php-cgi-ext");             phpbuilder.start();             //nativeapp(                     "/data/data/com.punk.qs/php-cgi-ext -c data/data/com.punk.qs/php.ini",                     "phpcgi");              log.d("php started ", "php started");         } catch (ioexception e) {             log.w("php startup failed ", e);             new errorlogger("phpcgi", e.tostring());          }     } else {         log.w("error runime lib", "runtime libs missing");      }     // return b;  }  public void nativeapp(string cmd, string tag) {      process nativeapp = null;      log.d("executing :", cmd);     try {          nativeapp = runtime.getruntime().exec(cmd);     } catch (ioexception e) {         log.e("runtime error : ", e.tostring());         new errorlogger("runtime", e.tostring());     }      bufferedreader reader = new bufferedreader(new inputstreamreader(             nativeapp.getinputstream()));     int read;     char[] buffer = new char[4096 * 8];     stringbuffer output = new stringbuffer();     try {          while ((read = reader.read(buffer)) > 0) {             output.append(buffer, 0, read);         }          reader.close();     } catch (ioexception e) {         log.e("io error : ", e.tostring());         new errorlogger("io", e.tostring());     }      // waits command finish.     try {         nativeapp.waitfor();     } catch (interruptedexception e) {          log.e("interruptedexception : ", e.tostring());         new errorlogger("intexp", e.tostring());     }      string nativeoutput = output.tostring();     if (nativeoutput != null)         isloaded = true;     log.d("output : " + cmd, nativeoutput);     new errorlogger("runlib", nativeoutput); } 

}

method runtimeprovider().execute()

invoked when user clicks on button

the best way go opensource project this , go through code copy assets , check on device or emulator have used project use php , lighthttpd in android..


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -