/**
 * Creates an array representation of an html tag.
 *
 * @param string       $selector Syntax: 'tag#id.class1.class2...classN', all elements are optional. Default tag is
 *                               'div'.
 * @param array|string $attrs    Can also receive the value of $content, but BEWARE: the content array MUST have
 *                               integer keys, otherwise it will be interpreted as an attributes array.
 * @param array|string $content
 * @return array
 */
function h($selector, $attrs = [], $content = [])
{
    $id = str_extract($selector, '/#([\\w\\-]*)/');
    $classes = str_extract($selector, '/\\.([\\w\\-\\.]*)/');
    $tag = $selector === '' ? 'div' : $selector;
    $classes = array_filter(explode('.', $classes));
    if (is_string($attrs)) {
        $content = $attrs;
        $attrs = [];
    } else {
        if (array_key_exists(0, $attrs)) {
            // supports having a null as the first array item.
            $content = $attrs;
            $attrs = [];
        }
    }
    if (isset($attrs['class'])) {
        $classes = array_merge($classes, explode(' ', $attrs['class']));
        unset($attrs['class']);
    }
    $outAttrs = [];
    if ($id) {
        $outAttrs['id'] = $id;
    }
    if ($classes) {
        $outAttrs['class'] = implode(' ', $classes);
    }
    // Put ID and CLASS attributes first.
    if ($outAttrs) {
        $outAttrs = array_merge($outAttrs, $attrs);
    } else {
        $outAttrs = $attrs;
    }
    return ['<' => $tag, '@' => $outAttrs, '[' => $content];
}
Exemple #2
0
function mail_prep($id)
{
    $r = mail_mails();
    if ($_SESSION['auth'] < 3) {
        $r = array($_SESSION['qbin']['adminmail'] => 1);
    }
    if ($r) {
        ksort($r);
        foreach ($r as $k => $v) {
            $j = 'jumpvalue(\'' . $id . '_' . addslashes($k) . '\'); Close(\'popup\');';
            $ret .= ljb('txtx', $j, '', str_extract('@', $k, 0, 0)) . ' ';
        }
        return divc('nb_pages', $ret);
    }
}
Exemple #3
0
function addfonts_j($var1, $var2, $res)
{
    $r = msql_read('', 'public_addfonts', '');
    if ($r) {
        $rk = array_keys_r($r, 0, 'k');
    }
    $res = ajx(substr($res, 0, -1), 1);
    $res = embed_detect($res, '{', '}', '');
    $res = str_replace(array('"', "'", ' ', "\n", "\r", "\t", "?#iefix", "?", "!"), '', $res);
    $ra = explode(';', $res);
    $nb = count($ra);
    for ($i = 0; $i < $nb; $i++) {
        list($attrb, $value) = split_right(':', $ra[$i], 0);
        if ($attrb == 'font-family') {
            $rb['name'] = $value;
        }
        $rab = explode(',', $ra[$i]);
        if ($rab) {
            foreach ($rab as $k => $va) {
                $rt = embed_detect($va, 'url(', ')', '');
                //echo $rt.br().br();
                if ($rt && !$rk[$rb['name']]) {
                    $rs = str_extract('#', $rt, 0, 0);
                    $xt = strrchr_b($rt, '.');
                    if ($xt && substr($rs, 0, 4) == 'http' && $xt != 'eot?') {
                        $rb[$xt] = $rs;
                    } else {
                        $noturl = 1;
                    }
                }
            }
        }
    }
    if ($rb[0]) {
        $rb = msq_reorder($rb);
    }
    //p($rb);
    $dfb['_menus_'] = array('name', 'eot', 'woff', 'svg', 'ttf');
    if (count($rb) > 1) {
        $r = msql_modif('users', 'public_addfonts', $rb, $dfb, 'push', '');
        //p($rb);
        return addf_read($r);
    } else {
        return btn('txtred', $noturl ? 'not absolte url' : 'already_exists');
    }
}
Exemple #4
0
 /**
  * Preset constructor.
  *
  * @param string $selector A CSS-compatible selector, supporting tag and class names.
  */
 public function __construct($selector)
 {
     $this->matchTag = str_extract($selector, '/^[\\w\\-]+/');
     $classes = '';
     do {
         $class = str_extract($selector, '/^\\.([\\w\\-]+)/');
         if ($class) {
             $classes .= sprintf('(?=.*\\b%s\\b)', preg_quote($class));
         }
     } while ($class);
     $this->matchClass = $classes ? "/^{$classes}/" : '';
     $prop = str_extract($selector, '/^\\[([\\w\\-]+)/');
     if ($prop) {
         $this->matchPropName = $prop;
         $this->matchPropValue = str_extract($selector, '/^=([^\\]]+)\\]/');
     }
 }
Exemple #5
0
function stat_list($c, $n)
{
    req('spe');
    $j = 'popup_plup___stats_stat*list_';
    //echo $c.'-'.$n;
    if ($c == 'nbv' or $c == 'nbu') {
        $ret = 'days: ' . $n . br();
    }
    if ($c == 'nbf') {
        $ret = 'user: '******'nbp') {
        $ret = 'article: ' . $n . br();
    }
    $sql = stat_list_sql($c, $n);
    $r = sql_b($sql, '', 0);
    //p($r);
    if ($c == 'nbv' or $c == 'nbu' or $c == 'nbf') {
        if ($r) {
            foreach ($r as $k => $v) {
                $id = substr(str_extract('&', $v[0]), 5);
                if (is_numeric($id)) {
                    $suj = suj_of_id($id);
                    //else $suj=$id;
                    $flw = lj('', 'popup_popart___' . $id, picto(articles));
                    $ret .= $v[1] . ' ' . lj('txtx', $j . 'nbp_' . $id, $suj) . ' ' . $flw . br();
                }
            }
        }
    } elseif ($c == 'nbp') {
        foreach ($r as $k => $v) {
            $ret .= $v[0] . ' ' . $v[3] . ' ' . lj('txtx', $j . 'nbf_' . $v[1], $v[2]) . ' ' . br();
        }
    }
    return $ret;
}
Exemple #6
0
function piege_daily($v)
{
    $d = trap_v_id($v, 'video/');
    if (!$d) {
        $d = trap_v_id($v, 'swf/');
    }
    $d = str_extract('_', $d, 0, 0);
    if ($d) {
        return '[' . $d . ':video]';
    }
}
Exemple #7
0
function rssin_load($f)
{
    $alx = alx();
    //sesmk('alx');
    $r = rssin_xml($f);
    if (!$r) {
        $r = rssin_old($f);
    }
    reqp('search');
    if ($r) {
        foreach ($r as $k => $v) {
            list($suj, $lnk, $dat) = $v;
            if (strpos($lnk, 'feedproxy')) {
                $lnk = feedproxy($lnk);
            }
            if (strpos($lnk, 'spip.')) {
                $lnk = strdeb($lnk, 'spip.') . str_extract('/spip', $lnk, 1, 1);
            }
            $id = recognize_article($lnk, $suj, $alx);
            $ret[] = array($suj, $lnk, $dat, $id);
        }
    }
    return $ret;
}
Exemple #8
0
function build_mod_subname($v)
{
    list($m, $p, $t, $c, $e, $g, $ch, $h) = $v;
    $t = str_extract(':', $t, 0, 0);
    if (strpos($p, '§')) {
        $p = str_extract('§', $p, 0, 1);
    }
    if (strpos($p, '__')) {
        $p = str_extract('__', $p, 0, 1);
    }
    $p = str_extract(':', $p, 0, 0);
    $p = str_extract(',', $p, 0, 0);
    $p = str_extract(' ', $p, 0, 0);
    $mb = mimes($m, $t ? $t : $p);
    return ($mb ? $mb . ' ' : '') . $m;
}
Exemple #9
0
 /**
  * Highlights syntax on a string of PHP source code.
  *
  * @param string $code The raw PHP code.
  * @return string HTML formatted source code.
  */
 static function highlight($code)
 {
     $o = highlight_string("<?php;{$code} ?>", true);
     $o = str_extract($o, '%php</span>.*?</span>(.*)<span[^>]*>\\?&gt;%s');
     return $o !== '' ? $o : $code;
 }
Exemple #10
0
function finder_flap_files($r, $o, $p)
{
    $jc = fi_droot();
    foreach ($r as $k => $v) {
        if (!$v['r']) {
            $furl = $jc . $v['url'];
            if ($v['img']) {
                list($w, $h) = fi_sizes($furl);
                $ico = ljb('', 'SaveBf', 'photo_users(slash)' . $v['j'] . '' . $w . '_' . $h, $v['img']) . ' ';
            } else {
                $ico = mimes($v['xt'], '', 18) . ' ';
            }
            $op = lkt('txtsmall', $furl, picto('url')) . ' ';
            if ($v['xt'] == '.mp3') {
                $mp3 = 1;
            }
            if ($v['xt'] == '.jpg') {
                $jpg = 1;
            }
            $lk = lj('', 'popup_fifunc___fi*reader*pop_' . $v['j'] . $v['dist'], etc($v['f'], 40)) . ' ';
            if (!auth(4)) {
                $sh = lkc('', 'plug/download.php?file=' . $furl, fi_pic('download'));
            } elseif ($v['prop'] == $_SESSION['qb']) {
                $sh = fi_info_shared($v['url'], randid());
            }
            $ret .= divc('', $ico . $op . $sh . $lk);
        }
    }
    $dir = '../' . str_extract('/', $furl, 1, 0);
    if ($mp3) {
        $rt = lj('', 'popup_callp___pop_jukebox_' . $dir . '_autosize', picto('play'));
    }
    if ($jpg) {
        $rt = lj('', 'popup_callp___pop_gallery*j_' . $dir . '_autosize', picto('play'));
    }
    return $rt . $ret;
}
Exemple #11
0
function inject_sql($r, $d)
{
    $d = str_replace(') VALUES', '),', $d);
    $d = str_replace(array('`', ", ''", "''"), array('', ", '-'", "\\'"), $d);
    $rb = explode("), '", $d);
    //very bad
    foreach ($rb as $k => $v) {
        if (substr($v, 0, 6) == 'INSERT') {
            $m = 1;
        } else {
            $m = 0;
        }
        $v = str_extract('(', $v, 0, 1);
        list($key, $v) = split_right(", '", $v);
        //echo $key.'-'.$v.br();
        $v = trim($v);
        $rd = '';
        if ($m) {
            $rc = explode(',', $v);
        } elseif ($v) {
            $rc = explode("', '", $v);
        }
        //p($rc);
        foreach ($rc as $vc) {
            if (substr($vc, 0, 1) == "'") {
                $vc = substr($vc, 1);
            }
            if (substr($vc, -1) == "'") {
                $vc = substr($vc, 0, -1);
            }
            $rd[] = trim($vc);
        }
        if ($m) {
            $r['_menus_'] = $rd;
        } elseif ($key && $rd) {
            $r[trim($key)] = $rd;
        }
    }
    return $r;
}
Exemple #12
0
function video_viewer($iv, $cr_div, $n)
{
    $r = $_SESSION['iv' . $iv];
    $_SESSION['cur_div'] = $cr_div;
    $jx = 'iv' . $iv . '_vview___' . $iv . '_' . $cr_div . '_';
    $ret .= divc('nb_pages right', nb_pages_j($r, $jx, $n));
    $ret .= bal('h3', lka(htac('read') . $r[$n][0], suj_of_id($r[$n][0])));
    $ret .= video_auto(str_extract('§', $r[$n][1], 0, 1), prma('content'), $r[$n][0], 3);
    return $ret . br();
}
Exemple #13
0
function functions_list($view, $f)
{
    $_SESSION['rec'] = array();
    if ($view) {
        $_GET['view'] = $view;
    }
    if ($f) {
        $_GET['func'] = $f;
    }
    $dr = str_extract('/', $view, 1, 0);
    if (!$view) {
        $dr = 'plug';
    }
    if (substr($dr, -1) == '/') {
        $dr = substr($dr, 0, -1);
    }
    $rep = scrut_dirb($dr);
    if ($rep) {
        ksort($rep);
    }
    $ret = explode_dirc($rep, $dr, 'treat_funcs');
    //if($_SESSION['rec'])asort($_SESSION['rec']);
    return array($rep, $ret);
}
Exemple #14
0
function db_init($f)
{
    $dr = str_extract('/', $f, 1, 0);
    if (!is_dir($dr)) {
        mkdir_r($dr);
    }
    if (!is_file($f)) {
        write_file($f, '');
    }
}