function show_small_image($id) { global $system; $images = rcms_scandir(GALLERY_PATH); $gal = ''; for ($i = 0; $i < count($images); $i++) { if (is_pict($images[$i])) { if ($id == $i) { $stat = getimagesize(GALLERY_PATH . $images[$id]); $w = $stat[0]; $h = $stat[1]; if ($w > 150) { $x = $w / 150; $h = $h / $x; $w = 150; } elseif ($h > 150) { $x = $h / 150; $w = $w / $x; $h = 150; } $gal .= '<a href="?module=gallery"><img src="' . GALLERY_PATH . $images[$id] . '" width="' . $w . '" height="' . $h . '" border=0></a>'; $system->showMenuWindow('', $gal, 'center'); } } } } $images = rcms_scandir(GALLERY_PATH); $imgcount = count($images) - 1; $random_image = rand(0, $imgcount); show_small_image($random_image);
static function text($text) { $content = ""; $related = 0; $rel_tooltips = ""; $lines = explode("\n", $text); $list = false; foreach ($lines as $line) { $line = trim($line); $first_char = substr($line, 0, 1); if (!$list and "=" == $first_char) { $content .= "<ul>"; } else { if ($list and "=" != $first_char) { $content .= "</ul>"; } } $list = $first_char === "="; if ($list) { $text = "<li>" . htmlspecialchars(trim(substr($line, 1, 999))) . "</li>"; } else { $text = "<p>" . htmlspecialchars($line) . "</p>"; } $text = str_replace("[**", "<span class=\"info\">", $text); $text = str_replace("**]", "</span>", $text); $text = str_replace("{{", "<em>", $text); $text = str_replace("}}", "</em>", $text); $text = str_replace("[[", "<strong>", $text); $text = str_replace("]]", "</strong>", $text); // process related if ('%' == $first_char) { list($head, $id_prods) = explode('|', trim(substr($line, 1, 999))); MySQL::query("SELECT id, cat, link, brand, title, brief, price FROM products WHERE shown=1 AND id IN ({$id_prods}) ORDER BY FIELD (id, {$id_prods})"); if (0 == MySQL::rows()) { continue; } $related++; $i = 0; $prods = array(); while ($row = MySQL::fetch()) { list($id, $cat, $link, $brand, $title, $brief, $price) = $row; $prods[$i++] = array($id, $cat, $link, $brand, $title, $brief, $price); } if ($_SERVER["REMOTE_ADDR"] == "109.99.148.134xx") { $text = '<div class="row"><div class="col-md-12">'; $text .= '<div class="carousel slide">'; $text .= '<div class="carousel-inner">'; $text .= 'test'; $text .= '</div></div></div></div>'; } $text = "<strong>{$head}</strong><ul id=\"related{$related}\" class=\"related-skin\">"; foreach ($prods as $prod) { list($id, $cat, $link, $brand, $title, $brief, $price) = $prod; $text .= "<li id='rel_{$id}'>" . show_small_image($link, ""); $text .= "<input type='hidden' value='/{$cat}/" . urlencode($link) . "'>"; $text .= "<div class='title'>{$title}</div>"; $text .= "<div class='brand'>{$brand}</div>"; $text .= "<div class='price'><strong>" . ($price + 0) . "</strong> LEI</div>"; $text .= "</li>"; $rel_tooltips .= "\t\$('#rel_{$id}').poshytip({ content: '" . str_replace("'", "\\'", $brief) . "', className: 'tip-darkgray', showTimeout: 100 });\n"; } $text .= "</ul>"; } // process links $offset = 0; while (true) { $beg = strpos($text, "<<", $offset); if (false === $beg) { break; } $end = strpos($text, ">>", $beg); if (false === $end) { $end = strlen($text); } $text1 = substr($text, 0, $beg); $text2 = substr($text, $beg + 8, $end - $beg - 8); $text3 = substr($text, $end + 8); list($link, $text) = explode("|", $text2); if (!$text) { $text = $uri; } $text2 = "<a href='{$link}'>{$text}</a>"; $text = $text1 . $text2 . $text3; $offset = $end; } $content .= $text; } if ($line) { $content .= "</ul>"; } if ($related) { $content .= "\n" . '<script type="text/javascript">' . "\n"; $content .= '$(document).ready(function() {' . "\n"; for ($i = 1; $i <= $related; $i++) { $content .= "\t" . '$("#related' . $i . '").jcarousel();' . "\n"; } $content .= $rel_tooltips; $content .= "});\n</script>\n"; } return $content; }