VirtueMart error: Credit Card Type not found
by Koree Monteloyola
I have just discovered what causes the "Credit Card Type not found" error in VirtueMart.
First problem : the "Credit Card Type" drop down box isn't displaying...this lead me to the 2nd problem, which is
Second problem : A javascript "writeDynaList" function is required, but is not included in your current javascript functions. So where will you find it?...moving on to the third problem
Third problem: the "writeDynaList" is inside the "JURI::root(true).'/includes/js/joomla.javascript.js'", but the javascript file isn't loading. WHY NOT?
The explanation can be found through this snippet of code in your <joomladirectory>/includes/application.php, and string search for this condition:
if ( $user->get('id') ) {
$document->addScript( JURI::root(true).'/includes/js/joomla.javascript.js');
}
}
This means, that the user has to be logged in to load the javascript file.
If you want to force your customers to login during checkout, go to:
Administrator->Component->Virtuemart->Configuration->Global->User Registration Settings
then set the value of "User Registration Type" to "Normal Account Creation"
Hope this post helps you. Cheers!
Simultaneously publish your articles to Twitter and Facebook
by Koree Monteloyola
I have combined and modified codes from Twitter's API and Facebook Connect in order to create a working sample that would let webpage viewers to share or publish a link (from a certain site) to their Twitter and Facebook accounts - simultaneously.
For the Twitter login, I prefer to use oAuth, since Basic authorization/authentication is very unsecure and would be terminated soon.
Here are some helpful developer links to get you started Ü
Facebook Connect
Facebook Connect
Facebook Connect Tutorial1
Connect/Demos
Twitter
Twitter API wiki
Beginner’s Guide to OAuth – Part I: Overview
Twitter-async
Of course, a few modification of my code would let you update your status using a dynamic text, but I'll leave that task to you.
Cheers!
Image Manipulation : Watermark images on the fly through PHP and GD
by Koree Monteloyola
Let's say you're given a hundred "digital" images and you need to put watermarks on each of those photos.
If you're going to do this manually, man! It would eat a lot of your time.
So here's a solution: a php script that would automatically merge a watermark to an image.
Requirements:
- PHP 4+
- GD 2.0+ Library
- watermark file should be saved as PNG-8, not PNG-24.
<?php
$err=0;
if(empty($_GET['path'])){
$path = 'images/wrongPath.gif';
$err++;
}else{
if(!is_file(getcwd().'/images/'.$_GET['path'])){
$path = 'images/wrongPath.gif';
}else{
$path = 'images/'.$_GET['path'];
}
}
$srcImage = $path;
header("Content-type: " . image_type_to_mime_type(exif_imagetype($srcImage)));
switch(exif_imagetype($srcImage)){
case IMAGETYPE_GIF:
$image = imagecreatefromgif($srcImage);
break;
case IMAGETYPE_JPEG:
$image = imagecreatefromjpeg($srcImage);
break;
case IMAGETYPE_PNG:
$image = imagecreatefrompng($srcImage);
break;
}
if(empty($err)){
$watermark = imagecreatefrompng(getcwd().'/images/watermark.png');
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
$size = getimagesize($srcImage);
$dest_x = $size[0] - $watermark_width - 10;
$dest_y = $size[1] -$watermark_height - 10;
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);
}
switch(exif_imagetype($srcImage)){
case IMAGETYPE_GIF:
imagegif($image);
break;
case IMAGETYPE_JPEG:
imagejpeg($image);
break;
case IMAGETYPE_PNG:
imagepng($image);
break;
}
imagedestroy($image);
imagedestroy($watermark);
?>
You can download a sample of the script here.
jEdit : A text editor for programmers
by Koree Monteloyola
I have been a web programmer for 5 years and I have been faithful to only 3 text editors, namely: Maguma, Dreamweaver and jEdit.
Among the 3, jEdit is my "weapon of choice". Again, this tool was introduced to me by k0n, because he's a show off. (haha! just kidding)
jEdit is written in Java and I've tried using it on Linux and Windows. It also has support for other programming & scripting language, such as java, perl, asp, php..and a lot more, you can see the list under Global options > Editing > Change settings for mode drop down box
What makes this text editor powerful is the plugins you can install to make it an advanced XML/XHTML text editor or an IDE.
Here is a screenshot of the "must have" plugins I use.

If you're using PHP, you should definitely install PHPParserPlugin and SideKick.
One of the "cool" things you can do with this editor is customizing the look&feel; if you notice I use a black background, to reduce the stress on my eyes, and I can have an upbeat Saito Hajime background image, like so:

Looks cool, eh?
So give this text editor a try, download it now!
Dynamically generate your website's RSS with PHP and MySQL
by Koree Monteloyola
This is the script I use to dynamically generate my site's RSS using php and mysql.
<?php
$sql = "SELECT * FROM mydatabase.mysite_articles";
$result = mysql_query($sqll) or die("Cannot generate rss");
$numrows = mysql_num_rows($result);
if($numrows > 0){
$now = date("D, d M Y H:i:s T");
$string = "<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>title of your site here</title>
<link>yoursite.com/rss.php</link>
<description>".htmlentities(site's description here)."</description>
<language>en-us</language>
<pubDate>".$now."</pubDate>
<lastBuildDate>".$now."</lastBuildDate>
<docs>url as reference of rss documentation</docs>
<managingEditor>emailhere@yoursite.com</managingEditor>
<webMaster>emailhere@yoursite.com</webMaster> ";
while($row = mysql_fetch_array($result)){
$string .= "<item> ";
$string .= "<title>".$row[title']."</title> ";
$string .= "<link>".$row['link']."</link> ";
$string .= "<description>".$row['link']."</description> ";
$output .= "<pubDate>".date("D, d M Y H:i:s T",$row['date_timestamp']))."</pubDate> ";
$string .= "</item> ";
}
$string .= "</channel> ";
$string .= "</rss> ";
header("Content-Type: application/rss+xml");
echo $string;
}
?>
Using a content-disposition header, which specifies the output and presentation of the body part as an xml/rss, there is no need to create a separate rss file (through fopen/fwrite).
The content-disposition header is being specified through this line of code:
header("Content-Type: application/rss+xml");




