Exemplo n.º 1
0
function ajax_http_send_response($ack = '', $type = 'text/html')
{
    global $charset, $opac_parse_html;
    if (is_array($ack) || is_object($ack)) {
        header("Content-Type: application/json; charset={$charset}");
        print json_encode($ack);
    } else {
        header("Content-Type: {$type}; charset={$charset}");
        if ($opac_parse_html && $type == 'text/html') {
            //Si on a de l'HTML et qu'on a activé le parse HTML alors il faut le faire...
            $ack = parseHTML($ack);
        }
        print $ack;
    }
}
Exemplo n.º 2
0
 private function sqlParameter($isADD, &$data, $name, &$field, &$EnumPrunecache, $isSerialized = false, $kA = '', $wS = '')
 {
     $output = false;
     $encapsulation = $isSerialized ? '' : '"';
     switch ($field[CONS_XML_TIPO]) {
         case CONS_TIPO_INT:
             if (isset($data[$name]) && $data[$name] !== "" && is_numeric($data[$name])) {
                 $output = $data[$name];
             } else {
                 if ($isADD && isset($field[CONS_XML_DEFAULT])) {
                     $output = $field[CONS_XML_DEFAULT];
                 }
             }
             break;
         case CONS_TIPO_LINK:
             if ($field[CONS_XML_LINKTYPE] == CONS_TIPO_INT || $field[CONS_XML_LINKTYPE] == CONS_TIPO_FLOAT) {
                 $encapsulation = '';
             }
             if (isset($data[$name]) && ($data[$name] !== '' && $data[$name] !== 0 || !isset($field[CONS_XML_MANDATORY]))) {
                 # non-mandatory links accept 0 values, otherwise 0 is not acceptable
                 if ((!$isADD && isset($field[CONS_XML_IGNORENEDIT]) || $isADD) && ($data[$name] === 0 || $data[$name] === '')) {
                     break;
                 } else {
                     if (($field[CONS_XML_LINKTYPE] == CONS_TIPO_INT || $field[CONS_XML_LINKTYPE] == CONS_TIPO_FLOAT) && ($data[$name] === '' || !is_numeric($data[$name]))) {
                         $data[$name] = 0;
                     } else {
                         if ($field[CONS_XML_LINKTYPE] == CONS_TIPO_VC && $data[$name] != '') {
                             if ($field[CONS_XML_SPECIAL] == "ucase") {
                                 $data[$name] = strtoupper($data[$name]);
                             }
                             if ($field[CONS_XML_SPECIAL] == "lcase") {
                                 $data[$name] = strtolower($data[$name]);
                             }
                         }
                     }
                 }
                 # if this is a parent, check if this won't create a cyclic parenting
                 if ($data[$name] !== 0 && $data[$name] !== '' && $field[CONS_XML_MODULE] == $this->name && $this->options[CONS_MODULE_PARENT] == $name) {
                     if (!$isADD && $data[$name] == $data[$this->keys[0]]) {
                         $data[$name] = 0;
                         $this->parent->errorControl->raise(128, $name, $this->name, "Parent=Self");
                         if (isset($field[CONS_XML_MANDATORY])) {
                             return false;
                         }
                     } else {
                         $antiCicle = $isADD ? array() : array($data[$this->keys[0]]);
                         $idP = isset($data[$name]) ? $data[$name] : 0;
                         if ($idP == null) {
                             $idP = 0;
                         }
                         while ($idP !== 0) {
                             $idP = $this->parent->dbo->fetch("SELECT {$name} FROM " . $this->dbname . " WHERE " . $this->keys[0] . "={$idP}");
                             if ($idP == NULL) {
                                 $idP = 0;
                             }
                             if (in_array($idP, $antiCicle)) {
                                 break;
                             }
                             // cicle!
                             $antiCicle[] = $idP;
                         }
                         unset($antiCicle);
                         if ($idP !== 0) {
                             # did not reach root
                             $this->parent->errorControl->raise(128, $name, $this->name, "Initial parent was = " . $data[$name]);
                             $data[$name] = 0;
                             if (isset($field[CONS_XML_MANDATORY])) {
                                 return false;
                             }
                         }
                     }
                 }
                 $output = $encapsulation . $data[$name] . $encapsulation;
             } else {
                 if ($isADD && isset($field[CONS_XML_DEFAULT])) {
                     if ($field[CONS_XML_DEFAULT] == "%UID%" && defined("CONS_AUTH_USERMODULE") && $field[CONS_XML_MODULE] == CONS_AUTH_USERMODULE && $_SESSION[CONS_SESSION_ACCESS_LEVEL] > 0 && isset($_SESSION[CONS_SESSION_ACCESS_USER]['id'])) {
                         $output = $encapsulation . $_SESSION[CONS_SESSION_ACCESS_USER]['id'] . $encapsulation;
                     } else {
                         if ($field[CONS_XML_DEFAULT] != "%UID%") {
                             $output = $encapsulation . $field[CONS_XML_DEFAULT] . $encapsulation;
                         }
                     }
                 }
             }
             break;
         case CONS_TIPO_FLOAT:
             if (isset($data[$name]) && $data[$name] !== "") {
                 $data[$name] = fv($data[$name]);
                 if (is_numeric($data[$name])) {
                     $output = str_replace(",", ".", $data[$name]);
                 } else {
                     if ($isADD && isset($field[CONS_XML_DEFAULT])) {
                         $output = $field[CONS_XML_DEFAULT];
                     }
                 }
             } else {
                 if ($isADD && isset($field[CONS_XML_DEFAULT])) {
                     $output = $field[CONS_XML_DEFAULT];
                 }
             }
             break;
         case CONS_TIPO_VC:
             if (isset($data[$name])) {
                 if (!isset($field[CONS_XML_SPECIAL]) || $field[CONS_XML_SPECIAL] != "urla") {
                     if (!isset($field[CONS_XML_CUSTOM])) {
                         $data[$name] = cleanString($data[$name], isset($field[CONS_XML_HTML]), $_SESSION[CONS_SESSION_ACCESS_LEVEL] == 100, $this->parent->dbo);
                     } else {
                         if (!$isSerialized) {
                             $data[$name] = addslashes_EX($data[$name], isset($field[CONS_XML_HTML]), $this->parent->dbo);
                         }
                     }
                 }
                 if (isset($field[CONS_XML_SPECIAL])) {
                     if ($field[CONS_XML_SPECIAL] == "urla") {
                         if (!isset($data[$name]) || $data[$name] == '') {
                             $source = isset($field[CONS_XML_SOURCE]) ? $field[CONS_XML_SOURCE] : "{" . $this->title . "}";
                             $tp = new CKTemplate($this->parent->template);
                             $tp->tbreak($source);
                             $data[$name] = $tp->techo($data);
                             unset($tp);
                         }
                         $data[$name] = str_replace(">", "", str_replace("<", "", str_replace(""", "", str_replace("'", "", $data[$name]))));
                         $data[$name] = removeSimbols($data[$name], true, false, CONS_FLATTENURL);
                     }
                     if ($field[CONS_XML_SPECIAL] == "login" && $data[$name] != "") {
                         if (!preg_match('/^([A-Za-z0-9_\\-\\.@]){4,20}$/', $data[$name])) {
                             $data[$name] = "";
                             $this->parent->errorControl->raise(129, $name, $this->name);
                             break;
                         }
                     }
                     if ($field[CONS_XML_SPECIAL] == "mail" && $data[$name] != "") {
                         if (!isMail($data[$name])) {
                             $data[$name] = "";
                             $this->parent->errorControl->raise(130, $name, $this->name);
                             break;
                         }
                     }
                     if ($field[CONS_XML_SPECIAL] == "ucase" && $data[$name] != "") {
                         $data[$name] = strtoupper($data[$name]);
                         $data[$name] = addslashes_EX($data[$name], isset($field[CONS_XML_HTML]), $this->parent->dbo);
                     }
                     if ($field[CONS_XML_SPECIAL] == "lcase" && $data[$name] != "") {
                         $data[$name] = strtolower($data[$name]);
                         $data[$name] = addslashes_EX($data[$name], isset($field[CONS_XML_HTML]), $this->parent->dbo);
                     }
                     if ($field[CONS_XML_SPECIAL] == "path" && $data[$name] != "") {
                         if (!preg_match('/^([A-Za-z0-9_\\/\\-]*)$/', $data[$name])) {
                             $data[$name] = "";
                             $this->parent->errorControl->raise(131, $name, $this->name);
                             break;
                         }
                     }
                     if ($field[CONS_XML_SPECIAL] == "onlinevideo" && $data[$name] != "") {
                         if (!preg_match('/^([A-Za-z0-9_\\-]){8,20}$/', $data[$name])) {
                             $data[$name] = "";
                             $this->parent->errorControl->raise(132, $name, $this->name);
                             break;
                         }
                     }
                     if ($field[CONS_XML_SPECIAL] == "time" && $data[$name] != "") {
                         if (!preg_match('/^([0-9]){1,2}(:)([0-9]){1,2}$/', $data[$name])) {
                             $data[$name] = "";
                             $this->parent->errorControl->raise(133, $name, $this->name);
                             break;
                         } else {
                             $data[$name] = explode(":", $data[$name]);
                             $data[$name][0] = (strlen($data[$name][0]) == 1 ? "0" : "") . $data[$name][0];
                             $data[$name][1] = (strlen($data[$name][1]) == 1 ? "0" : "") . $data[$name][1];
                             $data[$name] = $data[$name][0] . ":" . $data[$name][1];
                         }
                     }
                 }
                 if (!$isADD && isset($field[CONS_XML_IGNORENEDIT]) && $data[$name] == "") {
                     break;
                 } else {
                     if ($isADD && (!isset($data[$name]) || $data[$name] == '') && isset($field[CONS_XML_DEFAULT])) {
                         $data[$name] = $field[CONS_XML_DEFAULT];
                     }
                 }
                 $output = $encapsulation . $data[$name] . $encapsulation;
             }
             break;
         case CONS_TIPO_TEXT:
             if (isset($data[$name])) {
                 # WYSIWYG garbage ...
                 if (isset($field[CONS_XML_HTML]) && !isset($field[CONS_XML_CUSTOM])) {
                     $data[$name] = str_replace(" ", " ", trim($data[$name]));
                     if (isset($field[CONS_XML_SIMPLEEDITFORCE]) && $data[$name] != '') {
                         if (!defined('C_XHTML_AUTOTAB')) {
                             include CONS_PATH_INCLUDE . "xmlHandler.php";
                         }
                         $data[$name] = parseHTML($data[$name], true);
                         if ($data[$name] === false) {
                             $this->parent->errorControl->raise(190, $name, $this->name);
                             $data[$name] = '';
                             break;
                         }
                     }
                     if ($this->invalidHTML($data[$name])) {
                         # external editors garbage that can break HTML
                         $this->parent->errorControl->raise(135, $name, $this->name);
                     }
                 }
                 if (!isset($field[CONS_XML_CUSTOM])) {
                     $data[$name] = cleanString($data[$name], isset($field[CONS_XML_HTML]), $_SESSION[CONS_SESSION_ACCESS_LEVEL] == 100, $this->parent->dbo);
                 } else {
                     if (!$isSerialized) {
                         $data[$name] = addslashes_EX($data[$name], true, $this->parent->dbo);
                     }
                 }
                 if (!$isADD && isset($field[CONS_XML_IGNORENEDIT]) && $data[$name] == "") {
                     break;
                 }
                 $output = $encapsulation . $data[$name] . $encapsulation;
             } else {
                 if ($isADD && isset($field[CONS_XML_DEFAULT])) {
                     $output = $encapsulation . $field[CONS_XML_DEFAULT] . $encapsulation;
                 }
             }
             break;
         case CONS_TIPO_DATETIME:
         case CONS_TIPO_DATE:
             if (!isset($data[$name]) || $data[$name] == '') {
                 if (!$isADD && isset($field[CONS_XML_UPDATESTAMP])) {
                     $output = "NOW()";
                     $data[$name] = date("Y-m-d") . ($field[CONS_XML_TIPO] == CONS_TIPO_DATETIME ? " " . date("H:i:s") : "");
                     // might be used by friendly url or such
                     break;
                 } else {
                     if ($isADD && (isset($field[CONS_XML_TIMESTAMP]) || isset($field[CONS_XML_UPDATESTAMP]))) {
                         $output = "NOW()";
                         $data[$name] = date("Y-m-d") . ($field[CONS_XML_TIPO] == CONS_TIPO_DATETIME ? " " . date("H:i:s") : "");
                         // might be used by friendly url or such
                         break;
                     }
                 }
             }
             if (!isset($data[$name]) && isset($data[$name . "_day"])) {
                 # date came into separated fields, merge them
                 $theDate = $this->parent->intlControl->mergeDate($data, $name . "_");
                 if (!$theDate == false || ($theDate == "0000-00-00" || $theDate == "0000-00-00 00:00:00") && isset($field[CONS_XML_IGNORENEDIT])) {
                     break;
                 }
                 # empty date can be ignored, or corrupt date
                 $output = $encapsulation . $theDate . $encapsulation;
             } else {
                 # came in mySQL format or i18n fromat
                 if (isset($data[$name]) && $data[$name] != "") {
                     $data[$name] = trim($data[$name]);
                     $theDate = $data[$name];
                     $theDate = $this->parent->intlControl->dateToSql($theDate, $field[CONS_XML_TIPO] == CONS_TIPO_DATETIME);
                     // handles any format of human or sql date
                     if ($theDate === false) {
                         if (substr($data[$name], 0, 5) == "NOW()") {
                             $output = $data[$name];
                             $data[$name] = date("Y-m-d") . ($field[CONS_XML_TIPO] == CONS_TIPO_DATETIME ? " " . date("H:i:s") : "");
                             // might be used by friendly url or such
                         } else {
                             $this->parent->errorControl->raise(134, $name, $this->name);
                         }
                     } else {
                         $output = $encapsulation . $theDate . $encapsulation;
                         $data[$name] = $theDate;
                         // other fields might need it
                     }
                 } else {
                     if (isset($data[$name])) {
                         // blank
                         if (!$isADD && isset($field[CONS_XML_IGNORENEDIT])) {
                             break;
                         }
                         $output = isset($field[CONS_XML_MANDATORY]) && $field[CONS_XML_MANDATORY] ? $encapsulation . "0000-00-00" . ($field[CONS_XML_TIPO] == CONS_TIPO_DATETIME ? " 00:00:00" : "") . $encapsulation : 'NULL';
                     }
                 }
             }
             break;
         case CONS_TIPO_ENUM:
             if (isset($data[$name])) {
                 if ($data[$name] == "") {
                     # enum does not accept empty values, this means it's a NON-MANDATORY enum comming empty = NULL
                     $output = "NULL";
                 } else {
                     $data[$name] = str_replace("\"", "", str_replace("'", "", $data[$name]));
                     $output = $encapsulation . $data[$name] . $encapsulation;
                     if (isset($field[CONS_XML_AUTOPRUNE])) {
                         // possible prune
                         //$EnumPrunecache
                         preg_match("@ENUM \\(([^)]*)\\).*@", $field[CONS_XML_SQL], $regs);
                         $enums = explode(",", $regs[1]);
                         $pruneRecipient = "";
                         for ($ec = 0; $ec < count($enums); $ec++) {
                             if (isset($field[CONS_XML_AUTOPRUNE][$ec]) && $field[CONS_XML_AUTOPRUNE][$ec] == '*') {
                                 $pruneRecipient = $enums[$ec];
                             }
                         }
                         for ($ec = 0; $ec < count($enums); $ec++) {
                             if ("'" . $data[$name] . "'" == $enums[$ec]) {
                                 if (isset($field[CONS_XML_AUTOPRUNE][$ec]) && $field[CONS_XML_AUTOPRUNE][$ec] != '0' && $field[CONS_XML_AUTOPRUNE][$ec] != '*') {
                                     $EnumPrunecache[] = array($name, $field[CONS_XML_AUTOPRUNE][$ec], $pruneRecipient);
                                 }
                                 break;
                                 // for
                             }
                         }
                     }
                 }
             } else {
                 if ($isADD && isset($field[CONS_XML_DEFAULT])) {
                     $output = $encapsulation . $field[CONS_XML_DEFAULT] . $encapsulation;
                 }
             }
             break;
         case CONS_TIPO_OPTIONS:
             # must come as a string of 0 and 1
             if (isset($data[$name]) && strlen($data[$name]) >= count($field[CONS_XML_OPTIONS])) {
                 # test if they are all 0 and 1!
                 $ok = true;
                 for ($c = 0; $c < strlen($data[$name]); $c++) {
                     if ($data[$name][$c] != "0" && $data[$name][$c] != "1") {
                         $ok = false;
                         break;
                     }
                 }
                 if ($ok) {
                     $output = $encapsulation . $data[$name] . ($isADD ? '0000' : '') . $encapsulation;
                 }
             }
             break;
         case CONS_TIPO_UPLOAD:
             if (!$isADD) {
                 # upload on add happens AFTER the SQL include, so if it fails, we don't even bother processing upload
                 if (isset($data[$name . "_delete"]) || isset($_FILES[$name]) && $_FILES[$name]['error'] == 0) {
                     // delete ou update
                     $ids = "";
                     foreach ($this->keys as $key) {
                         $ids .= $data[$key] . "_";
                     }
                     $ids = substr($ids, 0, strlen($ids) - 1);
                     $this->deleteUploads($data, $name, $ids);
                 }
                 $upOk = $this->prepareUpload($name, $kA, $data);
                 $upvalue = $upOk == '0' ? 'y' : 'n';
                 if ($upOk != 0 && $upOk != 4) {
                     # notification for the upload (4 = nothing sent, 0 = sent and ok)
                     $this->parent->errorControl->raise(200 + $upOk, $upOk, $this->name, $name);
                 }
                 if ($upOk != 4) {
                     $output = $encapsulation . $upvalue . $encapsulation;
                 } else {
                     // no change, but take this oportunity and check if the file exists!
                     $upvalue = 'n';
                     $path = CONS_FMANAGER . $this->name . "/";
                     if (is_dir($path)) {
                         if (isset($this->fields[$name][CONS_XML_FILEPATH])) {
                             $path .= $this->fields[$name][CONS_XML_FILEPATH];
                             if ($path[strlen($path) - 1] != "/") {
                                 $path .= "/";
                             }
                             if (!is_dir($path)) {
                                 safe_mkdir($path);
                             }
                         }
                         # prepares filename with item keys
                         $filename = $path . $name . "_";
                         foreach ($this->keys as $key) {
                             $filename .= $data[$key] . "_";
                         }
                         $filename .= "1";
                         $upvalue = locateAnyFile($filename, $ext, isset($this->fields[$name][CONS_XML_FILETYPES]) ? $this->fields[$name][CONS_XML_FILETYPES] : '') ? 'y' : 'n';
                     }
                     $output = $encapsulation . $upvalue . $encapsulation;
                 }
             }
             break;
         case CONS_TIPO_ARRAY:
             if (isset($data[$name])) {
                 if (is_array($data[$name])) {
                     $output = $data[$name];
                 } else {
                     # came in serialized (JSON or php)
                     if ($data[$name][0] == '[') {
                         # JSON
                         $output = @json_decode($data[$name]);
                     } else {
                         $output = @unserialize($data[$name]);
                     }
                     # we will serialize the whole thing
                     if ($output === false) {
                         $this->parent->errorControl->raise(189, $name, $this->name);
                         $output = "";
                     }
                 }
             }
             break;
         case CONS_TIPO_SERIALIZED:
             if (isset($data[$name])) {
                 // came raw data, we store as is, YOU should serialize raw data
                 $data[$name] = addslashes_EX($data[$name], true);
                 if (isset($field[CONS_XML_IGNORENEDIT]) && $data[$name] == "") {
                     break;
                 }
                 $output = $encapsulation . $data[$name] . $encapsulation;
             } else {
                 if ($this->fields[$name][CONS_XML_SERIALIZED] > 1) {
                     // set to WRITE or ALL
                     // note: we ADD fields, never replace, because we should allow partial edits, thus we need to read the original data first
                     $sql = "SELECT {$name} FROM " . $this->dbname . " WHERE {$wS}";
                     $serialized = $this->parent->dbo->fetch($sql);
                     if ($serialized === false) {
                         $serialized = array();
                     } else {
                         $serialized = @unserialize($serialized);
                     }
                     $serializedFields = 0;
                     foreach ($this->fields[$name][CONS_XML_SERIALIZEDMODEL] as $exname => &$exfield) {
                         if (isset($data[$name . "_" . $exname])) {
                             $outfield = $this->sqlParameter(true, $data, $name . "_" . $exname, $exfield, $EnumPrunecache, true);
                             if ($outfield !== false && $outfield != 'NULL') {
                                 $serialized[$exname] = $outfield;
                             }
                             # we don't need to store NULL like in sql
                         }
                     }
                     $output = $encapsulation . addslashes_EX(serialize($serialized), true, $this->parent->dbo) . $encapsulation;
                 }
             }
             break;
     }
     # switch
     return $output;
 }
Exemplo n.º 3
0
            $loginform__ .= "<option value='empr.php?tab=loan_reza&lvl=all#empr-resa'>" . $msg["empr_my_resas"] . "</option>";
        }
        if ($opac_demandes_active && $allow_dema) {
            $loginform__ .= "<option value='empr.php?tab=request&lvl=list_dmde'>" . $msg["empr_my_dmde"] . "</option>";
        }
        $loginform__ .= "</select><br />";
        $loginform__ .= "<a href=\"index.php?logout=1\" id=\"empr_logout_lnk\">" . $msg["empr_logout"] . "</a>";
    }
    $loginform = str_replace("!!login_form!!", $loginform__, $loginform);
    $footer = str_replace("!!contenu_bandeau!!", ($opac_accessibility ? $accessibility : "") . $home_on_left . $loginform . $meteo . ($opac_facette_in_bandeau_2 ? "" : $lvl1 . $facette) . $adresse, $footer);
    $footer = str_replace("!!contenu_bandeau_2!!", $opac_facette_in_bandeau_2 ? $lvl1 . $facette : "", $footer);
}
print $footer;
if ($opac_parse_html || $cms_active) {
    if ($opac_parse_html) {
        $htmltoparse = parseHTML(ob_get_contents());
    } else {
        $htmltoparse = ob_get_contents();
    }
    ob_end_clean();
    if ($cms_active) {
        require_once $base_path . "/classes/cms/cms_build.class.php";
        $cms = new cms_build();
        $htmltoparse = $cms->transform_html($htmltoparse);
    }
    //Compression CSS
    if ($opac_compress_css == 1 && !$cms_active) {
        $compressed_file_exist = file_exists("./temp/full.css");
        require_once $class_path . "/curl.class.php";
        $dom = new DOMDocument();
        $dom->encoding = $charset;
Exemplo n.º 4
0
function parseHTML($file_name, $copy_dir, $space)
{
    global $file_done;
    if (array_key_exists($file_name, $file_done)) {
        return;
    }
    $file_done[$file_name] = true;
    echo $space . "Working on file: {$file_name}\n";
    $index = new DOMDocument();
    $index->loadHTMLFile($file_name);
    $found = array();
    $xpath = new DOMXPath($index);
    // Get rid of some unneeded links
    $results = $xpath->query("//a[starts-with(@href, 'file_')]");
    foreach ($results as $result) {
        //$result->parentNode->replaceChild( $result->firstChild, $result );
        $result->removeAttribute("href");
    }
    $results = $xpath->query("//a[@href]");
    foreach ($results as $result) {
        $href = $result->getAttribute("href");
        if ($href[0] != '#' && substr($href, 0, 6) != 'ihris_' || $href == 'ihris_qualify_form_fields.html' || $href == 'ihris_manage_form_fields.html') {
            $result->removeAttribute("href");
        }
    }
    $results = $xpath->query("//div[@id='footerHacked']");
    foreach ($results as $result) {
        $result->parentNode->removeChild($result);
    }
    $results = $xpath->query("//div[@id='catlinks']");
    foreach ($results as $result) {
        $result->parentNode->removeChild($result);
    }
    $results = $xpath->query("//small/i/div[@class='dablink']");
    foreach ($results as $result) {
        $small = $result->parentNode->parentNode;
        $small->parentNode->removeChild($small);
    }
    $results = $xpath->query("//div[@id='contentSub']");
    foreach ($results as $result) {
        $result->parentNode->removeChild($result);
    }
    $results = $xpath->query("//@href");
    foreach ($results as $result) {
        $href = $result->value;
        if (strpos($href, '#') !== false) {
            $href = substr($href, 0, strpos($href, '#'));
        }
        if ($href == '') {
            continue;
        }
        if (substr($href, -5) == ".html" && substr($href, 0, 6) != 'ihris_') {
            continue;
        }
        if (substr($href, 0, 7) == 'http://') {
            continue;
        }
        if (substr($href, 0, 8) == 'https://') {
            continue;
        }
        if ($href == "favicon.ico") {
            continue;
        }
        $found[] = $href;
    }
    $results = $xpath->query("//@src");
    foreach ($results as $result) {
        $src = $result->value;
        if ($src == '') {
            continue;
        }
        $found[] = $src;
    }
    $results = $xpath->query("//comment()");
    foreach ($results as $result) {
        $comment = $result->nodeValue;
        if ($comment[0] != '[') {
            continue;
        }
        $match = array();
        preg_match("/(href|src)=[\"']([^'\"]*)[\"']/", $comment, $match);
        if (count($match) > 0) {
            $found[] = $match[2];
        }
    }
    $fd = fopen("{$copy_dir}/{$file_name}", "w");
    $content = $index->saveXML();
    $content = preg_replace("/iHRIS:/", "", $content);
    $content = preg_replace("/ \\(4\\.0\\.5\\)/", "", $content);
    $content = preg_replace("/Osi:Books\\//", "", $content);
    fwrite($fd, $content);
    fclose($fd);
    foreach ($found as $file) {
        if (file_exists($file)) {
            if (substr($file, -5) == ".html") {
                parseHTML($file, $copy_dir, $space . " ");
                continue;
            } elseif (substr($file, -4) == ".css") {
                parseCSS($file, $copy_dir, $space . " ");
            }
            copy($file, "{$copy_dir}/{$file}");
        } else {
            echo $space . "{$file} does not exist.\n";
        }
    }
    echo $space . "Done with {$file_name}\n";
}
Exemplo n.º 5
0
                    $output_final .= $current->affichage_expl;
                }
                $output_final .= "<hr /> ";
            }
            if ($charset != 'utf-8') {
                $output_final = cp1252Toiso88591($output_final);
            }
        }
    }
    //print "</table>";
    if ($output == "printer") {
        $output_final .= "<script>self.print();</script>";
    }
}
if ($opac_parse_html) {
    $output_final = parseHTML($output_final);
}
if ($output != "email") {
    print pmb_bidi($output_final . "</body></html>");
} else {
    $headers = "MIME-Version: 1.0\n";
    $headers .= "Content-type: text/html; charset=" . $charset . "\n";
    $res_envoi = mailpmb("", $emaildest, $msg["print_emailobj"] . " {$opac_biblio_name} - {$date_today} ", ($emailcontent ? $msg["print_emailcontent"] . $emailcontent . "<br />" : '') . $output_final . "<br /><br />" . mail_bloc_adresse() . "</body></html> ", $opac_biblio_name, $opac_biblio_email, $headers);
    $vide_cache = filemtime("./styles/" . $css . "/" . $css . ".css");
    if ($res_envoi) {
        print "<html><head><meta http-equiv=Content-Type content=\"text/html; charset=" . $charset . "\" /><title>" . $msg["print_title"] . "</title></head><body><link rel=\"stylesheet\" href=\"./styles/" . $css . "/{$css}.css?" . $vide_cache . "\" />\n<br /><br /><center><h3>" . sprintf($msg["print_emailsucceed"], $emaildest) . "</h3><br />\n\t\t<a href=\"\" onClick=\"self.close(); return false;\">" . $msg["print_emailclose"] . "</a></center></body></html>";
    } else {
        echo "<html><head><meta http-equiv=Content-Type content=\"text/html; charset=" . $charset . "\" /><title>" . $msg["print_title"] . "</title></head><body><link rel=\"stylesheet\" href=\"./styles/" . $css . "/{$css}.css?" . $vide_cache . "\" />\n<br /><br /><center><h3>" . sprintf($msg["print_emailfailed"], $emaildest) . "</h3><br />\n\t\t<a href=\"\" onClick=\"self.close(); return false;\">" . $msg["print_emailclose"] . "</a></center></body></html>";
    }
}
global $pmb_logs_activate;
Exemplo n.º 6
0
 function apply_change($cadre, &$cache_cadre_object)
 {
     global $charset, $opac_parse_html;
     if (substr($cadre->build_obj, 0, strlen("cms_module_")) == "cms_module_") {
         $id_cadre = substr($cadre->build_obj, strrpos($cadre->build_obj, "_") + 1);
         if ($cache_cadre_object[$cadre->build_obj]) {
             $obj = $cache_cadre_object[$cadre->build_obj];
         } else {
             $obj = cms_modules_parser::get_module_class_by_id($id_cadre);
             $cache_cadre_object[$cadre->build_obj] = $obj;
         }
         if ($obj) {
             //on va chercher ses entetes...
             $this->headers = array_merge($this->headers, $obj->get_headers());
             $this->headers = array_unique($this->headers);
             //on s'occupe du cadre en lui-même
             //on récupère le contenu du cadre
             $res = $this->manage_cache_cadres("select", $cadre->build_obj, "html");
             if ($res["select"]) {
                 $html = $res["value"];
             } else {
                 $html = $obj->show_cadre();
                 if ($opac_parse_html) {
                     $html = parseHTML($html);
                 }
                 //on regarde si une condition n'empeche pas la mise en cache !
                 if ($obj->check_for_cache()) {
                     $this->manage_cache_cadres("insert", $cadre->build_obj, "html", $html);
                 }
             }
             //ca a peut-être l'air complexe, mais c'est logique...
             $tmp_dom = new domDocument();
             if ($charset == "utf-8") {
                 @$tmp_dom->loadHTML("<?xml version='1.0' encoding='{$charset}'>" . $html);
             } else {
                 @$tmp_dom->loadHTML($html);
             }
             if (!$tmp_dom->getElementById($obj->get_dom_id())) {
                 $this->setAllId($tmp_dom);
             }
             if ($this->dom->getElementById($cadre->build_parent)) {
                 $this->dom->getElementById($cadre->build_parent)->appendChild($this->dom->importNode($tmp_dom->getElementById($obj->get_dom_id()), true));
             }
             $dom_id = $obj->get_dom_id();
             //on rappelle le tout histoire de récupérer les CSS and co...
             $this->apply_dom_change($obj->get_dom_id(), $cadre);
         }
     } else {
         $this->apply_dom_change($cadre->build_obj, $cadre);
     }
 }
Exemplo n.º 7
0
        $infos_notice = $noti;
        $rqt_expl = " select section_libelle, location_libelle, statut_libelle, codestat_libelle, expl_date_depot, expl_date_retour, tdoc_libelle \n\t\t\t\t\tfrom exemplaires e\n\t\t\t\t\tleft join docs_codestat co on e.expl_codestat = co.idcode\n\t\t\t\t\tleft join docs_location dl on e.expl_location=dl.idlocation\n\t\t\t\t\tleft join docs_section ds on ds.idsection=e.expl_section\n\t\t\t\t\tleft join docs_statut dst on e.expl_statut=dst.idstatut \n\t\t\t\t\tleft join docs_type dt on dt.idtyp_doc=e.expl_typdoc\n\t\t\t\t\twhere expl_notice='" . $id_notice . "'";
        $res_expl = mysql_query($rqt_expl);
        while ($expl = mysql_fetch_array($res_expl)) {
            $infos_expl[] = $expl;
        }
    }
}
global $pmb_logs_activate;
if ($pmb_logs_activate) {
    //Enregistrement du log
    global $log, $infos_expl, $infos_notice;
    $rqt = " select empr_prof,empr_cp, empr_ville, empr_year, empr_sexe, empr_login, empr_date_adhesion, empr_date_expiration, count(pret_idexpl) as nbprets, count(resa.id_resa) as nbresa, code.libelle as codestat, es.statut_libelle as statut, categ.libelle as categ, gr.libelle_groupe,dl.location_libelle \n\t\t\tfrom empr e\n\t\t\tleft join empr_codestat code on code.idcode=e.empr_codestat\n\t\t\tleft join empr_statut es on e.empr_statut=es.idstatut\n\t\t\tleft join empr_categ categ on categ.id_categ_empr=e.empr_categ\n\t\t\tleft join empr_groupe eg on eg.empr_id=e.id_empr\n\t\t\tleft join groupe gr on eg.groupe_id=gr.id_groupe\n\t\t\tleft join docs_location dl on e.empr_location=dl.idlocation\n\t\t\tleft join resa on e.id_empr=resa_idempr\n\t\t\tleft join pret on e.id_empr=pret_idempr\n\t\t\twhere e.empr_login='******'user_code']) . "'\n\t\t\tgroup by resa_idempr, pret_idempr";
    $res = mysql_query($rqt);
    if ($res) {
        $empr_carac = mysql_fetch_array($res);
        $log->add_log('empr', $empr_carac);
    }
    $log->add_log('num_session', session_id());
    $log->add_log('expl', $infos_expl);
    $log->add_log('docs', $infos_notice);
    $log->save();
}
if ($opac_parse_html) {
    $htmltoparse = ob_get_contents();
    ob_end_clean();
    $res = parseHTML($htmltoparse);
    print $res;
}
/* Fermeture de la connexion */
mysql_close($dbh);
Exemplo n.º 8
0
 function apply_change($cadre, &$cache_cadre_object)
 {
     global $charset, $opac_parse_html;
     if (substr($cadre->build_obj, 0, strlen("cms_module_")) == "cms_module_") {
         if ($cadre->empty && $_SESSION["cms_build_activate"]) {
             $id_cadre = substr($cadre->build_obj, strrpos($cadre->build_obj, "_") + 1);
             $obj = cms_modules_parser::get_module_class_by_id($id_cadre);
             if ($obj) {
                 $query = "select cadre_name from cms_cadres where id_cadre = " . $id_cadre;
                 $result = pmb_mysql_query($query);
                 $row = pmb_mysql_fetch_object($result);
                 $html = "<span id='" . $cadre->build_obj . "' class='cmsNoStyles' type='cms_module_hidden' cadre_style='" . $cadre->build_css . "'><div id='" . $cadre->build_obj . "_conteneur' class='cms_module_hidden' style='display:none'>" . $row->cadre_name . "<div style='" . $cadre->build_css . "'></div></div></pan>";
                 $tmp_dom = new domDocument();
                 if ($charset == "utf-8") {
                     @$tmp_dom->loadHTML("<?xml version='1.0' encoding='{$charset}'>" . $html);
                 } else {
                     @$tmp_dom->loadHTML($html);
                 }
                 if (!$tmp_dom->getElementById($obj->get_dom_id())) {
                     $this->setAllId($tmp_dom);
                 }
                 if ($this->dom->getElementById($cadre->build_parent)) {
                     $this->dom->getElementById($cadre->build_parent)->appendChild($this->dom->importNode($tmp_dom->getElementById($obj->get_dom_id()), true));
                 }
                 $dom_id = $obj->get_dom_id();
                 //on rappelle le tout histoire de récupérer les CSS and co...
                 $this->apply_dom_change($obj->get_dom_id(), $cadre);
             }
         } else {
             if (!$cadre->empty) {
                 $id_cadre = substr($cadre->build_obj, strrpos($cadre->build_obj, "_") + 1);
                 if ($cache_cadre_object[$cadre->build_obj]) {
                     $obj = $cache_cadre_object[$cadre->build_obj];
                 } else {
                     $obj = cms_modules_parser::get_module_class_by_id($id_cadre);
                     $cache_cadre_object[$cadre->build_obj] = $obj;
                 }
                 if ($obj) {
                     //on va chercher ses entetes...
                     $headers = $obj->get_headers();
                     $this->headers['add'] = array_merge($this->headers['add'], $headers['add']);
                     $this->headers['replace'] = array_merge($this->headers['replace'], $headers['replace']);
                     $this->headers['add'] = array_unique($this->headers['add']);
                     $this->headers['replace'] = array_unique($this->headers['replace']);
                     //on s'occupe du cadre en lui-même
                     //on récupère le contenu du cadre
                     $res = $this->manage_cache_cadres("select", $cadre->build_obj, "html");
                     if ($res["select"]) {
                         $html = $res["value"];
                     } else {
                         $html = $obj->show_cadre();
                         if ($opac_parse_html) {
                             $html = parseHTML($html);
                         }
                         //on regarde si une condition n'empeche pas la mise en cache !
                         if ($obj->check_for_cache()) {
                             $this->manage_cache_cadres("insert", $cadre->build_obj, "html", $html);
                         }
                     }
                     //ca a peut-être l'air complexe, mais c'est logique...
                     $tmp_dom = new domDocument();
                     if ($charset == "utf-8") {
                         @$tmp_dom->loadHTML("<?xml version='1.0' encoding='{$charset}'>" . $html);
                     } else {
                         @$tmp_dom->loadHTML($html);
                     }
                     if (!$tmp_dom->getElementById($obj->get_dom_id())) {
                         $this->setAllId($tmp_dom);
                     }
                     if ($this->dom->getElementById($cadre->build_parent)) {
                         $this->dom->getElementById($cadre->build_parent)->appendChild($this->dom->importNode($tmp_dom->getElementById($obj->get_dom_id()), true));
                     }
                     $dom_id = $obj->get_dom_id();
                     //on rappelle le tout histoire de récupérer les CSS and co...
                     $this->apply_dom_change($obj->get_dom_id(), $cadre);
                 }
             }
         }
     } else {
         if ($cadre->build_type == "cadre" && $cadre->empty == 1 && $_SESSION["cms_build_activate"]) {
             $html = "<span id='" . $cadre->build_obj . "' class='cmsNoStyles' type='cms_module_hidden' cadre_style='" . $cadre->build_css . "'><div id='" . $cadre->build_obj . "_conteneur' class='cms_module_hidden' style='display:none'>" . $cadre->build_obj . "<div style='" . $cadre->build_css . "'></div></div></pan>";
             $tmp_dom = new domDocument();
             if ($charset == "utf-8") {
                 @$tmp_dom->loadHTML("<?xml version='1.0' encoding='{$charset}'>" . $html);
             } else {
                 @$tmp_dom->loadHTML($html);
             }
             if (!$tmp_dom->getElementById($cadre->build_obj)) {
                 $this->setAllId($tmp_dom);
             }
             if ($this->dom->getElementById($cadre->build_parent)) {
                 $this->dom->getElementById($cadre->build_parent)->appendChild($this->dom->importNode($tmp_dom->getElementById($cadre->build_obj), true));
             }
         }
         $this->apply_dom_change($cadre->build_obj, $cadre);
     }
 }
Exemplo n.º 9
0
        $table = $db->prefix . '_webspace';
        $db->insertDB($rec, $table);
    } else {
        $query = "\n\t\t\tUPDATE " . $db->prefix . "_webspace\n\t\t\tSET \n\t\t\twebspace_title=" . $db->qstr($title) . ",\n\t\t\twebspace_theme=" . $db->qstr($theme_name) . "\n\t\t\tWHERE \n\t\t\tuser_id=" . (int) $_SESSION['user_id'];
        $db->Execute($query);
    }
    if (!empty($title)) {
        makeThemeHeader($core_config['file']['dir'], (int) $_SESSION['user_id'], $theme_name, $title);
    } else {
        unlink($core_config['file']['dir'] . "/titles/" . (int) $_SESSION['user_id'] . ".png");
    }
    header('location: /editor');
    exit;
} elseif (isset($_POST['save_markup'])) {
    $html = trim($_POST['html']);
    $html = parseHTML($html, $core_config['security']['allowable_html_tags']);
    //	$css = trim($_POST['css']);
    //	$css = parseCSS($css);
    $query = "\n\t\tSELECT user_id\n\t\tFROM " . $db->prefix . "_webspace\n\t\tWHERE user_id=" . (int) $_SESSION['user_id'];
    $result = $db->Execute($query);
    if (empty($result)) {
        $rec = array();
        $rec['user_id'] = $_SESSION['user_id'];
        $rec['webspace_html'] = $html;
        //		$rec['webspace_css'] = $css;
        $table = $db->prefix . '_webspace';
        $db->insertDB($rec, $table);
    } else {
        $query = "\n\t\t\tUPDATE " . $db->prefix . "_webspace\n\t\t\tSET \n\t\t\twebspace_html=" . $db->qstr($html) . " \n\t\t\tWHERE \n\t\t\tuser_id=" . (int) $_SESSION['user_id'];
        $db->Execute($query);
    }
Exemplo n.º 10
0
 // no break: continue on to add post
 case 'post':
     // post a comment
     if (!$core->queryOk(array("#id_forum", "#id_forumthread", "fmessage"))) {
         $core->action = "index";
         $core->log[] = "Error on post";
         // fail to post comment but thread created ... destroy thread
         if ($_POST['bbaction'] == 'tpost') {
             $core->simpleQuery("DELETE FROM bb_thread WHERE id=" . $_POST['id_forumthread']);
         }
         return;
     }
     if (!defined('C_XHTML_AUTOTAB')) {
         include CONS_PATH_INCLUDE . "xmlHandler.php";
     }
     $postData = array('id_forum' => $_POST['id_forum'], 'id_forumthread' => $_POST['id_forumthread'], 'content' => parseHTML($_POST['fmessage'], true), 'id_author' => $_SESSION[CONS_SESSION_ACCESS_USER]['id'], 'props' => serialize(array()));
     $ok = $core->runAction('forumpost', CONS_ACTION_INCLUDE, $postData);
     if ($ok) {
         // kill cache for the post, it changed!
         $core->cacheControl->killCache("postsforidt" . $_POST['id_forumthread'] . "idf" . $_POST['id_forum'] . "*");
         // thread view
         $core->cacheControl->killCache("threadsfor" . $_POST['id_forumthread'] . "p*");
         // forum view
         $core->headerControl->internalFoward($_POST['url'] . "?lastpage=true");
     } else {
         // fail to post comment but thread created ... destroy thread
         if ($_POST['bbaction'] == 'tpost') {
             $core->simpleQuery("DELETE FROM bb_thread WHERE id=" . $_POST['id_forumthread']);
         }
         $core->log[] = "Error adding Post";
         $core->action = "forum";
Exemplo n.º 11
0
                 continue;
             }
             // Should the checkbox be checked
             if (isset($options[$name])) {
                 $checked = $options[$name] ? ' checked="checked"' : '';
             } else {
                 $checked = $details['default'] ? ' checked="checked"' : '';
             }
             // Add to array
             $toShow[] = array('name' => $name, 'title' => $details['title'], 'checked' => $checked);
         }
         // Add the form
         $parserOptions['addForm'] = replaceTags(loadTemplate('framedForm.inc', array('url' => $toLoad, 'toShow' => $toShow, 'return' => urlencode(currentURL()))));
     }
     // Parse HTML
     $fetch->return = parseHTML($fetch->return, $fullDoc);
     // Encode the whole page?
     if ($options['encodePage']) {
         $fetch->return = encodeSource($fetch->return);
     }
     break;
     # CSS document
 # CSS document
 case 'css':
     $fetch->return = parseCSS($fetch->return);
     break;
     # Javascript document
 # Javascript document
 case 'javascript':
     $fetch->return = parseJS($fetch->return);
     break;