Welcome to Geeklog, Anonymous Tuesday, November 26 2024 @ 08:51 am EST
Geeklog Forums
Make function in lib-custom
Status: offline
Sniper12
Forum User
Regular Poster
Registered: 11/25/03
Posts: 81
Location:Denmark
I have a block whit links in it, but now I won’t some php code in it, I have made the code for php but I can't seam to make it in to at function in lib-custom. Can somebody tell me how to make it or show me it whit this code, then I be happy, this is to show a small pic next to a link when a file is updated.
<BR>
<a href="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/forum/index.php">Forum</a>
<BR>
<A HREF="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/admin/upload.php">Opload fil (til brug i forum)</A>
<BR>
<A HREF="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/staticpages/index.php?page=20031128185418198">Galleri</A>
<BR>
<A HREF="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/links.php">Tilføj links / Links</A>
<BR>
<A HREF="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/staticpages/index.php?page=2003112817545733">Star League</A>
<?php
$filename = 'billeder/opload/starleague0405.htm';
$fourdaysago = time()-172800;
if (filemtime($filename) > $fourdaysago) {
echo '<IMG SRC="billeder/new_til_link.gif" BORDER="0" WIDTH="31" HEIGHT="12" ALIGN="bottom" ALT="Opdaterede inden for 2 dage siden">';
} else {
echo ' ';
}
?>
<BR>
<A HREF="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/staticpages/index.php?page=20031130215016369">Sports nyheder</A>
<BR>
<A HREF="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/staticpages/index.php?page=20040112204057225">Sportskalender</A><FONT SIZE="-3"> Opd.21/1-04</FONT>
<BR>
<A HREF="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/filemgmt/index.php">Downloads</A>
<BR>
<A HREF="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/staticpages/index.php?page=2004042418524068">Web butik</A>
Text Formatted Code
<A HREF="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/index.php?topic=General">Nyheder/Forside</A><BR>
<a href="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/forum/index.php">Forum</a>
<BR>
<A HREF="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/admin/upload.php">Opload fil (til brug i forum)</A>
<BR>
<A HREF="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/staticpages/index.php?page=20031128185418198">Galleri</A>
<BR>
<A HREF="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/links.php">Tilføj links / Links</A>
<BR>
<A HREF="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/staticpages/index.php?page=2003112817545733">Star League</A>
<?php
$filename = 'billeder/opload/starleague0405.htm';
$fourdaysago = time()-172800;
if (filemtime($filename) > $fourdaysago) {
echo '<IMG SRC="billeder/new_til_link.gif" BORDER="0" WIDTH="31" HEIGHT="12" ALIGN="bottom" ALT="Opdaterede inden for 2 dage siden">';
} else {
echo ' ';
}
?>
<BR>
<A HREF="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/staticpages/index.php?page=20031130215016369">Sports nyheder</A>
<BR>
<A HREF="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/staticpages/index.php?page=20040112204057225">Sportskalender</A><FONT SIZE="-3"> Opd.21/1-04</FONT>
<BR>
<A HREF="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/filemgmt/index.php">Downloads</A>
<BR>
<A HREF="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/staticpages/index.php?page=2004042418524068">Web butik</A>
10
13
Quote
Status: offline
Robin
Forum User
Full Member
Registered: 02/15/02
Posts: 725
Try this (a simplified version of your code
{
$retval .= '<A HREF="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/staticpages/index.php?page=2003112817545733">Star League</a>';
$filename = 'billeder/opload/starleague0405.htm';
$fourdaysago = time()-172800;
if (filemtime($filename) > $fourdaysago) {
$retval .= '<IMG SRC="http://www.sugecrew.dk/billeder/new_til_link.gif" BORDER="0" WIDTH="31" HEIGHT="12" ALIGN="bottom" ALT="Opdaterede inden for 2 dage siden">';
return $retval;
}
}
You can see it in action here
In $filename put a complete path to the file. At least I had to, to get it working.
Geeklog Polish Support Team
Text Formatted Code
function phpblock_sniper(){
$retval .= '<A HREF="http://www.sugecrew.dk/prideofvbk/geeklog/public_html/staticpages/index.php?page=2003112817545733">Star League</a>';
$filename = 'billeder/opload/starleague0405.htm';
$fourdaysago = time()-172800;
if (filemtime($filename) > $fourdaysago) {
$retval .= '<IMG SRC="http://www.sugecrew.dk/billeder/new_til_link.gif" BORDER="0" WIDTH="31" HEIGHT="12" ALIGN="bottom" ALT="Opdaterede inden for 2 dage siden">';
return $retval;
}
}
You can see it in action here
In $filename put a complete path to the file. At least I had to, to get it working.
Geeklog Polish Support Team
9
8
Quote
Mdangelo
Anonymous
Hi I am trying to ad the below code to a block
echo file_get_contents ('domain');
I first went into the block and tried to type that code and it was way too long- i saw the message about "phpblock_" however obviously if i cant fit the above code then adding the phpblock_ first will not work ;-)
I saw also the message about adding functions to lib-custom.php. If i wnat to declare that function within that file how do i do that, and then how to I call the function. Anyway I appreciate any insight anyone might be able to give.
echo file_get_contents ('domain');
I first went into the block and tried to type that code and it was way too long- i saw the message about "phpblock_" however obviously if i cant fit the above code then adding the phpblock_ first will not work ;-)
I saw also the message about adding functions to lib-custom.php. If i wnat to declare that function within that file how do i do that, and then how to I call the function. Anyway I appreciate any insight anyone might be able to give.
6
8
Quote
Status: offline
Robin
Forum User
Full Member
Registered: 02/15/02
Posts: 725
Quote by Mdangelo: Hi I am trying to ad the below code to a block
echo file_get_contents ('domain');
I first went into the block and tried to type that code and it was way too long- i saw the message about "phpblock_" however obviously if i cant fit the above code then adding the phpblock_ first will not work ;-)
echo file_get_contents ('domain');
I first went into the block and tried to type that code and it was way too long- i saw the message about "phpblock_" however obviously if i cant fit the above code then adding the phpblock_ first will not work ;-)
Actually I'm not sure what you are trying to achieve here.
Quote by Mdangelo:I saw also the message about adding functions to lib-custom.php. If i wnat to declare that function within that file how do i do that, and then how to I call the function. Anyway I appreciate any insight anyone might be able to give.
PHP Blocks are usually declared in the file lib-custom.php.
After adding any new function to lib-custom.php then you can add a php block (following the install instructions).
A function structure is like this
Text Formatted Code
function phpblock_whatevernameyoulike(){
your code goes here
}
Geeklog Polish Support Team
8
11
Quote
mdangelo
Anonymous
ahh Robin- Appreciate the help. I have an adserver script that dynamically writes text links to a file which I then wanted to call and have them show up in my sponsors block. I may have to use a new block for the php- but thats cool.
Thanks for the help. Im interested to see whats in store for g2 when it comes out... long whiles from now! heh
Thanks for the help. Im interested to see whats in store for g2 when it comes out... long whiles from now! heh
10
9
Quote
All times are EST. The time is now 08:51 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content