<?
error_reporting (0);
session_start();
require_once("classes.php");
$dn = $_SERVER["SCRIPT_NAME"];
if (!empty($_SERVER["DOCUMENT_NAME"]))
{$dn = $_SERVER["DOCUMENT_NAME"];}
$_cfg = parse_ini_file("config.ini", false);
$_tpl = parse_ini_file("admin/templates.ini", false);
$change_conditions = implode("", file($_cfg["conditions_filename"]));
// подсчитываем количество страниц для отображения
function num_pages($page, $messages_count, $messages_on_page)
{
global $dn, $_cfg;
if ($messages_count > $messages_on_page) {
$pages = (int)($messages_count/$messages_on_page);
if ($messages_count%($pages*$messages_on_page) != 0)
{$pages++;}
$start = ((int)(($page-1)/$_cfg["pages_on_row"]))*$_cfg["pages_on_row"];
$end = $start+$_cfg["pages_on_row"];
if ($pages < $start+$_cfg["pages_on_row"])
{$end = $pages;}
if (!empty($_SERVER["QUERY_STRING"])) {
foreach ($_GET as $k => $v) {
if ($k != "page") {
if ($qs == "")
{$qs .= $k."=".$_GET[$k];}
else
{$qs .= "&".$k."=".$_GET[$k];}
}
}
}
if (empty($qs))
{$qs .= "?";}
else
{$qs = "?".$qs."&";}
print "<p>";
if ($start > 0)
{print "<a class="part" href=".$dn.$qs."page=".$start.">...</a> | ";}
for ($i = $start+1; $i <= $end; $i++) {
if ($i == $page)
{print "<span class="part"><b><font color="#DF0808">".$i."</font></b></span> | ";}
else
{print "<a class="part" href=".$dn.$qs."page=".$i.">".$i."</a> | ";}
}
if ($pages > $start+$_cfg["pages_on_row"])
{print "<a class="part" href=".$dn.$qs."page=".($start+$_cfg["pages_on_row"]+1).">...</a>";}
print "</p>";
}
}
function CheckURL($url) {
global $_cfg, $codes;
$c = false;
$data = implode("", file($url));
$p = parse_url($_cfg["site_url"]);
$site_url_1 = $p["scheme"]."://".$p["host"];
$h = explode(".", $p["host"]);
if ($h[0] == "www") {
array_splice($h, 0, 1);
$site_url_2 = $p["scheme"]."://".implode(".", $h);
}
else {
array_unshift($h, "www");
$site_url_2 = $p["scheme"]."://".implode(".", $h);
}
for ($i=0; $i<$codes->rows_count; $i++) {
if (!$_cfg["check_all_urls"]) {
if (eregi($codes->file_arrays["name"][$i], $data))
{$c = true;}
}
else {
if (eregi($site_url_1, $data))
{$c = true;}
if (eregi($site_url_2, $data))
{$c = true;}
}
if ($c)
{break;}
}
return $c;
}
function change_template($msg, $var_array)
{
foreach ($var_array as $k => $v) {
$msg = eregi_replace("{".$k."}", (string)$v, $msg);
}
return $msg;
}
function send_mail($from, $to, $subject, $file_template, $var_array)
{
$body = change_template(implode("", file($file_template)), $var_array);
$body = eregi_replace("rn", "<br>", $body);
$body = $body."<br><br>".
"--------------------<br>".
"LinksPro - скрипт для обмена ссылками<br>";
$subject = change_template($subject, $var_array);
$headers = "(anti-spam-content-type:) text/html; charset=windows-1251 rnFrom: ".$from."rnX-Mailer: PHP/".phpversion();
return mail($to, $subject, $body, $headers);
}
function mail_form($links, $link, $parts, $part, $status, $from, $to, $subject, $file_template) {
global $_cfg, $_tpl, $codes;
$v = array();
$v[$_tpl["linkspro_url"]] = $_cfg["site_url"]."/".$_cfg["linkspro_dir"]."/index.htm";
$v[$_tpl["linkspro_admin_url"]] = $_cfg["site_url"]."/".$_cfg["linkspro_dir"]."/admin/admin.php";
$v[$_tpl["linkspro_page_url"]] = $_cfg["site_url"]."/".$_cfg["linkspro_dir"]."/index.htm?part=".$part."&page=".((int)(($links->get_position($link)-1)/$_cfg["messages_on_page"])+1);
$v[$_tpl["linkspro_change_link"]] = htmlspecialchars($links->get_value($link, "name"));
$v[$_tpl["linkspro_change_page_url"]] = $links->get_value($link, "url_page");
$v[$_tpl["linkspro_change_site_url"]] = $links->get_value($link, "url_site");
$v[$_tpl["linkspro_change_num"]] = $links->get_position($link);
$v[$_tpl["linkspro_change_status"]] = $status->get_value($links->get_value($link, "status"), "name");
$v[$_tpl["linkspro_change_category"]] = $parts->get_value($part, "name");
$v[$_tpl["linkspro_codes"]] = $code_names;
$v["site_url"] = $_cfg["site_url"];
$v["admin_mail"] = $_cfg["admin_mail"];
send_mail($from,
$to,
$subject,
$file_template,
$v);
}
$status = new class_filework;
$status->column_names = array("id", "name", "font");
$status->column_separator = $_cfg["column_separator"];
$status->filename = $_cfg["status_filename"];
$status->fill_arrays();
$parts = new class_part;
$parts->column_names = array("id", "name");
$parts->filename = $_cfg["parts_filename"];
$parts->column_separator = $_cfg["column_separator"];
$parts->parts_dir = $_cfg["parts_dir"];
$parts->fill_arrays();
$codes = new class_filework;
$codes->column_names = array("id", "name", "active");
$codes->filename = $_cfg["codes_filename"];
$codes->column_separator = $_cfg["column_separator"];
$codes->fill_arrays();
$code_names = "";
for ($i=0; $i<$codes->rows_count; $i++) {
if ($codes->file_arrays["active"][$i] == "1") {
if (strlen($code_names) + strlen($codes->file_arrays["name"][$i]) < 1300) {
if ($i != 0)
{$code_names = $code_names."rnrn".$codes->file_arrays["name"][$i];}
else
{$code_names = $code_names.$codes->file_arrays["name"][$i];}
}
else {
$code_names = $code_names."rnrn"."...";
break;
}
}
}
?>