e { return $content; } } } /** * print message or array in debug mode * * @param string $message */ function printDebug ($message) { if(DEBUG) { if(!is_scalar($message)) { print("
");
			var_dump($message);
			print("
"); } else { print($message); } } } /** * log page generation performances (queries number and time) * * @param int $idSite * * @param bool true */ function recordDbQueryCount($idSite) { // records query count and time to compute this page $res = substr(getMicrotime()-$GLOBALS['time_start'], 0, 4); $r = query("INSERT INTO ".T_QUERY_LOG." (idsite, query, time, date, daytime)" . " VALUES ('$idSite', '".$GLOBALS['query_count']."', '$res', CURRENT_DATE(), CURRENT_TIME())"); return true; } /** * operation called by secureVar * * @param int|string $var * * @return int|string */ function secureVarOperation($var) { if(is_array( $var )) { foreach($var as $key => $value) { if(is_array($value)) { $var[$key] = secureVarOperation($value); } else { $var[$key] = htmlspecialchars(trim($value)); } } } else { $var = htmlspecialchars(trim($var)); } return databaseSecure($var); } function databaseSecure($var) { $db =& Db::getInstance(); if($db->isReady()) { if(is_array($var)) { foreach($var as $key => $value) { if(is_array($value)) { $var[$key] = databaseSecure($value); } else { $var[$key] = databaseEscape($value); } } } else { $var = databaseEscape($var); } } return $var; } /** * secures the variable from SQL injection and from cross site scripting * * @param int|string|array $var * @param int|string|array var secured */ function secureVar($var) { if(is_scalar($var)) { return secureVarOperation($var); } else if(is_array($var)) { foreach($var as $key => $value) { $var[$key] = secureVarOperation($value); } return $var; } else { return $var; } } /** * special stripslashes managing fucking magic_quotes * * @param string|array $str * * @return string|array stripslashed, or not */ function stripslashesPmv($str) { if (get_magic_quotes_gpc()) { if(is_array($str)) { foreach($str as $key => $value) { $str[$key] = stripslashes($value); } return $str; } else { return stripslashes($str); } } else { return $str; } } /** * set an int or string to a precise length, completing on the left with zero (O) * * @param all $id * @param int $length * * @return string string to length $length */ function setToLength($id, $length) { settype($id, 'string'); $l = strlen($id); for($i=0;$i<$length-$l;$i++) { $id='0'.$id; } return $id; } /** * returns seconds since midnight today * * @return int seconds since midnight today */ function todayTime() { return date("H") * 3600 + date("i") * 60 + date("s"); } ?>e { return $content; } } } /** * print message or array in debug mode * * @param string $message */ function printDebug ($message) { if(DEBUG) { if(!is_scalar($message)) { print("
");
			var_dump($message);
			print("
"); } else { print($message); } } } /** * log page generation performances (queries number and time) * * @param int $idSite * * @param bool true */ function recordDbQueryCount($idSite) { // records query count and time to compute this page $res = substr(getMicrotime()-$GLOBALS['time_start'], 0, 4); $r = query("INSERT INTO ".T_QUERY_LOG." (idsite, query, time, date, daytime)" . " VALUES ('$idSite', '".$GLOBALS['query_count']."', '$res', CURRENT_DATE(), CURRENT_TIME())"); return true; } /** * operation called by secureVar * * @param int|string $var * * @return int|string */ function secureVarOperation($var) { if(is_array( $var )) { foreach($var as $key => $value) { if(is_array($value)) { $var[$key] = secureVarOperation($value); } else { $var[$key] = htmlspecialchars(trim($value)); } } } else { $var = htmlspecialchars(trim($var)); } return databaseSecure($var); } function databaseSecure($var) { $db =& Db::getInstance(); if($db->isReady()) { if(is_array($var)) { foreach($var as $key => $value) { if(is_array($value)) { $var[$key] = databaseSecure($value); } else { $var[$key] = databaseEscape($value); } } } else { $var = databaseEscape($var); } } return $var; } /** * secures the variable from SQL injection and from cross site scripting * * @param int|string|array $var * @param int|string|array var secured */ function secureVar($var) { if(is_scalar($var)) { return secureVarOperation($var); } else if(is_array($var)) { foreach($var as $key => $value) { $var[$key] = secureVarOperation($value); } return $var; } else { return $var; } } /** * special stripslashes managing fucking magic_quotes * * @param string|array $str * * @return string|array stripslashed, or not */ function stripslashesPmv($str) { if (get_magic_quotes_gpc()) { if(is_array($str)) { foreach($str as $key => $value) { $str[$key] = stripslashes($value); } return $str; } else { return stripslashes($str); } } else { return $str; } } /** * set an int or string to a precise length, completing on the left with zero (O) * * @param all $id * @param int $length * * @return string string to length $length */ function setToLength($id, $length) { settype($id, 'string'); $l = strlen($id); for($i=0;$i<$length-$l;$i++) { $id='0'.$id; } return $id; } /** * returns seconds since midnight today * * @return int seconds since midnight today */ function todayTime() { return date("H") * 3600 + date("i") * 60 + date("s"); } ?> $this->adminUser; } function getAdminPartner() { return $this->adminPartner; } function getIdToUse() { return $this->idToUse; } // for pages detail function loadIdToUse() { $this->idToUse = getRequestVar('idtouse', 'sum', 'string'); } function redirectToModule( $name ) { $url = Request::getPhpmvRoot() . "index.php?mod=".$name; if(Request::getCurrentCompleteUrl() != $url) { header("Location: $url"); exit; } } function loadSiteId() { if($this->getModuleName() == 'list_logos') return true; $site = getRequestVar('site', Site::getFirstSiteAvailable(), 'int'); $db =& Db::getInstance(); if($db->isReady() && $db->areAllTablesInstalled() && !Request::isCurrentModuleAnInstallModule() ) { // check site asked is ok if($site != -1) { $r = query("SELECT idsite FROM ".T_SITE); $idSite = array(); while($l = mysql_fetch_assoc($r)) { $idSite[] = $l['idsite']; } if(sizeof($idSite) == 0) { $GLOBALS['header_error_message_tpl'] = $GLOBALS['lang']['generique_aucune_site_bdd']; Request::redirectToModule( 'admin_site_general&action=add'); $site = false; } elseif( !in_array( $site, $idSite) ) { $site = 0; } } } $this->site = (int)$site; } function isCurrentModuleAnInstallModule() { return substr(Request::getModuleNameFromUrl(), 0, 8) === 'install_'; } function isCurrentModuleAGraphModule() { return substr(Request::getModuleNameFromUrl(), 0, 10) === 'view_graph'; } function isCurrentModuleAViewModule() { return substr(Request::getModuleNameFromUrl(), 0, 4) === 'view'; } function getTablesClean() { return getRequestVar('clean', 0, 'int'); } function getGraphType() { return getRequestVar('graph_type', null, 'int'); } function getGraphData() { return getRequestVar('graph_data', null, 'string'); } function getPeriod() { return $this->period; } function setSiteId($siteId) { $this->site = $siteId; } function getSiteId( $askedForExistingSite = true ) { // case we asked for the real index asked, including site=-1 which means sites summary // so when asked for site for the SELECT HTML site generation if(!$askedForExistingSite && isset($this->site_index)) { return $this->site_index; } return $this->site; } function getDate() { return $this->date; } function offsetDate($o_minDay) { $date = Archive::offsetDate(new Date($this->date), $o_minDay); $this->date = $date->get(); } function getContinentZoom() { return $this->id_details_continent; } function loadContinentZoom() { $a_continent = array('eur', 'amn', 'ams', 'afr', 'oce', 'asi'); $c = getRequestVar('id_details_continent', false, 'string'); if( !in_array($c, $a_continent)) { $this->id_details_continent = false; } else { $this->id_details_continent = $c; } } } ?>