コード例 #1
0
ファイル: get.php プロジェクト: akiyatkin/files
        return false;
    }
    return infra_theme($folder . $result);
}, array($fdata['path']), isset($_GET['re']));
$ans = array('src' => $isrc);
if (!$src) {
    if (!infra_isphp()) {
        header('HTTP/1.0 404 Not Found');
    }
    return;
}
$fdata = infra_srcinfo($src);
if (in_array($fdata['ext'], array('docx'))) {
    $txt = files\Docx::get($src);
    return Ans::txt($txt);
}
if (in_array($fdata['ext'], array('mht'))) {
    $txt = files\Mht::get($src);
    return Ans::txt($txt);
}
if (in_array($fdata['ext'], array('xls', 'xlsx'))) {
    $ans = files\Xlsx::get($src);
    return Ans::ans($ans);
}
if (in_array($fdata['ext'], array('tpl', 'html', 'htm', 'php'))) {
    $txt = infra_loadTEXT($src);
    return Ans::txt($txt);
}
if (!infra_isphp()) {
    header('HTTP/1.0 400 Bad Request');
}
コード例 #2
0
ファイル: filters.php プロジェクト: akiyatkin/catalog
             if (preg_match("/[:]/", $pos[$prop['posid']])) {
                 continue;
             }
             if (!Xlsx::isSpecified($pos[$prop['posid']])) {
                 continue;
             }
             $r = false;
             if ($prop['separator']) {
                 $arval = explode($prop['separator'], $pos[$prop['posid']]);
             } else {
                 $arval = array($pos[$prop['posid']]);
             }
             foreach ($arval as $i => $value) {
                 $idi = infra_forFS($value);
                 $id = mb_strtolower($idi);
                 if (!Xlsx::isSpecified($id)) {
                     continue;
                 }
                 $r = true;
                 $params[$k]['option'][$id]['filter']++;
             }
             if ($r) {
                 $params[$k]['filter']++;
             }
             //Позиций с этим параметром
         }
     }
     //У скольки позиций в выборке у которых этот параметр не указан
     $params[$k]['nofilter'] = sizeof($poss) - $params[$k]['filter'];
     //
 }
コード例 #3
0
ファイル: position.php プロジェクト: akiyatkin/catalog
use itlife\files\Xlsx;
infra_cache_no();
$orig_val = infra_toutf(strip_tags($_GET['val']));
$orig_art = infra_toutf(strip_tags($_GET['art']));
$val = infra_strtolower($orig_val);
$art = infra_strtolower($orig_art);
$args = array($val, $art);
$ans = array();
$pos = Catalog::cache('position', function ($val, $art) {
    $data = Catalog::init();
    // список всей продукции
    return Xlsx::runPoss($data, function (&$pos, $i, &$group) use(&$val, &$art) {
        if (mb_strtolower($pos['producer']) !== $val) {
            return;
        }
        if (mb_strtolower($pos['article']) !== $art) {
            return;
        }
        return $pos;
    });
}, $args, isset($_GET['re']));
if (isset($_GET['seo'])) {
    if (!$pos) {
        return infra_err($ans, 'Position not found');
    }
    $link = $_GET['seo'];
    $link = $link . '/' . $pos['producer'] . '/' . $pos['article'];
    $ans['external'] = '*catalog/seo.json';
    $ans['canonical'] = infra_view_getPath() . '?' . $link;
    return infra_ans($ans);
}
コード例 #4
0
ファイル: producers.php プロジェクト: oduvanio/catalog
$fd = Catalog::initMark($ans);
if (isset($_GET['lim'])) {
    $lim = $_GET['lim'];
} else {
    $lim = '0,20';
}
$p = explode(',', $lim);
if (sizeof($p) != 2) {
    return infra_err($ans, 'Is wrong paramter lim');
}
$start = (int) $p[0];
$count = (int) $p[1];
$args = array($start, $count);
$list = Catalog::cache('producers.php', function ($start, $count) {
    $ans = array();
    $conf = infra_config();
    $data = Catalog::init();
    $prods = array();
    Xlsx::runPoss($data, function (&$pos) use(&$prods) {
        @$prods[$pos['Производитель']]++;
    });
    arsort($prods, SORT_NUMERIC);
    $prods = array_slice($prods, $start, $count);
    return $prods;
}, $args, isset($_GET['re']));
$ans['menu'] = infra_loadJSON('*catalog/menu.json');
$ans['list'] = $list;
$conf = infra_config();
$ans['breadcrumbs'][] = array('href' => '', 'title' => $conf['catalog']['title'], 'add' => 'group');
$ans['breadcrumbs'][] = array('href' => 'producers', 'title' => 'Производители');
return infra_ret($ans);
コード例 #5
0
ファイル: read.php プロジェクト: akiyatkin/files
$text = Mht::get('*files/tests/resources/' . $name);
if (mb_strlen($text) != 1935) {
    return Ans::err($ans, 'Cant read ' . $name . ' ' . strlen($text));
}
$name = 'test.html';
$text = Mht::get('*files/tests/resources/' . $name);
if (strlen($text) != 1073) {
    return Ans::err($ans, 'Cant read ' . $name . ' ' . strlen($text));
}
$data = Xlsx::init('*files/tests/resources/test.xlsx');
if (!$data) {
    return Ans::err($ans, 'Cant read test.xlsx');
}
$data = Xlsx::init('*files/tests/resources/test.csv');
if (!$data) {
    return Ans::err($ans, 'Cant read test.csv');
}
if (sizeof($data['childs']) != 1) {
    return Ans::err($ans, 'Cant read test.csv ' . sizeof($data['childs']));
}
$num = ini_get('mbstring.func_overload');
if ($num != 0) {
    $ans['class'] = 'bg-warning';
    return Ans::err($ans, 'mbstring.func_overload should be 0, not ' . $num);
} else {
    $data = Xlsx::get('*files/tests/resources/test.xls');
    if (sizeof($data['childs'][0]['data']) != 30) {
        return Ans::err($ans, 'Cant read test.xls ' . sizeof($data['childs'][0]['data']));
    }
}
return Ans::ret($ans, 'tpl, mht, docx, xls, xlsx read ok!');
コード例 #6
0
ファイル: filters.php プロジェクト: oduvanio/catalog
             }
             if (!Xlsx::isSpecified($pos['more'][$v['posid']])) {
                 continue;
             }
             $params[$k]['option'][$pos['more'][$v['posid']]]['filter']++;
             $params[$k]['filter']++;
         }
     } else {
         $mymd = array_diff_key($md, array_flip(array($v['mdid'])));
         $res = Catalog::search($mymd);
         $poss = $res['list'];
         foreach ($poss as &$pos) {
             if (preg_match("/[:]/", $pos[$v['posid']])) {
                 continue;
             }
             if (!Xlsx::isSpecified($pos[$v['posid']])) {
                 continue;
             }
             $params[$k]['option'][$pos[$v['posid']]]['filter']++;
             $params[$k]['filter']++;
         }
     }
     $params[$k]['nofilter'] = sizeof($poss) - $params[$k]['filter'];
 }
 //ДОБАВИЛИ option values
 foreach ($params as $k => $v) {
     if ($v['more']) {
         $right = array('more', $v['mdid']);
         $add = 'more.';
     } else {
         $right = array($v['mdid']);
コード例 #7
0
ファイル: Catalog.php プロジェクト: oduvanio/catalog
 public static function getPos(&$pos)
 {
     $args = array($pos['producer'], $pos['article']);
     return Catalog::cache('getPos', function () use($pos) {
         Xlsx::addFiles($pos);
         $files = explode(',', @$pos['Файлы']);
         foreach ($files as $f) {
             if (!$f) {
                 continue;
             }
             $f = trim($f);
             $conf = infra_config();
             Xlsx::addFiles($pos, $conf['catalog']['dir'] . $f);
         }
         $files = array();
         foreach ($pos['files'] as $f) {
             if (is_string($f)) {
                 $f = infra_theme($f);
                 //убрали звездочку
                 $d = infra_srcinfo(infra_toutf($f));
             } else {
                 $d = $f;
                 $f = $d['src'];
             }
             $d['size'] = round(filesize(infra_tofs($f)) / 1000000, 2);
             if (!$d['size']) {
                 $d['size'] = '0.01';
             }
             $files[] = $d;
         }
         $pos['files'] = $files;
         if ($pos['texts']) {
             foreach ($pos['texts'] as $k => $t) {
                 $pos['texts'][$k] = infra_loadTEXT('*files/get.php?' . $t);
             }
         }
         return $pos;
     }, $args);
 }