View file adminka/reklama.php

File size: 1.57Kb
<?php
session_name("SESID");
session_start();
include ('../verh.php');
if($_SESSION['pass']!=$adminpass) {exit;}

if (isset($_POST['save'])) {
	$d='';
	for ($i=0; $i<5; $i++) {
		$link=$_POST["link$i"];
		$text=$_POST["text$i"];
		if (empty($link)) {
			$d.="\r\n";
		} elseif(preg_match('|^http:|', $text)) {
			$d.="<a href='$link'><img src='$text'/></a><br/>\r\n";
		} else {
			$d.="<a href='$link'>$text</a><br/>\r\n";
		}
	}
	$d=preg_replace('|<br/>\s{0,2}$|', '', $d);
	if ($_REQUEST['s']=='v') {file_put_contents('../images/rek_verh.txt', $d);}
	if ($_REQUEST['s']=='n') {file_put_contents('../images/rek_niz.txt', $d);}
	echo "Сохранено<br/>";
}


if (empty($_REQUEST['s'])) {
	echo "<a href='reklama.php?s=v'>Верх</a><br/><a href='reklama.php?s=n'>Низ</a><br/>";
} else {
	if ($_REQUEST['s']=='v') {$d=file('../images/rek_verh.txt');}
	if ($_REQUEST['s']=='n') {$d=file('../images/rek_niz.txt');}
	echo "<form action='reklama.php' method='post'><input type='hidden' name='s' value='$_REQUEST[s]'/>";
	echo "URL ссылки - подпись/URL баннера<br/>";
	for ($i=0; $i<5; $i++) {
		if (!preg_match("|^<a\s+href=\'([^']+)\'><img\s+src=\'([^']+)\'/></a>|", $d[$i], $m)) {
			preg_match("|^<a\s+href=\'([^']+)\'>([^<>]+)</a>|", $d[$i], $m);
		}
		$link=@$m[1];
		$text=@$m[2];
		echo "<input type='text' name='link$i' value='$link'/> ";
		echo "<input type='text' name='text$i' value='$text'/><br/>";
	}
	echo "<input type='submit' name='save' value='Сохранить'/></form>";
}


echo "<a href=\"apanel.php\">Админка</a><br/>";
include ('../niz.php');
?>