Viewing file: functions.php (12.7 KB) -rw----r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php /* if(get_magic_quotes_gpc()) { remove_magic_quotes($_POST); remove_magic_quotes($_GET); remove_magic_quotes($_REQUEST); remove_magic_quotes($_SERVER); remove_magic_quotes($_FILES); remove_magic_quotes($_COOKIE); } */ $langs = array ('fr'); function diffDatePub($recordedDate){
$todays_date = date("Y-m-d"); $today = strtotime($todays_date); $expiration_date = strtotime($recordedDate);
if ($expiration_date-$today>2) { echo "success"; } else if ($expiration_date-$today==0) { echo "warning"; } else { echo "important"; } }
function countqlq($fromtable, $conditionwhere, $prifix){ $db = Database::obtain(); $sql=""; $row=""; $sql.$prifix = "SELECT COUNT(*) AS amount FROM `".$fromtable."` WHERE ".$conditionwhere.""; $row.$prifix = $db->query_first($sql.$prifix); echo $row.$prifix['amount']; } function updateSimpleValue($champRecord, $theTable){ if(isset($_REQUEST['action']) && ($_REQUEST['action']=="edit") && isset($_REQUEST['id']) && !empty($_REQUEST['id']) ){ $db = Database::obtain(); $sqlToUpdate = "SELECT ".$champRecord." from `".$theTable."` WHERE id=".$db->escape($_REQUEST['id']).""; $recordToUpdate = $db->query_first($sqlToUpdate); return 'value="'.stripslashes($recordToUpdate[$champRecord]).'"'; }} function idRecord($champRecord, $theTable){ if(isset($_REQUEST['action']) && ($_REQUEST['action']=="edit") && isset($_REQUEST['id']) && !empty($_REQUEST['id']) ){ $db = Database::obtain(); $sqlToUpdate = "SELECT ".$champRecord." from `".$theTable."` WHERE id=".$db->escape($_REQUEST['id']).""; $recordToUpdate = $db->query_first($sqlToUpdate); if($db->affected_rows > 0){ return '<input type="hidden" name="idRecord" value="'.$db->escape($_REQUEST['id']).'" />'; } }} function updateSimplephoto($champRecord, $theTable, $cheminPhoto, $width, $height){ if(isset($_REQUEST['action']) && ($_REQUEST['action']=="edit") && isset($_REQUEST['id']) && !empty($_REQUEST['id']) ){ $db = Database::obtain(); $sqlToUpdate = "SELECT ".$champRecord.", vignette from `".$theTable."` WHERE id=".$db->escape($_REQUEST['id']).""; $recordToUpdate = $db->query_first($sqlToUpdate); return '<a href="'.$cheminPhoto.'/'.stripslashes($recordToUpdate[$champRecord]).'" title="" class="lightbox"><img src="'.$cheminPhoto.'/'.$recordToUpdate['vignette'].'" alt="" width="'.$width.'" height="'.$height.'"></a>'; }} /////////// function updateAreaValue($champRecord, $theTable){ if(isset($_REQUEST['action']) && ($_REQUEST['action']=="edit") && isset($_REQUEST['id']) && !empty($_REQUEST['id']) ){ $db = Database::obtain(); $sqlToUpdate = "SELECT ".$champRecord." from `".$theTable."` WHERE id=".$db->escape($_REQUEST['id']).""; $recordToUpdate = $db->query_first($sqlToUpdate); return stripslashes($recordToUpdate[$champRecord]); }} //////////// function updateChekedValue($champRecord, $theTable){ if(isset($_REQUEST['action']) && ($_REQUEST['action']=="edit") && isset($_REQUEST['id']) && !empty($_REQUEST['id']) ){ $db = Database::obtain(); $sqlToUpdate = "SELECT ".$champRecord." from `".$theTable."` WHERE id=".$db->escape($_REQUEST['id']).""; $recordToUpdate = $db->query_first($sqlToUpdate); // echo $recordToUpdate[''.$champRecord.'']; if($recordToUpdate[''.$champRecord.'']=="1") echo 'checked="checked" '; } else echo 'checked="checked" ';
}
function updateListedValue($nomChamp, $champRecord, $theTable){ if(isset($_REQUEST['action']) && ($_REQUEST['action']=="edit") && isset($_REQUEST['id']) && !empty($_REQUEST['id']) ){ $db = Database::obtain(); $sqlToUpdate = "SELECT ".$champRecord." from `".$theTable."` WHERE id=".$db->escape($_REQUEST['id']).""; $recordToUpdate = $db->query_first($sqlToUpdate); return ' <script type="text/javascript"> $(document).ready(function() { $("'.$nomChamp.' option[value=\''.$recordToUpdate[''.$champRecord.''].'\']").attr(\'selected\', \'selected\'); }); </script>';
}}
function dateConv($value) { $table = explode('-',$value); $temp_array = array();
for ($i=2;$i>=0;$i--) { array_push($temp_array,$table[$i]); } $final = implode('/',$temp_array); } /////////////////////// function activeOuiNon($valActive){ if($valActive==1) echo "Oui"; else echo "Non"; } /////////////////////// function mynl2br($text) { return strtr($text, array("\r\n" => '<br />', "\r" => '<br />', "\n" => '<br />')); } // function br2nl( $input ) { $out = str_replace( "<br>", "\n", $input ); $out = str_replace( "<br/>", "\n", $out ); $out = str_replace( "<br />", "\n", $out ); $out = str_replace( "<BR>", "\n", $out ); $out = str_replace( "<BR/>", "\n", $out ); $out = str_replace( "<BR />", "\n", $out ); return stripslashes($out); } ////////////////// function userActionLowed($theAction, $toAficheAction, $elseToAficheAction){ $db = Database::obtain();
include_once("./class/simple_acl.php"); $userId = $_SESSION['UserId']; $userLevel = $_SESSION['UserLevel']; $acl = new SimpleAcl($userId,$userLevel); $acl->adminLevel =1;
$sqlUserConnect="SELECT * FROM `lfi_users` WHERE `id`='".$db->escape($_SESSION['UserId'])."'"; $rowUserConnect = $db->query_first($sqlUserConnect); $dbActions= explode(',',$rowUserConnect['actions']); if(in_array($theAction,$dbActions)) { $thisActionAccess=$theAction; } else $thisActionAccess="koko"; $acl->addResource("".$thisActionAccess."",$rowUserConnect['level']); if ($acl->isValid("".$theAction."")) { echo $toAficheAction;}else {echo $elseToAficheAction;} }
/////////////////// function multidelete($table, $theID){ $db = Database::obtain(); if(isset($_REQUEST['supprimer']) && isset($_REQUEST['checkbox'])) // from button name="delete" { $checkbox = $_REQUEST['checkbox']; //from name="checkbox[]" $countCheck = count($_REQUEST['checkbox']); for($i=0;$i<$countCheck;$i++) { $del_id = $checkbox[$i]; $sql = "DELETE FROM `".$table."` WHERE ".$theID." = $del_id"; $db->query($sql); }}}
/////////////////////////////////////////////////////////////////////////////////// function multiaction( $table, $theID){ $db = Database::obtain(); if(isset($_REQUEST['checkbox'])) // from button name="delete" { $checkbox = $_REQUEST['checkbox']; //from name="checkbox[]" $countCheck = count($_REQUEST['checkbox']); for($i=0;$i<$countCheck;$i++) { $del_id = $checkbox[$i];
/*if($_REQUEST['actiontodo']=="supprimer"){ $sql = "DELETE FROM `".$table."` WHERE ".$theID." = $del_id"; }*/
if(isset($_REQUEST['activerecord'])){ $sql = "UPDATE ".$table." set active='1' WHERE ".$theID." = $del_id"; } if(isset($_REQUEST['desactiverecord'])){ $sql = "UPDATE ".$table." set active='0' WHERE ".$theID." = $del_id"; } $db->query($sql); } }} //FUNCTION MENU ACTIVATION ( CURRENT CLASS CSS° function currentMENU($thispage){ if($thispage == basename($_SERVER['PHP_SELF']) ) echo $cur="active"; else echo $cur=""; }
//FUNCTION MENU ACTIVATION ( CURRENT CLASS CSS° function currentSouMENU($action){ if(isset($_GET['action']) && $action==$_GET['action'] ) echo $cur="this"; else echo $cur=""; } ?> <?php function activeNo($recTable, $theid, $theTable){ if($recTable==1) return '<a href="javascript:void(0);" title="Activer" class="activee toactive label label-success activerecord" id="'.$theid.'" rel="'.$theTable.'" alt="'.$recTable.'">Activé</a>'; else return '<a href="javascript:void(0);" class="noactiverecord toactive label label-error" id="'.$theid.'" title="Déscativer" rel="'.$theTable.'" alt="'.$recTable.'">Désactivé</a>'; }
function activeImgGaleri($recTable, $theid, $theTable){ if($recTable==1) return ' <button class="btn btn-small btn-success tip toactiveimage" title="Activer" id="'.$theid.'" rel="'.$theTable.'" alt="'.$recTable.'"> <span class="icon-share-alt icon-white"></span></button>'; else return ' <button class="btn btn-small btn-warning tip toactiveimage" id="'.$theid.'" title="Déscativer" rel="'.$theTable.'" alt="'.$recTable.'"><span class="icon-warning-sign icon-white"></span></button> '; } function isValidateBien($datafield, $filed){ //$data[$datafield]=(isset($filed) && trim($db->escape($filed))!="") ? trim($db->escape($filed)) : ""; } // MULTI SUPPRISEION function multideleteGal($table, $theID){ $db = Database::obtain(); if(isset($_REQUEST['supprimerS']) && isset($_REQUEST['checkboxs'])) // from button name="delete" { $checkbox = $_REQUEST['checkboxs']; //from name="checkbox[]" $countCheck = count($_REQUEST['checkboxs']); for($i=0;$i<$countCheck;$i++) { $del_id = $checkbox[$i]; $supimage = "SELECT * FROM `".$table."` WHERE ".$theID." =$del_id"; $supimage = @mysql_query($supimage) or die(mysql_error()); $supimagee = @mysql_fetch_array($supimage); $sql = "delete from `".$table."` WHERE ".$theID." =$del_id"; $db->query($sql);
if(($supimagee['nom']!='') && (file_exists('../images/prdgallery/'.$supimagee['nom']))){ unlink('../images/prdgallery/'.$supimagee['nom']); } } } } // MULTI DESACTIVATION function multidesactiveGal($table, $theID){ $db = Database::obtain(); if(isset($_REQUEST['desactiverS']) && isset($_REQUEST['checkboxs'])) // from button name="delete" { $checkbox = $_REQUEST['checkboxs']; //from name="checkbox[]" $countCheck = count($_REQUEST['checkboxs']); for($i=0;$i<$countCheck;$i++) { $del_id = $checkbox[$i]; $req = "UPDATE `".$table."` SET active='0' WHERE ".$theID." =$del_id"; $req = @mysql_query($req) or die(mysql_error()); } } } // MULTI ACTIVATION function multiactiveGal($table, $theID){ $db = Database::obtain(); if(isset($_REQUEST['activerS']) && isset($_REQUEST['checkboxs'])) // from button name="delete" { $checkbox = $_REQUEST['checkboxs']; //from name="checkbox[]" $countCheck = count($_REQUEST['checkboxs']); for($i=0;$i<$countCheck;$i++) { $del_id = $checkbox[$i]; $req = "UPDATE `".$table."` SET active='1' WHERE ".$theID." =$del_id"; $req = @mysql_query($req) or die(mysql_error()); } } }
function conversionDateFrancais($date,$numerique = FALSE) { //Si on veut la convertir au format numérique if ($numerique == TRUE) return substr($date,8,2) . "/" . substr($date,5,2) . "/" . substr($date,0,4); //Si on veut la convertir au format textuel $moisFr = array ( "01" => "janvier", "02" => "février", "03" => "mars", "04" => "avril", "05" => "mai", "06" => "juin", "07" => "juillet", "08" => "août", "09" => "septembre", "10" => "octobre", "11" => "novembre", "12" => "décembre" ); //On définit le jour $dateFr['jour'] = substr($date,8,2); //On définit le mois $dateFr['mois'] = $moisFr[substr($date,5,2)]; //On définit l'année $dateFr['annee'] = substr($date,0,4); //On fusionne le tout $date = join (" ", $dateFr); return $date; } function conversionHeureFrancais($heure) { //On sépare les heures des minutes $tab = explode(':',$heure); //On construit la phrase en français $heure = $tab[0].'h'.$tab[1]; return $heure; }
function rand_string( $length ) { $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $str=""; $size = strlen( $chars ); for( $i = 0; $i < $length; $i++ ) { $str .= $chars[ rand( 0, $size - 1 ) ]; }
return $str; } function selectParent($theTable, $idTable, $idCurent, $champShow){ $db = Database::obtain(); $sqlShowRecord = "SELECT ".$champShow." from `".$theTable."` WHERE ".$idTable."=".$db->escape($idCurent).""; $recordShowRecord = $db->query_first($sqlShowRecord); echo stripslashes($recordShowRecord[$champShow]); }
function funcMultilangueChamp($coutI, $labelTitre, $champName, $thisPageContent, $theTable, $langs, $tailleChamp, $required){ $db = Database::obtain(); for($i=0; $i<=$coutI; $i++){ echo' <div class="control-group"> <label class="control-label" for="focusedInput">'.$labelTitre.' '.ucfirst($langs[$i]).'</label> <div class="controls"> <input class="'.$tailleChamp.' focused '.$required.'" id="'.$champName.$langs[$i].'" name="'.$champName.$langs[$i].'" type="text" placeholder="'.$labelTitre.' '.$thisPageContent.' '.ucfirst($langs[$i]).'" '.updateSimpleValue($champName.$langs[$i], $theTable).'> </div> </div>'; } } function funcMultilangueAria($coutI, $labelTitre, $champName, $thisPageContent, $theTable, $langs, $required, $cleditor, $row){ $db = Database::obtain(); for($i=0; $i<=$coutI; $i++){ echo' <div class="control-group"> <label class="control-label" for="textarea'.$langs[$i].'">'.$labelTitre.' '.ucfirst($langs[$i]).'</label> <div class="controls"> <textarea class="focused '.$required.' '.$cleditor.'" id="'.$champName.$langs[$i].'" name="'.$champName.$langs[$i].'" rows="'.$row.'" placeholder="'.$labelTitre.' '.$thisPageContent.' '.ucfirst($langs[$i]).'" style="width:500px;" >'.updateAreaValue($champName.$langs[$i], $theTable).'</textarea> </div> </div>'; } }
?>
|