Ejemplo n.º 1
0
/**
 * フロントのワードの取得
 */
function rand_words()
{
    $m = date('m', strtotime('today'));
    $day = date('md', strtotime('today'));
    $filename = __DIR__ . '/data/' . $m . '.csv';
    $word = '';
    $data = array();
    if (file_exists($filename)) {
        $data = get_csv($filename);
        foreach ($data as $key => &$value) {
            if ($value[0] === $day) {
                unset($value[0]);
                $words = $data[$key];
                break;
            }
        }
        $word = $words[array_rand($words)];
    }
    return trim($word);
}
function varRow($urlPath, $urlDir, $fileName, $service, $querystring, $varname, $productt, $domainn, $pointLat, $pointLong, $localPath, $opendapPath, $varQuery)
{
    if ($domainn == 'point') {
        $querystringAsciiBinary = "";
        //need to figure this out
        $latStartIndex = 0;
        $latEndIndex = 0;
        $longStartIndex = 0;
        $longEndIndex = 0;
    }
    $netcdfString = "<a href='{$urlPath}/{$service}/{$urlDir}/{$fileName}{$querystring}' target='_blank'>netCDF</a>";
    $asciiString = "<a href='{$urlPath}/dodsC/{$urlDir}/{$fileName}.ascii{$querystringAsciiBinary}' target='_blank'>ascii</a>";
    $binaryString = "<a href='{$urlPath}/dodsC/{$urlDir}/{$fileName}.dods{$querystringAsciiBinary}' target='_blank'>binary</a>";
    $opendapString = "<a href='{$urlPath}/dodsC/{$urlDir}/{$fileName}.html' target='_blank'>OPenDAP</a>";
    if ($productt == 'macav2livneh' || $productt == 'macav1metdata') {
        $tempString = str_replace('NWCSC_INTEGRATED_SCENARIOS_ALL_CLIMATE', 'NWCSC_IS_ALL_SCAN', $urlDir);
        $datasetQuery = "?dataset={$tempString}/{$fileName}";
        //	}else if($productt=='vic' || $product=='ulm'){
        //	}else if($productt=='3pg' || $productt=="mc2_WithFireSuppression" || $productt=="mc2_WithoutFireSuppression"){
    }
    $catalogString = "<a href='{$urlPath}/catalog/{$urlDir}/catalog.html{$datasetQuery}' target='_blank'>Catalog Page</a>";
    if ($domainn == 'point') {
        $csvString = get_csv($varQuery, $pointLat, $pointLong);
        $csvString = "<a href='{$csvString}' target='_blank'>csv</a>";
        $downloadString = "--{$catalogString} --{$opendapString}--{$netcdfString}--{$asciiString}--{$binaryString}--{$csvString}";
    } else {
        $downloadString = "--{$catalogString} --{$opendapString}--{$netcdfString}--{$asciiString}--{$binaryString}";
    }
    $html = <<<HereDoc
\t\t<span style="padding: 0 40px">
\t\t<input type="checkbox" name="filedownload[]" checked="checked" value="{$urlPath}/{$service}/{$urlDir}/{$fileName}{$querystring}">
\t\t{$varname}
\t\t</span>
\t\t<br>
\t\t<span style="padding: 0 100px">{$downloadString}</span>
HereDoc;
    return $html;
}
Ejemplo n.º 3
0
<?php

function get_csv($archivo)
{
    $i = $m = 0;
    $data = array();
    if (($gestor = fopen($archivo, "r")) !== FALSE) {
        while (($datos = fgetcsv($gestor, 21500, ";")) !== FALSE) {
            $data[$i] = $datos;
            $i++;
        }
    }
    return $data;
}
$var = get_csv("tablakm.csv");
print_r($var);
Ejemplo n.º 4
0
/**
 * Count pages and redirect pages
 */
function macro_PageCount($formatter, $value = '', $options = array())
{
    global $DBInfo;
    $mode = '';
    $use_js = false;
    if (!empty($value)) {
        $vals = get_csv($value);
        if (!empty($vals)) {
            foreach ($vals as $v) {
                if (in_array($v, array('noredirect', 'redirect'))) {
                    $mode = $v;
                } else {
                    if ($v == 'js') {
                        $use_js = true;
                    }
                }
            }
        }
    }
    if ($formatter->_macrocache and empty($options['call']) and !$use_js) {
        return $formatter->macro_cache_repl('PageCount', $value);
    }
    if (empty($options['call']) and !$use_js) {
        $formatter->_dynamic_macros['@PageCount'] = 1;
    }
    $js = '';
    $mid = $formatter->mid++;
    if ($use_js) {
        $url = $formatter->link_url('', '?action=pagecount/ajax');
        $js = <<<JS
<script type='text/javascript'>
/*<![CDATA[*/
(function() {
var url = "{$url}";
var mode = "{$mode}";
var txt = HTTPGet(url);
var ret = window["eval"]("(" + txt + ")");
var rc = document.getElementById("macro-{$mid}");
var out = ret['pagecount'];
if (mode == 'noredirect')
    out -= ret['redirect'];
else if (mode == 'redirect')
    out = ret['redirect'];
rc.innerHTML = out;
})();
/*]]>*/
</script>
JS;
    }
    $redirects = 0;
    if (!empty($mode)) {
        $sc = new Cache_Text('settings');
        if (($redirects = $sc->fetch('redirect')) === false) {
            $rc = new Cache_Text('redirect');
            $redirects = 0;
            if (method_exists($rc, 'count')) {
                $redirects = $rc->count();
            }
            $sc->update('redirect', $redirects, 60 * 60 * 24);
        }
        if ($mode == 'redirect') {
            return '<span class="macro" id="macro-' . $mid . '">' . $redirects . '<span>' . $js;
        }
    }
    $count = $DBInfo->getCounter();
    return '<span class="macro" id="macro-' . $mid . '">' . ($count - $redirects) . '</span>' . $js;
}
Ejemplo n.º 5
0
 */
require_once '_csv_common.php';
/**
 * POSTの格納
 * @var [type]
 */
foreach ($_POST as $key => $value) {
    $tmp = $value;
    ${$key} = $tmp;
}
$data_flg = false;
$day = $m . $d;
$new_data = array();
$filename = './data/' . $m . '.csv';
//csvと該当日の内容の取得
$data = get_csv($filename);
$words = get_words($data, $day);
//csvの走査
//日付既存の場合
foreach ($data as $key => $value) {
    if ($value[0] === $day) {
        $texts = str_replace(array("\r\n", "\r", "\n"), "\n", $texts);
        //改行コードの統一
        $value = explode("\n", $day . "\n" . $texts);
        $new_data[] = $value;
        $data_flg = true;
        continue;
    }
    $new_data[] = $value;
}
//日付新規の場合
Ejemplo n.º 6
0
 function get_acl_raw($action = 'read', &$options)
 {
     if (in_array($options['id'], $this->allowed_users)) {
         return true;
     }
     global $DBInfo;
     $pg = $options['page'];
     $user = $options['id'];
     $groups = $this->get_acl_group($user);
     // check groups in the user information.
     $u =& $DBInfo->user;
     if ($u->id == $options['id'] && !empty($u->groups)) {
         $groups = array_merge($groups, $u->groups);
     }
     $groups[] = '@ALL';
     $groups[] = $user;
     $allowed = array();
     $denied = array();
     $protected = array();
     $gpriority = $this->gpriority;
     $gregex = implode('|', $groups);
     #get ACL info.
     #$matches= preg_grep('/^('.$pg.'|\*)\s+('.$gregex.')\s+/', $this->AUTH_ACL);
     $matches = preg_grep('/^[^#@].*\\s+(' . $gregex . ')\\s+/', $this->AUTH_ACL);
     if (count($matches)) {
         foreach ($matches as $rule) {
             #if (in_array($rule[0],array('@','#'))) continue;
             $rule = preg_replace('/#.*$/', '', $rule);
             # delete comments
             $rule = rtrim($rule);
             $tmp = preg_match('/^(.*)\\s+(' . $gregex . ')\\s+(allow|protect|deny)\\s*(.*)?$/i', $rule, $acl);
             if (!$tmp) {
                 continue;
             }
             $found = 0;
             if (!$acl[4]) {
                 $acl[4] = '*';
             }
             if ($acl[1] != '*' and $acl[1] != $pg) {
                 $prules = get_csv($acl[1]);
                 // a regex or a simplified pattern like as
                 // HelpOn* -> HelpOn.*
                 // MoniWiki/* -> MoniWiki\/.*
                 foreach ($prules as $prule) {
                     if ($prule == $pg) {
                         $found = 10;
                         break;
                     } else {
                         $pre = '^';
                         $post = '$';
                         if ($prule[0] == '^') {
                             $pre = '';
                         }
                         if (substr($prule, -1) == '$') {
                             $post = '';
                         }
                         // is it a regex or a simplified pattern
                         $prule = preg_replace(array('/(?:\\.)?\\*/', "/(?<!\\\\)\\//"), array('.*', '\\/'), $prule);
                         if (@preg_match("/{$pre}{$prule}{$post}/", $pg)) {
                             $found = 5;
                             break;
                         }
                     }
                 }
                 if (!$found) {
                     continue;
                 }
             } else {
                 if ($acl[1] == $pg) {
                     $found = 10;
                 }
             }
             if ($acl[3] == 'allow') {
                 $tmp = explode(',', $acl[4]);
                 $tmp = array_flip($tmp);
                 if ($acl[2] == $user) {
                     $pri = 4;
                 } else {
                     if ($acl[2] == '@ALL') {
                         $pri = 1;
                     } else {
                         $pri = !empty($gpriority[$acl[2]]) ? $gpriority[$acl[2]] : 2;
                     }
                 }
                 # get group prio
                 $pri += $found;
                 // set explicitly
                 $keys = array_keys($tmp);
                 foreach ($keys as $t) {
                     if (isset($allowed[$t]) and $allowed[$t] > $pri) {
                         unset($tmp[$t]);
                     } else {
                         $tmp[$t] = $pri;
                     }
                     if (isset($denied[$t]) and $denied[$t] <= $pri) {
                         unset($denied[$t]);
                     }
                 }
                 $allowed = array_merge($allowed, $tmp);
             } else {
                 if ($acl[3] == 'deny') {
                     $tmp = explode(',', $acl[4]);
                     $tmp = array_flip($tmp);
                     if ($acl[2] == $user) {
                         $pri = 4;
                     } else {
                         if ($acl[2] == '@ALL') {
                             $pri = 1;
                         } else {
                             $pri = $gpriority[$acl[2]] ? $gpriority[$acl[2]] : 2;
                         }
                     }
                     # set group prio
                     $pri += $found;
                     // set explicitly
                     $keys = array_keys($tmp);
                     foreach ($keys as $t) {
                         if (isset($denied[$t]) and $denied[$t] > $pri) {
                             unset($tmp[$t]);
                         } else {
                             $tmp[$t] = $pri;
                         }
                         if (isset($allowed[$t]) and $allowed[$t] <= $pri) {
                             unset($allowed[$t]);
                         }
                     }
                     $denied = array_merge($denied, $tmp);
                 } else {
                     if ($acl[3] == 'protect') {
                         $tmp = explode(',', $acl[4]);
                         $tmp = array_flip($tmp);
                         $protected = array_merge($protected, $tmp);
                     }
                 }
             }
         }
     }
     $protected = array_keys($protected);
     if (!empty($this->DB->acl_debug)) {
         ob_start();
         print "<h4>" . _("ACL groups") . "</h4>\n";
         print implode(',', $groups);
         print "\n";
         print "<h4>" . _("Allowed ACL actions") . "</h4>\n";
         foreach ($allowed as $k => $v) {
             print $k . " ({$v}),";
         }
         #print_r($allowed);
         print "\n";
         print "<h4>" . _("Denied ACL actions") . "</h4>\n";
         foreach ($denied as $k => $v) {
             print $k . " ({$v}),";
         }
         #print_r($denied);
         print "\n";
         print "<h4>" . _("Protected ACL actions") . "</h4>\n";
         print implode(',', $protected);
         $options['msg'] .= ob_get_contents();
         ob_end_clean();
     }
     $this->_acl_ok = 1;
     $this->_allowed = $allowed;
     $this->_denied = $denied;
     $this->_protected = $protected;
     return array($allowed, $denied, $protected);
 }
Ejemplo n.º 7
0
 function cache_instructions($pi, $params = array())
 {
     global $Config;
     global $DBInfo;
     $pagename = $this->name;
     // update aliases
     if (!empty($Config['use_alias'])) {
         $ac = new Cache_text('alias');
         // is it removed ?
         if ($ac->exists($pagename) and empty($pi['#alias']) and empty($pi['#title'])) {
             // remove aliases
             store_aliases($pagename, array());
         } else {
             if (!$ac->exists($pagename) or $ac->mtime($pagename) < $this->mtime() or !empty($_GET['update_alias'])) {
                 $as = array();
                 // parse #alias
                 if (!empty($pi['#alias'])) {
                     $as = get_csv($pi['#alias']);
                 }
                 // add #title as a alias
                 if (!empty($pi['#title'])) {
                     $as[] = $pi['#title'];
                 }
                 // update aliases
                 store_aliases($pagename, $as);
             }
         }
     }
     // update redirects cache
     $redirect = isset($pi['#redirect'][0]) ? $pi['#redirect'] : null;
     update_redirects($pagename, $redirect, $params['refresh']);
     if (!empty($Config['use_keywords']) or !empty($Config['use_tagging']) or !empty($_GET['update_keywords'])) {
         $tcache = new Cache_text('keyword');
         $cache = new Cache_text('keywords');
         $cur = $tcache->fetch($pagename);
         if (empty($cur)) {
             $cur = array();
         }
         $keys = array();
         if (empty($pi['#keywords'])) {
             $tcache->remove($pagename);
         } else {
             $keys = explode(',', $pi['#keywords']);
             $keys = array_map('trim', $keys);
             if (!$tcache->exists($pagename) or $tcache->mtime($pagename) < $this->mtime() or !empty($_GET['update_keywords'])) {
                 $tcache->update($pagename, $keys);
             }
         }
         $adds = array_diff($keys, $cur);
         $dels = array_diff($cur, $keys);
         // merge new keywords
         foreach ($adds as $a) {
             if (!isset($a[0])) {
                 continue;
             }
             $l = $cache->fetch($a);
             if (!is_array($l)) {
                 $l = array();
             }
             $l = array_merge($l, array($pagename));
             $cache->update($a, $l);
         }
         // remove deleted keywords
         foreach ($dels as $d) {
             if (!isset($d[0])) {
                 continue;
             }
             $l = $cache->fetch($d);
             if (!is_array($l)) {
                 $l = array();
             }
             $l = array_diff($l, array($pagename));
             $cache->update($d, $l);
         }
     }
     if (!empty($pi['#title']) and !empty($Config['use_titlecache'])) {
         $tc = new Cache_text('title');
         $old = $tc->fetch($pagename);
         if (!isset($pi['#title'])) {
             $tc->remove($pagename);
         } else {
             if ($old != $pi['#title'] or !$tcache->exists($pagename) or !empty($_GET['update_title'])) {
                 $tc->update($pagename, $pi['#title']);
             }
         }
     }
     return;
 }
function import_me($tabelle)
{
    $tabelle_in_gross = strtoupper($tabelle);
    // Tabelle in GROßBUCHSTABEN
    $datei = "{$tabelle}.csv";
    // DATEINAME
    // $CSVarray = get_csv($file);
    $array = get_csv($datei);
    // DATEI IN ARRAY EINLESEN
    // echo "<pre>";
    // print_r($array);
    echo $array[0];
    // ZEILE 0 mit Überschriften
    $feldernamen[] = explode(":", $array[0]);
    // FELDNAMEN AUS ZEILE 0 IN ARRAY EINLESEN
    $anzahl_felder = count($feldernamen[0]);
    // ANZAHL DER IMPORT FELDER
    $feld1 = $feldernamen[0][0];
    // FELD1 - IMPORT nur zur info
    echo "<h1>{$feld1}</h1>";
    echo "<b>Importiere daten aus {$datei} nach MYSQL {$tabelle_in_gross}:</b><br><br>";
    // echo "<pre>";
    // print_r($zeile);
    // echo "</pre>";
    $anzahl_zeilen = count($array);
    for ($i = 5000; $i < 9175; $i++) {
        $zeile[$i] = $array[$i];
        // Zeile in Array einlesen
        $red = $zeile[$i];
        $zeile[$i][0] = textrep($zeile[$i][0]);
        $zeile[$i][1] = textrep($zeile[$i][1]);
        $zeile[$i][2] = textrep($zeile[$i][2]);
        $zeile[$i][3] = textrep($zeile[$i][3]);
        $zeile[$i][4] = textrep($zeile[$i][4]);
        $zeile[$i][5] = textrep($zeile[$i][5]);
        $zeile[$i][6] = textrep($zeile[$i][6]);
        $zeile[$i][7] = textrep($zeile[$i][7]);
        $zeile[$i][8] = textrep($zeile[$i][8]);
        $zeile[$i][9] = textrep($zeile[$i][9]);
        /* MV begin */
        $form = new mietkonto();
        $einheit_name = rtrim(ltrim($zeile[$i][8]));
        // echo "$einheit_name<br>";
        $geldkonto_ins = new geld_konten_id_ermitteln();
        if (!empty($einheit_name)) {
            /* Einheit */
            $einheit_kostentraeger_id = einheit_id_aus_transtab($einheit_name);
            $geldkonto_ins->geld_konten_id_ermitteln_f('Einheit', $einheit_kostentraeger_id);
            $einheit_geldkonto_id = $geldkonto_ins->konto_id;
            /*
             * $objekt_kostentraeger_name = rtrim(ltrim($zeile[$i][7]));
             * if($objekt_kostentraeger_name == 'II-2007'){
             * $objekt_kostentraeger_id = '1';
             * }
             * $objekt_kostentraeger_name = rtrim(ltrim($zeile[$i][7]));
             * if($objekt_kostentraeger_name == 'III-2007'){
             * $objekt_kostentraeger_id = '2';
             * }
             *
             * $objekt_kostentraeger_name = rtrim(ltrim($zeile[$i][7]));
             * if($objekt_kostentraeger_name == 'V-2007'){
             * $objekt_kostentraeger_id = '3';
             * }
             *
             * $objekt_kostentraeger_name = rtrim(ltrim($zeile[$i][7]));
             * if($objekt_kostentraeger_name == 'E-2007'){
             * $objekt_kostentraeger_id = '4';
             * }
             * $objekt_kostentraeger_name = rtrim(ltrim($zeile[$i][7]));
             * if($objekt_kostentraeger_name == 'FON-2007'){
             * $objekt_kostentraeger_id = '12';
             * }
             *
             * if($objekt_kostentraeger_name == 'GBN-8-2007' OR $objekt_kostentraeger_name == 'GBN-7-2007' OR $objekt_kostentraeger_name == 'GBN-5-2007' OR $objekt_kostentraeger_name == 'GBN-G-2007'){
             * $objekt_kostentraeger_id = '13';
             * }
             *
             * if($objekt_kostentraeger_name == 'HW-35-2007' OR $objekt_kostentraeger_name == 'HW-37-39-2007' OR $objekt_kostentraeger_name == 'HW-41-2007' OR $objekt_kostentraeger_name == 'GBN-G-2007'){
             * $objekt_kostentraeger_id = '14';
             * }
             *
             * $objekt_kostentraeger_name = rtrim(ltrim($zeile[$i][7]));
             * if($objekt_kostentraeger_name == 'L�-2007'){
             * $objekt_kostentraeger_id = '15';
             * }
             */
            $objekt_kostentraeger_id = rtrim(ltrim($zeile[$i][7]));
            $geldkonto_ins->geld_konten_id_ermitteln_f('Objekt', $objekt_kostentraeger_id);
            $objekt_geldkonto_id = $geldkonto_ins->konto_id;
            /* Überprüfen ob Einheit Geldkonto = Objektgeldkonto und falls unterschiedlich buchen auf Objektgeldkonto weil FM das Objektgeldkonto unabhängig von Einheit belastet. Nur so stimmt die Kontobelastung und -buchung */
            if ($einheit_geldkonto_id != $objekt_geldkonto_id) {
                // echo "<h1> E_KONTO: $einheit_geldkonto_id != OBJEKT_KONTO:$objekt_geldkonto_id</h1>";
                $geldkonto_ins->konto_id = $objekt_geldkonto_id;
                $kostentraeger_typ = 'Objekt';
                $kostentraeger_id = $objekt_kostentraeger_id;
            } else {
                $kostentraeger_typ = 'Einheit';
                $geldkonto_ins->konto_id = $einheit_geldkonto_id;
                $kostentraeger_id = $einheit_kostentraeger_id;
            }
            // echo "NACH ÄNDERUNG KT:$kostentraeger_typ KID:$kostentraeger_id KONTO:$geldkonto_ins->konto_id<br>";
        } else {
            $kostentraeger_typ = 'Objekt';
            $kostentraeger_id = rtrim(ltrim($zeile[$i][7]));
            $geldkonto_ins->geld_konten_id_ermitteln_f('Objekt', $kostentraeger_id);
        }
        // print_r($geldkonto_ins);
        $v_zweck = rtrim(ltrim($zeile[$i][3]));
        if (!preg_match("/Miete Sollstellung/i", $v_zweck)) {
            if (!empty($geldkonto_ins->konto_id) && !empty($kostentraeger_typ) && !empty($kostentraeger_id)) {
                // if(!empty($kostentraeger_typ) && !empty($kostentraeger_id)){
                $datum = $zeile[$i][1];
                // echo "$i. $datum<br>";
                $datum_arr = explode(".", $datum);
                $tag = $datum_arr[0];
                $monat = $datum_arr[1];
                $jahr = $datum_arr[2];
                $datum_sql = "{$jahr}-{$monat}-{$tag}";
                $buchungskonto = rtrim(ltrim($zeile[$i][9]));
                $buchungskonto = str_replace("'", "", $buchungskonto);
                $buchungskonto = substr($buchungskonto, 0, 4);
                // Beispiel 5: substr ( '1234567', -2, 3 )
                $v_zweck = rtrim(ltrim($zeile[$i][3]));
                // $v_zweck = str_replace("'", "", $v_zweck);
                // $v_zweck = str_replace("\n", " ", $v_zweck);
                // $v_zweck = str_replace("\r", " ", $v_zweck);
                $betrag = rtrim(ltrim($zeile[$i][2]));
                $betrag = $form->nummer_komma2punkt($betrag);
                // $zb_exists = $form->check_zahlbetrag('888888', $kostentraeger_typ, $kostentraeger_id, $datum_sql, $betrag, $v_zweck, $geldkonto_ins->konto_id, $buchungskonto);
                // if(!$zb_exists){
                // echo "Existiert nicht, wird hinzugefügt:<br>$zeile[$i]<br>";
                insert_geldbuchung($geldkonto_ins->konto_id, $buchungskonto, '888888', 'IMPORT', $v_zweck, $datum_sql, $kostentraeger_typ, $kostentraeger_id, $betrag);
                // }
            } else {
                // echo "<h1>$i KTYP:$kostentraeger_typ, K_ID: $kostentraeger_id GELDKONTO: $geldkonto_ins->konto_id</h1>";
                echo "<pre>";
                print_r($red);
                echo "</pre>";
            }
        } else {
            // echo "$i - sollstellung<br>";
        }
        $zb_exists = $form->check_zahlbetrag('888888', $kostentraeger_typ, $kostentraeger_id, $datum_sql, $betrag, $v_zweck, $geldkonto_ins->konto_id, $buchungskonto);
        if (!$zb_exists && !preg_match("/Miete Sollstellung/i", $v_zweck)) {
            echo "Nicht importiert Zeile {$i} +1:<br><br>";
            print_r($zeile[$i]);
        }
        unset($geldkonto_ins->konto_id);
        unset($kostentraeger_id);
        unset($kostentraeger_typ);
        unset($einheit_name);
        unset($geldkonto_ins);
    }
    // END FOR
}
Ejemplo n.º 9
0
    fclose($handle);
    $my_file = '../json/rango7.json';
    $handle = fopen($my_file, 'w') or die('Cannot open file:  ' . $my_file);
    //implicitly
    fwrite($handle, json_encode($precios_7));
    fclose($handle);
    $my_file = '../json/rango8.json';
    $handle = fopen($my_file, 'w') or die('Cannot open file:  ' . $my_file);
    //implicitly
    fwrite($handle, json_encode($precios_8));
    fclose($handle);
    $my_file = '../json/rango9.json';
    $handle = fopen($my_file, 'w') or die('Cannot open file:  ' . $my_file);
    //implicitly
    fwrite($handle, json_encode($precios_9));
    fclose($handle);
    $my_file = '../json/rango10.json';
    $handle = fopen($my_file, 'w') or die('Cannot open file:  ' . $my_file);
    //implicitly
    fwrite($handle, json_encode($precios_10));
    fclose($handle);
    return $modelos;
}
if ($var = get_csv("BASE_FINAL.csv")) {
    $marcas_nvo = marcas($var['marcas']);
    $mod = modelos($var);
}
?>


Ejemplo n.º 10
0
 function cache_instructions($pi, $params = array())
 {
     global $Config;
     global $DBInfo;
     $pagename = $this->name;
     // update aliases
     if (!empty($Config['use_alias'])) {
         $ac = new Cache_text('alias');
         // is it removed ?
         if ($ac->exists($pagename) and empty($pi['#alias']) and empty($pi['#title'])) {
             // remove aliases
             store_aliases($pagename, array());
         } else {
             if (!$ac->exists($pagename) or $ac->mtime($pagename) < $this->mtime() or !empty($_GET['update_alias'])) {
                 $as = array();
                 // parse #alias
                 if (!empty($pi['#alias'])) {
                     $as = get_csv($pi['#alias']);
                 }
                 // add #title as a alias
                 if (!empty($pi['#title'])) {
                     $as[] = $pi['#title'];
                 }
                 // update aliases
                 store_aliases($pagename, $as);
             }
         }
     }
     // update #redirect
     $rc = new Cache_Text('redirect');
     $old = $rc->fetch($pagename);
     if ($old or isset($pi['#redirect'][0])) {
         // update invert redirect index
         $rc2 = new Cache_Text('redirects');
         if (!empty($params['refresh']) or $old != $pi['#redirect']) {
             // update direct cache
             $rc->update($pagename, $pi['#redirect']);
             $nr = $pi['#redirect'];
             if (($p = strpos($nr, '#')) > 0) {
                 // get pagename only
                 //$anchor = substr($nr, $p);
                 $nr = substr($nr, 0, $p);
             }
             if (!isset($nr[0])) {
                 $rc->remove($pagename);
             } else {
                 if (!preg_match('@^https?://@', $nr)) {
                     // not a URL redirect
                     // add redirect links
                     $redirects = $rc2->fetch($nr);
                     if (empty($redirects)) {
                         $redirects = array();
                     }
                     $redirects = array_merge($redirects, array($pagename));
                     $rc2->update($nr, $redirects);
                 }
             }
             while ($old != '' and $old != false) {
                 // get pagename only
                 if (($p = strpos($old, '#')) > 0) {
                     //$anchor = substr($old, $p);
                     $old = substr($old, 0, $p);
                 }
                 if ($nr == $old) {
                     break;
                 }
                 // check A#s-1 ~ A#s-2 redirects
                 // delete redirect links
                 $l = $rc2->fetch($old);
                 if ($l !== false and is_array($l)) {
                     $redirects = array_diff($l, array($pagename));
                     if (empty($redirects)) {
                         $rc2->remove($old);
                     } else {
                         $rc2->update($old, $redirects);
                     }
                 }
                 break;
             }
         }
     }
     if (!empty($Config['use_keywords']) or !empty($Config['use_tagging']) or !empty($_GET['update_keywords'])) {
         $tcache = new Cache_text('keyword');
         $cache = new Cache_text('keywords');
         $cur = $tcache->fetch($pagename);
         if (empty($cur)) {
             $cur = array();
         }
         $keys = array();
         if (empty($pi['#keywords'])) {
             $tcache->remove($pagename);
         } else {
             $keys = explode(',', $pi['#keywords']);
             $keys = array_map('trim', $keys);
             if (!$tcache->exists($pagename) or $tcache->mtime($pagename) < $this->mtime() or !empty($_GET['update_keywords'])) {
                 $tcache->update($pagename, $keys);
             }
         }
         $adds = array_diff($keys, $cur);
         $dels = array_diff($cur, $keys);
         // merge new keywords
         foreach ($adds as $a) {
             if (!isset($a[0])) {
                 continue;
             }
             $l = $cache->fetch($a);
             if (!is_array($l)) {
                 $l = array();
             }
             $l = array_merge($l, array($pagename));
             $cache->update($a, $l);
         }
         // remove deleted keywords
         foreach ($dels as $d) {
             if (!isset($d[0])) {
                 continue;
             }
             $l = $cache->fetch($d);
             if (!is_array($l)) {
                 $l = array();
             }
             $l = array_diff($l, array($pagename));
             $cache->update($d, $l);
         }
     }
     if (!empty($pi['#title']) and !empty($Config['use_titlecache'])) {
         $tc = new Cache_text('title');
         $old = $tc->fetch($pagename);
         if (!isset($pi['#title'])) {
             $tc->remove($pagename);
         } else {
             if ($old != $pi['#title'] or !$tcache->exists($pagename) or !empty($_GET['update_title'])) {
                 $tc->update($pagename, $pi['#title']);
             }
         }
     }
     return;
 }
Ejemplo n.º 11
0
 function get_acl($action = 'read', &$options)
 {
     if (in_array($options['id'], $this->allowed_users)) {
         return 1;
     }
     $pg = $options['page'];
     $user = $options['id'];
     $groups = array();
     $groups[] = '@ALL';
     $ip_info = array();
     // ip address based info
     if ($user != 'Anonymous') {
         $groups[] = '@User';
     } else {
         $this->acl_ip_info($ip_info);
     }
     // has acl ip address info ?
     if (!empty($ip_info)) {
         $myip = ip2long($_SERVER['REMOTE_ADDR']);
         $mygrp = array();
         $rules = array_keys($ip_info);
         foreach ($rules as $rule) {
             $ret = normalize_network($rule);
             if (!$ret) {
                 continue;
             }
             // ignore
             $network = $ret[0];
             $netmask = $ret[1];
             #print $network . '/' . $netmask . "\n";
             if (is_int($netmask)) {
                 $netmask = 0xffffffff << 32 - $netmask;
             } else {
                 $netmask = ip2long($netmask);
             }
             $network = ip2long($network);
             if (($myip & $netmask) == ($network & $netmask)) {
                 $mygrp = array_merge($mygrp, $ip_info[$rule]);
             } else {
                 if ($myip == $network) {
                     $mygrp = array_merge($mygrp, $ip_info[$rule]);
                 }
             }
         }
         // group found ?
         if (!empty($mygrp)) {
             $groups = array_merge($groups, $mygrp);
         }
     }
     $groups[] = $user;
     $allowed = array();
     $denied = array();
     $protected = array();
     $gpriority = array();
     # group priorities
     #get group info.
     $matches = preg_grep('/^(@[^\\s]+)\\s+(.*,?' . $user . ',?.*)/', $this->AUTH_ACL);
     foreach ($matches as $line) {
         $grp = preg_split('/\\s+/', $line);
         $groups[] = $grp[0];
         if ($grp[2]) {
             $gpriority[$grp[0]] = $grp[2];
         } else {
             $gpriority[$grp[0]] = 2;
         }
         # default group priority
     }
     $gregex = implode('|', $groups);
     #get ACL info.
     #$matches= preg_grep('/^('.$pg.'|\*)\s+('.$gregex.')\s+/', $this->AUTH_ACL);
     $matches = preg_grep('/^[^#@].*\\s+(' . $gregex . ')\\s+/', $this->AUTH_ACL);
     if (count($matches)) {
         foreach ($matches as $rule) {
             #if (in_array($rule[0],array('@','#'))) continue;
             $rule = preg_replace('/#.*$/', '', $rule);
             # delete comments
             $rule = rtrim($rule);
             $tmp = preg_match('/^(.*)\\s+(' . $gregex . ')\\s+(allow|protect|deny)\\s*(.*)?$/i', $rule, $acl);
             if (!$tmp) {
                 continue;
             }
             if (!$acl[4]) {
                 $acl[4] = '*';
             }
             if ($acl[1] != '*' and $acl[1] != $pg) {
                 $prules = get_csv($acl[1]);
                 // a regex or a simplified pattern like as
                 // HelpOn* -> HelpOn.*
                 // MoniWiki/* -> MoniWiki\/.*
                 $found = false;
                 foreach ($prules as $prule) {
                     if ($prule == $pg) {
                         $found = true;
                         break;
                     } else {
                         $pre = '^';
                         $post = '$';
                         if ($prule[0] == '^') {
                             $pre = '';
                         }
                         if (substr($prule, -1) == '$') {
                             $post = '';
                         }
                         // is it a regex or a simplified pattern
                         $prule = preg_replace(array('/(?:\\.)?\\*/', "/(?<!\\\\)\\//"), array('.*', '\\/'), $prule);
                         if (@preg_match("/{$pre}{$prule}{$post}/", $pg)) {
                             $found = true;
                             break;
                         }
                     }
                 }
                 if (!$found) {
                     continue;
                 }
             }
             if ($acl[3] == 'allow') {
                 $tmp = explode(',', $acl[4]);
                 $tmp = array_flip($tmp);
                 if ($acl[2] == $user) {
                     $pri = 4;
                 } else {
                     if ($acl[2] == '@ALL') {
                         $pri = 1;
                     } else {
                         $pri = !empty($gpriority[$acl[2]]) ? $gpriority[$acl[2]] : 2;
                     }
                 }
                 # get group prio
                 $keys = array_keys($tmp);
                 foreach ($keys as $t) {
                     if (isset($allowed[$t]) and $allowed[$t] > $pri) {
                         unset($tmp[$t]);
                     } else {
                         $tmp[$t] = $pri;
                     }
                     if (isset($denied[$t]) and $denied[$t] <= $pri) {
                         unset($denied[$t]);
                     }
                 }
                 $allowed = array_merge($allowed, $tmp);
             } else {
                 if ($acl[3] == 'deny') {
                     $tmp = explode(',', $acl[4]);
                     $tmp = array_flip($tmp);
                     if ($acl[2] == $user) {
                         $pri = 4;
                     } else {
                         if ($acl[2] == '@ALL') {
                             $pri = 1;
                         } else {
                             $pri = $gpriority[$acl[2]] ? $gpriority[$acl[2]] : 2;
                         }
                     }
                     # set group prio
                     $keys = array_keys($tmp);
                     foreach ($keys as $t) {
                         if (isset($denied[$t]) and $denied[$t] > $pri) {
                             unset($tmp[$t]);
                         } else {
                             $tmp[$t] = $pri;
                         }
                         if (isset($allowed[$t]) and $allowed[$t] <= $pri) {
                             unset($allowed[$t]);
                         }
                     }
                     $denied = array_merge($denied, $tmp);
                 } else {
                     if ($acl[3] == 'protect') {
                         $tmp = explode(',', $acl[4]);
                         $tmp = array_flip($tmp);
                         $protected = array_merge($protected, $tmp);
                     }
                 }
             }
         }
     }
     $protected = array_keys($protected);
     if (!empty($this->DB->acl_debug)) {
         ob_start();
         print "<h4>" . _("ACL groups") . "</h4>\n";
         print implode(',', $groups);
         print "\n";
         print "<h4>" . _("Allowed ACL actions") . "</h4>\n";
         foreach ($allowed as $k => $v) {
             print $k . " ({$v}),";
         }
         #print_r($allowed);
         print "\n";
         print "<h4>" . _("Denied ACL actions") . "</h4>\n";
         foreach ($denied as $k => $v) {
             print $k . " ({$v}),";
         }
         #print_r($denied);
         print "\n";
         print "<h4>" . _("Protected ACL actions") . "</h4>\n";
         print implode(',', $protected);
         $options['msg'] .= ob_get_contents();
         ob_end_clean();
     }
     $this->_acl_ok = 1;
     $this->_allowed = $allowed;
     $this->_denied = $denied;
     $this->_protected = $protected;
     return array($allowed, $denied, $protected);
 }
Ejemplo n.º 12
0
 private function _initialize_queue()
 {
     $this->char_list = get_csv($this->filename_csv);
     $this->queues = GutenManager::create_queues($this->char_list);
 }