Open source photo gallery - Plogger

Tuesday, May 26, 2009 Posted by Md. Monjurul Hasan 0 comments
I was in need of a photo gallery - ofcourse open source, and I got two choices - Plogger and Gallery. Gallery2 will give you many features while plogger is really simple and worth for my small requirements. It has easy admin panel and also gives the basic features including slideshow - so I decided to rely on Plogger. I have modified the default theme and it worked fine.
First I removed the footer-text ('Powered by Plogger') from page (for that I commented out this line - print plogger_link_back(); in ploggerdir/themes/default/footer.php)
and
modified the css to decrease the search box width (added this line

#jump-search-container input[type=text] {
width: 120px;
}

in ploggerdir/themes/default/gallery.css ).

Still working on it.

Debug Shell and Python Script from console

Tuesday, May 19, 2009 Posted by Md. Monjurul Hasan 0 comments
> When running Shell script, enable the debug mode with -x option.E.g. sh -x yourscript.sh
> When running Python script, import pdb - the Python debugger, call the set_trace() function and enter n in the console for next debug output. E.g.

#!/usr/bin/python
# epdb1.py -- experiment with the Python debugger, pdb
import pdb
def combine(s1,s2): # define subroutine combine, which...
s3 = s1 + s2 + s1 # sandwiches s2 between copies of s1, ...
s3 = '"' + s3 +'"' # encloses it in double quotes,...
return s3 # and returns it.
a = "aaa"
pdb.set_trace()
b = "bbb"
c = "ccc"
final = combine (a,b)
print final
Labels:

Email tips for PHP Pear

Posted by Md. Monjurul Hasan 0 comments
Email facility is required for almost every application. Hence these tips are helpful.

1. For datetime in proper format,
$headers["Date"] = date("r");

2. For both HTML and text mail,
 $headers["Content-Type"] = "multipart/alternative";

3. For sending mail with SMTP Authentication,
$mail = Mail::factory(
"smtp",
array ('host' => $host,
'auth' => 'true',
'username' => $username,
'password' => $password)
);


A quick helpful tutorial: http://email.about.com/od/emailprogrammingtips/qt/et073006.htm
Labels: , ,

Upgraded to Windows® 7 RC

Posted by Md. Monjurul Hasan 0 comments
Just safely upgraded my windows from vista to 7 without taking backup. It required additional 8 GB in installation directory. Looks pretty cool. Like the new taskbar. This version is valid till June,2010. So I am an original windows user at last!!
Labels: ,

HTTP VS HTTPS

Posted by Md. Monjurul Hasan 0 comments
I was trying to study the basics of them. Summarized here what I have got.

> http send everything you do in plan text for any one to read.

> https is slower and requires a secure server and therefore would be much more expensive. Browsing doesn't require secure socket layer.

https encrypts everything you do so that no one can read what you type but the recipient.

The problem with encrypting data is that you cant just encrypt it and say only yahoo can read it. Both you and yahoo have to have a secret key so that yahoo can decrypt what you sent and encrypt private stuff for you to read.

This is accomplised by an encryption scheme known as public key. Yahoo puts out a public key so that every one can encrypt stuff that only yahoo can read its like a one way key: you can package stuff up and send it to yahoo so that they can read it with theire private key but some one with a public key cant see what you encrypted.

So you package up a key for yahoo to use to talk to you and you are all set.

Why all internet communication isn't done like this is because of what is known as the man in the middle attack, and its solution.

It's quite simply to pretend to be yahoo.com if you know what you doing. so I pretend to be yahoo and all traffic you think is going to yahoo comes to me. you ask me for my public key I respond back with an fake public private key pair that I made then I ask yahoo for there public key and every thing you to I do I just watch for anything interesting like Credit cards etc.

To be continued...
Labels: ,

Tips for Dom PDF

Posted by Md. Monjurul Hasan 0 comments
See what I have experienced so far. May be useful for you too.

  1. No need to install, can be called directly.But be sure php-xml package is installed. You can be sure from phpinfo().

  2. When using, change the path in dompdf_config.inc if necessary

  3. Be sure that the html code is clean i.e. tags are closed

  4. Dom PDF can not render multiple html pages with a single table. I was facing of getting a single page while original was more than one


To be continued....
Labels:

SugarCRM: Search directly using url

Posted by Md. Monjurul Hasan 0 comments
This url can save your time! It takes you to the SugarCRM search form and gives the search result for the desired string in Accounts module. Can search in multiple modules (use &)

http://yoursugarcrm.com/index.php?module=Home&query_string=test&advanced=true&action=UnifiedSearch&search_form=false&query_string=yourstring&search_mod_Accounts=true

Remember, you have to login into your SugarCRM before using this url.
Labels:

Dom PDF: PDF support for Smarty templates

Posted by Md. Monjurul Hasan 0 comments
I was having some troubles with PDF report generation. I used Smarty Templates, so I was looking for PDF class that will support Smarty output.

Finally I stayed on Dom PDF. It supports PHP 5 and CSS 2.1.


//include the dom pdf
require('dompdf/dompdf_config.inc.php');

//fetch the HTML output from smarty template
$htmlcontent=$smarty->fetch('smarty_template.tpl');

//call dom pdf class
$dompdf = new DOMPDF();
$dompdf->load_html($htmlcontent);
$dompdf->render();
//display output in browser
$dompdf->stream();
//or, save as a pdf
$pdf = $dompdf->output();
file_put_contents("tmp/filename.pdf", $pdf);


There are other options like set paper size etc. You can try this.
Labels: ,

Get the browser's response from authenticated site using curl

Posted by Md. Monjurul Hasan 0 comments
Some days ago I needed the images generated by a secure webpage on a routine basis (you have to enter by giving username and password and when it is clicked it runs its cgi script/php file). Without going to the browser I simply ran a shell script from cron which mainly has the following command.

curl -u username:password url

saved a lot of tym!!
Labels: ,

SugarCRM: Adding custom fields in custom module without using studio

Posted by Md. Monjurul Hasan 0 comments
SugarCRM is really handy using studio. Otherwise, Its giving me pain. Currently I am using SugarCRM version 5.0.0f.

I am trying to merge my changes from development CRM to main CRM without using studio. For this I need to add the custom fields,relations and change the current view (EditView, DetailView, ListView and SearchPanels) since I have modified it.

Lets c guys what I have done in the meantime.

  1. Added two database modulename_cstm and fields_meta_data and dump them from my dev crm database.
    if you have already these database, then just insert the new entries.

  2. For custom relationship, created a metadata file (module1module2MetaData.php) in sugarcrm/metadata dir and included that file in two files of custom directory.
    custom/application/Ext/Include/modules.ext.php and
    custom/Extension/application/Ext/TableDictionary/modulename.php

  3. Created an entry in following files
    custom/Extension/modules/ModuleName/Ext/Layoutdefs/modulename.php
    custom/Extension/modules/ModuleName/Ext/Vardefs/modulename.php

  4. Created folder in custom/Extension/modules/ same as other module [name it as your related module]
    watch out Layout and Vardef file in that directory

  5. Change in files modules/ModuleName/Ext/Vardef and modules/ModuleName/Ext/Layout if necessary

  6. Label of the fields should be present in custom/modules/ModuleName/language/en_us.lang.php

  7. New viewdefs files should be present at custom/modules/ModuleName/metadata/

  8. Do not forget to quick repair and rebuild from sugar admin


After all these works, I have found my changes merged and working, but the studio views are still like previous. So I am working on it.

Cheers!
Labels: