Welcome to Fogfighters Hungary!
 
  Login or Register
.week  
Time
 
 
 
Languages
Select Interface Language:

 
Google Translation
Translation
 
Traffic Report
 
Where are you from?
 
Map Random
Objective
Troop_Train
View Troop_Train
The Allies must destroy armour reinforcements being transported on two trains.
Hits: 7
Total Maps: 85
 
Modules
· Home
· About Easter
· Büntetés kalkulátor
· Bible
· Biorythm
· Birds
· Black Gallery
· Cats
· Coppermine
· Dogs
· eCards
· ET Game manual
· ET Handbuch
· ET játékleírás
· ET Maps
· Fórumok
· FIFA World Cup 2006
· Fish
· Google Guide
· Googlemaps
· Hírküldés
· Help Desk
· Internet_TV
· Keresés
· Letöltések
· Members List
· Member_Map
· News
· Online Radios
· PHP-Nuke_HOWTO
· PHP-Nuke_Tools
· Private Messages
· Punkbuster
· Saját beállításaid
· Shout Box
· Statisztikák
· Szavazások
· Szerencsejáték
· Tagfelvétel
· Viccek
· Videó kollekció
· Web címek
· Web Development
 
MS-Analysis
Top-Ten Countries visiting Fogfighters Hungary

1 United States United States
2 China China
3 Viet nam Viet nam
4 Russian Federation Russian Federation
5 France France
6 Hungary Hungary
7 unknown unknown
8 Ukraine Ukraine
9 Canada Canada
10 United Kingdom United Kingdom
11 Germany Germany
12 Netherlands Netherlands
13 Poland Poland
14 Italy Italy
15 Taiwan, Province of China Taiwan, Province of China
16 Seychelles Seychelles
17 Australia Australia
18 Romania Romania
19 Indonesia Indonesia
20 India India
21 Thailand Thailand
22 Sweden Sweden
23 Brazil Brazil
24 Japan Japan
25 South Africa South Africa
26 Lithuania Lithuania
27 Argentina Argentina
28 Spain Spain
29 Iran, Islamic Republic of Iran, Islamic Republic of
30 Chile Chile
31 Luxembourg Luxembourg
32 Turkey Turkey
33 Moldova, Republic of Moldova, Republic of
34 Korea, Republic of Korea, Republic of
35 Belarus Belarus
36 Malaysia Malaysia
37 Venezuela Venezuela
38 Switzerland Switzerland
39 Singapore Singapore
40 Colombia Colombia
41 Hong Kong Hong Kong
42 Mexico Mexico
43 Mongolia Mongolia
44 Czech Republic Czech Republic
45 Belize Belize
46 Greece Greece
47 Honduras Honduras
48 Estonia Estonia
49 Latvia Latvia
50 Bulgaria Bulgaria

View MS-Analysis
 
Scrolling Links
Mods:































Community:




































Clans:






























































League:










Anticheat:












Other:

































 
Special days




July


 
Képes Naptár
There is a problem right now with this block.
 
CPG Random Picture

Kilátás az ablakból

 
Latest Videos


Last added videos

Orvosnál

Orvosnál

Last added videos

Funny

Funny Mortar

Last added videos

Shy

Shy Rose - I Cry For You
 
How to display images in PHP-Nuke blocks

20.8. How to display images in PHP-Nuke blocks

Blocks offer a quick way to incorporate content in PHP-Nuke. They are happily used to display images, since they can be placed anywhere in the three layout columns - and their position can be comfortably changed from the administration panel. A very common use of blocks in PHP-Nuke is to display dynamic images, i.e. images that change depending on some parameter of dynamic nature, most offen time: a daily quote, a daily weather forecast or a daily comic.

Most of the time you will not be the original author of the quote, forecast or comic. You will want to fetch this content from some popular source on the Internet.

Important Before you proceed: think on copyright!
 

We will describe the tecnology that allows you to use somebody else's work to make your site more beautiful, attractive or informative. This almost certainly touches that person's copyright. Please take the time to read the admonition on copyright in Section 8.2.3!

PHP enables you to read a remote URL, store its whole content in one (!) variable, then search the contents of the variable for any regular expression (for regular expressions, see Section 25.3). We will use this technique to find out the filename of the User Friendly daily comic strip, in order to display it in a PHP-Nuke block. This UserFriendly block reads the User Friendly daily cartoon page line by line, searches for the pattern

whatever<IMG ALT="Latest Strip"whateverSRC="imagefile">whatever

extracts the location of the image file (imagefile) from it and displays it in the block. The PHP code of the User Friendly block is a classic example of how you can do this "scrapping" in PHP (-Nuke):

<?php
if (eregi("block-User_Friendly.php",$PHP_SELF)) { (1)
    Header("Location: index.php");
    die();
}
$ufurl =  "http://www.userfriendly.org/static/"; (2)
$content = "<i>ufurl:</i> $ufurl<br>";
$imagefile = ""; (3)
if (!($textfile = fopen( "$ufurl",  "r"))) { (4)
    $content .= "$ufurl<br> could not be opened<br>"; (5)
    die();
}
while (!feof($textfile)) { (6)
    $line = fgets($textfile, 1500);          (7)
    if (eregi( ".*<IMG ALT=\"Latest Strip\".*SRC=\"(.*)\">.*", $line, $out)) { (8)
        $imagefile = $out[1]; (9)
        break;
    }
}
fclose($textfile);
$content = "<p align=center>";
$content .= "<A HREF=\"http://www.userfriendly.org\" target=\"_blank\">
<IMG SRC=\"$imagefile\" alt=\"User Friendly by Illiad\"></A>"; (10)
?>
(1)
This is the standard check at the start of every PHP-Nuke block: if the name of the script, as it was called by the user, contains the full name of the block, then the user must have called the block directly. In this case we redirect him to the home page. As with modules, a direct call of a block not only will not work, it will also bypass all security measures of PHP-Nuke (see for example Section 23.4.3).
(2)
The URL of the remote page containing the dynamic image.
(3)
Initialization of the image filename.
(4)
We open the remote page for reading ("r"). This operation returns a "file handle", a unique identifier for the opened file, which is stored in $textfile.
(5)
If the opening operation failed, we output an error message in the content variable of the block and quit.
(6)
If the opening operation succeeded, we start reading the content of the remote page in a loop, line-by-line, until the end-of-file (eof) character is encountered.
(7)
We only read 1500 characters at a time. This is more than enough for our purposes.
(8)
This is where all the magic takes place! We search the line we just read for occurences of a regular expression. The expression itself means
whatever<IMG ALT="Latest Strip"whateverSRC="imagefile">whatever

where "whatever" may be any content, including space. The regular expression contains a subexpression in the place of the image filename. This results in the file name being stored in the $out array, as its first element.

(9)
We copy the first element the $out array to the $imagefile variable. By construction of the regular expression above, $imagefile now contains the image filename of the daily comic strip. We only have to display it!
(10)
We echo an image anchor using as source the filename we just "scrapped" from our source page. This displays the daily comic strip without fetching the image to our web server (hot linking!).

A similar technique is used in news aggregators, like the MyHeadlines module (see Section 8.3.9), that "scrap" news sources for pieces of dynamic information that are not otherwise available (i.e. not available as RSS/RDF news feeds), see Template Based Scraping. For each source page, a regular expression is stored in a table. Its subexpressions will automatically store the dynamic information pieces that are of interest to us in the elements of some $out array. We would then only have to display those elements for each source.

Tip Quod medicina aliis, aliis est acre venenum[1]
 

If you are an artist whose images are being hot-linked with the above methods without your permission, you are certainly not excited. But don't despair! You can defend your work with a simple technique that requires only the Apache mod_rewrite module and a few lines in your .htaccess file. See Section 25.6.

Notes

[1]

One person's medicine is another's foul poison.

Send all questions and comments to:
Webmaster
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest Fogfighters Hungary © 2007 - 2022

You can syndicate our news using the file backend.php or ultramode.txt

PHP-Nuke Copyright © 2005 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.26 Seconds

:: subBlack phpbb2 style by spectre :: PHP-Nuke theme by www.nukemods.com ::