IMPORTANT - Downloading Policy
By downloading any of the software, you have agreed and understood the terms below:
THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESSED, IMPLIED OR OTHERWISE, INCLUDING AND WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR OR HIS COMPANY BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, LOSS OF INFORMATION, OR ANY OTHER LOSS), WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR INABILITY TO USE THIS SOFTWARE.
PHP Info
Here I will put the functions I am using in displaying YouTube videos, MD Games pictures; getting directory pictures and more....
If you find them usefull, use them !
If you want to test any of these codes select the code, copy and paste it into a PHP file. You must have a web server to interpret you PHP code, I recommend WAMP, easy to install and easy to use. The file must pe saved into 'www' folder. Download WAMP
here.
If you are using one of these codes, please send me an e-mail with the link where you are using this code. I will put you on the site !
CyE PHP Show Gallery
See
CyE PHP Show Gallery 1.3 in action. (deactivated)
See
CyE PHP Show Gallery 2.0 in action.
The codes are here:
Download CyE PHP Show Gallery 2.0. (downloads:
662)
Download CyE PHP Show Gallery 1.3. (downloads:
161)
Feel free to use CyE PHP Show Gallery in any way. But i would appreciate if you keep the link that points to my website.
History:
[August 24-28, 2008]: CyE PHP Show Gallery 2.0
- TABLEless files;
- Gallery is modularized; it has 24 files; //restructured alot
- no ads whatsoever;
- no marquee effect, you can see now all the pictures
- the big picture opens into a new window over the gallery, and you can see the other pictures just pressing on the left half (for previous image) or right half (for next image) of the current image;
CyE PHP Show Gallery 1.3
- changed the background-color of the menus
- added sorted directories
- changed the background color to image on Nav Menus
- added updates
- added name of the picture
- added link to the big picture
- thumbnails are now sorted (for a better view)
- some properties defined for the tables in 'lib.php'
- restructured the ads (moved ads to the inner table for esthetics)
- restructured the file in 2 files: the same file and lib.php
CyE PHP Show Gallery 1.2
- added navigation links: first picture, previous picture, next picture and last picture
Top
June.28.2008 - How to display YouTube videos on a web page ?
When you have to display videos on a web page you need the
<table> tag and a lot of writing, which is time consuming. This method is realised manually, cuz you have to add each time the new video into the array. In the future I will do a "sort of" automatized method.
I am using this code to show game trailers on
http://cyecorp.ro/mdgames/trailers.php.
The Code
(now this code it's ok)
<?php
//defining an array of trailer video names
$arr_trailer_names = Array('Gun Metal', 'Left 4 Dead ', 'Alone in the Dark',
'BattleStations Pacific', 'Facebreaker', 'Dead Space', 'Bio Shock 2007',
'Iron Man', 'Turok', 'Grid 2008', 'Gears of War ', 'Call of Duty 5 - World at War',
'The Incredible Hulk', 'Alien arena 2008');
//defining an array of trailer video links
$arr_trailer_links = Array('QuBvqnLU7dI', 'a5spmvBxLp4', '3PF0cqD-uno', '23WEAyGLF50',
'aoJAUYLCPS4', 'ycksHmQnXnQ', 'CoYorK3E4aM', 'LLQqRcD-KkM', 'MpDK8apZKWA',
'C8PG0-nw7_g', 'ccWrbGEFgI8', 'eOwZocUUFao', 'd7HzVoAQ0ug', 'YW27tsUU7n8');
//defining number of trailers
$noe_items = count($arr_trailer_names);
//defining the width and height for a video as seen in youtube, but customized
$w = 300;
$h = 300;
//defining the number of videos on a table row
$items_on_a_row = 2;
//defining the colors for the player
$color1 = "0xe1600f";
$color2 = "0xfebd01";
$border = "0";
//TABLE Header
print "<TABLE width=\"460\" border=\"0\">";
print "<TR>";
print "<TD bgcolor=\"#6699FF\" width=\"20\">Date</TD>";
for ($i = 0; $i < $items_on_a_row; $i++) {
print "<TD bgcolor=\"#6699FF\" width=\"300\">Trailer Name</TD>";
}
print "</TR>";
//TABLE Body that contains the Date and Videos
print "<TR bgcolor=\"#DDDDDD\">";
print "<TD>[June 25, 2008]</TD>";
for ($i = 0; $i < $noe_items; $i++) {
$link_youtube = "<object width=\"".$w."\" height=\"".$h."\"><param name=\"movie\"
value=\"http://www.youtube.com/v/".$arr_trailer_links[$i]."&hl=en\"></param><embed
src=\"http://www.youtube.com/v/".$arr_trailer_links[$i]."&hl=en\"
type=\"application/x-shockwave-flash\"
width=\"".$w."\" height=\"".$h."\"></embed></object>";
print "<TD>".$arr_trailer_names[$i]."<BR>".$link_youtube."</TD>";
//must close the table ROW and open a new row
$mod = bcmod($i+1, $items_on_a_row );
if ($mod == 0) {
print "</TR>";
print "<TR bgcolor=\"#DDDDDD\">";
print "<TD></TD>";
}//endif
}//endfor
//close the last row and then close the table
print "</TR>";
print "</Table>";
?>
The Explanation
Couple of notes before I explain the code:
As part of my programming style I use:
- $arr_ArrayName - an array of whatever you want (which is better than $ArrayName);
- $noe_Entity - variable that has the Number Of Elements of an Entity;
Examples:
$arr_trailer_names is better than
$trailer_names; if you have a variable named
$trailer_name and if you use and editor that knows code completion you'll get confused. For me it's better to have
$arr_WHATEVER than
$WHATEVER for an array.
If you have multiple arrays:
$arr_students,
$arr_schools and
$arr_teacher_names to know the number of items for each array you will have
$noe_students,
$noe_schools and
$noe_teacher_names. You coul'd have
$noe_items instead of
$noe_students and then
$noe_schools and
$noe_teacher_names, but then you'll get confused, you will not know which
$noe_ is associated with which
$arr_. This is not so restricted, so you can use it how you want.
You have this
YouTube link:
http://www.youtube.com/watch?v=BZmE3fUKU5U, from this link we extract the value for
v, which is
BZmE3fUKU5U. So we don't need the full link only the last part from it. It is easier.
$items_on_a_row should be computed as follows: size of the screen, table, div or whatever divided by the width of the video. (e.g.: width=250 and the table width where you want the videos is 750, so it means that on a row we can have 3 videos.)
The colors for the player I won't use them right now;
Download the Code
Download CyE PHP Show Videos (downloads:123)
Top
July.04.2008 - How to display the last image of directory that contains pictures ?
preRequisite:
IrfanView, this is what I use in general, the dimension for thumbnail that I use is 140x105, not mandatory. You can resize it as you please, but remember the name should be like this: tn_$N, where $N = name of the picture. (e.g.: ArcticPole.jpg, the thumbnail should be tn_ArcticPole.jpg)
By the way, the pictures should not be different as name, meaning that for the code to work the pictures should be like this: Picture_Something_xx.jpg where xx=00, 99 OR Picture_Something_xxx.jpg where xxx=000, 999 OR WhatEverPictureName_numbers. (Having pictures from a camera will work, I tend to rename those picture with
CyE File Renamer to recognize what's in the picture or where I have taken them.)
Maybe the next version will be with the code needed that when you copy a picture, that is last added, that picture should be shown, no matter the name or the extension of the picture.Everytime you will copy a picture into a directory, you want to show that picture without modifying the code. So get the code for this problem.
I am using this code to show always the last picture that I copy, here it is (first section on the right side):
http://ctconstructii.ro.
The Code
<?php
//IMAGES
$arr_imgs = Array();
$dir = "img/fantana/mai/";
$hand = opendir($dir);
while (false !== ($f = readdir($hand))) {
if ( $f != "." && $f != ".." ) {
//only images, meaning no directories
if ( !is_dir($dir.$f ) ) {
//only pics without 'tn_'
if ( strpos(" ".$f, "tn_") === false ) {
array_push($arr_imgs, $f);
}
}
}
}//endwhile
closedir($hand);
sort($arr_imgs);
//everytime a picture is loaded in 'img/fantana/mai'
//the last one will be displayed as wanted;
print '<A HREF="'.$dir.$arr_imgs[ count($arr_imgs) - 1 ].'" target="_blank"><IMG SRC="'.$dir.'tn_'.
$arr_imgs[ count($arr_imgs) - 1 ].'" WIDTH="140" HEIGHT="105" BORDER="0" ALT=""></A>';
?>
The Explanation
I was thinking that the code is self explanatory, because I am using comments on this code (this does not mean that I'm using comments on 100% of the code...

), but there are things that I need to explain.
$dir = directory with the pictures and thumbnails, don't forget to add a ONLY ONE slash at the end, like in the code
strpos is tricky, it returns zero (0) in case of true which is not so good, because zero (0) it is also false when nothing found; so I'am adding a space in front of the string so the result will start at the position one (1). This thing does the trick !
sort($arr_imgs) = I must sort the pictures so the last picture uploaded should be shown;
count($arr_imgs) - 1 = I should replace this code with something more clear for the code to be readable, not right now, you can use something like:
$noe_imgs = count($arr_imgs) and then
$arr_imgs[ $noe_imgs - 1 ];Download the Code
Download CyE PHP Show Last Picture (downloads:132) - directory not included, only de PHP file.
Top
July.09.2008 - How to transform your email address, so the bot's will not recognize it ?
Of course we need to fight the SPAM when posting our email addresses. I've come up with a function that does the fighting. It can be improved that at every refresh of the page to show something else, this can be done using an array, for now I will stick with this.
I am using this function on the
http://ctconstructii.ro 'Contact' Section
Update - July.16.2008 (do not use "?", because when you click a morphed email address something is left out, so I modified the code... )
The Code
<?php
function morphEmail($email) {
$at = "@";
$dot = ".";
$text_at = " [i am AT] "; //" [i am AT ] "
$text_dot = " [got DOTs] "; //" [got DOTs ?] "
list($ID, $domain) = explode($at, $email);
$arr_domain_LMs = explode($dot, $domain);
$domain = "";
for ($i = 0; $i < count($arr_domain_LMs) - 1; $i++) {
$domain .= $arr_domain_LMs[ $i ].$text_dot;
}
$domain .= $arr_domain_LMs[ count($arr_domain_LMs) - 1 ];
return $ID.$text_at.$domain;
}
?>
The Explanation
Of course now, I'm explaining the code. I did not put any comments. The reason is that I don't want to overload de readability of it.
I will explain the code using an example:
$email ="IDthatIHaveChosen@subDomain.Domain.com" (like I've said, fighting against SPAM, no real email address given)
Everybody know that every email address is composed of:
- a screen name, an ID or chosen nickname: IDthatIHaveChosen (I am referring to this as ID from now on);
- the symbols: @ and . (dot);
- the domain (in this example with subdomain): subDomain.Domain.;
- and the extension (in this case): com.
For a plain email address like
IDthatIHaveChosen@subDomain.Domain.com one second to get the email and send SPAM to it. Fighting SPAM means that we have to come up with some sort of methods to beat the bots. I am using a method that replaces the symbols with some human readable text.
The functions replaces
@ with
[i am AT] (with 2 spaces, one before the starting square bracket and one after the closing square bracket) and
. (dot) with
[got DOTs] (same here with 2 spaces). You can replace with some other text, remember the text should be understandable.
In the first 4 lines I'm setting the symbols and the text to be replaced with.
First STEP: Get your ID and domain separated by
@ using
list and
explode.
$ID = IDthatIHaveChosen @ subDomain.Domain.com = $domainSecond STEP: It is best to use an array for the domain elements separated by
. (dot).
Why not use list instead ?
I don't know how many subdomains an email has, so I cannot use something like:
list($s1, $s2, $s3, $s4...) = explode($dot, $domain);So, the elements of a domain will be stored into an array:
$arr_domain_LMs = ('subDomain', 'Domain', 'com') (this is not PHP code, it's for showing purpose only)Third Step: Constructing the new mail (morphed email)
- replace each . (dot) and concatenate with every array's element (constructing the new domain): subdomain [got DOTs] Domain [got DOTs] com;
- replace @ with the text specified: [i am AT ] ;
- return the result.
The morphed email will be:
IDthatIHaveChosen [i am AT] subdomain [got DOTs] Domain [got DOTs] com;
Pretty interesting, now show me a bot that can send an email using this morphed email address !
Just update my email by using this function

, see the
Contact section.
The Test
Download the Code
Download CyE PHP Morph Email (downloads:125).
Top
March.25.2009 - How to display pictures on a web page ?
(did not do the update on the PC, so I'm putting once again the function)
Usage:
<?php
displayImages("path/to/my/images/", 7); //7 pictures on a table row
?>
The Code
<?php
function displayImages($dir, $pics_on_row) {
//IMAGES
$imgs = Array();
$hand = opendir($dir);
while (false !== ($f = readdir($hand))) {
if ( $f != "." && $f != ".." ) {
//only images
if ( !is_dir($dir.$f ) ) {
//only pics without 'tn_'
if ( strpos(" ".$f, "tn_") === false ) {
array_push($imgs, $f);
}
}
}
}//endwhile
closedir($hand);
sort($imgs);
print "<TABLE>";
print "<TR>";
for ($i = 0; $i < count($imgs); $i++) {
$pic = $imgs[ $i ];
print "<TD align=left><a href=\"".$dir.$pic."\" alt=\"".$pic."\" title=\"".$pic."\">
<IMG SRC=\"".$dir."tn_".$pic."\" BORDER=\"0\">\n</a></td>\n";
$mod = bcmod($i+1, $pics_on_row);
if ($mod == 0) {
print "</TR>";
print "<TR>";
}
}
print "</TR>";
print "</TABLE>";
}//displayImages
?>
Top 
Next Article - (still upcoming)