Ejemplo n.º 1
0
 /**
  * @see parent::getValue()
  */
 function getValue($object, $smarty = null, $params = array())
 {
     if (!isset($this->byteUnit)) {
         return parent::getValue($object, $smarty, $params);
     }
     $propValue = $object->{$this->fieldName};
     $ratio = 1;
     switch ($this->byteUnit) {
         case "GB":
             $ratio *= 1024;
         case "MB":
             $ratio *= 1024;
         case "KB":
             $ratio *= 1024;
         case "B":
         default:
     }
     return CMbString::toDecaBinary($propValue * $ratio);
 }
Ejemplo n.º 2
0
 /**
  * @see parent::updateFormFields()
  */
 function updateFormFields()
 {
     parent::updateFormFields();
     $this->_file_size = CMbString::toDecaBinary($this->doc_size);
     $this->getSendProblem();
     $this->loadRefCategory();
 }
 /**
  * Embed all the external resources of the current output buffer inside a single file and outputs it.
  *
  * @param string $path Path to save the files to
  * 
  * @return void|string
  */
 private static function allInOne($path = null, $options = array())
 {
     if ($path) {
         self::$_path = rtrim($path, "/\\") . "/";
     }
     CApp::setMemoryLimit("256M");
     self::$_fp_out = CMbPath::getTempFile();
     $re_img = "/<img([^>]*)src\\s*=\\s*[\"']([^\"']+)[\"']([^>]*)(>|\$)/i";
     $re_link = "/<link[^>]*rel=\"stylesheet\"[^>]*href\\s*=\\s*[\"']([^\"']+)[\"'][^>]*>/i";
     $re_script = "/<script[^>]*src\\s*=\\s*[\"']([^\"']+)[\"'][^>]*>\\s*<\\/script>/i";
     $re_a = "/<a([^>]*)href\\s*=\\s*[\"']embed:([^\"']+)[\"']([^>]*)>/i";
     $ignore_scripts = !empty($options["ignore_scripts"]);
     // End Output Buffering
     ob_end_clean();
     ob_start();
     rewind(self::$_fp_in);
     while (!feof(self::$_fp_in)) {
         $line = fgets(self::$_fp_in);
         $line = preg_replace_callback($re_img, array('self', 'replaceImgSrc'), $line);
         $line = preg_replace_callback($re_link, array('self', 'replaceStylesheet'), $line);
         if (!$ignore_scripts) {
             $line = preg_replace_callback($re_script, array('self', 'replaceScriptSrc'), $line);
         }
         if (self::$_path) {
             $line = preg_replace_callback($re_a, array('self', 'replaceAEmbed'), $line);
         }
         fwrite(self::$_fp_out, $line);
     }
     ob_end_clean();
     $length = 0;
     rewind(self::$_fp_out);
     $full_str = "";
     while (!feof(self::$_fp_out)) {
         $line = fgets(self::$_fp_out);
         $length += strlen($line);
         $line = str_replace("[[AIO-length]]", CMbString::toDecaBinary($length), $line);
         if (strpos($line, "[[AIO-memory]]") !== false) {
             $line = str_replace("[[AIO-memory]]", self::getOutputMemory(true), $line);
         }
         if ($path) {
             $full_str .= $line;
         } else {
             echo $line;
         }
     }
     return $full_str;
 }
 function getListFilesDetails($current_directory)
 {
     $contain = scandir($current_directory);
     $fileInfo = array();
     foreach ($contain as $_contain) {
         $full_path = $current_directory . $_contain;
         if (!is_dir($full_path) && @filetype($full_path) && !is_link($full_path)) {
             $fileInfo[] = array("type" => "f", "user" => fileowner($full_path), "size" => CMbString::toDecaBinary(filesize($full_path)), "date" => strftime(CMbDT::ISO_DATETIME, filemtime($full_path)), "name" => $_contain, "relativeDate" => CMbDT::daysRelative(fileatime($full_path), CMbDT::date()));
         }
     }
     return $fileInfo;
 }
Ejemplo n.º 5
0
 private function _getListFilesDetails($folder = ".")
 {
     if (!$this->connexion) {
         throw new CMbException("CSourceFTP-connexion-failed", $this->hostname);
     }
     $files = ftp_rawlist($this->connexion, $folder);
     if ($files === false) {
         throw new CMbException("CSourceFTP-getlistfiles-failed", $this->hostname);
     }
     $system = $this->type_system;
     $limit = 9;
     if ($system && strpos($system, "Windows") !== false) {
         $limit = 4;
     }
     $fileInfo = array();
     foreach ($files as $_file) {
         $pregInfo = preg_split("/[\\s]+/", $_file, $limit);
         if ($system && strpos($system, "Windows") !== false) {
             $format = "m-d-y h:iA";
             $datetime = "{$pregInfo['0']} {$pregInfo['1']}";
             $type = strpos($pregInfo[2], "DIR") ? "d" : "f";
             $user = "";
             $size = $pregInfo[2];
             $name = $pregInfo[3];
         } else {
             $year = $pregInfo[7];
             if (strpos($year, ":")) {
                 $year = explode("-", CMbDT::date());
                 $year = $year[0] . " {$pregInfo['7']}";
             }
             $format = "M-d-Y H:i";
             $datetime = "{$pregInfo['5']}-{$pregInfo['6']}-{$year}";
             $type = $pregInfo[0];
             $user = "******";
             $size = $pregInfo[4];
             $name = $pregInfo[8];
         }
         if (strpos($type, "d") !== false || $pregInfo[0] == "total") {
             continue;
         }
         $datetime = DateTime::createFromFormat($format, $datetime);
         $date = "";
         if ($datetime) {
             $date = $datetime->format("d-m-Y H:m");
         }
         $fileInfo[] = array("type" => $type, "user" => $user, "size" => CMbString::toDecaBinary($size), "date" => $date, "name" => $name, "relativeDate" => CMbDT::daysRelative($date, CMbDT::date()));
     }
     return $fileInfo;
 }
Ejemplo n.º 6
0
 /**
  * Converts a value to decabinary format
  * Example: {$value|decabinary}
  *
  * @param float $value The value to format
  *
  * @return string
  */
 function decabinary($value)
 {
     $decabinary = CMbString::toDecaBinary($value);
     return "<span title=\"{$value}\">{$decabinary}</span>";
 }
Ejemplo n.º 7
0
if (file_exists(CMbDebug::DEBUG_PATH)) {
    $debug_size = filesize(CMbDebug::DEBUG_PATH);
    $debug_size_limit = CMbDebug::DEBUG_SIZE_LIMIT;
    $offset = -1;
    if ($debug_size > $debug_size_limit) {
        $offset = $debug_size - $debug_size_limit;
    }
    $debug_content = file_get_contents(CMbDebug::DEBUG_PATH, false, null, $offset);
}
// Récupération de la liste des utilisateurs disponibles
$user = new CUser();
$user->template = "0";
$order = "user_last_name, user_first_name";
$list_users = $user->loadMatchingList($order);
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("log", $log_content);
$smarty->assign("log_size", CMbString::toDecaBinary($log_size));
$smarty->assign("debug", $debug_content);
$smarty->assign("debug_size", CMbString::toDecaBinary($debug_size));
$smarty->assign("error_log", $error_log);
$smarty->assign("error_type", $error_type);
$smarty->assign("server_ip", $server_ip);
$smarty->assign("order_by", $order_by);
$smarty->assign("group_similar", $group_similar);
$smarty->assign("error_types", CError::getErrorTypesByCategory());
$smarty->assign("user_id", $user_id);
$smarty->assign("list_users", $list_users);
$smarty->assign("human", $human);
$smarty->assign("robot", $robot);
$smarty->display('view_logs.tpl');
Ejemplo n.º 8
0
if ($hash == 'clean') {
    unlink($filename);
    build_error_log();
}
if ($hash) {
    $doc = new DOMDocument();
    @$doc->loadHTMLFile($filename);
    $xpath = new DOMXPath($doc);
    $elements = $xpath->query("//div[@title='{$hash}']");
    foreach ($elements as $element) {
        $element->parentNode->removeChild($element);
    }
    $content = $doc->saveHTML();
    file_put_contents(CError::LOG_PATH, $content);
}
$log_content = null;
$log_size = 0;
if (file_exists($filename)) {
    $log_size = filesize($filename);
    $log_size_limit = CError::LOG_SIZE_LIMIT;
    $offset = -1;
    if ($log_size > $log_size_limit) {
        $offset = $log_size - $log_size_limit;
    }
    $log_content = file_get_contents($filename, false, null, $offset);
}
$log_size_deca = CMbString::toDecaBinary($log_size);
if (CAppUI::conf("error_logs_in_db")) {
    CAppUI::js("Control.Tabs.setTabCount('{$control_tabs_name}', '{$log_size_deca}')");
}
echo $log_content;
Ejemplo n.º 9
0
 /**
  * Method to load cartos infos
  *
  * @param CSearch $c_search the csearch
  * @param array   $aggreg   the aggreg
  *
  * @return array
  */
 function loadCartoInfos($c_search, $aggreg)
 {
     $result = array();
     $search = new CSearchIndexing();
     // récupération de l'index, cluster
     $index = $c_search->loadIndex();
     $cluster = $c_search->_client->getCluster();
     // statistiques du cluster
     $path = '_cluster/stats';
     $response = $c_search->_client->request($path, Request::GET);
     $data = $response->getData();
     $result['stats']['cluster']["nbIndex"] = $data["indices"]["count"];
     $result['stats']['cluster']["nbDocsTotal"] = $data["indices"]["docs"]["count"];
     // récupération du mapping et du name_index
     $result['mapping'] = $index->getMapping();
     $result['mappingjson'] = json_encode($result['mapping']);
     $result['name_index'] = $index->getName();
     // récupération de la taille totale des indexes et de statistiques
     $stats = $index->getStats()->getData();
     $result['size'] = CMbString::toDecaBinary($stats["_all"]["primaries"]["store"]["size_in_bytes"]);
     // récupération de l'état des shards
     $result['stats']['shards']["total"] = $stats["_shards"]['total'];
     $result['stats']['shards']["successful"] = $stats["_shards"]['successful'];
     $result['stats']['shards']["failed"] = $stats["_shards"]['failed'];
     // récupération de statistiques
     $name = CAppUI::conf("search index_name");
     $result['stats']["search"]['total'] = $stats["indices"][$name]["primaries"]["search"]["query_total"];
     $result['stats']["search"]['average_time'] = $stats["indices"][$name]["primaries"]["search"]["query_time_in_millis"];
     // récupération du nombre de docs "indexés",  "à indexer" et récupération des types d'éléments restant à indexer.
     $result['nbDocs_indexed'] = $index->count();
     $result['nbdocs_to_index'] = $search->countList();
     $order = "`object_class`, COUNT(`object_class`) AS `total`";
     $result['nbdocs_to_index_by_type'] = $search->countMultipleList(null, null, "object_class", null, $order);
     // récupération du statut de la connexion et du cluster
     $result['status'] = $cluster->getHealth()->getStatus();
     $result['connexion'] = $c_search->_client->hasConnection();
     // récupération des données de l'agregation
     $aggreg = $aggreg->getAggregation("ref_type");
     $result["aggregation"] = $aggreg["buckets"];
     return $result;
 }