PHP Classes

File: test.php

Recommend this page to a friend!
  Classes of Luis Martinez Ulloa   PHP Termux API   test.php   Download  
File: test.php
Role: Example script
Content type: text/plain
Description: Web test all methods
Class: PHP Termux API
Control Android device using Termux application
Author: By
Last change:
Date: 7 years ago
Size: 8,523 bytes
 

Contents

Class file image Download
<?php

//wide test
// lsmartinez@gmail.com
$photo = "photo.jpg";
$dwldfile = "http://cl1.php.net/get/php_manual_en.html.gz/from/this/mirror";
$url = "http://www.php.net/";
//please change this variables before running this example, to adapt to your
//language and own phone number.
$test = "prueba desde php 7";
//your phone
$phone = "999999999";
$lang = "es";
$notimpl = "no implementado aun.";

//---------------------------------------------------------------------------

if (file_exists("termuxapi.php")) {
    require_once
'termuxapi.php';

   
$termux = new termuxapi();
   
$msg = " ";
   
$title = "Web Test";
    if (isset(
$_GET["f"])) {
        switch (
$_GET['f']) {
            case
'1':
               
$title = "Location";
               
$msg = $termux->location();
                break;
            case
'2':
               
$title = "Battery";
               
$msg = $termux->battery_status();
                break;
            case
'3':
               
$title = "cam info";
               
$msg = $termux->camera_info();
                break;
            case
'4':
               
$title = "take picture";
               
$termux->camera_photo($photo);
               
$msg = "<img src='$photo'>";
                break;
            case
'5':
               
$title = "get clipbd";
               
$msg = $termux->clipboard_get();
                break;
            case
'6':
               
$title = "set clipbd";
               
$termux->clipboard_set($test);
                break;
            case
'7':
               
$title = "contacts";
               
$msg = $termux->contact_list();
                break;
            case
'8':
               
$title = "download";
               
$termux->download($dwldfile);
                break;
            case
'9':
               
$title = "notify";
               
$termux->notification($test);
                break;
            case
'10':
               
$title = "open url";
               
$termux->open_url($url);
                break;
            case
'11':
               
$title = "share";
               
$termux->share($photo);
                break;
            case
'12':
               
$title = "sms inbox";
               
$msg = $termux->sms_inbox();
                break;
            case
'13':
               
$title = "sms send";
               
$termux->sms_send($phone, $test);
                break;
            case
'14':
               
$title = "phone info";
               
$msg = $termux->telephony_deviceinfo();
                break;
            case
'15':
               
$title = "toast";
               
$termux->toast($test);
                break;
            case
'16':
               
$title = "tts engines";
               
$msg = $termux->tts_engines();
                break;
            case
'17':
               
$title = "tts speak";
               
$termux->tts_speak($test, "", $lang);
                break;
            case
'18':
               
$title = "vibrate";
               
$termux->vibrate();
                break;
            case
'19':
               
$title = "wifi info";
               
$msg = $termux->wifi_connectioninfo();
                break;
            case
'20':
               
$title = "wifi scan";
               
$msg = $termux->wifi_scaninfo();
                break;

            default:
               
$msg = $notimpl;
                break;
        }
        if (
strstr("{[", substr($msg, 0, 1)) !== false) {
           
$msg = "<pre>$msg</pre>";
        }
    }
}
$selfie = basename(__FILE__);
?><!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <meta name="description" content="testing of termux:API from php">
        <meta name="author" content="">
        <title>Termux:API <?= $title ?></title>
        <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
        <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
        <style>
            p > img {
                width: 100%;
            }

            body {
                padding-top: 70px;
                padding-bottom: 30px;
            }

        </style>
    </head>

    <body>

        <nav class="navbar navbar-inverse navbar-fixed-top">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="<?= $selfie ?>">Termux:API <?= $title ?></a>
                </div>
                <div id="navbar" class="navbar-collapse collapse">
                </div>
            </div>
        </nav>

        <div class="container theme-showcase" role="main">

            <p>
                <a class="btn btn-default" href="<?= $selfie ?>?f=1"><span class="fa fa-map-marker"></span><span class="fa fa-question"></span></a>
                <a class="btn btn-primary" href="<?= $selfie ?>?f=2"><span class="fa fa-battery-4"></span><span class="fa fa-question"></span></a>
                <a class="btn btn-success" href="<?= $selfie ?>?f=3"><span class="fa fa-camera"></span><span class="fa fa-question"></span></a>
                <a class="btn btn-info" href="<?= $selfie ?>?f=4"><span class="fa fa-camera"></span><span class="fa fa-flash"></span></a>
                <a class="btn btn-warning" href="<?= $selfie ?>?f=5"><span class="fa fa-copy"></span></a>
                <a class="btn btn-danger" href="<?= $selfie ?>?f=6"><span class="fa fa-paste"></span></a>
                <a class="btn btn-default" href="<?= $selfie ?>?f=7"><span class="fa fa-users"></span></span><span class="fa fa-list"></span></a>
                <a class="btn btn-primary" href="<?= $selfie ?>?f=8"><span class="fa fa-download"></span></a>
                <a class="btn btn-success" href="<?= $selfie ?>?f=9"><span class="fa fa-flag"></span></a>
                <a class="btn btn-info" href="<?= $selfie ?>?f=10"><span class="fa fa-globe"></span></a>
                <a class="btn btn-warning" href="<?= $selfie ?>?f=11"><span class="fa fa-share-alt"></span></a>
                <a class="btn btn-danger" href="<?= $selfie ?>?f=12"><span class="fa fa-envelope-o"></span></span><span class="fa fa-list"></span></a>
                <a class="btn btn-default" href="<?= $selfie ?>?f=13"><span class="fa fa-envelope"></span></a>
                <a class="btn btn-primary" href="<?= $selfie ?>?f=14"><span class="fa fa-mobile-phone"></span><span class="fa fa-question"></span></a>
                <a class="btn btn-success" href="<?= $selfie ?>?f=15"><span class="fa fa-comment"></span></a>
                <a class="btn btn-info" href="<?= $selfie ?>?f=16"><span class="fa fa-volume-off"></span><span class="fa fa-question"></span></a>
                <a class="btn btn-warning" href="<?= $selfie ?>?f=17"><span class="fa fa-user"></span><span class="fa fa-volume-up"></span></a>
                <a class="btn btn-danger" href="<?= $selfie ?>?f=18"><span class="fa fa-mobile-phone"></span><span class="fa fa-bomb"></span></a>
                <a class="btn btn-default" href="<?= $selfie ?>?f=19"><span class="fa fa-wifi"></span><span class="fa fa-area-chart"></span></a>
                <a class="btn btn-primary" href="<?= $selfie ?>?f=20"><span class="fa fa-wifi"></span><span class="fa fa-list"></span></a>
            </p>

            <p>
                <?= $msg ?>
</p>


        </div>
        <script src="http://code.jquery.com/jquery-3.1.1.min.js" type="text/javascript"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    </body>
</html>