Fynnon |
1st May 2008 16:59 |
Friends block
ok since everybody had trouble with the last version i did this again and corrected a couple of things and taken out half the crap that wasnt even needed tbh
it was full html code that wasnt even being used such as etc
run this sql
Code:
CREATE TABLE `friendsblock` (
`id` int(10) unsigned NOT NULL auto_increment,
`added` datetime default NULL,
`image` text NOT NULL,
`descr` text NOT NULL,
`url` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=207;
in your stdhead add this just above the
still in stdhead add this where you want the block to show up
Code:
begin_block("Friends");?>
|
end_block();
now make a friendsblockadd.php and ad to your root
Code:
require_once("include/bittorrent.php");
dbconn(false);
loggedinorreturn();
if (get_user_class() < UC_SYSOP)
stderr("Error", "There is no access........");
stdhead("To add in the friends");
begin_frame("To add in the friends :.");
begin_table();
?>
end_table();
end_frame();
$res2 = mysql_query("SELECT count(id) FROM friendsblock") or die(mysql_error());
$row = mysql_fetch_array($res2);
$url = " .$_SERVER[PHP_SELF]?";
$count = $row[0];
$perpage = 15;
list($pagertop, $pagerbottom, $limit) = pager($perpage, $count, $url);
begin_frame("To edit :.");
if ($count == 0)
print("There is nothing:( \n");
else
{
//print("\n");
begin_table();
print("Button | It is added | Description | URL Site | Edit. | Delete. | \n");
$res = mysql_query("SELECT id,added,image,descr,url from friendsblock ORDER BY added DESC $limit") or sqlerr(__FILE__, __LINE__);
while ($arr = mysql_fetch_assoc($res))
{
print(" | $arr[added] | $arr[descr] | $arr[url] | [Edit.] | [Del.] | \n");
}
end_table();
//print(" \n");
echo $pagerbottom;
}
end_frame();
stdfoot();
?>
now make a friendsmanage.php and add to your root
Code:
require "include/bittorrent.php";
dbconn();
loggedinorreturn();
if (get_user_class() < UC_SYSOP)
stderr("Error", "There is no access........");
$action = $_GET["action"];
if ($action == 'delete')
{
$id = $_GET["id"];
if (!is_valid_id($id))
stderr("Error","bad id");
$returnto = $_GET["returnto"];
$sure = $_GET["sure"];
if (!$sure)
stderr("Delete","Are you sure you want to delete? Press\n" .
"here to confirm.");
mysql_query("DELETE FROM friendsblock WHERE id=$id") or sqlerr(__FILE__, __LINE__);
if ($returnto != "")
header("Location: $returnto");
else
$warning = "Successfully deleted.";
}
if ($action == 'edit')
{
$id = (int) $_GET["id"];
if (!is_valid_id($id))
stderr("Error","Bad id");
$res = mysql_query("SELECT * FROM friendsblock WHERE id=$id") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) != 1)
stderr("Error", "There are no friends ID $id.");
$arr = mysql_fetch_array($res);
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$image = $_POST['image'];
if ($image == "")
stderr("Error", "Enter URL of the Button?!");
$descr = $_POST['descr'];
if ($descr == "")
stderr("Error", "Enter the description?!");
$url = $_POST['url'];
if ($url == "")
stderr("Error", "Enter URL site?!");
$image = sqlesc($image);
$descr = sqlesc($descr);
$url = sqlesc($url);
mysql_query("UPDATE friendsblock SET image=$image,descr=$descr,url=$url WHERE id=$id") or sqlerr(__FILE__, __LINE__);
$returnto = $_POST['returnto'];
if ($returnto != "")
header("Location: $returnto");
else
$warning = "Error,Error..........";
}
else
{
$returnto = $_GET['returnto'];
stdhead();
begin_frame("Edit :.");
print("\n");
end_frame();
stdfoot();
die;
}
}
?>
lastly make a takefriends.php and add to your root
Code:
require_once("include/bittorrent.php");
dbconn();
loggedinorreturn();
if (get_user_class() < UC_SYSOP)
stderr("Error", "There is no access....");
function bark($msg) {
stdhead();
stdmsg("Error!", $msg);
stdfoot();
exit;
}
if (!$_POST["image"])
bark("Enter URL the address of the button.");
$image = $_POST["image"];
if (!$_POST["descr"])
bark("Enter the description.");
$descr = $_POST["descr"];
if (!$_POST["url"])
bark("Enter URL Site.");
$url = $_POST["url"];
$image = sqlesc($image);
$descr = sqlesc($descr);
$url = sqlesc($url);
$added = sqlesc(get_date_time());
mysql_query("INSERT INTO friendsblock (added,image,descr,url) VALUES($added,$image,$descr,$url)") or sqlerr(__FILE__, __LINE__);
$id = mysql_insert_id();
header("Refresh: 0; url=friendsblockadd.php");
?>
thats it :smile:
|