Пример #1
0
function generate_xml($post, $path)
{
    $structure_txt = file_get_contents($path, true);
    if ($structure_txt == False) {
        echo "{$path} is not readable. Try changing the permission of the destination folder and {$path} to 777 if it exists.";
        exit;
    }
    $lines = explode("\n", $structure_txt);
    $i = 0;
    $return_value = "";
    foreach ($lines as $line) {
        if ($line != "" and $line != " " and $line[0] != '#') {
            if (preg_match_all('#\\<[^,]+\\>#', $line, $arr, PREG_PATTERN_ORDER)) {
                $return_value .= line(trim($arr[0][0]));
            } else {
                if (preg_match_all('#([^(), <>]+)\\(([^()]+)\\)#', $line, $arr, PREG_SET_ORDER)) {
                    $tag = sanitize(trim($arr[0][1]));
                    $items = explode_and_trim(',', $arr[0][2]);
                    $i++;
                    $content = line("<{$tag}>");
                    $show = false;
                    foreach ($items as $var) {
                        $var = sanitize($var);
                        $var_name = $tag . "_" . $var;
                        $var_name = preg_replace('/\\./', '_', $var_name);
                        if (isset($post[$var_name]) and $post[$var_name] != "") {
                            $inside = sanitize($post[$var_name]);
                            $content .= line("<{$var}>{$inside}</{$var}>");
                            $show = true;
                        }
                    }
                    $content .= line("</{$tag}>");
                    if ($show == true) {
                        $return_value .= $content;
                    }
                }
            }
        }
    }
    return $return_value;
}
Пример #2
0
 /**
  * @static
  * @return bool
  */
 public static function inDebugMode()
 {
     if (defined("PIMCORE_DEBUG")) {
         return PIMCORE_DEBUG;
     }
     $conf = Config::getSystemConfig();
     $debug = (bool) $conf->general->debug;
     // enable debug mode only for one IP
     if ($conf->general->debug_ip && $conf->general->debug) {
         $debug = false;
         $debugIpAddresses = explode_and_trim(',', $conf->general->debug_ip);
         if (in_array(Tool::getClientIp(), $debugIpAddresses)) {
             $debug = true;
         }
     }
     return $debug;
 }