|
Server IP : 10.128.40.6 / Your IP : 216.73.216.233 Web Server : Apache System : Linux webd006.cluster128.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : logmcpe ( 111175) PHP Version : 7.3.33 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/logmcpe/www/TEST/../MC/includes/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
/**
* All of WebCalendar's functions
*
* @author Craig Knudsen <cknudsen@cknudsen.com>
* @copyright Craig Knudsen, <cknudsen@cknudsen.com>, http://www.k5n.us/cknudsen
* @license http://www.gnu.org/licenses/gpl.html GNU GPL
* @package WebCalendar
*/
if (empty ($PHP_SELF) && ! empty ($_SERVER) &&
! empty ($_SERVER['PHP_SELF'])) {
$PHP_SELF = $_SERVER['PHP_SELF'];
}
if (! empty ($PHP_SELF) && preg_match ("/\/includes\//", $PHP_SELF)) {
die ("You can't access this file directly!");
}
/**
* Array of global variables which are not allowed to by set via HTTP GET/POST
*
* This is a security precaution to prevent users from overriding any global
* variables
*
* @global array $noSet
*/
$noSet = array (
"is_admin" => 1,
"db_type" => 1,
"db_host" => 1,
"db_login" => 1,
"db_password" => 1,
"db_persistent" => 1,
"PROGRAM_NAME" => 1,
"PROGRAM_URL" => 1,
"readonly" => 1,
"single_user" => 1,
"single_user_login" => 1,
"use_http_auth" => 1,
"user_inc" => 1,
"includedir" => 1,
"NONUSER_PREFIX" => 1,
"languages" => 1,
"browser_languages" => 1,
"pub_acc_enabled" => 1,
"user_can_update_password" => 1,
"admin_can_add_user" => 1,
"admin_can_delete_user" => 1,
);
// This code is a temporary hack to make the application work when
// register_globals is set to Off in php.ini (the default setting in
// PHP 4.2.0 and after).
//if (empty ($HTTP_GET_VARS)) $HTTP_GET_VARS = $_GET;
if (! empty ($_GET)) {
while (list($key, $val) = @each($_GET)) {
// don't allow anything to have <script> in it...
if (! is_array ($val)) {
if (preg_match ("/<\s*script/i", $val)) {
echo "Security violation!"; exit;
}
}
if ($key == "login") {
if (strstr ($PHP_SELF, "log in.php")) {
//$GLOBALS[$key] = $val;
$GLOBALS[$key] = $val;
}
} else {
if (empty ($noSet[$key])) {
$GLOBALS[$key] = $val;
//echo "XXX $key<br />\n";
}
}
//echo "GET var '$key' = '$val' <br />\n";
}
reset ($_GET);
}
//if (empty ($HTTP_POST_VARS)) $HTTP_POST_VARS = $_POST;
if (! empty ($_POST)) {
while (list($key, $val) = @each($_POST)) {
// don't allow anything to have <script> in it... except 'template'
if (! is_array ($val) && $key != 'template') {
if (preg_match ("/<\s*script/i", $val)) {
echo "Security violation!"; exit;
}
}
if (empty ($noSet[$key])) {
$GLOBALS[$key] = $val;
}
}
reset ($_POST);
}
//while (list($key, $val) = @each($HTTP_POST_FILES)) {
// $GLOBALS[$key] = $val;
//}
//while (list($key, $val) = @each($HTTP_SESSION_VARS)) {
// $GLOBALS[$key] = $val;
//}
//if (empty ($HTTP_COOKIE_VARS)) $HTTP_COOKIE_VARS = $_COOKIE;
if (! empty ($_COOKIE)) {
while (list($key, $val) = @each($_COOKIE)) {
if (empty ($noSet[$key]) && substr($key,0,12) == "webcalendar_") {
$GLOBALS[$key] = $val;
}
//echo "COOKIE var '$key' = '$val' <br />\n";
}
reset ($_COOKIE);
}
// Don't allow a user to put "login=XXX" in the URL if they are not
// coming from the login.php page.
if (empty ($PHP_SELF) && ! empty ($_SERVER['PHP_SELF']))
$PHP_SELF = $_SERVER['PHP_SELF']; // backward compatibility
if (empty ($PHP_SELF))
$PHP_SELF = ''; // this happens when running send_reminders.php from CL
if (! strstr ($PHP_SELF, "login.php") && ! empty ($GLOBALS["login"])) {
$GLOBALS["login"] = "";
}
/*
* Functions start here. All non-function code should be above this
*
* Note to developers:
* Documentation is generated from the function comments below.
* When adding/updating functions, please follow the following conventions
* seen below. Your cooperation in this matter is appreciated :-)
*
* If you want your documentation to link to the db documentation,
* just make sure you mention the db table name followed by "table"
* on the same line. Here's an example:
* Retrieve preferences from the webcal_user_pref table.
*
*/
/**
* Gets the value resulting from an HTTP POST method.
*
* <b>Note:</b> The return value will be affected by the value of
* <var>magic_quotes_gpc</var> in the php.ini file.
*
* @param string $name Name used in the HTML form
*
* @return string The value used in the HTML form
*
* @see getGetValue
*/
function getPostValue ($name) {
//global $HTTP_POST_VARS;
//if (isset ($_POST) && is_array ($_POST) && ! empty ($_POST[$name])) {
if (isset ($_POST) && is_array ($_POST)) {
//$HTTP_POST_VARS[$name] = $_POST[$name];
return $_POST[$name];
}/* else if (! isset ($HTTP_POST_VARS)) {
return null;
} else if (! isset ($HTTP_POST_VARS[$name])) {
return null;
}
//return ($HTTP_POST_VARS[$name]);*/
return null;
}
/**
* Gets the value resulting from an HTTP GET method.
*
* <b>Note:</b> The return value will be affected by the value of
* <var>magic_quotes_gpc</var> in the php.ini file.
*
* If you need to enforce a specific input format (such as numeric input), then
* use the {@link getValue()} function.
*
* @param string $name Name used in the HTML form or found in the URL
*
* @return string The value used in the HTML form (or URL)
*
* @see getPostValue
*/
function getGetValue ($name) {
//global $HTTP_GET_VARS;
//if (isset ($_GET) && is_array ($_GET) && ! empty ($_GET[$name])) {
if (isset ($_GET) && is_array ($_GET)) {
//$HTTP_GET_VARS[$name] = $_GET[$name];
return $_GET[$name];
}/* else if (! isset ($HTTP_GET_VARS)) {
return null;
} else if (! isset ($HTTP_GET_VARS[$name])) {
return null;
}
return ($HTTP_GET_VARS[$name]);*/
return null;
}
/**
* Logs a debug message.
*
* Generally, we do not leave calls to this function in the code. It is used
* for debugging only.
*
* @param string $msg Text to be logged
*/
function do_debug ($msg) {
// log to /tmp/webcal-debug.log
//error_log (date ("Y-m-d H:i:s"). "> $msg\n",
// 3, "/tmp/webcal-debug.log");
//error_log (date ("Y-m-d H:i:s"). "> $msg\n",
// 2, "sockieman:2000");
}
/** Sends a redirect to the specified page.
*
* The database connection is closed and execution terminates in this function.
*
* <b>Note:</b> MS IIS/PWS has a bug in which it does not allow us to send a
* cookie and a redirect in the same HTTP header. When we detect that the web
* server is IIS, we accomplish the redirect using meta-refresh. See the
* following for more info on the IIS bug:
*
* {@link http://www.faqts.com/knowledge_base/view.phtml/aid/9316/fid/4}
*
* @param string $url The page to redirect to. In theory, this should be an
* absolute URL, but all browsers accept relative URLs (like
* "month.php").
*
* @global string Type of webserver
* @global array Server variables
* @global resource Database connection
*/
function do_redirect ($url) {
global $SERVER_SOFTWARE, $_SERVER, $c;
// Replace any '&' with '&' since we don't want that in the HTTP
// header.
$url = str_replace ('&', '&', $url);
if (empty ($SERVER_SOFTWARE))
$SERVER_SOFTWARE = $_SERVER["SERVER_SOFTWARE"];
//echo "SERVER_SOFTWARE = $SERVER_SOFTWARE <br />\n"; exit;
if ((substr ($SERVER_SOFTWARE, 0, 5) == "Micro") ||
(substr ($SERVER_SOFTWARE, 0, 3) == "WN/")) {
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html
PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
<head>\n<title>Redirect</title>\n" .
"<meta http-equiv=\"refresh\" content=\"0; url=$url\" />\n</head>\n<body>\n" .
"Redirecting to.. <a href=\"".$url."\">here</a>.</body>\n</html>";
} else {
Header ("Location: $url");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html
PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
<head>\n<title>Redirect</title>\n</head>\n<body>\n" .
"Redirecting to ... <a href=\"".$url."\">here</a>.</body>\n</html>";
}
dbi_close ($c);
exit;
}
/**
* Prints out a date selection box for use in a form.
*
* @param string $prefix Prefix to use in front of form element names
* @param int $date Currently selected date (in YYYYMMDD format)
*
* @uses date_selection_html
*/
function print_date_selection ($prefix, $date, $num_years_from='-5', $num_years_to='10', $form='', $params='') {
print date_selection_html ($prefix, $date, $num_years_from, $num_years_to, $form, $params);
}
/**
* Gets the Sunday of the week that the specified date is in.
*
* If the date specified is a Sunday, then that date is returned.
*
* @param int $year Year
* @param int $month Month (1-12)
* @param int $day Day of the month
*
* @return int The date (in UNIX timestamp format)
*
* @see get_monday_before
*/
function get_sunday_before ($year, $month, $day) {
$weekday = date ("w", mktime (3, 0, 0, $month, $day, $year));
$newdate = mktime (3, 0, 0, $month, $day - $weekday, $year);
return $newdate;
}
/**
* Gets the Monday of the week that the specified date is in.
*
* If the date specified is a Monday, then that date is returned.
*
* @param int $year Year
* @param int $month Month (1-12)
* @param int $day Day of the month
*
* @return int The date (in UNIX timestamp format)
*
* @see get_sunday_before
*/
function get_monday_before ($year, $month, $day) {
$weekday = date ("w", mktime (3, 0, 0, $month, $day, $year));
if ($weekday == 0)
return mktime (3, 0, 0, $month, $day - 6, $year);
if ($weekday == 1)
return mktime (3, 0, 0, $month, $day, $year);
return mktime (3, 0, 0, $month, $day - ($weekday - 1), $year);
}
/**
* Returns the full name of the specified month.
*
* Use {@link month_short_name()} to get the abbreviated name of the month.
*
* @param int $m Number of the month (0-11)
*
* @return string The full name of the specified month
*
* @see month_short_name
*/
function month_name ($m) {
switch ($m) {
case 0: return "Janvier";
case 1: return "Février";
case 2: return "Mars";
case 3: return "Avril";
case 4: return "Mai";
case 5: return "Juin";
case 6: return "Juillet";
case 7: return "Août";
case 8: return "Septembre";
case 9: return "Octobre";
case 10: return "Novembre";
case 11: return "Décembre";
}
return "";
}
/**
* Returns the abbreviated name of the specified month (such as "Jan").
*
* Use {@link month_name()} to get the full name of the month.
*
* @param int $m Number of the month (0-11)
*
* @return string The abbreviated name of the specified month (example: "Jan")
*
* @see month_name
*/
function month_short_name ($m) {
switch ($m) {
case 0: return "Jan";
case 1: return "Fev";
case 2: return "Mar";
case 3: return "Avr";
case 4: return "Mai";
case 5: return "Juin";
case 6: return "Juil";
case 7: return "Août";
case 8: return "Sep";
case 9: return "Oct";
case 10: return "Nov";
case 11: return "Déc";
}
}
/**
* Returns the full weekday name.
*
* Use {@link weekday_short_name()} to get the abbreviated weekday name.
*
* @param int $w Number of the day in the week (0=Sunday,...,6=Saturday)
*
* @return string The full weekday name ("Sunday")
*
* @see weekday_short_name
*/
function weekday_name ($w) {
switch ($w) {
case 0: return "Dimanche";
case 1: return "Lundi";
case 2: return "Mardi";
case 3: return "Mercredi";
case 4: return "Jeudi";
case 5: return "Vendredi";
case 6: return "Samedi";
}
}
/**
* Returns the abbreviated weekday name.
*
* Use {@link weekday_name()} to get the full weekday name.
*
* @param int $w Number of the day in the week (0=Sunday,...,6=Saturday)
*
* @return string The abbreviated weekday name ("Sun")
*/
function weekday_short_name ($w) {
switch ($w) {
case 0: return "Dim";
case 1: return "Lun";
case 2: return "Mar";
case 3: return "Mer";
case 4: return "Jeu";
case 5: return "Ven";
case 6: return "Sam";
}
}
// ***********************************************************************
// Functions for getting information about boss and their assistant.
// ***********************************************************************
/**
* Removes non-word characters from the specified text.
*
* @param string $data Input text
*
* @return string The converted text
*/
function clean_word($data) {
return preg_replace("/\W/", '', $data);
}
/**
* Removes non-digits from the specified text.
*
* @param string $data Input text
*
* @return string The converted text
*/
function clean_int($data) {
return preg_replace("/\D/", '', $data);
}
/*
* Fonction qui retourne le taux de facturation entre une période pour un client
*
* Prend en argument une date de début, une date de fin de type "Ymd",
* un numero client, client_id, et le numero agence $agence
*
*/
function taux_fact($debP, $finP, $cli_id, $agence) {
// Initialisation au début du moisde $debP et fin du mois de $finP
$from = date("Ymd", mktime(0, 0, 0, substr($debP,4,2), 01, substr($debP,0,4)) );
$to = date("Ymd", mktime(0, 0, 0, substr($finP,4,2), date("t",int2time($finP)-360), substr($finP,0,4)) );
// la somme des annulations en heure
//vérifier rôle de en_cours!='1'
// attribut facture !?
$req=dbi_query("SELECT SUM( pr.presta_Hduree ) 'somme' FROM ".TABLE_PREST." pr JOIN ".TABLE_EXCEPT." ex
WHERE pr.client_id=".$cli_id." AND ex.presta_id=pr.presta_id AND pr.agence_id='".$agence."' AND inter_abs!='1' AND presta_recur='1' AND ex.date between '".$from."' AND '".$to."' AND new_presta_id IS NULL AND facture!='1' ");
$c=dbi_fetch_row($req);
$somme = $c['somme'] === NULL ? 0 : $c['somme']/60;
//vérifier rôle de en_cours!='1'
// Liste des prestations du client
$q = dbi_query("SELECT * FROM ".TABLE_PREST." WHERE client_id ='".$cli_id."' AND agence_id=".$agence." AND presta_id NOT In (SELECT new_presta_id FROM ".TABLE_EXCEPT." WHERE new_presta_id is not null)") ;
//echo "SELECT * FROM ".TABLE_PREST." WHERE client_id ='".$cli_id."' AND agence_id=".$agence." AND presta_id NOT In (SELECT new_presta_id FROM ".TABLE_EXCEPT." WHERE new_presta_id is not null) <br>";
// Somme des heures réalisées
$tmps=0;
while($p = dbi_fetch_row($q))
{
if($cli_id==1290) echo "<br> Presta : ".$p['presta_id']."<br>";
$date = get_occurence($p['presta_id'], 0, $from) ;
$current = 0 ;
$offset = 0 ;
while($date !== false && $date['date'] <= $to)
{
$tmps += $date['duree'] ;
if($cli_id==1290) echo " :: temps : ".$tmps.", datePresta : ".$date['date']." from : ".$from."<br>";
if($current == $date['date'])
$offset ++ ;
else
$offset = 0 ;
$current = $date['date'] ;
$date = get_occurence($p['presta_id'], 1+$offset, $date['date']) ;
}
}
$temps = $tmps === NULL ? 0 : $tmps/60;
$totalheur = $temps + $somme;
$tauxFact = $totalheur == 0 ? 0 : round((1-( $somme/$totalheur ))*100, 2);
return($tauxFact);
}
//if($_SERVER["REMOTE_ADDR"]=="82.228.70.64")
// function de test des semaines alternés
//require_once('test2_functions_planning_part2-V2.php');
// function stable qui gère les bugs
function track () {
if ($_SESSION['login'][0]=='') {
$boundary = "-----=".md5(uniqid(rand())) ;
$headers = "Content-Type: multipart/alternative; boundary=\"$boundary\"\n" ;
$headers .= "Content-Transfer-Encoding: base64\n" ;
$headers .= "From: \"Ménage & Cie\" <$email>\n" ;
$headers .= "MIME-Version: 1.0\n" ;
$txt = print_r($_POST, true).'<br><br>';
$txt .= print_r($_GET, true).'<br><br>';
$txt .= print_r($_SESSION, true).'<br><br>';
$txt .= print_r($_SERVER, true).'<br><br>';
$message = "--$boundary\n" ;
$message .= "Content-type: text/plain; Charset=\"utf-8\"\n" ;
$message .= "Content-Transfer-Encoding: base64\n\n" ;
$message .= chunk_split(base64_encode(utf8_encode(stripslashes($txt))))."\n";
$message .= "--$boundary\n" ;
$message .= "Content-type: text/html; Charset=\"utf-8\"\n" ;
$message .= "Content-Transfer-Encoding: base64\n\n" ;
$message .= chunk_split(base64_encode(utf8_encode(stripslashes($txt))))."\n";
$message .= "--$boundary--\n" ;
mail('','log '.$_SESSION['menu']['page'],$message,$headers);
}
}
//else
// require_once('functions_planning_part2-V2.php');
function array_values_bd ($tableau) {
if (is_array($tableau)) return array_values($tableau);
else return '';
}
?>
