Thread: Friends block
View Single Post
  #1  
Old 1st May 2008, 16:59
Fynnon's Avatar
Fynnon Fynnon is offline
xxx
 
Join Date: Nov 2007
P2P
Posts: 984
Default 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

Code:
    <script>
                      nereidFadeObjects = new Object();
                      nereidFadeTimers = new Object();
                      function nereidFade(object, destOp, rate, delta){
                    if (!document.all)
                         return
                    if (object != '[object]'){ //do this so I can take a string too
                         setTimeout('nereidFade('+object+','+destOp+','+rate+','+delta+')',0);
                         return;
                    }
                         clearTimeout(nereidFadeTimers[object.sourceIndex]);
                         diff = destOp-object.filters.alpha.opacity;
                         direction = 1;
                    if (object.filters.alpha.opacity > destOp){
                         direction = -1;
                    }
                         delta=Math.min(direction*diff,delta);
                         object.filters.alpha.opacity+=direction*delta;
                    if (object.filters.alpha.opacity != destOp){
                         nereidFadeObjects[object.sourceIndex]=object;
                         nereidFadeTimers[object.sourceIndex]=setTimeout('nereidFade(nereidFadeObjects['+object.sourceIndex+'],'+destOp+','+rate+','+delta+')',rate);
                       }
                    }
                    </script>
still in stdhead add this where you want the block to show up

Code:
    begin_block("Friends");?>
                 <table width="100%" border="0" cellspacing="1" cellpadding="1" class="forumline" align="center">
                    <tr><td width="100%" class="row1">
                   
                   
                    <CENTER><MARQUEE BEHAVIOR='SCROLL' ALIGN='CENTER' VALIGN='BOTTOM' DIRECTION='UP' SCROLLAMOUNT='1' SCROLLDELAY='1' ONMOUSEOVER='this.stop()' ONMOUSEOUT='this.start()'>
                    <table class='forumline' cellpadding='0' cellspacing='0'>
                    <?
                        $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("<tr><td class=row1 height='10' border=0><p align='center'>[img]$arr[image][/img]
                        
\n");
                    ?>
                      </td></p></center></a></td></tr>
                      </table></MARQUEE>
                      </td>
                     
                      </table>
                 
                    <?
                     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();

    ?>
    <form action="takefriends.php" method="post">
    <?
    tr("URL Buttons: ", "<input type=\"text\" name=\"image\" size=\"80\" />
(upload Button on <a href=http://img293.imageshack.us>http://img293.imageshack.us</a>)", 1);
    tr("Description: ", "<textarea name=\"descr\" rows=\"10\" cols=\"80\"></textarea>", 1);
    tr("URL Site : ", "<input type=\"text\" name=\"url\" size=\"60\" /> 
(http://www.torrentstrike.info)
\n", 1);
    ?>
    <tr><td class="row1" align="center" colspan="2"><input type="submit" value="Ok!" /></td></tr>
    </form>
    <?
    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("<p align=center>There is nothing:(</p>\n");
    else
    {
    //print("<table width=100% id=torrenttable cellpadding=4 cellspacing=1 bgcolor=#000000 border=0 >\n");
    begin_table();
    print("<tr><td class=colhead>Button</td><td class=colhead align=left>It is added</td><td class=colhead align=left>Description</td><td class=colhead>URL Site</td><td class=colhead>Edit.</td><td class=colhead>Delete.</td></tr>\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("<tr><td class=row1 width='18'><IMG src=$arr[image] border=0></td><td class=row1 align=left>$arr[added]</td><td class=row1 align=left>$arr[descr]</td><td class=row1 align=left>$arr[url]</td><td class=row1 width='18'align=left><font class=middle>[<a class=altlink href=friendsmanage.php?action=edit&id=" . $arr['id'] . "&returnto=" . urlencode($_SERVER['PHP_SELF']) . ">Edit.</a>]</td><td class=row1 width='18'align=left>[<a class=altlink href=friendsmanage.php?action=delete&id=" . $arr['id'] . "&returnto=" . urlencode($_SERVER['PHP_SELF']) . ">Del.</a>]</td></tr>\n");
    }
    end_table();
    //print("</table>\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" .
    "<a href=?action=delete&id=$id&returnto=$returnto&sure=1>here</a> 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("<form method=post action=?action=edit&id=$id>\n");
    print("<table border=0 cellspacing=0 cellpadding=5>\n");
    print("<tr><td><input type=hidden name=returnto value=$returnto></td></tr>\n");
    print("<tr><td>URL Buttons:<font color=#ff0000>*</font></td><td colspan=2 align=left><input type=text size=60 name=image value=\"" . htmlspecialchars($arr["image"]) . "\">
</tr>\n");
    print("<tr><td>Description:<font color=#ff0000>*</font></td><td colspan=2 align=left><textarea name=descr rows=8 cols=60>" . htmlspecialchars($arr["descr"]) . "</textarea></tr>\n");
    print("<tr><td>URL Site:<font color=#ff0000>*</font></td><td colspan=2 align=left><input type=text size=60 name=url value=\"" . htmlspecialchars($arr["url"]) . "\">
</tr>
    \n");
    print("<tr><td align=center><input type=submit value='??!' class=btn></td></tr>\n");
    print("</table>\n");
    print("</form>\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:
Reply With Quote
The Following 2 Users Say Thank You to Fynnon For This Useful Post:
bit4you (19th September 2010), Phogo (23rd June 2010)