$chrono = new Chronometer(); $chrono->start(); $segment = CValue::get("segment", 1000); $step = CValue::get("step", 1); $from = $step > 1 ? 100 + $segment * ($step - 2) : 0; $to = $step > 1 ? 100 + ($step - 1) * $segment : 100; $padded = str_pad($step, "3", "0", STR_PAD_LEFT); $htmpath = "tmp/ordre/medecin{$padded}.htm"; $xmlpath = "tmp/ordre/medecin{$padded}.xml"; $csvpath = "tmp/ordre/medecin{$padded}.csv"; CMbPath::forceDir(dirname($htmpath)); $mode = CValue::get("mode"); // Step 1: Emulates an HTTP request if ($mode == "get") { $departement = CValue::get("departement"); $cookiepath = CAppUI::getTmpPath("cookie.txt"); $page = $step - 1; $url_ch1 = "http://www.conseil-national.medecin.fr/annuaire"; $url_ch2 = "http://www.conseil-national.medecin.fr/annuaire/resultats?page={$page}"; $post = array("sexe" => 3, "departement" => $departement, "op" => "Recherche", "form_build_id" => "form-c2b45a67c53fdd389338ffee58d2c1c2", "form_id" => "cn_search_med_advanced_form"); $ch = curl_init(); $ch2 = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiepath); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiepath); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_URL, $url_ch1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post)); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Connection:: keep-alive"));
* @category Forms * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ * @link http://www.mediboard.org */ CCanDo::checkEdit(); $tmp_filename = $_FILES["import"]["tmp_name"]; $dom = new DOMDocument(); $dom->load($tmp_filename); $xpath = new DOMXPath($dom); if ($xpath->query("/mediboard-export")->length == 0) { CAppUI::js("window.parent.ExClass.uploadError()"); CApp::rip(); } $temp = CAppUI::getTmpPath("ex_class_import"); $uid = preg_replace('/[^\\d]/', '', uniqid("", true)); $filename = "{$temp}/{$uid}"; CMbPath::forceDir($temp); move_uploaded_file($tmp_filename, $filename); // Cleanup old files (more than 4 hours old) $other_files = glob("{$temp}/*"); $now = time(); foreach ($other_files as $_other_file) { if (filemtime($_other_file) < $now - 3600 * 4) { unlink($_other_file); } } CAppUI::js("window.parent.ExClass.uploadSaveUID('{$uid}')"); CApp::rip();
/** * Put logs in buffer and store them. * Use direct storage if buffer_life time config is 0 * * @param self[] $logs Log collection to put in buffer * * @return void */ static function bufferize($logs) { $class = get_called_class(); // No buffer use standard unique fast store $buffer_lifetime = CAppUI::conf("access_log_buffer_lifetime"); if (!$buffer_lifetime) { if ($msg = static::fastMultiStore($logs)) { mbLog("Could not store logs: {$msg}", $class); trigger_error($msg, E_USER_WARNING); } return; } // Buffer logs into file $buffer = CAppUI::getTmpPath("{$class}.buffer"); foreach ($logs as $_log) { file_put_contents($buffer, serialize($_log) . PHP_EOL, FILE_APPEND); } // Unless lifetime is reached by random, don't unbuffer logs if (rand(1, $buffer_lifetime) !== 1) { return; } // Move to temporary buffer to prevent concurrent unbuffering $tmpbuffer = tempnam(dirname($buffer), basename($buffer) . "."); if (!rename($buffer, $tmpbuffer)) { // Keep the log for a while, should not be frequent with buffer lifetime 100+ mbLog("Probable concurrent logs unbuffering", $class); return; } // Read lines from temporary buffer $lines = file($tmpbuffer); $buffered_logs = array(); foreach ($lines as $_line) { $buffered_logs[] = unserialize($_line); } $assembled_logs = static::assembleLogs($buffered_logs); if ($msg = static::fastMultiStore($assembled_logs)) { trigger_error($msg, E_USER_WARNING); return; } // Remove the useless temporary buffer unlink($tmpbuffer); $buffered_count = count($buffered_logs); $assembled_count = count($assembled_logs); mbLog("'{$buffered_count}' logs buffered, '{$assembled_count}' logs assembled", $class); }
/* $Id: ajax_old_dhe.php 8419 2010-03-29 14:51:55Z MyttO $ */ /** * @package Mediboard * @subpackage ecap * @version $Revision: 8419 $ * @author SARL OpenXtrem * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html */ CCanDo::checkAdmin(); $max_rows = CView::request("max_rows", "num default|1000"); $max_lines = CView::request("max_lines", "num default|1000000"); $phase = CView::request("phase", "enum list|connection|query|multiple_load_execute"); $min_duration = CView::request("min_duration", "num default|1"); CView::checkin(); $phase = strtr($phase, "_", " "); $path = CAppUI::getTmpPath("mb-log.html"); if (false == ($resource = fopen($path, "r"))) { CAppUI::stepMessage("no log available"); } $lines_count = 0; $entries = array(); while (($line = fgets($resource)) !== false) { if ($max_lines && $lines_count >= $max_lines) { break; } $lines_count++; $matches = array(); if (preg_match("/\\[(.*)\\] CRecordSante400: slow '(.*)' in '(.*)' seconds/", $line, $matches)) { $entry = array("datetime" => $matches[1], "phase" => $matches[2], "duration" => $matches[3]); // Filter on actions if ($phase && $entry["phase"] != $phase) {
<?php /** * $Id$ * * @package Mediboard * @subpackage System * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ CCanDo::checkAdmin(); // Size in KB $size = CValue::get("size", 100); $size = min($size, 10 * 1024); // Cap it to 10MB MAX $big_file = CAppUI::getTmpPath("bandwidth_test/big.bin"); CMbPath::forceDir(dirname($big_file)); file_put_contents($big_file, str_pad("", 1024 * $size, "a")); // Must be a "normal" char so that it's not url encoded $empty_file = CAppUI::getTmpPath("bandwidth_test/empty.bin"); file_put_contents($empty_file, "");
<?php /** * $Id$ * * @category Etablissement * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ * @link http://www.mediboard.org */ CCanDo::checkAdmin(); $uid = CValue::post("file_uid"); $from_db = CValue::post("fromdb"); $options = CValue::post("options"); $options = stripslashes_deep($options); $uid = preg_replace('/[^\\d]/', '', $uid); $temp = CAppUI::getTmpPath("group_import"); $file = "{$temp}/{$uid}"; $import = new CGroupsImport($file); try { $import->import($from_db, $options); } catch (Exception $e) { CAppUI::stepAjax($e->getMessage(), UI_MSG_WARNING); }
/** * Output the content to the standard output * * @return void */ static function output($options = array()) { if (self::$_aio) { $path = CAppUI::getTmpPath("embed-" . md5(uniqid("", true))); if (self::$_aio === "savefile") { $str = self::allInOne($path); file_put_contents("{$path}/index.html", $str); $zip_path = "{$path}.zip"; CMbPath::zip($path, $zip_path); header("Content-Type: application/zip"); header("Content-Disposition: attachment; filename=\"" . basename($zip_path) . "\";"); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . filesize($zip_path)); readfile($zip_path); unlink($zip_path); CMbPath::remove($path); CApp::rip(); } else { self::allInOne(null, $options); } } else { // Flush zero-ifies ob_get_length self::$flushed_output_length += ob_get_length(); ob_end_flush(); } }
<?php /** * $Id$ * * @category Search * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @link http://www.mediboard.org */ CCanDo::checkAdmin(); $lock_file = CAppUI::getTmpPath("search_indexing"); CMbPath::forceDir($lock_file); $lock_file .= "/search_indexing.lock"; $lock_timeout = 100; if (file_exists($lock_file)) { if (filemtime($lock_file) + $lock_timeout > time()) { echo "Script locked search_indexing\n"; return; } else { echo "Lock file present, but too old, we continue search_indexing\n"; } } /** * remove the lock * * @param string $lock_file The file which lock traitement * * @return void */
* @author SARL OpenXtrem <*****@*****.**> * @license OXOL, see http://www.mediboard.org/public/OXOL * @link http://www.mediboard.org */ CCanDo::checkAdmin(); $path = CAppUI::getTmpPath("pmsi"); $path .= "/cim10/LIBCIM10.TXT"; $result = array(); if (file_exists($path)) { if (!($fp = fopen("{$path}", "r+"))) { CAppUI::displayAjaxMsg("Echec de l'ouverture du fichier LIBCIM10.txt", UI_MSG_WARNING); } else { while (!feof($fp)) { // On récupère une ligne $ligne = fgets($fp); if ($ligne) { $ligne = utf8_encode($ligne); $_ligne = explode('|', $ligne); $_ligne = array_map("trim", $_ligne); $result[] = implode(";", $_ligne) . "\n"; } } fclose($fp); // On ferme le fichier } $path = CAppUI::getTmpPath("pmsi"); $fic = $path . "/cim10/MCCIM10.csv"; $fichier = fopen($fic, "w+"); fwrite($fichier, implode("", $result)); fclose($fichier); CApp::rip(); }
* * @param string $lock_file The file which lock traitement * * @return void */ function rmLock($lock_file) { @unlink($lock_file); } register_shutdown_function("rmLock", $lock_file); // LOCK // touch($lock_file); set_time_limit(600); set_min_memory_limit("1024M"); //TRAITEMENT $name_repository = CValue::get("name_repository"); $dir_repository = CValue::get("dir_repository"); $name_snapshot = CValue::get("name_snapshot"); try { $snapshot = new CSearchSnapshot(); //create a client $snapshot->createClient(); $snapshot->loadIndex(); $snapshot->createSnapshot(); //$snapshot->deleteIndexAndRestore($name_repository, $name_snapshot, true, true); $snapshot->snapshot($name_repository, CAppUI::getTmpPath($dir_repository), $name_snapshot); CAppUI::displayAjaxMsg("La création du snapshot de l'index s'est bien déroulée", UI_MSG_OK); } catch (Exception $e) { mbLog($e->getMessage()); CAppUI::displayAjaxMsg("La création du snapshot de l'index a recontré un problème", UI_MSG_WARNING); }
<?php /** * $Id$ * * @package Mediboard * @subpackage System * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ CCanDo::checkEdit(); $file = $_FILES["fileupload"]; $token = str_replace(".", "", uniqid("imp_", true)); $new_path = CAppUI::getTmpPath("object_import/{$token}"); CMbPath::forceDir(dirname($new_path)); move_uploaded_file($file["tmp_name"], $new_path); $dom = new CMbXMLObjectExport(); $dom->load($new_path); $smarty = new CSmartyDP(); $smarty->assign("token", $token); $smarty->assign("dom", $dom); $smarty->display("inc_object_import_configure.tpl");