function addaemploi($id_aemploi, $montant, $date_paiement, $mode_paiement, $ref_pj, $pj) { global $db; $nextid = getnextidtable('autorisation_emploi'); $usrid = $_SESSION['userid']; $date = date('Y-m-d-', strtotime($date_paiement)); $values["pj"] = MySQL::SQLValue($pj); $values["ref_pj"] = MySQL::SQLValue($ref_pj); $values["id_aemploi"] = MySQL::SQLValue($id_aemploi); $values["mode_paiement"] = MySQL::SQLValue($mode_paiement); $values["date_paiement"] = MySQL::SQLValue($date); $values["montant"] = MySQL::SQLValue($montant); $values["addby"] = MySQL::SQLValue($usrid); if (!$db->InsertRow("autorisation_emploi", $values)) { $db->Kill($db->Error()); return false; } else { $sql = $db->BuildSQLInsert("autorisation_emploi", $values); logg('Enregistrement Autorisation Emploi ', 246, $nextid, $_SESSION['userid']); if ($pj != "") { $basedir = "upload/Autorisation"; if (!file_exists($basedir)) { mkdir($basedir, 0, true); } $newdir = $basedir . "/"; copyfile($pj, $nextid, $newdir, "Attachement_autorisation_"); autoarchive($newdir . changnom($pj, $nextid, 'Attachement_autorisation_'), "Fichier joint autorisation emploi {$nextid}", 246, $nextid, "autorisation_emploi", "pj", $_SESSION['userid'], cryptage(session::get('service'), 0)); } } return true; }
function edit_fournisseur($rs, $nom, $prenom, $adr, $if, $ville, $pays, $tel, $mail, $mobile, $fax, $id) { global $db; $values["rs"] = MySQL::SQLValue($rs); $values["nom"] = MySQL::SQLValue($nom); $values["prenom"] = MySQL::SQLValue($prenom); $values["adr"] = MySQL::SQLValue($adr); $values["if"] = MySQL::SQLValue($if); $values["ville"] = MySQL::SQLValue($ville); $values["pays"] = MySQL::SQLValue($pays); $values["tel"] = MySQL::SQLValue($tel); $values["email"] = MySQL::SQLValue($mail); $values["mobile"] = MySQL::SQLValue($mobile); $values["fax"] = MySQL::SQLValue($fax); $where["id"] = MySQL::SQLValue($id); // Execute the Update $result = $db->UpdateRows("fournisseur", $values, $where); if (!$result) { $db->Kill($db->Error()); return false; } else { logg("Validation Entrée {$id} ", 100, 0, $_SESSION['userid']); return true; } }
function add_contrat($nextid, $titre, $fournisseur, $date, $montant_global, $article, $paragraphe, $chapitre, $pj) { global $db; $usrid = $_SESSION['userid']; $date = date('Y-m-d-', strtotime($date)); $values["titre"] = MySQL::SQLValue($titre); $values["date"] = MySQL::SQLValue($date); $values["id_fournisseur"] = MySQL::SQLValue($fournisseur); $values["id_chapitre"] = MySQL::SQLValue($chapitre); $values["id_article"] = MySQL::SQLValue($article); $values["id_paragraphe"] = MySQL::SQLValue($paragraphe); $values["montant_global"] = MySQL::SQLValue($montant_global); $values["montant_paye"] = MySQL::SQLValue(0); $values["pourcentage"] = MySQL::SQLValue(0); $values["montant_rest"] = MySQL::SQLValue($montant_global); $values["addby"] = MySQL::SQLValue($usrid); if (!$db->InsertRow("contrat", $values)) { $db->Kill($db->Error()); return false; } else { logg('Enregistrement Contrat Fournisseur ', 254, $nextid, $_SESSION['userid']); // Save PJ to archive if ($pj != "") { $basedir = "upload/contrat"; if (!file_exists($basedir)) { mkdir($basedir, 0, true); } $newdir = $basedir . "/"; copyfile($pj, $nextid, $newdir, "Attachement_contrat_"); autoarchive($newdir . changnom($pj, $nextid, 'Attachement_contrat_'), "Fichier joint contrat fournisseur {$nextid}", 254, $nextid, "contrat", "pj", $_SESSION['userid'], cryptage(session::get('service'), 0)); } } return true; }
function cleanupjson() { logg("Cleanup json"); $dir = "../json/"; $files = rd($dir); foreach($files as $fnum => $fname) { // Stuff.. $fpath = "{$dir}{$fname}"; if (is_dir($fpath)) { continue; } // Clear temp files... if (strpos($fpath,"station_info.TMP.")!==FALSE) { logg(" - TMP: {$fpath}"); unlink($fpath); } // Clear old station_info files.. elseif (strpos($fpath,"station_info.")!==FALSE) { $timeold = time() - (60*60*24); // 60s * 60m = 1 hour // -> calced in seconds if (filemtime($fpath)<$timeold) { logg(" - OLD: {$fpath}"); unlink($fpath); } } } /**/ }
function editlocation($nextid, $nom, $adresse, $pj, $tel, $mail, $villa, $date_debut, $date_fin, $type_paiement, $montant_location, $agarantie_location) { global $db; $usrid = $_SESSION['userid']; $datedebut = date('Y-m-d-', strtotime($date_debut)); $datefin = date('Y-m-d-', strtotime($date_fin)); $values["nomlocataire"] = MySQL::SQLValue($nom); $values["adresse"] = MySQL::SQLValue($adresse); $values["tel"] = MySQL::SQLValue($tel); $values["mail"] = MySQL::SQLValue($mail); $values["idvilla"] = MySQL::SQLValue($villa); $values["date_debut"] = MySQL::SQLValue($datedebut); $values["date_fin"] = MySQL::SQLValue($datefin); $values["montant"] = MySQL::SQLValue($montant_location); $values["depot_garantie"] = MySQL::SQLValue($agarantie_location); $values["type_paiement"] = MySQL::SQLValue($type_paiement); $where["id"] = MySQL::SQLValue($nextid); if (!$db->UpdateRows("contrat_location_villa", $values, $where)) { $db->Kill($db->Error()); return false; } else { $sql = $db->BuildSQLInsert("contrat_location_villa", $values); logg('Enregistrement Location Villa ', 100, $nextid, $_SESSION['userid']); if ($pj != "") { $basedir = "upload/location"; if (!file_exists($basedir)) { mkdir($basedir, 0, true); } $newdir = $basedir . "/"; copyfile($pj, $nextid, $newdir, "Attachement_location_"); autoarchive($newdir . changnom($pj, $nextid, 'Attachement_location_'), "Fichier joint location ville {$nextid}", 100, $nextid, "location_villa", "pj", $_SESSION['userid'], cryptage(session::get('service'), 0)); } return true; } }
function setcontrat($id, $date, $pj) { global $db; $etat = "Résilié"; $nextid = getnextidtable('contrat_location_villa'); $date = date('Y-m-d-', strtotime($date)); $values["date_resiliation"] = MySQL::SQLValue($date); $values["etat"] = MySQL::SQLValue($etat); $where["id"] = MySQL::SQLValue($id); if (!$db->UpdateRows("contrat_location_villa", $values, $where)) { $db->Kill($db->Error()); return false; } else { $sql = $db->BuildSQLInsert("contrat_location_villa", $values); logg('Enregistrement Location Villa ', 233, $id, $_SESSION['userid']); if ($pj != "") { $basedir = "upload/location"; if (!file_exists($basedir)) { mkdir($basedir, 0, true); } $newdir = $basedir . "/"; copyfile($pj, $id, $newdir, "Attachement_location_"); autoarchive($newdir . changnom($pj, $id, 'Attachement_location_'), "Fichier joint location ville {$id}", 233, $id, "contrat_location_villa", "pj_resiliation", $_SESSION['userid'], cryptage(session::get('service'), 0)); } return true; } }
function editcollecte($idcontrat, $paiement, $date, $pj) { global $db; $usrid = $_SESSION['userid']; $nextid = getnextidtable('collecte'); //$date1=date_create($date); //$datep=date_format($date1,"Y-m-d"); $date_paiement = date('Y-m-d-', strtotime($date)); $values["mode_paiement"] = MySQL::SQLValue($paiement); $values["date_paiement"] = MySQL::SQLValue($date_paiement); $where["id"] = MySQL::SQLValue($idcontrat); if (!$db->UpdateRows("collecte", $values, $where)) { $db->Kill($db->Error()); return false; } else { $sql = $db->BuildSQLInsert("collecte", $values); logg('Enregistrement collecte ', 201, $nextid, $_SESSION['userid']); if ($pj != "") { $basedir = "upload/collecte"; if (!file_exists($basedir)) { mkdir($basedir, 0, true); } $newdir = $basedir . "/"; copyfile($pj, $nextid, $newdir, "collecte"); autoarchive($newdir . changnom($pj, $nextid, 'collecte'), "Fichier joint collecte {$nextid}", 201, $nextid, "collecte", "piece_jointe", $_SESSION['userid'], cryptage(session::get('service'), 0)); } return true; } }
function edit_quote($id, $date, $montant, $pj) { global $db; $date = date('Y-m-d-', strtotime($date)); $values["datinsert"] = MySQL::SQLValue($date); $values["montant"] = MySQL::SQLValue($montant); $where["id"] = MySQL::SQLValue($id); if (!$db->UpdateRows("quotpatronal", $values, $where)) { $db->Kill($db->Error()); return false; } else { $sql = $db->BuildSQLInsert("quotpatronal", $values); logg('Enregistrement Quote Part Patronal ', 175, $id, $_SESSION['userid']); if ($pj != "") { $basedir = "upload/quotpatronal"; if (!file_exists($basedir)) { mkdir($basedir, 0, true); } $newdir = $basedir . "/"; copyfile($pj, $id, $newdir, "Attachement_quotpatronal_"); autoarchive($newdir . changnom($pj, $id, 'Attachement_quotpatronal_'), "Fichier joint Quote Part Patronal {$id}", 175, $id, "quotpatronal", "piece_jointe", $_SESSION['userid'], cryptage(session::get('service'), 0)); } return true; } }
function setcollecte($id, $mode_paiement, $pj, $date_paiement) { global $db; //$nextid=getnextidtable('collecte'); $date = date('Y-m-d-', strtotime($date_paiement)); $values["mode_paiement"] = MySQL::SQLValue($mode_paiement); $values["date_paiement"] = MySQL::SQLValue($date); $values["etat_paiement"] = MySQL::SQLValue("Payé"); $where["id"] = MySQL::SQLValue($id); if (!$db->UpdateRows("collecte", $values, $where)) { $db->Kill($db->Error()); return false; } else { $sql = $db->BuildSQLInsert("collecte", $values); logg('Enregistrement collecte ', 195, $id, $_SESSION['userid']); if ($pj != "") { $basedir = "upload/collecte"; if (!file_exists($basedir)) { mkdir($basedir, 0, true); } $newdir = $basedir . "/"; copyfile($pj, $id, $newdir, "Attachement_collecte_"); autoarchive($newdir . changnom($pj, $id, 'Attachement_collecte_'), "Fichier joint collecte {$id}", 195, $id, "collecte", "piece_jointe", $_SESSION['userid'], cryptage(session::get('service'), 0)); } return true; } }
function editnote($objet, $note, $id, $dat) { global $db; $date = date('Y-m-d', strtotime($dat)); $getan = date('Y', strtotime($dat)); $usrid = $_SESSION['userid']; $values["objet"] = MySQL::SQLValue($objet); $values["dat"] = MySQL::SQLValue($date); $where["id"] = MySQL::SQLValue($id); // Execute the insert $result = $db->UpdateRows("noteservice", $values, $where); // ajout champs table synchrone $sql = $db->BuildSQLUpdate("noteservice", $values, $where); $valuesf["req"] = MySQL::SQLValue($sql); $r = $db->InsertRow("temprequet", $valuesf); // If we have an error if (!$result) { // Show the error and kill the script $db->Kill('Error Update'); return false; } else { logg('Modification Note de service', 12, $id, $_SESSION['userid']); $basedir = "upload/noteservice/{$getan}"; // save file if (!file_exists($basedir)) { mkdir($basedir, 0, true); } $newdir = $basedir . "/"; if ($note != "") { copyfile($note, $id, $newdir, "note_"); //autoarchive($newdir.changnom($note,$id,'note_'),"Note de service N° $id ",12,$id,"noteservice", "file", $_SESSION['userid'],cryptage(session::get('service'),0)); } return true; } }
function editreform($nextid, $titre, $desc, $montant, $pj, $date) { global $db; $usrid = $_SESSION['userid']; $date_operation = date('Y-m-d-', strtotime($date)); $values["titre"] = MySQL::SQLValue($titre); $values["description"] = MySQL::SQLValue($desc); $values["montant"] = MySQL::SQLValue($montant); $values["date_operation"] = MySQL::SQLValue($date_operation); $where["id"] = MySQL::SQLValue($nextid); if (!$db->UpdateRows("produit_reform", $values, $where)) { $db->Kill($db->Error()); return false; } else { $sql = $db->BuildSQLInsert("produit_reform", $values); logg('Enregistrement Produit Reform ', 167, $nextid, $_SESSION['userid']); if ($pj != "") { $basedir = "upload/produit"; if (!file_exists($basedir)) { mkdir($basedir, 0, true); } $newdir = $basedir . "/"; copyfile($pj, $nextid, $newdir, "Attachement_produit_reform"); autoarchive($newdir . changnom($pj, $nextid, 'Attachement_produit_reform'), "Fichier joint produit Reform {$nextid}", 100, $nextid, "produit_reform", "pj", $_SESSION['userid'], cryptage(session::get('service'), 0)); } return true; } }
function delet($id) { global $db; $req = "delete from contrat_location_villa where id={$id}"; if (!$db->Query($req)) { $db->Kill($db->Error()); return true; } else { logg("Suppression Entrée {$id} ", 73, 0, $_SESSION['userid']); return false; } }
function delet_autorisation($autorisation) { global $db; $req = "delete from autorisation_emploi where id ={$autorisation}"; $valuesf["req"] = MySQL::SQLValue($req); $r = $db->InsertRow("temprequet", $valuesf); if (!$db->Query($req)) { $db->Kill($db->Error()); return false; } else { logg("Suppression Entrée {$autorisation} ", 243, 0, $_SESSION['userid']); return true; } }
function delet_compte($id) { global $db; $req = "delete from compte where id ={$id}"; $valuesf["req"] = MySQL::SQLValue($req); $r = $db->InsertRow("temprequet", $valuesf); if (!$db->Query($req)) { $db->Kill($db->Error()); return false; } else { logg("Suppression Entrée {$id} ", 179, 0, $_SESSION['userid']); return true; } }
function cleanupjson() { logg("Cleanup json"); $dir = "../json/"; $files = rd($dir); foreach ($files as $fnum => $fname) { $fpath = "{$dir}{$fname}"; if (is_dir($fpath)) { continue; } if (strpos($fpath, "station_info.TMP.") !== FALSE) { logg(" - {$fpath}"); unlink($fpath); } } }
function delet($note) { //first delete files delfromarchive($note); global $db; $req = "delete from noteservice where id=" . $note; $valuesf["req"] = MySQL::SQLValue($req); $r = $db->InsertRow("temprequet", $valuesf); if (!$db->Query($req)) { $db->Kill('Error1'); return false; } else { logg("Suppression Entrée {$note} ", 12, 0, $_SESSION['userid']); return true; } }
function delet($id) { global $db; //$sqldir="SELECT concat('upload/aemploi/',ste,'/',YEAR(datdemand),'/',id) as dir FROM `aemploi` WHERE id=$id"; //$dir = $db->QuerySingleValue0($sqldir); //removeDir::deleteDir("$dir/"); $req = "delete from nation where id={$id}"; $valuesf["req"] = MySQL::SQLValue($req); $r = $db->InsertRow("temprequet", $valuesf); if (!$db->Query($req)) { $db->Kill($db->Error()); return true; } else { logg("Suppression Entrée {$id} ", 73, 0, $_SESSION['userid']); return false; } }
function addlocation($nextid, $nomlocataire, $nomresponsable, $adresse, $tel, $mail, $villa, $date_debut, $date_fin, $montant, $depot_garantie, $pj, $cycle) { global $db; $usrid = $_SESSION['userid']; $datedebut = date('Y-m-d-', strtotime($date_debut)); $datefin = date('Y-m-d-', strtotime($date_fin)); $values["nomlocataire"] = MySQL::SQLValue($nomlocataire); $values["nomresponsable"] = MySQL::SQLValue($nomresponsable); $values["adresse"] = MySQL::SQLValue($adresse); $values["tel"] = MySQL::SQLValue($tel); $values["mail"] = MySQL::SQLValue($mail); $values["date_debut"] = MySQL::SQLValue($datedebut); $values["date_fin"] = MySQL::SQLValue($datefin); $values["montant"] = MySQL::SQLValue($montant); $values["depot_garantie"] = MySQL::SQLValue($depot_garantie); //$values["type_paiement"] = MySQL::SQLValue($type_paiement); $values["addby"] = MySQL::SQLValue($usrid); $values["etat"] = MySQL::SQLValue('Attente Validation'); $values["cycle_paiement"] = MySQL::SQLValue($cycle); $values["idvilla"] = MySQL::SQLValue($villa); //if(($db->QuerySingleValue0("SELECT id FROM contrat_location_villa where etat='en cours' and idvilla ='".tp('villa')."'")==0) if (!$db->InsertRow("contrat_location_villa", $values)) { $db->Kill($db->Error()); return false; } else { $sql = $db->BuildSQLInsert("contrat_location_villa", $values); logg('Enregistrement Location Villa ', 196, $nextid, $_SESSION['userid']); if ($pj != "") { $basedir = "upload/location"; if (!file_exists($basedir)) { mkdir($basedir, 0, true); } $newdir = $basedir . "/"; copyfile($pj, $nextid, $newdir, "Attachement_location_"); autoarchive($newdir . changnom($pj, $nextid, 'Attachement_location_'), "Fichier joint location villa {$nextid}", 196, $nextid, "contrat_location_villa", "pj", $_SESSION['userid'], cryptage(session::get('service'), 0)); } } return true; }
function addnote($objet, $note, $id, $dat) { global $db; $date = date('Y-m-d', strtotime($dat)); $getan = date('Y', strtotime($dat)); $usrid = $_SESSION['userid']; $values["objet"] = MySQL::SQLValue($objet); $values["file"] = MySQL::SQLValue(changnom($note, $id, 'note_')); $values["dat"] = MySQL::SQLValue($date); $values["addby"] = MySQL::SQLValue($usrid); // Execute the insert $result = $db->InsertRow("noteservice", $values); $sql = $db->BuildSQLInsert("noteservice", $values); $valuesf["req"] = MySQL::SQLValue($sql); $r = $db->InsertRow("temprequet", $valuesf); // If we have an error if (!$result) { // Show the error and kill the script $db->Kill('Error insert'); return false; } else { logg('Enregistrement Note de service', 12, $id, $_SESSION['userid']); $basedir = "upload/noteservice/{$getan}"; // save file if (!file_exists($basedir)) { mkdir($basedir, 0, true); } $newdir = $basedir . "/"; if ($note != "") { copyfile($note, $id, $newdir, "note_"); autoarchive($newdir . changnom($note, $id, 'note_'), "Note de service N° {$id} ", 12, $id, "noteservice", "file", $_SESSION['userid'], cryptage(session::get('service'), 0)); } return true; } /* if($lettre!=""){ copyfile($lettre,$id,$newdir,"lettre_"); autoarchive($newdir.changnom($lettre,$id,'lettre_'),"Lettre demande Autorisation d'Emploi $id ",44,$id,"aemploi", "lettre", $_SESSION['userid'],cryptage(session::get('service'),0)); } */ }
function add_ets_diplom($id, $ets_dip, $groupe, $idgrp, $pay) { global $db; $values["pay"] = MySQL::SQLValue($pay); $values["ets"] = MySQL::SQLValue($ets_dip); $values["groupe"] = MySQL::SQLValue($groupe); $values["groupe_id"] = MySQL::SQLValue($idgrp); $values["addby"] = MySQL::SQLValue($_SESSION['userid']); // Execute the insert //$result = $db->InsertRow("offre", $values); // If we have an error if (!$db->InsertRow("ets_diplom", $values)) { // Show the error and kill the script $db->Kill($db->Error()); return false; } else { logg("Engistrement Etablissement Diplome {$id}", 125, $id, $_SESSION['userid']); $sql = $db->BuildSQLInsert("ets_diplom", $values); $valuesf["req"] = MySQL::SQLValue($sql); $r = $db->InsertRow("temprequet", $valuesf); return true; } }
function editsecteur($id, $secteur, $is_groupe, $id_groupe) { global $db; $values["secteur"] = MySQL::SQLValue($secteur); if ($is_groupe == 1) { $values["groupe"] = MySQL::SQLValue(1); $values["idgroupe"] = MySQL::SQLValue($id); } else { $values["groupe"] = MySQL::SQLValue(0); $values["idgroupe"] = MySQL::SQLValue($id_groupe); } $values["addby"] = MySQL::SQLValue($_SESSION['userid']); $where["id"] = MySQL::SQLValue($id); // Execute the insert // If we have an error if (!($result = $db->UpdateRows("secteur", $values, $where))) { // Show the error and kill the script $db->Kill($db->Error()); return false; } else { logg("Modification Métier {$id}", 125, $id, $_SESSION['userid']); return true; } }
function addcollecte($nextid, $id, $prix, $paiement, $pj) { global $db; $values["id_location"] = MySQL::SQLValue($id); $values["prix_mensuel"] = MySQL::SQLValue($prix); $values["mode_paiement"] = MySQL::SQLValue($paiement); if (!$db->InsertRow("collecte", $values)) { $db->Kill($db->Error()); return false; } else { $sql = $db->BuildSQLInsert("collecte", $values); logg('Enregistrement collecte ', 100, $nextid, $_SESSION['userid']); if ($pj != "") { $basedir = "upload/collecte"; if (!file_exists($basedir)) { mkdir($basedir, 0, true); } $newdir = $basedir . "/"; copyfile($pj, $nextid, $newdir, "Attachement_collecte_"); autoarchive($newdir . changnom($pj, $nextid, 'Attachement_collecte_'), "Fichier joint collecte {$nextid}", 100, $nextid, "collecte", "piece_jointe", $_SESSION['userid'], cryptage(session::get('service'), 0)); } return true; } }
function start($PARAMS) { if (isset($PARAMS["secure"]) and !isset($_SERVER["HTTPS"])) { //logg("server name: ".$_SERVER["SERVER_NAME"]."\nrequest uri: ".$_SERVER["REQUEST_URI"]); //header("Location: https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]); // redirect to https header("Location: https://t.oslo.opera.com" . $_SERVER["REQUEST_URI"]); // redirect to https [T version] exit(0); } // defined constants define("DEFAULT_CHUNK_SIZE", 1024 * 1024); // DEFAULT_CHUNK_SIZE is 1 MB // define startup defaults $SUPPORT_RANGE_HEADER = true; // whether or not we (the server) support the range header [default: true ] $FORCE_BROWSER_NOCACHE = false; // whether or not to send no-cache (and friends) headers [default: false ] $FORCE_CHUNKED = false; // whether or not to send chunked data [default: false ] $filename = "11s.webm"; // media file to serve [default: 11s.webm ] //$filename = "../../../../../../resources/media/webm/11s.webm"; // media file to serve [default: 11s.webm ] $rate = 0.0; // data burst rate [default: no limit ] $chunksize = 1.0 * DEFAULT_CHUNK_SIZE; // max chunk size [default: 1 MB ] $sleep = 0.0; // delay between chunks [default: 0s ] $timeout = 3; // timeout for the connection [default: 3s ] $limitsize = false; // limit the number of bytes to send [default: disabled ] $ifrange = false; // control if-range behavior [default: disabled ] // the below parameter has meaning only if USE_CONTENTRANGE is true and SUPPORT_HEADER_RANGE is true $offset = 0; // bytes added to range end to invoke invalid response [default: 0 ] // list of headers to send $HEADERS = array(); $USE_ETAG = false; // whether or not to send the etag header [default: false ] $HTTP_STATUS = false; // http status header to send (use 206 or 200 if not set) [default: false ] $date = false; // date header to send [default: don't send any ] $contenttype = "application/octet-stream"; // content type header to send (autodetected if not set) [default: application/octet-stream ] // the below headers have meaning only if SUPPORT_RANGE_HEADER is true (norange parameter is not set) $USE_CONTENTRANGE = true; // whether or not to send the content range header [default: true ] $acceptranges = "bytes"; // accept ranges header to send [default: bytes ] // the below headers have meaning only if FORCE_BROWSER_CACHE is false (nocache parameter is not set) $expires = false; // expires header to send [default: don't send any ] $lastmodified = false; // last modified header to send [default: don't send any ] $cachecontrol = false; // cache control header to send [default: don't send any ] $id = $_SERVER["REMOTE_ADDR"]; // set the script execution ID (for use with force timeout) [default: client IP ] // override default values with provided parameters (+sanity checks) if (isset($PARAMS["norange"])) { $SUPPORT_RANGE_HEADER = false; } // disable server support for the range header if (isset($PARAMS["nocache"])) { $FORCE_BROWSER_NOCACHE = true; } // enable sending of no-cache (and friends) headers if (isset($PARAMS["chunked"])) { $FORCE_CHUNKED = true; } // enable Transfer-Encoding: chunked (disable Content-Length) if (isset($PARAMS["contentrange"])) { $USE_CONTENTRANGE = false; } // disable sending the Content-Range header if (isset($PARAMS["acceptranges"])) { $acceptranges = $PARAMS["acceptranges"]; } // change the default Accept-Ranges header if (isset($PARAMS["etag"])) { $USE_ETAG = true; } // enable sending the ETag header if (isset($PARAMS["status"])) { $HTTP_STATUS = $PARAMS["status"]; } // change the default HTTP/1.1 status header if (isset($PARAMS["date"])) { $date = $PARAMS["date"]; } // enable sending the Date header and set it's value or 'yes' for current date -1s if (isset($PARAMS["expires"])) { $expires = $PARAMS["expires"]; } // enable sending the Expires header and set to how many seconds from current date it should be set if (isset($PARAMS["lastmodified"])) { $lastmodified = $PARAMS["lastmodified"]; } // enable sending the Last-Modified header and set it's value or 'yes' for the actual file modification date if (isset($PARAMS["cachecontrol"])) { $cachecontrol = $PARAMS["cachecontrol"]; } // enable sending the Cache-Control header and set it's value if (isset($PARAMS["file"])) { $filename = $PARAMS["file"]; } // set custom file name if (isset($PARAMS["size"])) { $limitsize = $PARAMS["size"]; } // limit the number of bytes to send if (isset($PARAMS["if-range"])) { $ifrange = $PARAMS["if-range"]; } // control the if-range behavior if (isset($PARAMS["timeout"]) and is_numeric($PARAMS["timeout"])) { $timeout = floatval($PARAMS["timeout"]); } // set custom timeout if (isset($PARAMS["rate"]) and is_numeric($PARAMS["rate"])) { $rate = floatval($PARAMS["rate"]) * DEFAULT_CHUNK_SIZE; } // set custom size if (isset($PARAMS["contenttype"])) { $contenttype = $PARAMS["contenttype"]; } else { $contenttype = getcontenttype($filename, $contenttype); } // or try to determine what it is based on filename if (isset($PARAMS["contentrangeoffset"])) { $offset = intval($PARAMS["offset"]); } // add some bytes to the range end to invoke an invalid range response if (isset($PARAMS["forcetimeout"])) { die(setForceTimeoutLock($PARAMS["forcetimeout"])); } // enable instant "timeout" simulation if (isset($PARAMS["id"])) { $id = $PARAMS["id"]; } // set script execution ID (for use with force timeout) if (!($video = fopen($filename, "r"))) { exit(0); } // check if file exists and can be opened for reading $filesize = $limitsize ? intval($limitsize) : filesize($filename); // get filesize (used frequently later on) if ($ifrange and $_SERVER["HTTP_IF_RANGE"]) { switch ($ifrange) { case "200": // case 200 $SUPPORT_RANGE_HEADER = false; // disable range support (same as norange=1) break; case "400": // case 400 header("HTTP/1.1 400 Bad Request"); // send bad request status die("Sorry, requested range (" . $_SERVER["HTTP_RANGE"] . ") is not satisfiable!"); // and exit the script break; } } if (isset($_SERVER["HTTP_RANGE"]) and $SUPPORT_RANGE_HEADER) { $RANGE = explode("=", $_SERVER["HTTP_RANGE"]); // split the header into type and range // sanity check if (count($RANGE, 2)) { $RANGE = explode("-", $RANGE[1]); // split the range into start and end // sanity checks if (count($RANGE) == 1) { array_push($RANGE, $filesize - 1); } // make sure the range end value is set if (is_numeric($RANGE[0])) { $RANGE[0] = intval($RANGE[0]); } else { $RANGE[0] = 0; } // if not then set to default: 0 if (is_numeric($RANGE[1])) { $RANGE[1] = intval($RANGE[1]); } else { $RANGE[1] = $filesize - 1; } // if not then set to default: max (filesize - 1 as per RFC) } else { $RANGE = array(0, $filesize - 1); } // set default start and end values array_unshift($RANGE, $_SERVER["HTTP_RANGE"]); // just because :) // set the required response headers for a range request array_push($HEADERS, "HTTP/1.1 " . ($HTTP_STATUS ? $HTTP_STATU : "206 Partial Content")); array_push($HEADERS, "Accept-Ranges: " . $acceptranges); if ($USE_CONTENTRANGE) { array_push($HEADERS, "Content-Range: bytes " . $RANGE[1] . "-" . ($RANGE[2] + $offset) . "/" . $filesize); } } else { // set headers for a standard http server response array_push($HEADERS, "HTTP/1.1 " . ($HTTP_STATUS ? $HTTP_STATUS : "200 OK")); $RANGE = array("not set", 0, $filesize - 1); } // set additional required and optional headers if ($FORCE_CHUNKED) { array_push($HEADERS, "Transfer-Encoding: chunked"); } else { array_push($HEADERS, "Content-Length: " . ($RANGE[2] - $RANGE[1] + 1)); } // ELSE set the Content-Length header if ($USE_ETAG) { array_push($HEADERS, "ETag: " . md5(floor(mktime() / 30) * 30)); } // IF etag was requested set the ETag header if ($date) { $date = $date == "yes" ? httpdate(time() - 1) : $date; // use the date provided or create a data 1s in the past array_push($HEADERS, "Date: " . $date . " GMT"); // and set the Date header } if ($FORCE_BROWSER_NOCACHE) { array_push($HEADERS, "Last-Modified: " . httpdate(filemtime($filename)) . " GMT"); array_push($HEADERS, "Cache-Control: max-age=0, no-cache, no-store, must-revalidate"); array_push($HEADERS, "Pragma: no-cache"); array_push($HEADERS, "Expires: Wed, 11 Jan 1984 05:00:00 GMT"); } else { if ($cachecontrol) { array_push($HEADERS, "Cache-Control: " . $cachecontrol); } // IF cache control was requested set Cache-Control header if ($lastmodified) { $lastmodified = $lastmodified == "yes" ? httpdate(filemtime($filename)) : $lastmodified; // use the lastmodified provided or get the actual file modification date array_push($HEADERS, "Last-Modified: " . $lastmodified); // set Last-Modified header } if ($expires) { array_push($HEADERS, "Expires: " . gmdate("D, j M Y H:i:s T", time() + $expires)); // set the Expires header array_push($HEADERS, "Cache-Control: max-age=" . $expires . ", must-revalidate"); // and the Cache-Control header with max-age and must-revalidate } } array_push($HEADERS, "Content-Type: " . $contenttype); // add the content type header foreach ($HEADERS as $header) { header($header); } // send the headers // move the file pointer to the range start (with sanity check) if (fseek($video, $RANGE[1]) == -1) { $position = 0; } else { $position = $RANGE[1]; } // set the position to where we seeked in the file // initialize timers and counters $chunks = 0; // initialize the chunk counter $bytes = 0; if ($rate != 0) { $usleep = 10; // initialize time interval for sending data chunks to 10 microseconds when data rate is limited $chunksize = round($rate * ($usleep / 1000000)); // initialize chunk size based on data rate limit } logg("\n"); logg("-------------------"); logg("Range: " . $RANGE[0]); logg("script id: " . $id); logg("rate: " . ($rate != 0 ? $rate . " B/s" : "no limit") . ", sleep: " . $sleep / 1000000 . ", usleep: " . $usleep . ", chunksize: " . $chunksize); logg("timeout: " . $timeout . "s"); logg("clear locks: " . clearForceTimeoutLocks()); $timers = new TimerManager(); $timers->start("total"); // initialize data burst timer $timers->start("timeout"); // initialize the connection timer // start the data sending loop while (connection_status() == CONNECTION_NORMAL) { ignore_user_abort(true); // allow the client to abort the connection set_time_limit($timeout); // this doesn't seem to work at all if (checkForceTimeoutLock($id)) { logg("exit reason: forced timeout"); break; } // if forced timeout is enabled if ($timers->elapsed("timeout") > $timeout) { logg("exit reason: timeout"); break; } // if timeout, then break if ($RANGE[2] + 1 <= $position) { logg("exit reason: done"); break; } // break if we've sent all the requested data (range end limit) if ($rate != 0) { $chunksize = max($chunksize + (round($timers->elapsed("total") * $rate) - ($position + $chunksize)), 0); } if ($RANGE[2] + 1 < $position + $chunksize) { // otherwise the file pointer will be set to far for the next read, also we $chunksize = $RANGE[2] + 1 - $position; // might read past file end } $timers->start("timeout"); // reset the connection timer (we want to timeout only on idle connections, // eg. video paused, not on active ones, eg. video playing) if ($chunksize > 0) { $timers->start("fread"); $data = fread($video, $chunksize); // read the data $timers->stop("fread"); $position += $chunksize; // update the current position $bytes += $chunksize; $chunks += 1; // increment the chunk counter //logg("chunk ".($chunks).": ".($position - $chunksize)."-".($position - 1)." [".(strlen($data))." bytes] (size: ".($chunksize).")"); // send the data to the client print $data; $timers->start("flush"); flush(); $timers->stop("flush"); $timers->start("obflush"); ob_flush(); $timers->stop("obflush"); } $timers->start("sleep"); usleep($usleep); // wait before sending the next chunk of data $timers->stop("sleep"); } $timers->stop("total"); logg("connection status: " . connection_status()); logg("sent: " . $bytes . " bytes in " . $chunks . " chunks [avg chunksize: " . $bytes / $chunks . " bytes, rate: " . $bytes / $timers->total("sleep") . " B/s, real rate: " . $bytes / $timers->total("total") . " B/s]"); logg("bench: " . $timers->show("fread") . ", " . $timers->show("flush") . ", " . $timers->show("obflush") . ", " . $timers->show("sleep") . ", " . $timers->show("total")); logg("-------------------"); fclose($video); // close the file exit(0); // exit the script }
function get_pic_comments($pid) { global $CONFIG; $comment_query = "SELECT msg_author, msg_date, msg_body FROM " . $CONFIG['TABLE_COMMENTS'] . " WHERE pid=" . $pid . " LIMIT 5"; logg($comment_query); $result = cpg_db_query($comment_query); $rows = cpg_db_fetch_rowset($result); return $rows; }
break; case "station": $id = $_POST["id"]; $station = $_POST["station"]; if (!$id || !$stations) { error("Error: !post[id] || !post[station]"); } $filename = "station_users/station_{$id}.json"; $fw = fw($filename, $station); if (!$fw) { error("Error: Could not write '{$filename}'"); } $json["data"] = json_decode('{"post":"ok"}', true); $json["info"] = array(); $jsons = json_encode($json); logg($jsons); echo $jsons; break; case "station_icon": // NOTE: does not return json, it returns http responses! // TODO: yes? $filename = $_FILES['file']['name']; $filepath = "../static/uploaded/{$filename}"; $filetmp = $_FILES['file']['tmp_name']; /* // redundant check. this is easily faked.. $postkey = $_POST["key"]; $getkey = $queryobj["key"]; if ($postkey!=$getkey) { http_response_code(403); error("Access denied'"); }
} } if ($_POST['user_name'] && $_POST['user_pass'] && $_POST['login']) { $sql = "select * from users where nazwa = '" . $_POST['user_name'] . "' and haslo = md5('" . $_POST['user_pass'] . "') "; $result = mysql_query($sql); if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_array($result)) { if ($row['akt'] == 0) { $_SESSION['komunikat'] = '<b>Konto jest nieaktywne !</b>'; #unset($_SESSION); } elseif ($row['haslo_do'] != '' && $row['haslo_do'] <= date("Y-m-d")) { $_SESSION['komunikat'] = '<b>Hasło wygasło musi zostać zmienione</b>'; $_SESSION['zmiana_hasla'] = 5; } else { $_SESSION['uzytk'] = $row; logg($sql, 'nieznany'); echo "<meta http-equiv=\"refresh\" content=\"0;url=index.php\">"; } } } } echo '<table bgcolor="#D9E0E7" width="50%" height="80%" align="center" border="1" cellspacing="0" cellpadding="0">'; echo '<tr valign="center"><td align="center">'; #echo '<font color=red>Logowanie</font><br>'; echo '<b>' . $_SESSION['komunikat'] . '</b>'; #echo '<table valign="center" border=0><tr>'; echo '<form action="index.php" method="post" class="fancy" id="fancy">'; echo '<fieldset >'; echo '<legend>Logowanie</legend>'; echo '<ul>'; echo '<div class="style1" id="main">';
echo '<td align="center"><input type=submit value="Edytuj dane osobowe" name="wyb_pac_ed[' . $row['id'] . ']" ></td>'; if ($row[5] == 0) { echo '<td align="center"><input type=submit value="Usuń pacjenta" name="wyb_pac_del[' . $row['id'] . ']"></td>'; } echo '</tr>'; } echo '</table>'; } } if ($_SESSION['wyb_pac_id'] && $_SESSION['zap_pac_na_wiz_czas'] == '' && $_SESSION['dod_pac_lab'] == '' && $_GET['page'] == '') { #$sql="select DATE_FORMAT(wizyty.data, '%Y-%m-%d %k:%i') as data, sl_gab.nazwa , wizyty.id, wizyty_inf.wywiad, wizyty_inf.badanie, wizyty_inf.zalecenia from wizyty, wizyty_inf, sl_gab where wizyty.akt = 1 and wizyty.id = wizyty_inf.id_wiz and sl_gab.id = wizyty.id_gab and id_pac = ".$_SESSION['wyb_pac_id']; $sql = "SELECT DATE_FORMAT( wizyty.data, '%Y-%m-%d %k:%i' ) AS \r\n\t\tdata , sl_gab.nazwa, wizyty.id, wizyty_inf.wywiad, wizyty_inf.badanie, wizyty_inf.zalecenia, sl_uslugi.nazwa as typ_wiz, sl_uslugi.id_grupy, sl_uslugi.nazwa_opis\r\n\t\tFROM wizyty\r\n\t\tLEFT JOIN wizyty_inf ON wizyty.id = wizyty_inf.id_wiz\r\n\t\tLEFT JOIN sl_gab ON sl_gab.id = wizyty.id_gab\r\n\t\tLEFT JOIN sl_uslugi ON sl_uslugi.id = wizyty.typ_wiz\r\n\t\tLEFT JOIN user_gab ON sl_gab.id = user_gab.id_gab\r\n\t\tWHERE wizyty.akt =1\r\n\t\tand\r\n\t\tuser_gab.id_user = "******"\r\n\t\tAND wizyty.id_pac =" . $_SESSION['wyb_pac_id'] . " order by data desc"; #echo $sql; echo '<div align="center">'; $result = mysql_query($sql); logg($sql, $_SESSION['u']); while ($row = mysql_fetch_array($result)) { echo '<div class="linia" align="center">'; $dz = date("Y-m-d h:s"); if ($dz < $row[0]) { echo '<font color=#0000ff>'; } else { echo '<font color=#ff0000>'; } echo $row['nazwa'] . ' - ' . $row['typ_wiz'] . ' - ' . $row[0]; echo '</font>'; echo '<input type=submit value="Edycja wizyty" name="wyb_wiz_ed[' . $row['id'] . ']" >'; echo '<div id="lista"><div><div class="highlight"><b>'; if ($row['badanie'] == '' && $row['zalecenia'] == '' && $row['wywiad'] == '') { echo '<font color=#ff0000>Brak opisu wizyty</font>'; } else {
function console($message, $EOL = true, $log = true, $level = 1) { if (!defined("DEBUG") or DEBUG >= $level) { $message .= $EOL === true ? PHP_EOL : ""; $time = (ENABLE_ANSI === true ? FORMAT_AQUA . date("H:i:s") . FORMAT_RESET : date("H:i:s")) . " "; $replaced = TextFormat::clean(preg_replace('/\\x1b\\[[0-9;]*m/', "", $time . $message)); if ($log === true and (!defined("LOG") or LOG === true)) { logg(date("Y-m-d") . " " . $replaced, "console", false, $level); } if (ENABLE_ANSI === true) { $add = ""; if (preg_match("/\\[([a-zA-Z0-9]*)\\]/", $message, $matches) > 0) { switch ($matches[1]) { case "ERROR": case "SEVERE": $add .= FORMAT_RED; break; case "INTERNAL": case "DEBUG": $add .= FORMAT_GRAY; break; case "WARNING": $add .= FORMAT_YELLOW; break; case "NOTICE": $add .= FORMAT_AQUA; break; default: $add = ""; break; } } $message = TextFormat::toANSI($time . $add . $message . FORMAT_RESET); } else { $message = $replaced; } echo $message; } }
function addeditcastcrew($tmdb, $tmdb_id) { $crew = $tmdb->getMovieCast($tmdb_id); // Add/update crew $query = "DELETE from crews where movie_id = " . $tmdb_id . ""; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); if (count($crew["crew"]) > 0) { foreach ($crew["crew"] as $c) { $c['name'] = preg_replace("/'/", "\\'", $c['name']); $c['name'] = preg_replace("/\"/", "\\\"", $c['name']); $c['job'] = preg_replace("/'/", "\\'", $c['job']); $c['job'] = preg_replace("/\"/", "\\\"", $c['job']); $query = "INSERT INTO `crews` (person_id, movie_id, name, job, profile_path) VALUES (" . $c["id"] . ",{$tmdb_id},'" . $c["name"] . "','" . $c["job"] . "','" . $c["profile_path"] . "')"; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); logg("new crew person added {$c['name']}"); } } // Add/update cast $query = "DELETE from casts where movie_id = " . $tmdb_id . ""; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); if (count($crew["cast"]) > 0) { foreach ($crew["cast"] as $c) { $c['name'] = preg_replace("/'/", "\\'", $c['name']); $c['character'] = preg_replace("/'/", "\\'", $c['character']); $c['name'] = preg_replace("/\"/", "\\\"", $c['name']); $c['character'] = preg_replace("/\"/", "\\\"", $c['character']); $query = "INSERT INTO `casts` (person_id, movie_id, name, character_name, ordered, cast_id, profile_path) VALUES (" . $c["id"] . ",{$tmdb_id},'" . $c["name"] . "','" . $c["character"] . "'," . $c["order"] . "," . $c["cast_id"] . ",'" . $c["profile_path"] . "')"; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); logg("new cast person added {$c['name']}"); } } }
protected function _error($line) { logg($line, 'error'); }