130 lines
3.1 KiB
PHP
Executable File
130 lines
3.1 KiB
PHP
Executable File
<?php define('__ROOT__', dirname(__FILE__) );
|
|
require_once __ROOT__.'/manager/autoloader.php';
|
|
|
|
use \manager\ModuleRequest;
|
|
use \manager\ResourceDispatcher;
|
|
use \manager\sessionManager;
|
|
use \manager\ManagerError;
|
|
use \manager\Repo;
|
|
use \manager\Database;
|
|
use \manager\lightdb;
|
|
|
|
use \api\client;
|
|
|
|
debug();
|
|
|
|
|
|
/* PARSAGE DE JOURNAUX D'APPEL
|
|
*
|
|
*
|
|
*/
|
|
function parseCallLog(){
|
|
/* [2] On cree la requete
|
|
=========================================================*/
|
|
$request = new ModuleRequest('call_log/unserialize', array(
|
|
'phone_number' => '01 02 03 04 05'
|
|
));
|
|
$answer = $request->dispatch(); // on l'execute
|
|
|
|
/* [3] Si erreur
|
|
=========================================================*/
|
|
if( $answer->error != ManagerError::Success ){
|
|
// on l'explicite
|
|
var_dump( ManagerError::explicit($answer->error) );
|
|
// on quitte
|
|
return;
|
|
}
|
|
|
|
|
|
/* [4] Sinon on recupere le resultat
|
|
=========================================================*/
|
|
$directory = $answer->get('directory');
|
|
$logs = $answer->get('logs');
|
|
|
|
foreach($directory as $num=>$name)
|
|
echo $num.' <> '.$name.'<br>';
|
|
}
|
|
|
|
// parseCallLog();
|
|
|
|
|
|
/* [1] Test du client de l'API generique
|
|
=========================================================*/
|
|
// $api = new client();
|
|
|
|
// $response = $api->send('generate-network-chart-data', array(
|
|
// '@token'=> '52945efbed43b50c12413f2f0e9519bfd9e98ce8'
|
|
// ));
|
|
|
|
// var_dump($response);
|
|
|
|
|
|
/* [2] Gestion du getter dynamique des Repos
|
|
=========================================================*/
|
|
// var_dump( \manager\repo\user::getById(1) );
|
|
// var_dump( \manager\repo\user::getByLogin('xdrm') );
|
|
// var_dump( \manager\repo\subject::getById(69) );
|
|
// var_dump( \manager\repo\relation::getById(638, 640, 30) );
|
|
|
|
|
|
|
|
/* [3] Test de la vérification du format de fichier pour l'upload
|
|
=========================================================*/
|
|
// <!-- <form action='' method='POST' enctype='multipart/form-data'>
|
|
// <input type='file' name='file'>
|
|
// <input type='submit' value='Upload'>
|
|
// </form>
|
|
// var_dump($_FILES);
|
|
//
|
|
// if( isset($_FILES) ){
|
|
//
|
|
// $request = new ModuleRequest('upload/call_log', array('phone_number'=>'01 02 03 04 05') );
|
|
// $response = $request->dispatch();
|
|
// var_dump( ManagerError::explicit($response->error) );
|
|
//
|
|
// }
|
|
|
|
|
|
|
|
|
|
// Lancement du téléchargement
|
|
// $req = new ModuleRequest('download/phone', array('subjects'=>[200]));
|
|
// $res = $req->dispatch();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// RUN database
|
|
$db = new lightdb('testdb1');
|
|
function microtime_float()
|
|
{
|
|
list($usec, $sec) = explode(" ", microtime());
|
|
return ((float)$usec + (float)$sec);
|
|
}
|
|
|
|
$a = microtime_float();
|
|
/* [1] INSERTION DE 1000*1000 éléments
|
|
=========================================================*/
|
|
$data = array();
|
|
for( $i = 0 ; $i < 1000 ; $i++ )
|
|
$data['key'.$i] = 'valeur'.$i;
|
|
|
|
$average = 0;
|
|
for( $i = 0 ; $i < 100 ; $i++ ){
|
|
$a = microtime_float();
|
|
$db->fetch('data'.$i);
|
|
$average += microtime_float()-$a;
|
|
}
|
|
|
|
var_dump('1000 * '.strlen(json_encode($data)) );
|
|
var_dump('INSERT avg. : '.($average/100) );
|
|
|
|
/* [2] RECUPERATION DE 1000*1000 ELEMENTS
|
|
=========================================================*/
|
|
|
|
|
|
$db->close();
|