Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

285 lines (262 sloc) 7.449 kb
<?php
/* Documentation tag for Doxygen
*/
/*! \mainpage Epitech-Mobile Documentation
*
* \section intro_sec Introduction
*
* This is the Epitech-Mobile documentation.
*
* \section install_sec Installation
*
* \subsection install_subsec Required:
* - PHP server with support of curl and if possible ssh2_ functions
*
* Kind of updated sources are here : https://github.com/mikklfrcompany/epitech-mobile
*
* \section usage_sec Usage
*
* \subsection running Calling the Api:
* - Post and Get request are handled by android.php <BR><BR>
*
* You can query: <BR><BR>http://sshd.mikkl.fr/epitech_mobile/intra/android.php<BR>
* or https://sshd.mikkl.fr/epitech_mobile/intra/android.php<BR>
* \subsection example Example :
* - Http post to android.php in order to get today's events<BR>
* post['login'] = epitech-login <BR>
* post['passwd'] = epitech-ppp-password <BR>
* post['action'] = 'day'; <BR><BR>
* Result is like :<BR>
*(Conferences) Bar Camp : les Labos vous invitent ! :_: Conference :_: p10 :_: 19:00 :_: 03:00 :_: <BR><BR>
* For each event output is : <BR>
* Event_name :_: Event_type :_: Event_location :_: Event_time_start :_: Event_time_lenght :_:<BR><BR>
*
*<B>You need to post 'login' and 'passwd' with every action !</B>
*\subsection actions Actions Lists :
* - post['action'] = 'day' :<BR>
* Return todays events<BR>
* Event_name :_: Event_type :_: Event_location :_: Event_time_start :_: Event_time_lenght :_:<BR><BR>
* - post['action'] = 'day' and post['date'] = DDMMYY : <BR>
* Return DDMMYY events <BR>
* Event_name :_: Event_type :_: Event_location :_: Event_time_start :_: Event_time_lenght :_:<BR><BR>
* - post['action'] = 'projects' :<BR>
* Return current projects<BR>
* project_name :_: text_date_issue<BR><BR>
* - post['action'] = 'notes' :<BR>
* Return marks<BR>
* Project_date:_:Project_module:_:Project_name:_:Project_mark:_:Project_comment<BR><BR>
* - post['action'] = 'fire' :<BR>
* Return fire status and alerts<BR>
* Fire_color:_:Fire_comment:_:[Alerts:_:]<BR><BR>
* - post['action'] = 'my_susie' :<BR>
* Return susies<BR>
* Susie_description :_: Susie_name :_: Susie_time_begin :_: Susie_time_end :_: Susie_date :_: Susie_nb_registered_users :_: Susie_url:_:Susie_url<BR><BR>
* - post['action'] = 'my_tokens' :<BR>
* Return tokens<BR>
* token_id:_: Event_desc:_:Event_comment:_:<BR><BR>
* - post['action'] = 'susie_register' and post['url'] = susie_url:<BR>
* Try to register to a susie class<BR>
* Return_suscribe:_:<BR><BR>
* - post['action'] = 'susie_unregister' and post['url'] = susie_url:<BR>
* Try to unregister to a susie class<BR>
* Return_unsuscribe:_:<BR><BR>
* - post['action'] = 'susie_list' and post['date'] = DDMMYY :<BR>
* Return list of susie for DDMMYY<BR>
* Susie_url:_: Susie_theme :_: Susie_name :_: Susie_begin_time :_: Susie_lenght :_: Susie_date :_: nbr_user:_:<BR><BR>
* - post['action'] = 'report' and post['user'] = login_report :<BR>
* Return report of login_report<BR>
* login:_:nom:_:ids:_:promo_bocal :_:location_bocal:_:sip_nbr:_:diplomes:_:netsoul:_:Close_status:_:[project_date:_:project_module:_:project_name:_:project_mark:_:project_comment:_:]<BR><BR>
* - post['action'] = 'version' :<BR>
* Return current version<BR>
* Version<BR><BR>
* - post['action'] = 'token' and post['event_id'] = event_id and post['token_val'] = token_val :<BR>
* Try to validate token<BR>
* Return_token_try:_:<BR><BR>
* <BR><BR>
* \authors Denis Mondon (mondon_d@epitech.eu), Jonathan Picques (picque_j@epitech.eu), Michael Ohayon (ohayon_m@epitech.eu)
* <BR><BR>
*
*/
require_once("user.class.php");
define("SEPARATOR", ":_:");
define("VERSION", 4.6);
$login = isset($_REQUEST['login']) ? $_REQUEST['login'] : NULL;
$passwd = isset($_REQUEST['passwd']) ? $_REQUEST['passwd'] : NULL;
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : NULL;
$date = isset($_REQUEST['date']) ? $_REQUEST['date'] : NULL;
$user = isset($_REQUEST['user']) ? $_REQUEST['user'] : NULL;
$url = isset($_REQUEST['url']) ? $_REQUEST['url'] : NULL;
function stripSpacesAndTabs($str)
{
$str = preg_replace( '/\s+/', ' ', $str);
return ($str);
}
if (!isset($login) || !isset($passwd) || !isset($action))
die('ERR_PARAMS');
$epiuser = new EpitechUser($login, $passwd);
if ($epiuser->isset == false)
{
if ($epiuser->error == EpitechUser::ERR_USER_NOTSET)
die('ERR_USER_NOTSET');
else if ($epiuser->error == EpitechUser::ERR_LOGIN)
die('ERR_LOGIN');
else if ($epiuser->error == EpitechUser::ERR_CURL)
die('ERR_INTRA');
die('ERR_UNKNOWN');
}
if ($action == 'day')
{
$day = $epiuser->get_day($date);
foreach ($day as $res) {
foreach($res as $e) {
echo epur_html($e);
echo SEPARATOR;
}
}
}
if ($action == 'week')
{
$week = $epiuser->get_week($date);
$i = 1;
foreach ($week as $e => $day)
{
$wtf = substr($e, -8);
$mmonth = $wtf[2].$wtf[3];
$dday = $wtf[0].$wtf[1];
$yyear = substr($wtf, -4);
echo $i."-".$dday."/".$mmonth."/".$yyear.SEPARATOR;
foreach ($day as $res) {
foreach($res as $e) {
echo trim(epur_html($e));
echo SEPARATOR;
}
}
$i++;
}
}
if ($action == 'projects')
{
$projects = $epiuser->get_projects();
foreach ($projects as $res) {
foreach($res as $e) {
echo epur_html($e);
echo SEPARATOR;
}
}
}
if ($action == 'notes')
{
$notes = $epiuser->get_notes();
foreach ($notes as $res) {
$i = 0;
foreach($res as $e) {
echo epur_html($e);
echo SEPARATOR;
$i++;
}
}
}
if ($action == 'fire')
{
$fire = $epiuser->get_fire();
foreach ($fire as $res) {
echo stripSpacesAndTabs(epur_html($res));
echo SEPARATOR;
}
}
if ($action == 'my_susie')
{
$susie = $epiuser->get_my_susie();
$i = 0;
while ($i < sizeof($susie))
{
$j = 0;
while ($susie[$i][$j])
{
echo stripSpacesAndTabs(epur_html($susie[$i][$j]));
echo SEPARATOR;
$j++;
}
$i++;
}
}
if ($action == 'my_tokens')
{
$tokens = $epiuser->get_my_tokens();
$i = 0;
while ($i < sizeof($tokens))
{
$j = 0;
while ($tokens[$i][$j])
{
echo stripSpacesAndTabs(epur_html($tokens[$i][$j]));
echo SEPARATOR;
$j++;
}
$i++;
}
}
if ($action == 'susie_register')
{
$rep = $epiuser->get_susie_register($url);
echo $rep;
}
if ($action == 'susie_unregister')
{
$rep = $epiuser->get_susie_unregister($url);
echo $rep;
}
if ($action == 'susie_status')
{
$fire = $epiuser->get_susiestatus($url);
echo " ";
$i = 0;
while ($fire[$i])
{
echo stripSpacesAndTabs(epur_html($fire[$i]));
echo SEPARATOR;
$i++;
}
}
if ($action == 'susie_list')
{
$susie = $epiuser->get_susielist($date);
$i = 0;
while ($i < sizeof($susie))
{
$j = 0;
while ($susie[$i][$j])
{
echo stripSpacesAndTabs(epur_html($susie[$i][$j]));
echo SEPARATOR;
$j++;
}
$i++;
}
}
if ($action == 'report')
{
$projects = $epiuser->get_report($user);
foreach ($projects['report'] as $e)
{
echo epur_html($e);
echo SEPARATOR;
}
foreach ($projects['notes'] as $res) {
foreach($res as $e) {
echo epur_html($e);
echo SEPARATOR;
}
}
}
if ($action == 'version')
echo VERSION;
if ($action == 'token')
{
$event_id = isset($_REQUEST['event_id']) ? $_REQUEST['event_id'] : NULL;
$token_val = isset($_REQUEST['token_val']) ? $_REQUEST['token_val'] : NULL;
if (!isset($event_id) || !isset($token_val))
die('ERR_PARAMS');
$epiuser->validate_token(array('event_id' => $event_id, 'token_val' => $token_val));
}
?>
Jump to Line
Something went wrong with that request. Please try again.