Permalink
Browse files

sources php

  • Loading branch information...
mikklfr committed Jun 20, 2012
1 parent af0bdb2 commit 35cc626ac1f437bdaae05281ffa84d0cbfc3b2af
Showing with 1,535 additions and 0 deletions.
  1. +206 −0 android.php
  2. +31 −0 exporter.class.php
  3. +79 −0 func.inc.php
  4. +59 −0 functions.inc.php
  5. +122 −0 liveview.php
  6. +621 −0 parser.php
  7. +76 −0 ssh.class.php
  8. +341 −0 user.class.php
View
@@ -0,0 +1,206 @@
+<?php
+
+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));
+ }
+
+?>
View
@@ -0,0 +1,31 @@
+<?php
+
+require_once("user.class.php");
+
+class EpitechExporter
+{
+ CONST ERR_NOT_SET = -42;
+ private $user = NULL;
+ public $isset = false;
+ public $error = NULL;
+
+ public function __construct($user = NULL)
+ {
+ if (!isset($user) || $user->isset === false)
+ {
+ $this->error = EpitechExporter::ERR_NOT_SET;
+ return ($this);
+ }
+ $this->user = $user;
+ $this->isset = true;
+ return ($this);
+ }
+
+ public function export_day($date = NULL)
+ {
+ $ret = $this->user->get_week($date);
+ echo json_encode($ret);
+ }
+}
+
+?>
View
@@ -0,0 +1,79 @@
+<?php
+
+function sort_multi_array($array, $key)
+{
+ $keys = array();
+ for ($i = 1;$i < func_num_args(); $i++) {
+ $keys[$i - 1] = func_get_arg($i);
+ }
+ $func = function ($a, $b) use ($keys)
+ {
+ for ($i = 0; $i<count($keys); $i++)
+ {
+ if ($a[$keys[$i]] != $b[$keys[$i]]) {
+ return (($a[$keys[$i]] < $b[$keys[$i]]) ? -1 : 1);
+ }
+ }
+ return (0);
+ };
+ usort($array, $func);
+ return ($array);
+}
+
+function rstrpos($haystack, $needle, $offset)
+{
+ $size = strlen($haystack);
+ $pos = strpos(strrev($haystack), strrev($needle), ($size - $offset));
+ if ($pos === false)
+ return (false);
+ return ($size - $pos - strlen($needle));
+}
+
+function epur_html($html) {
+ if (empty($html))
+ return ($html);
+ return (strip_tags($html));
+}
+
+function week_from_monday($date) {
+ $day = $date[0].$date[1];
+ $month = $date[2].$date[3];
+ $year = $date[4].$date[5].$date[6].$date[7];
+ $wkday = date('l', mktime('0', '0', '0', $month, $day, $year));
+ switch($wkday) {
+ case 'Monday': $numDaysToMon = 0; break;
+ case 'Tuesday': $numDaysToMon = 1; break;
+ case 'Wednesday': $numDaysToMon = 2; break;
+ case 'Thursday': $numDaysToMon = 3; break;
+ case 'Friday': $numDaysToMon = 4; break;
+ case 'Saturday': $numDaysToMon = 5; break;
+ case 'Sunday': $numDaysToMon = 6; break;
+ }
+ $monday = mktime('0','0','0', $month, $day-$numDaysToMon, $year);
+ $seconds_in_a_day = 86400;
+ for($i = 0; $i < 7; $i++)
+ $dates[$i] = date('dmY',$monday + ($seconds_in_a_day * $i));
+ return ($dates);
+}
+
+function rec_tree($ssh, $path, $depth = 0)
+{
+ $file_list = $ssh->exec('ls -aF '.$path);
+ $file_list = explode("\n", $file_list);
+ foreach ($file_list as $file)
+ {
+ if (empty($file) || $file == "./" || $file == '../')
+ continue;
+ $flen = strlen($file) - 1;
+ echo str_repeat(' ', $depth);
+ if ($flen > 0 && $file[$flen] == '/')
+ {
+ echo $file."<br />";
+ rec_tree($ssh, $path.$file, $depth + 1);
+ }
+ else
+ echo $file."<br />";
+ }
+}
+
+?>
View
@@ -0,0 +1,59 @@
+<?php
+function sort_multi_array ($array, $key)
+{
+ $keys = array();
+ for ($i = 1;$i < func_num_args(); $i++) {
+ $keys[$i - 1] = func_get_arg($i);
+ }
+ $func = function ($a, $b) use ($keys)
+ {
+ for ($i = 0; $i<count($keys); $i++)
+ {
+ if ($a[$keys[$i]] != $b[$keys[$i]]) {
+ return (($a[$keys[$i]] < $b[$keys[$i]]) ? -1 : 1);
+ }
+ }
+ return (0);
+ };
+ usort($array, $func);
+ return ($array);
+}
+
+function rstrpos($haystack, $needle, $offset)
+{
+ $size = strlen($haystack);
+ $pos = strpos(strrev($haystack), strrev($needle), ($size - $offset));
+ if ($pos === false)
+ return (false);
+ return ($size - $pos - strlen($needle));
+}
+
+function epur_html($html) {
+ if (empty($html))
+ return ($html);
+ return (strip_tags($html));
+}
+
+function week_from_monday($date) {
+ $day = $date[0].$date[1];
+ $month = $date[2].$date[3];
+ $year = $date[4].$date[5].$date[6].$date[7];
+ $wkday = date('l', mktime('0', '0', '0', $month, $day, $year));
+ switch($wkday) {
+ case 'Monday': $numDaysToMon = 0; break;
+ case 'Tuesday': $numDaysToMon = 1; break;
+ case 'Wednesday': $numDaysToMon = 2; break;
+ case 'Thursday': $numDaysToMon = 3; break;
+ case 'Friday': $numDaysToMon = 4; break;
+ case 'Saturday': $numDaysToMon = 5; break;
+ case 'Sunday': $numDaysToMon = 6; break;
+ }
+ $monday = mktime('0','0','0', $month, $day-$numDaysToMon, $year);
+ $seconds_in_a_day = 86400;
+ for($i = 0; $i < 7; $i++)
+ $dates[$i] = date('dmY',$monday + ($seconds_in_a_day * $i));
+ return ($dates);
+}
+
+
+?>
Oops, something went wrong.

0 comments on commit 35cc626

Please sign in to comment.