Пример #1
0
function block($query, $template, $separator = "", $template_up = "", $paging = "", $errormessage = "", $rrid = 0)
{
    global $DB, $Q, $Q2, $module_name, $module_filepath, $page, $id, $inf, $paging_count, $usd_price, $searchname;
    $SQL = "SELECT * FROM " . $module_name . " WHERE id = '1372'";
    $result = $Q->query($DB, $SQL);
    $curs_usd = mysql_fetch_assoc($result);
    $curs_usd = $curs_usd[f1];
    if (ereg("id=[^ ]+[^0-9 ]+", $query)) {
        return $errormessage;
    }
    if (ereg("id=\$", $query)) {
        return $errormessage;
    }
    if (ereg("id= ", $query)) {
        return $errormessage;
    }
    $query = correct_query($query);
    $filename = $module_filepath . "/_t/_items/" . $template . ".tpl";
    if (!file_exists($filename)) {
        switch ($template) {
            case "date":
                $template_normal = "[date]";
                break;
            case "name":
                $template_normal = "[name]";
                break;
            case "anons":
                $template_normal = "[anons]";
                break;
            case "text":
                $template_normal = "[text]";
                break;
            case "f1":
                $template_normal = "[f1]";
                break;
        }
    }
    if (!$template_normal) {
        if (!file_exists($filename)) {
            return "File " . $template . ".tpl not found.";
        }
        $f = file($filename);
        $template_normal = join("", $f);
    }
    if ($separator) {
        $filename = $module_filepath . "/_t/_items/" . $separator . ".tpl";
        if (file_exists($filename)) {
            $f = file($filename);
            $separator = join("", $f);
        } else {
            return "File " . $separator . ".tpl not found.";
        }
    }
    $filename = $module_filepath . "/_t/_items/" . $template_up . ".tpl";
    if (file_exists($filename)) {
        $f = file($filename);
        $template_up = join("", $f);
    }
    $count = "";
    if (!ereg("^[0-9]+", $query)) {
        $query = "select * from " . $module_name . " where " . $query;
        if ($paging) {
            if (!$page) {
                $page = 1;
            }
            $query .= " limit " . ($page - 1) * $paging . "," . $paging;
        }
        $Q->query($DB, $query);
        $count = $Q->numrows();
        $standart_query = 1;
    } else {
        $q = split(",", $query);
        $query = $q[1];
        $count = $q[0];
        if (trim($query)) {
            $query = "select * from " . $module_name . " where " . $query;
            $Q->query($DB, $query);
            $info = $Q->getrow();
        }
        $standart_query = 0;
    }
    // recourse rid
    if ($standart_query && $rrid) {
        $query = ereg_replace("limit.*", "", $query);
        rblock($query, $rrid);
        $standart_query = 2;
        $count = $paging;
        $paging_count = count($inf);
    }
    //echo $query;
    $row = array();
    //echo $count;
    for ($i = 0; $i < $count; $i++) {
        if ($standart_query == 1) {
            $info = $Q->getrow();
        }
        if ($standart_query == 2) {
            $info = $inf[($page - 1) * $paging + $i];
        }
        if (!trim($info)) {
            $count = $i;
            break;
        }
        $anonspicture = "";
        $anypicture = "";
        $ridname = "";
        if (ereg("\\[ridname\\]", $template_normal)) {
            $Q2->query($DB, "select * from " . $module_name . " where id=" . $info[rid]);
            $info2 = $Q2->getrow();
            $ridname = $info2[name];
        }
        if (ereg("anypicture", $template_normal)) {
            $s = getfiles_pictures($module_filepath . "/attachments/" . $info[id] . "/");
            if (trim($s[0])) {
                $anypicture = "<img src=/attachments/" . $info[id] . "/" . $s[0] . " border=0";
            }
        }
        if (ereg("anonspicture", $template_normal)) {
            $filename = $module_filepath . "/attachments/" . $info[id] . "/anons.jpg";
            if (file_exists($filename)) {
                $anonspicture = "<img src=/attachments/" . $info[id] . "/anons.jpg border=0";
            }
        }
        $date = ereg_replace(" .+", "", $info[date]);
        $date = split("\\-", $date);
        $date = $date[2] . "." . $date[1] . "." . $date[0];
        $r = ereg_replace("\\[name\\]", $info[name], $template_normal);
        $r = ereg_replace("\\[id\\]", $info[id], $r);
        $r = ereg_replace("\\[date\\]", $date, $r);
        $r = ereg_replace("\\[lang\\]", $info[lang], $r);
        $r = ereg_replace("\\[archive\\]", $info[archive], $r);
        $r = ereg_replace("\\[aname\\]", $info[aname], $r);
        $r = ereg_replace("\\[rid\\]", $info[rid], $r);
        $r = ereg_replace("\\[ridname\\]", $ridname, $r);
        $r = ereg_replace("\\[anons\\]", $info[anons], $r);
        if (ereg("\\[text\\]", $r)) {
            $r = ereg_replace("\\[text\\]", prepare_text($info), $r);
        }
        $r = ereg_replace("\\[f1\\]", $info[f1], $r);
        $r = ereg_replace("\\[f2\\]", $info[f2], $r);
        $r = ereg_replace("\\[f3\\]", $info[f3], $r);
        $r = ereg_replace("\\[f4\\]", $info[f4], $r);
        $r = ereg_replace("\\[f5\\]", $info[f5], $r);
        $r = ereg_replace("\\[f6\\]", $info[f6], $r);
        $r = ereg_replace("\\[f7\\]", $info[f7], $r);
        $r = ereg_replace("\\[f8\\]", $info[f8], $r);
        $r = ereg_replace("\\[f9\\]", $info[f9], $r);
        $r = ereg_replace("\\[number\\]", "" . ($i + 1) . "", $r);
        if ($anonspicture) {
            $r = ereg_replace("\\[anonspicture(.*)\\]", $anonspicture . " \\1 >", $r);
        } else {
            $r = ereg_replace("\\[anonspicture(.*)\\]", "", $r);
        }
        if ($anypicture) {
            $r = ereg_replace("\\[anypicture(.*)\\]", $anypicture . " \\1 >", $r);
        } else {
            $r = ereg_replace("\\[anypicture(.*)\\]", "", $r);
        }
        $row[$i] = $r;
    }
    for ($i = 0; $i < $count; $i++) {
        $row[$i] = ereg_replace("\\?\\>", "", $row[$i]);
        $r = preg_match_all("/<\\?([^]+)/U", $row[$i], $res, PREG_PATTERN_ORDER);
        //	$row[$i]=ereg_replace("\<\?[^\?]+\?\>","",$row[$i]);
        $row[$i] = ereg_replace("\\<\\?[^]+", "", $row[$i]);
        $row[$i] = split("", $row[$i]);
        for ($o = 0; $o < count($res[1]); $o++) {
            $res[1][$o] = ereg_replace("", "\\?\\>", $res[1][$o]);
            eval(ereg_replace("echo ", "\$row[\$i][{$o}].=", $res[1][$o]));
        }
        $row[$i] = join("", $row[$i]);
    }
    $template_up = ereg_replace("\\[item\\]", "", $template_up);
    if ($template_up) {
        $template_up_new = "";
        $r = array();
        for ($i = 0; $i < $count; $i++) {
            if (!ereg("", $template_up_new)) {
                if ($i != 0) {
                    $r[] = $template_up_new;
                }
                $template_up_new = $template_up;
            }
            $template_up_new = ereg_replace("^([^]*)", "\\1" . $row[$i], $template_up_new);
        }
        $r[] = ereg_replace("", "", $template_up_new);
        $row = join($separator, $r);
    } else {
        $row = join($separator, $row);
    }
    if (!$count) {
        return $errormessage;
    }
    return $row;
}
Пример #2
0
function block($query, $template, $separator = "", $template_up = "", $paging = "", $errormessage = "", $rrid = 0)
{
    global $DB, $Q, $Q2, $module_name, $module_filepath, $page, $id, $inf, $paging_count;
    //if(ereg("id=[^ ]+[^0-9 ]+",$query))
    //	return $errormessage;
    if (ereg("id=\$", $query)) {
        return $errormessage;
    }
    if (ereg("id= ", $query)) {
        return $errormessage;
    }
    $query = correct_query($query);
    //echo $query;
    $filename = $module_filepath . "/_t/_items/" . $template . ".tpl";
    if (!file_exists($filename)) {
        switch ($template) {
            case "date":
                $template_normal = "[date]";
                break;
            case "name":
                $template_normal = "[name]";
                break;
            case "anons":
                $template_normal = "[anons]";
                break;
            case "text":
                $template_normal = "[text]";
                break;
            case "f1":
                $template_normal = "[f1]";
                break;
            case "f3":
                $template_normal = "[f3]";
                break;
            case "f9":
                $template_normal = "[f9]";
                break;
        }
    }
    if (!$template_normal) {
        if (!file_exists($filename)) {
            return "File " . $template . ".tpl not found.";
        }
        $f = file($filename);
        $template_normal = join("", $f);
    }
    if ($separator) {
        $filename = $module_filepath . "/_t/_items/" . $separator . ".tpl";
        if (file_exists($filename)) {
            $f = file($filename);
            $separator = join("", $f);
        } else {
            return "File " . $separator . ".tpl not found.";
        }
    }
    $filename = $module_filepath . "/_t/_items/" . $template_up . ".tpl";
    if (file_exists($filename)) {
        $f = file($filename);
        $template_up = join("", $f);
    }
    $count = "";
    if (!ereg("^[0-9]+", $query)) {
        $query = "select * from " . $module_name . " where " . $query;
        if ($paging) {
            if (!$page) {
                $page = 1;
            }
            $query .= " limit " . ($page - 1) * $paging . "," . $paging;
        }
        $Q->query($DB, $query);
        $count = $Q->numrows();
        $standart_query = 1;
    } else {
        $q = split(",", $query);
        $query = $q[1];
        $count = $q[0];
        if (trim($query)) {
            $query = "select * from " . $module_name . " where " . $query;
            $Q->query($DB, $query);
            $info = $Q->getrow();
        }
        $standart_query = 0;
    }
    // recourse rid
    if ($standart_query && $rrid) {
        $query = ereg_replace("limit.*", "", $query);
        rblock($query, $rrid);
        $standart_query = 2;
        $paging_count = count($inf);
        $count = $paging_count;
        if ($count > $paging) {
            $count = $paging;
        }
    }
    //echo $query;
    $row = array();
    for ($i = 0; $i < $count; $i++) {
        if ($standart_query == 1) {
            $info = $Q->getrow();
        }
        if ($standart_query == 2) {
            $info = $inf[($page - 1) * $paging + $i];
        }
        $anonspicture = "";
        $anypicture = "";
        $ridname = "";
        if (ereg("\\[ridname\\]", $template_normal)) {
            $Q2->query($DB, "select * from " . $module_name . " where id=" . $info[rid]);
            $info2 = $Q2->getrow();
            $ridname = $info2[name];
        }
        if (ereg("anypicture", $template_normal)) {
            $s = getfiles_pictures($module_filepath . "/attachments/" . $info[id] . "/");
            if (trim($s[0])) {
                $anypicture = "<img src=/attachments/" . $info[id] . "/" . $s[0] . " border=0";
            }
        }
        if (ereg("anonspicture", $template_normal)) {
            $filename = $module_filepath . "/attachments/" . $info[id] . "/anons.jpg";
            if (file_exists($filename)) {
                $anonspicture = "<img src=/attachments/" . $info[id] . "/anons.jpg border=0";
            }
        }
        $date = ereg_replace(" .+", "", $info[date]);
        $date = split("\\-", $date);
        $date = $date[2] . "." . $date[1] . "." . $date[0];
        $r = ereg_replace("\\[name\\]", $info[name], $template_normal);
        $r = ereg_replace("\\[id\\]", $info[id], $r);
        $r = ereg_replace("\\[date\\]", $date, $r);
        $r = ereg_replace("\\[lang\\]", $info[lang], $r);
        $r = ereg_replace("\\[rid\\]", $info[rid], $r);
        $r = ereg_replace("\\[ridname\\]", $ridname, $r);
        $r = ereg_replace("\\[anons\\]", $info[anons], $r);
        $r = ereg_replace("\\[aname\\]", $info[aname], $r);
        $r = ereg_replace("\\[archive\\]", $info[archive], $r);
        if (ereg("\\[text\\]", $r)) {
            $r = ereg_replace("\\[text\\]", prepare_text($info), $r);
        }
        $r = ereg_replace("\\[f1\\]", $info[f1], $r);
        $r = ereg_replace("\\[f2\\]", $info[f2], $r);
        $r = ereg_replace("\\[f3\\]", $info[f3], $r);
        $r = ereg_replace("\\[f4\\]", $info[f4], $r);
        $r = ereg_replace("\\[f5\\]", $info[f5], $r);
        $r = ereg_replace("\\[f6\\]", $info[f6], $r);
        $r = ereg_replace("\\[f7\\]", $info[f7], $r);
        $r = ereg_replace("\\[f8\\]", $info[f8], $r);
        $r = ereg_replace("\\[f9\\]", $info[f9], $r);
        $r = ereg_replace("\\[existence\\]", $info[existence], $r);
        $r = ereg_replace("\\[number\\]", "" . (($page - 1) * $paging + $i + 1) . "", $r);
        if ($anonspicture) {
            $r = ereg_replace("\\[anonspicture(.*)\\]", $anonspicture . " \\1 >", $r);
        } else {
            $r = ereg_replace("\\[anonspicture(.*)\\]", "", $r);
        }
        if ($anypicture) {
            $r = ereg_replace("\\[anypicture(.*)\\]", $anypicture . " \\1 >", $r);
        } else {
            $r = ereg_replace("\\[anypicture(.*)\\]", "", $r);
        }
        $row[$i] = $r;
    }
    for ($i = 0; $i < $count; $i++) {
        $row[$i] = ereg_replace("\\?\\>", "", $row[$i]);
        $r = preg_match_all("/<\\?([^]+)/U", $row[$i], $res, PREG_PATTERN_ORDER);
        //	$row[$i]=ereg_replace("\<\?[^\?]+\?\>","",$row[$i]);
        $row[$i] = ereg_replace("\\<\\?[^]+", "", $row[$i]);
        $row[$i] = split("", $row[$i]);
        for ($o = 0; $o < count($res[1]); $o++) {
            $res[1][$o] = ereg_replace("", "\\?\\>", $res[1][$o]);
            eval(ereg_replace("echo ", "\$row[\$i][{$o}].=", $res[1][$o]));
        }
        $row[$i] = join("", $row[$i]);
    }
    $template_up = ereg_replace("\\[item\\]", "", $template_up);
    if ($template_up) {
        $template_up_new = "";
        $r = array();
        for ($i = 0; $i < $count; $i++) {
            if (!ereg("", $template_up_new)) {
                if ($i != 0) {
                    $r[] = $template_up_new;
                }
                $template_up_new = $template_up;
            }
            $template_up_new = ereg_replace("^([^]*)", "\\1" . $row[$i], $template_up_new);
        }
        $r[] = ereg_replace("", "", $template_up_new);
        $row = join($separator, $r);
    } else {
        $row = join($separator, $row);
    }
    if (!$count) {
        return $errormessage;
    }
    $arr_links = array();
    $ereg = '"<a[^<]*</a>"';
    $you_preg = '"href=(\\"[^\\"]*)\\""';
    preg_match_all($ereg, $row, $arr_links);
    for ($i = 0; $i < count($arr_links[0]); $i++) {
        if (ereg("youtube", $arr_links[0][$i])) {
            $params = strip_tags($arr_links[0][$i]);
            if (ereg("х", $params)) {
                $params = split("х", $params);
            }
            if (ereg("x", $params)) {
                $params = split("x", $params);
            }
            $youtube = array();
            preg_match_all($you_preg, $arr_links[0][$i], $youtube);
            $youtube[1][0] = str_replace("watch?v=", "v/", $youtube[1][0]);
            $youtube[1][0] = str_replace("&amp;feature=topvideos", "", $youtube[1][0]);
            $player = '<object width="' . $params[0] . '" height="' . $params[1] . '"><param name="movie" value=' . $youtube[1][0] . '&hl=ru_RU&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src=' . $youtube[1][0] . '&hl=ru_RU&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' . $params[0] . '" height="' . $params[1] . '"></embed></object>';
            /*
            
            		$player = '<object width="'.$params[0].'" height="'.$params[1].'"><param name="movie" value='.$youtube[1][0].'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src='.$youtube[1][0].'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'.$params[0].'" height="'.$params[1].'"></embed></object>';*/
            $row = str_replace($arr_links[0][$i], $player, $row);
        }
    }
    return $row;
}