Welcome Guest [Log In] [Register]
This board has been archived and is no longer accepting new questions. If you have a support question for your ZetaBoard, please visit us at the new support board. Registration is free and easy.


Visit the NEW ZetaBoards Support forum!

Username:   Password:
Add Reply
For Developers: Load Profile posts; Faster then ajax (PHP)
Topic Started: Feb 18 2008, 07:55 PM (1,309 Views)
DynamicIP
Member Avatar
I'm known as Nor
[ *  * ]
Code:
 

function loadProfile( $id , $domain)
{
$content = file_get_contents( $domain . $id . "/" );
$doc = new DOMDocument();
@$doc->loadHTML($content);
$tags = $doc->getElementsByTagName('dd');
$x = 0;
$count = '';
foreach($tags as $tag)
{
if( $x == 1 )
break;
$count = $tag->nodeValue;
$x +=1;
}
return "var postcount = '$count';";
}


How you would use this is:

Code:
 

echo loadProfile("3000","http://support.zetaboards.com/profile/");


You could automate this for logged in users for your scripts.

Code:
 

<script src='http://ex-code.info/zbpostcount.php?u=3008&url=http://s1.zetaboards.com/TheInfernoSinX/profile/' type='text/javascript'></script>
<a href='javascript:alert(postcount);'>View User 3008 Post Count</a>


Requirements:
Server
PHP5
PHP5 DomDocument :)

Preview:
http://s1.zetaboards.com/TheInfernoSinX/index/ (Click on the link Above the header)

My server may be slow today doing server upgrades(still fast though), but if you want you could use this url for your own usage:

Code:
 

http://ex-code.info/zbpostcount.php?u=ACCOUNT#&url=URL


PHP Used in example
Code:
 

<?php
function loadProfile( $id , $domain)
{
$content = file_get_contents( $domain . $id . "/" );
$doc = new DOMDocument();
@$doc->loadHTML($content);
$tags = $doc->getElementsByTagName('dd');
$x = 0;
$count = '';
foreach($tags as $tag)
{
if( $x == 1 )
break;
$count = $tag->nodeValue;
$x +=1;
}
return "var postcount = '$count';";
}
echo loadProfile($_GET['u'],$_GET['url']);
?>


Very easy automate for shop codes and what not ;)...
(I own my hosting so be happy I share with you ;))

I love PHP5 more everyday :P..


For 100% accuracy:

Quote:
 

function loadProfile( $domain, $id )
{
$content = file_get_contents( $domain . $id . "/" );
$dd = explode("<dd>", $content);
$x = explode("</dd>",$dd[1]);
$x = trim($x[0]);
return $x;
}
Edited by DynamicIP, Feb 20 2008, 05:38 PM.
Offline Profile Quote Post Goto Top
 
RyuraGS
Member Avatar
Member
[ *  *  * ]
Haha nice one.

I was actually just developing something similar to this for modBase :D
Offline Profile Quote Post Goto Top
 
DynamicIP
Member Avatar
I'm known as Nor
[ *  * ]
Thanks ;).. I was going to use ajax then I'm like PHP DOM ftw hehe, working on this marketplace script for some site opening next week.
Offline Profile Quote Post Goto Top
 
thelegend1987
Member
[ * ]
Nevermind. It was another code we were both running that was slowing everything to a crawl.
Edited by thelegend1987, Feb 18 2008, 11:26 PM.
Offline Profile Quote Post Goto Top
 
Phlip (S)
Member Avatar
Member
[ *  *  *  * ]
A bit pointless. :-/ There's too many codes, too.
Offline Profile Quote Post Goto Top
 
DynamicIP
Member Avatar
I'm known as Nor
[ *  * ]
If you don't program yeah its pointless to you, please don't spam if you don't code or have a clue about what this does..
Offline Profile Quote Post Goto Top
 
Viral
Member Avatar
i'm stanley nao
[ *  *  *  *  * ]
Wow, very nice.

Read it through a couple of times and think I understand it.

1. Load the profile page.
2. Loop through the dds to find the Post count one
3. Return it.

??

Nice code,
Viral .
Offline Profile Quote Post Goto Top
 
DynamicIP
Member Avatar
I'm known as Nor
[ *  * ]
There will be problems if you have HTML in javascript tags (E.G:: you want to add a new table or something) so basically javascript src='' to display addons for your mods will make the script run perfectly.
Offline Profile Quote Post Goto Top
 
Dennis
Member Avatar
Member Extraordinaire

You should loop through all the profile elements and return them all in an array. That would make this far more useful.

Nice work so far, though. :)
Offline Profile Quote Post Goto Top
 
DynamicIP
Member Avatar
I'm known as Nor
[ *  * ]
Yeah maybe, if I get time.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · User Created Codes · Next Topic »
Add Reply