2016-04-04 09:47:17 +00:00
|
|
|
<?php define('__ROOT__', dirname(__FILE__) );
|
|
|
|
require_once __ROOT__.'/manager/autoloader.php';
|
|
|
|
|
|
|
|
use \manager\ModuleRequest;
|
|
|
|
use \manager\ResourceDispatcher;
|
2016-04-11 10:20:34 +00:00
|
|
|
use \manager\sessionManager;
|
2016-04-04 09:47:17 +00:00
|
|
|
use \manager\ManagerError;
|
|
|
|
use \manager\Repo;
|
2016-04-17 10:34:24 +00:00
|
|
|
use \manager\Database;
|
2016-05-18 07:41:36 +00:00
|
|
|
use \manager\lightdb;
|
2016-04-04 09:47:17 +00:00
|
|
|
|
2016-04-11 14:05:32 +00:00
|
|
|
use \api\client;
|
2016-04-04 09:47:17 +00:00
|
|
|
|
2016-04-18 14:21:24 +00:00
|
|
|
debug();
|
2016-04-04 09:47:17 +00:00
|
|
|
|
|
|
|
|
2016-04-04 12:04:36 +00:00
|
|
|
/* PARSAGE DE JOURNAUX D'APPEL
|
2016-04-04 09:47:17 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2016-04-04 12:04:36 +00:00
|
|
|
function parseCallLog(){
|
2016-04-08 14:58:40 +00:00
|
|
|
/* [2] On cree la requete
|
2016-04-04 12:04:36 +00:00
|
|
|
=========================================================*/
|
2016-04-18 14:21:24 +00:00
|
|
|
$request = new ModuleRequest('call_log/unserialize', array(
|
2016-04-20 13:21:01 +00:00
|
|
|
'phone_number' => '01 02 03 04 05'
|
|
|
|
));
|
2016-04-13 12:49:53 +00:00
|
|
|
$answer = $request->dispatch(); // on l'execute
|
2016-04-04 09:47:17 +00:00
|
|
|
|
2016-04-08 14:58:40 +00:00
|
|
|
/* [3] Si erreur
|
2016-04-04 12:04:36 +00:00
|
|
|
=========================================================*/
|
2016-04-08 14:58:40 +00:00
|
|
|
if( $answer->error != ManagerError::Success ){
|
|
|
|
// on l'explicite
|
|
|
|
var_dump( ManagerError::explicit($answer->error) );
|
|
|
|
// on quitte
|
|
|
|
return;
|
2016-04-04 12:04:36 +00:00
|
|
|
}
|
2016-04-04 09:47:17 +00:00
|
|
|
|
|
|
|
|
2016-04-08 14:58:40 +00:00
|
|
|
/* [4] Sinon on recupere le resultat
|
2016-04-04 12:04:36 +00:00
|
|
|
=========================================================*/
|
2016-04-18 14:21:24 +00:00
|
|
|
$directory = $answer->get('directory');
|
|
|
|
$logs = $answer->get('logs');
|
2016-04-04 12:04:36 +00:00
|
|
|
|
2016-04-18 14:21:24 +00:00
|
|
|
foreach($directory as $num=>$name)
|
|
|
|
echo $num.' <> '.$name.'<br>';
|
2016-04-04 12:04:36 +00:00
|
|
|
}
|
2016-04-04 09:47:17 +00:00
|
|
|
|
2016-05-03 08:23:48 +00:00
|
|
|
// parseCallLog();
|
2016-04-18 20:45:55 +00:00
|
|
|
|
2016-04-11 14:05:32 +00:00
|
|
|
|
2016-05-03 08:23:48 +00:00
|
|
|
/* [1] Test du client de l'API generique
|
|
|
|
=========================================================*/
|
2016-04-13 11:36:49 +00:00
|
|
|
// $api = new client();
|
2016-04-18 09:38:43 +00:00
|
|
|
|
2016-04-18 06:42:26 +00:00
|
|
|
// $response = $api->send('generate-network-chart-data', array(
|
2016-04-15 10:10:38 +00:00
|
|
|
// '@token'=> '52945efbed43b50c12413f2f0e9519bfd9e98ce8'
|
2016-04-13 11:36:49 +00:00
|
|
|
// ));
|
2016-04-11 15:08:46 +00:00
|
|
|
|
2016-04-13 11:36:49 +00:00
|
|
|
// var_dump($response);
|
2016-04-17 15:46:34 +00:00
|
|
|
|
2016-04-19 12:35:40 +00:00
|
|
|
|
2016-05-03 08:23:48 +00:00
|
|
|
/* [2] Gestion du getter dynamique des Repos
|
|
|
|
=========================================================*/
|
2016-04-19 12:35:40 +00:00
|
|
|
// var_dump( \manager\repo\user::getById(1) );
|
2016-05-09 12:33:18 +00:00
|
|
|
// var_dump( \manager\repo\user::getByLogin('xdrm') );
|
|
|
|
// var_dump( \manager\repo\subject::getById(69) );
|
|
|
|
// var_dump( \manager\repo\relation::getById(638, 640, 30) );
|
2016-04-19 09:14:28 +00:00
|
|
|
|
2016-05-03 08:23:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* [3] Test de la vérification du format de fichier pour l'upload
|
|
|
|
=========================================================*/
|
2016-05-17 14:51:24 +00:00
|
|
|
?>
|
|
|
|
<!-- <form action='' method='POST' enctype='multipart/form-data'>
|
|
|
|
<input type='file' name='file'>
|
|
|
|
<input type='submit' value='Upload'>
|
|
|
|
</form> -->
|
|
|
|
<?php
|
2016-05-03 08:23:48 +00:00
|
|
|
// var_dump($_FILES);
|
|
|
|
//
|
|
|
|
// if( isset($_FILES) ){
|
|
|
|
//
|
2016-05-11 20:02:20 +00:00
|
|
|
// $request = new ModuleRequest('upload/call_log', array('phone_number'=>'01 02 03 04 05') );
|
2016-05-03 08:23:48 +00:00
|
|
|
// $response = $request->dispatch();
|
|
|
|
// var_dump( ManagerError::explicit($response->error) );
|
2016-05-03 09:47:05 +00:00
|
|
|
//
|
2016-05-03 08:23:48 +00:00
|
|
|
// }
|
|
|
|
|
2016-05-18 09:44:31 +00:00
|
|
|
|
2016-05-20 10:07:48 +00:00
|
|
|
/* [4] Test download via AJAX
|
|
|
|
=========================================================*/
|
2016-05-24 06:58:37 +00:00
|
|
|
$dates = array(
|
|
|
|
'01 janv. 2015',
|
|
|
|
'02 févr. 2015',
|
|
|
|
'03 mars 2015',
|
|
|
|
'04 avr. 2015',
|
|
|
|
'05 mai 2015',
|
|
|
|
'06 juin 2015',
|
|
|
|
'07 juil. 2015',
|
|
|
|
'08 août 2015',
|
|
|
|
'09 sept. 2015',
|
|
|
|
'10 nov. 2015',
|
|
|
|
'11 oct. 2015',
|
|
|
|
'12 dec. 2015',
|
|
|
|
);
|
|
|
|
|
|
|
|
function correctDates($date){
|
|
|
|
$date = str_replace('janv.', 'jan.', $date);
|
|
|
|
$date = str_replace('févr.', 'feb.', $date);
|
|
|
|
$date = str_replace('mars', 'march', $date);
|
|
|
|
$date = str_replace('avr.', 'apr.', $date);
|
|
|
|
$date = str_replace('mai', 'may', $date);
|
|
|
|
$date = str_replace('juin', 'june', $date);
|
|
|
|
$date = str_replace('juil.', 'july', $date);
|
|
|
|
$date = str_replace('août', 'aug.', $date);
|
|
|
|
|
|
|
|
return strtotime($date);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach($dates as $date)
|
|
|
|
var_dump( date('d/m/Y H:i:s', correctDates($date)) );
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-22 12:49:20 +00:00
|
|
|
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
|
|
|
var_dump( array_keys($db->index()));
|
|
|
|
$db->close();
|
2016-05-23 09:10:24 +00:00
|
|
|
|
|
|
|
$db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/');
|
|
|
|
var_dump( array_keys($db->index()));
|
|
|
|
$db->close();
|
2016-05-22 15:36:49 +00:00
|
|
|
$req = new ModuleRequest('chart/direction', array( 'subject' => 273 ));
|
2016-05-21 16:27:10 +00:00
|
|
|
|
2016-05-22 12:49:20 +00:00
|
|
|
$res = $req->dispatch();
|
2016-05-20 17:08:58 +00:00
|
|
|
|
2016-05-21 16:27:10 +00:00
|
|
|
if( $res->error != ManagerError::Success )
|
|
|
|
var_dump( ManagerError::explicit($res->error) );
|
2016-05-20 17:08:58 +00:00
|
|
|
|
2016-05-21 16:27:10 +00:00
|
|
|
var_dump($res);
|
2016-05-20 10:07:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
// $start = microtime(true);
|
|
|
|
// $f = new SplFileObject('compress.zlib://'.__ROOT__.'/tmp/test1.gz', 'w');
|
|
|
|
// $f->fwrite('SOME TEXT');
|
|
|
|
// $f=null;
|
|
|
|
// var_dump('writing time : '.(microtime(true)-$start));
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $start = microtime(true);
|
|
|
|
// $f2 = new SplFileObject('compress.zlib://'.__ROOT__.'/tmp/test1.gz', 'r');
|
|
|
|
// $read = $f2->fgets();
|
|
|
|
// $f2=null;
|
|
|
|
// var_dump('reading time : '.(microtime(true)-$start));
|
|
|
|
// var_dump($read);
|
|
|
|
//
|
|
|
|
// exit();
|
|
|
|
|
|
|
|
|
2016-05-18 09:44:31 +00:00
|
|
|
/* [4] Analyse des performances de `lightdb`
|
|
|
|
=========================================================*/
|
2016-05-18 11:56:02 +00:00
|
|
|
// $start = microtime(true);
|
|
|
|
// $db = new lightdb('test1', __ROOT__.'/tmp/');
|
2016-05-20 10:07:48 +00:00
|
|
|
//
|
|
|
|
// /* (0) Création des objets à insérer */
|
2016-05-18 09:44:31 +00:00
|
|
|
// $object_10 = array();
|
|
|
|
// for( $i = 0 ; $i < 10 ; $i++ )
|
|
|
|
// $object_10["key-$i-"] = "value-$i-";
|
|
|
|
// $o10len = strlen( json_encode($object_10) );
|
|
|
|
//
|
|
|
|
// $object_100 = array();
|
|
|
|
// for( $i = 0 ; $i < 100 ; $i++ )
|
|
|
|
// $object_100["key-$i-"] = "value-$i-";
|
|
|
|
// $o100len = strlen( json_encode($object_100) );
|
|
|
|
//
|
|
|
|
// $object_1000 = array();
|
|
|
|
// for( $i = 0 ; $i < 1000 ; $i++ )
|
|
|
|
// $object_1000["key-$i-"] = "value-$i-";
|
|
|
|
// $o1000len = strlen( json_encode($object_1000) );
|
|
|
|
|
|
|
|
|
2016-05-20 10:07:48 +00:00
|
|
|
|
2016-05-18 09:44:31 +00:00
|
|
|
/* (1) Insertion de 1000 données */
|
|
|
|
// {1} Insertion d'objects de taille 10 //
|
|
|
|
// var_dump("Inserting 1000* object_10($o10len)");
|
|
|
|
// $start = microtime(true);
|
|
|
|
//
|
2016-05-20 10:07:48 +00:00
|
|
|
// $data = array();
|
2016-05-18 09:44:31 +00:00
|
|
|
// for( $i = 0 ; $i < 1000 ; $i++ )
|
2016-05-20 10:07:48 +00:00
|
|
|
// // $db->insert("object-10-$i", $object_10);
|
|
|
|
// $data["object-10-$i"] = $object_10;
|
|
|
|
//
|
|
|
|
// $db->insertAll($data);
|
2016-05-18 09:44:31 +00:00
|
|
|
//
|
|
|
|
// $stop = microtime(true);
|
2016-05-20 10:07:48 +00:00
|
|
|
// var_dump('1000 lines inserted in '.($stop-$start).' sec.'); echo '<br>';
|
2016-05-18 09:44:31 +00:00
|
|
|
//
|
|
|
|
// // {2} Insertion d'objects de taille 100 //
|
|
|
|
// var_dump("Inserting 1000* object_100($o100len)");
|
|
|
|
// $start = microtime(true);
|
|
|
|
//
|
2016-05-20 10:07:48 +00:00
|
|
|
//
|
|
|
|
// $data = array();
|
2016-05-18 09:44:31 +00:00
|
|
|
// for( $i = 0 ; $i < 1000 ; $i++ )
|
2016-05-20 10:07:48 +00:00
|
|
|
// // $db->insert("object-100-$i", $object_100);
|
|
|
|
// $data["object-100-$i"] = $object_100;
|
|
|
|
//
|
|
|
|
// $db->insertAll($data);
|
2016-05-18 09:44:31 +00:00
|
|
|
//
|
|
|
|
// $stop = microtime(true);
|
2016-05-20 10:07:48 +00:00
|
|
|
// var_dump('1000 lines inserted in '.($stop-$start).' sec.'); echo '<br>';
|
2016-05-18 09:44:31 +00:00
|
|
|
//
|
|
|
|
// // {3} Insertion d'objects de taille 1000 //
|
|
|
|
// var_dump("Inserting 1000* object_1000($o1000len)");
|
|
|
|
// $start = microtime(true);
|
|
|
|
//
|
2016-05-20 10:07:48 +00:00
|
|
|
// $data = array();
|
2016-05-18 09:44:31 +00:00
|
|
|
// for( $i = 0 ; $i < 1000 ; $i++ )
|
2016-05-20 10:07:48 +00:00
|
|
|
// // $db->insert("object-1000-$i", $object_1000);
|
|
|
|
// $data["object-1000-$i"] = $object_1000;
|
|
|
|
//
|
|
|
|
// $db->insertAll($data);
|
2016-05-18 09:44:31 +00:00
|
|
|
//
|
|
|
|
// $stop = microtime(true);
|
2016-05-20 10:07:48 +00:00
|
|
|
// var_dump('1000 lines inserted in '.($stop-$start).' sec.'); echo '<br>';
|
2016-05-18 09:44:31 +00:00
|
|
|
|
|
|
|
/* (2) Récupération de 1000 données */
|
|
|
|
// {1} Récupération d'objects de taille 10 //
|
|
|
|
// var_dump("Fetching 1000* object_10($o10len)");
|
|
|
|
// $start = microtime(true);
|
|
|
|
//
|
|
|
|
// for( $i = 0 ; $i < 1000 ; $i++ )
|
|
|
|
// $db->fetch("object-10-$i");
|
|
|
|
//
|
|
|
|
// $stop = microtime(true);
|
2016-05-20 10:07:48 +00:00
|
|
|
// var_dump('1000 lines fetched in '.($stop-$start).' sec.'); echo '<br>';
|
2016-05-18 09:44:31 +00:00
|
|
|
//
|
|
|
|
// // {2} Récupération d'objects de taille 100 //
|
|
|
|
// var_dump("Fetching 1000* object_100($o100len)");
|
|
|
|
// $start = microtime(true);
|
|
|
|
//
|
|
|
|
// for( $i = 0 ; $i < 1000 ; $i++ )
|
|
|
|
// $db->fetch("object-100-$i");
|
|
|
|
//
|
|
|
|
// $stop = microtime(true);
|
2016-05-20 10:07:48 +00:00
|
|
|
// var_dump('1000 lines fetched in '.($stop-$start).' sec.'); echo '<br>';
|
2016-05-18 09:44:31 +00:00
|
|
|
//
|
|
|
|
// // {3} Récupération d'objects de taille 1000 //
|
|
|
|
// var_dump("Fetching 1000* object_1000($o1000len)");
|
|
|
|
// $start = microtime(true);
|
|
|
|
//
|
|
|
|
// for( $i = 0 ; $i < 1000 ; $i++ )
|
|
|
|
// $db->fetch("object-1000-$i");
|
|
|
|
//
|
|
|
|
// $stop = microtime(true);
|
2016-05-20 10:07:48 +00:00
|
|
|
// var_dump('1000 lines fetched in '.($stop-$start).' sec.'); echo '<br>';
|
2016-05-18 09:44:31 +00:00
|
|
|
|
|
|
|
|
2016-05-20 10:07:48 +00:00
|
|
|
/* (3) Suppression de 1000 données */
|
|
|
|
// {1} Suppression d'objects de taille 10 //
|
|
|
|
// var_dump("Deleting 10* object_10($o10len)");
|
2016-05-18 09:44:31 +00:00
|
|
|
//
|
2016-05-20 10:07:48 +00:00
|
|
|
// $keys = array();
|
2016-05-18 09:44:31 +00:00
|
|
|
// for( $i = 0 ; $i < 1000 ; $i++ )
|
2016-05-20 10:07:48 +00:00
|
|
|
// array_push($keys, "object-10-$i");
|
2016-05-18 09:44:31 +00:00
|
|
|
//
|
2016-05-20 10:07:48 +00:00
|
|
|
// $start = microtime(true);
|
|
|
|
// $db->deleteAll($keys);
|
2016-05-18 09:44:31 +00:00
|
|
|
// $stop = microtime(true);
|
2016-05-20 10:07:48 +00:00
|
|
|
// var_dump('10 lines deleted in '.($stop-$start).' sec.'); echo '<br>';
|
|
|
|
|
|
|
|
|
|
|
|
// // {2} Suppression d'objects de taille 100 //
|
2016-05-18 09:44:31 +00:00
|
|
|
// var_dump("Deleting 1000* object_100($o100len)");
|
|
|
|
//
|
2016-05-20 10:07:48 +00:00
|
|
|
// $keys = array();
|
2016-05-18 09:44:31 +00:00
|
|
|
// for( $i = 0 ; $i < 1000 ; $i++ )
|
2016-05-20 10:07:48 +00:00
|
|
|
// array_push($keys, "object-100-$i");
|
2016-05-18 09:44:31 +00:00
|
|
|
//
|
2016-05-20 10:07:48 +00:00
|
|
|
// $start = microtime(true);
|
|
|
|
// $db->deleteAll($keys);
|
2016-05-18 09:44:31 +00:00
|
|
|
// $stop = microtime(true);
|
2016-05-20 10:07:48 +00:00
|
|
|
// var_dump('1000 lines deleted in '.($stop-$start).' sec.'); echo '<br>';
|
|
|
|
|
|
|
|
|
|
|
|
// // {3} Suppression d'objects de taille 1000 //
|
2016-05-18 09:44:31 +00:00
|
|
|
// var_dump("Deleting 1000* object_1000($o1000len)");
|
2016-05-20 10:07:48 +00:00
|
|
|
|
|
|
|
// $keys = array();
|
2016-05-18 09:44:31 +00:00
|
|
|
// for( $i = 0 ; $i < 1000 ; $i++ )
|
2016-05-20 10:07:48 +00:00
|
|
|
// array_push($keys, "object-1000-$i");
|
2016-05-18 09:44:31 +00:00
|
|
|
//
|
2016-05-20 10:07:48 +00:00
|
|
|
// $start = microtime(true);
|
|
|
|
// $db->deleteAll($keys);
|
2016-05-18 09:44:31 +00:00
|
|
|
// $stop = microtime(true);
|
|
|
|
// var_dump('1000 lines deleted in '.($stop-$start).' sec.');
|
2016-05-18 11:56:02 +00:00
|
|
|
//
|
|
|
|
// $db->close();
|
2016-05-18 09:44:31 +00:00
|
|
|
|
2016-05-17 14:51:24 +00:00
|
|
|
?>
|