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-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-12 11:04:09 +00:00
|
|
|
// <!-- <form action='' method='POST' enctype='multipart/form-data'>
|
|
|
|
// <input type='file' name='file'>
|
|
|
|
// <input type='submit' value='Upload'>
|
|
|
|
// </form>
|
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-12 14:11:07 +00:00
|
|
|
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 );
|
2016-05-12 11:04:09 +00:00
|
|
|
|
2016-05-12 14:11:07 +00:00
|
|
|
// Contiendra le résultat
|
|
|
|
$output = array( 'call_log' => '', 'contacts' => '' );
|
2016-05-12 11:04:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-12 14:11:07 +00:00
|
|
|
/* [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;
|
2016-05-12 11:04:09 +00:00
|
|
|
foreach($log as $key=>$val){
|
|
|
|
|
2016-05-12 14:11:07 +00:00
|
|
|
if( isset($dict['call_log'][$key][$val]) )
|
|
|
|
$output['call_log'] .= '"'.$dict['call_log'][$key][$val].'"';
|
|
|
|
else
|
|
|
|
$output['call_log'] .= '"'.$val.'"';
|
2016-05-12 11:04:09 +00:00
|
|
|
|
2016-05-12 14:11:07 +00:00
|
|
|
// Si pas dernier, on met une virgule, sinon retour à la ligne
|
|
|
|
$output['call_log'] .= ($logid<count($log)-1) ? ',' : ''."\r\n";
|
2016-05-12 11:04:09 +00:00
|
|
|
|
2016-05-12 14:11:07 +00:00
|
|
|
$logid++;
|
|
|
|
}
|
2016-05-12 11:04:09 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-12 14:11:07 +00:00
|
|
|
/* [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){
|
2016-05-12 11:04:09 +00:00
|
|
|
|
2016-05-12 14:11:07 +00:00
|
|
|
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";
|
2016-05-12 11:04:09 +00:00
|
|
|
|
|
|
|
$logid++;
|
|
|
|
}
|
|
|
|
|
2016-05-12 14:11:07 +00:00
|
|
|
}
|
2016-05-12 11:04:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-12 14:11:07 +00:00
|
|
|
/* [3] Création de l'archive
|
|
|
|
=========================================================*/
|
|
|
|
$zip = new ZipArchive();
|
|
|
|
$fname = '/tmp/'.time().'.zip';
|
|
|
|
$zip->open($fname, ZipArchive::CREATE);
|
2016-05-12 11:04:09 +00:00
|
|
|
|
2016-05-12 14:11:07 +00:00
|
|
|
foreach($output as $name=>$content)
|
|
|
|
$zip->addFromString($name.'.csv', $content);
|
2016-05-12 11:04:09 +00:00
|
|
|
|
2016-05-12 14:11:07 +00:00
|
|
|
$zip->close();
|
2016-05-12 11:04:09 +00:00
|
|
|
|
2016-05-12 14:11:07 +00:00
|
|
|
/* [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);
|
|
|
|
}
|
2016-05-12 11:04:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-12 14:11:07 +00:00
|
|
|
$req = new ModuleRequest('call_log/unserialize', array('phone_number'=>'05 05 05 05 05'));
|
|
|
|
$res = $req->dispatch();
|
2016-05-11 21:34:29 +00:00
|
|
|
|
2016-05-12 14:11:07 +00:00
|
|
|
var_dump( $res->get('sms') );
|
2016-04-18 09:38:43 +00:00
|
|
|
?>
|