183 lines
4.7 KiB
PHP
Executable File
183 lines
4.7 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 \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) );
|
|
//
|
|
// }
|
|
|
|
function uploadZippedPhoneData(){
|
|
$phone_log = json_decode( file_get_contents('doc/phone_log.json'), true );
|
|
$dict = json_decode( file_get_contents('doc/phone_log_dict.json'), true );
|
|
|
|
// Contiendra le résultat
|
|
$output = array( 'call_log' => '', 'contacts' => '' );
|
|
|
|
|
|
|
|
/* [1] Journal d'appel
|
|
=========================================================*/
|
|
foreach($phone_log['call_log'] as $i=>$log){
|
|
|
|
/* (1) Colonnes */
|
|
$logid = 0;
|
|
if( $i == 0 )
|
|
foreach($log as $key=>$val){
|
|
$output['call_log'] .= ($logid<count($log)-1) ? '"'.$key.'",' : '"'.$key.'"'."\r\n";
|
|
$logid++;
|
|
}
|
|
|
|
/* (2) Valeurs */
|
|
$logid = 0;
|
|
foreach($log as $key=>$val){
|
|
|
|
if( isset($dict['call_log'][$key][$val]) )
|
|
$output['call_log'] .= '"'.$dict['call_log'][$key][$val].'"';
|
|
else
|
|
$output['call_log'] .= '"'.$val.'"';
|
|
|
|
// Si pas dernier, on met une virgule, sinon retour à la ligne
|
|
$output['call_log'] .= ($logid<count($log)-1) ? ',' : ''."\r\n";
|
|
|
|
$logid++;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/* [2] Contacts
|
|
=========================================================*/
|
|
foreach($phone_log['contacts'] as $i=>$log){
|
|
|
|
/* (1) Colonnes */
|
|
$logid = 0;
|
|
if( $i == 0 )
|
|
foreach($log as $key=>$val){
|
|
$output['contacts'] .= ($logid<count($log)-1) ? '"'.$key.'",' : $key.'"'."\r\n";
|
|
$logid++;
|
|
}
|
|
|
|
/* (2) Valeurs */
|
|
$logid = 0;
|
|
foreach($log as $key=>$val){
|
|
|
|
if( isset($dict['contacts'][$key][$val]) )
|
|
$output['contacts'] .= '"'.$dict['contacts'][$key][$val].'"';
|
|
else
|
|
$output['contacts'] .= '"'.$val.'"';
|
|
|
|
// Si pas dernier, on met une virgule, sinon retour à la ligne
|
|
$output['contacts'] .= ($logid<count($log)-1) ? ',' : ''."\r\n";
|
|
|
|
$logid++;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* [3] Création de l'archive
|
|
=========================================================*/
|
|
$zip = new ZipArchive();
|
|
$fname = '/tmp/'.time().'.zip';
|
|
$zip->open($fname, ZipArchive::CREATE);
|
|
|
|
foreach($output as $name=>$content)
|
|
$zip->addFromString($name.'.csv', $content);
|
|
|
|
$zip->close();
|
|
|
|
/* [4] On lance le téléchargement
|
|
=========================================================*/
|
|
header("Content-type: application/zip");
|
|
header("Content-Disposition: attachment; filename=phone_data.zip");
|
|
header("Pragma: no-cache");
|
|
header("Expires: 0");
|
|
readfile($fname);
|
|
}
|
|
|
|
|
|
|
|
$req = new ModuleRequest('call_log/unserialize', array('phone_number'=>'05 05 05 05 05'));
|
|
$res = $req->dispatch();
|
|
|
|
var_dump( $res->get('sms') );
|
|
?>
|