Note that when you display in HTML, the image is in thumbnail. But when you pass the value to this function, it shouldn't be the thumbnail, but the original image.
Saturday, October 20, 2007
Enlarge an image from thumbnail
Just copy and paste this javascript, and write an anchor link which when clicked, call this function. A very simple function but I just post it anyway. I may forget about it once I look away.
Note that when you display in HTML, the image is in thumbnail. But when you pass the value to this function, it shouldn't be the thumbnail, but the original image.
Note that when you display in HTML, the image is in thumbnail. But when you pass the value to this function, it shouldn't be the thumbnail, but the original image.
Tuesday, October 2, 2007
Batch uploading form
This is the html file to do batch uploading. Basically it's just a simple upload form.
The script for the batch uploading is in the previous post. Redirect the page and combine it with the script file anyway you want you page to be.
The script for the batch uploading is in the previous post. Redirect the page and combine it with the script file anyway you want you page to be.
| CSV File Upload | |
|---|---|
I have to print screen the codes as this blog actually capture my script and turn it into html. | |
Batch uploading function
This function is to do batch uploading into database. I will provide the skin file in my next post. Basically the file uploaded is in CSV format.
function batch_upload() {
global $user;
// get vars & $post vars
$this->get = &$GLOBALS[HTTP_GET_VARS];
$this->post = &$GLOBALS[HTTP_POST_VARS];
// see if submitted form
$submit=$this->post;
if(!$submit){
header("location:upload.html");
} else {
$farg=&$GLOBALS[HTTP_POST_FILES];
if ($farg) {
foreach(array_keys($farg) as $fdn) {
if ($farg[$fdn][tmp_name]) {
$fname = $farg[$fdn][tmp_name];
exec("chmod 744 $fname");
$ref = $user[_id]."_".time(); //to be use to indentify record
//create a tmp_table before hand
//assign all the previous record as old record. so that will not confuse with new records
mysql_query("update tmp_table set is_new = 'no'");
$cmd = "LOAD DATA INFILE '$fname' INTO TABLE tmp_table FIELDS TERMINATED BY ',' ENCLOSED BY '".'"'."' LINES TERMINATED BY '\r\n' (field1,field2,field3,field4)";
$result=mysql_query($cmd);
//distinguish new record from the new one
mysql_query("update tmp_table set ref = '$ref' where is_new = 'yes'");
//start to transfer into real table
mysql_query("insert into real_table (field1,field2,field3,field4) select field1,field2,field3,field4 from tmp_table where ref='$ref'");
header("location:doneupload.php");
}
}
}
}
function batch_upload() {
global $user;
// get vars & $post vars
$this->get = &$GLOBALS[HTTP_GET_VARS];
$this->post = &$GLOBALS[HTTP_POST_VARS];
// see if submitted form
$submit=$this->post;
if(!$submit){
header("location:upload.html");
} else {
$farg=&$GLOBALS[HTTP_POST_FILES];
if ($farg) {
foreach(array_keys($farg) as $fdn) {
if ($farg[$fdn][tmp_name]) {
$fname = $farg[$fdn][tmp_name];
exec("chmod 744 $fname");
$ref = $user[_id]."_".time(); //to be use to indentify record
//create a tmp_table before hand
//assign all the previous record as old record. so that will not confuse with new records
mysql_query("update tmp_table set is_new = 'no'");
$cmd = "LOAD DATA INFILE '$fname' INTO TABLE tmp_table FIELDS TERMINATED BY ',' ENCLOSED BY '".'"'."' LINES TERMINATED BY '\r\n' (field1,field2,field3,field4)";
$result=mysql_query($cmd);
//distinguish new record from the new one
mysql_query("update tmp_table set ref = '$ref' where is_new = 'yes'");
//start to transfer into real table
mysql_query("insert into real_table (field1,field2,field3,field4) select field1,field2,field3,field4 from tmp_table where ref='$ref'");
header("location:doneupload.php");
}
}
}
}
Email blast
Today i just done an email blasting, so thought of posting it here. You can put in the bcc, cc, as you like. The email of the recipients is taken from the database. The body of the message will appear exactly as how you type it in.
Here's the code :
//do the query from the database
$query="SELECT name,fname,password,email from user where status='active'";
$result=mysql_query($query);
//if this line doesn't work, replace it with while(mysql_fetch_array(xxx))
while(list(,$arr)=each($query)) {
$email=$arr[email];
$name=$arr[name];
$password=$arr[password];
$fname=$arr[fname];
//check if a particular user has 2 emails account. change the '/' according to your database input
$twoemail=strstr($email,'/');
$pos=strpos($email,'/');
//if user has two emails
if($twoemail) {
$first=substr($email,0,$pos);
$second=substr($twoemail,1);
$to = $first.",".$second;
$from="mailto:$from=support@blablabla";
$bcc="whoever@lala.com";
$subject = "Welcome to BLABLABLA";
$body = "
Dear $name,
Welcome to the BLABLABLA
URL: http://www.alldogsworld.com/
Login-ID: $name
Password: $password
Best Regards
Administrator
______________________________________________
This is an auto-generated mail. Please do not reply to this mail.
";
if (mail($to, $subject, $body, "From: $from\r\nBcc:$bcc")) {
echo("I have spam your mailbox. Muahahhaa");
} else {
echo("Message delivery failed...go stand in a corner");
}
} else {
//user has only one email
$to = $email;
$from="support@xxxxxxx";
$bcc="iampig@gmail.com";
$subject = "Welcome to bla bla bla";
$body = "
Dear $name,
Welcome to the bla bla bla
URL: http://www.alldogsworld.com/ Login-ID: $name Password: $password
Best Regards
Administrator
______________________________________________
This is an auto-generated mail. Please do not reply to this mail.
";
if (mail($to, $subject, $body, "From: $from\r\nBcc:$bcc")) {
echo("I have spam your mailbox. Muahahaha");
} else {
echo(" Message delivery failed...go stand in a corner");
}
}
header('location:sent.php');
Here's the code :
//do the query from the database
$query="SELECT name,fname,password,email from user where status='active'";
$result=mysql_query($query);
//if this line doesn't work, replace it with while(mysql_fetch_array(xxx))
while(list(,$arr)=each($query)) {
$email=$arr[email];
$name=$arr[name];
$password=$arr[password];
$fname=$arr[fname];
//check if a particular user has 2 emails account. change the '/' according to your database input
$twoemail=strstr($email,'/');
$pos=strpos($email,'/');
//if user has two emails
if($twoemail) {
$first=substr($email,0,$pos);
$second=substr($twoemail,1);
$to = $first.",".$second;
$from="mailto:$from=support@blablabla";
$bcc="whoever@lala.com";
$subject = "Welcome to BLABLABLA";
$body = "
Dear $name,
Welcome to the BLABLABLA
URL: http://www.alldogsworld.com/
Login-ID: $name
Password: $password
Best Regards
Administrator
______________________________________________
This is an auto-generated mail. Please do not reply to this mail.
";
if (mail($to, $subject, $body, "From: $from\r\nBcc:$bcc")) {
echo("I have spam your mailbox. Muahahhaa");
} else {
echo("Message delivery failed...go stand in a corner");
}
} else {
//user has only one email
$to = $email;
$from="support@xxxxxxx";
$bcc="iampig@gmail.com";
$subject = "Welcome to bla bla bla";
$body = "
Dear $name,
Welcome to the bla bla bla
URL: http://www.alldogsworld.com/ Login-ID: $name Password: $password
Best Regards
Administrator
______________________________________________
This is an auto-generated mail. Please do not reply to this mail.
";
if (mail($to, $subject, $body, "From: $from\r\nBcc:$bcc")) {
echo("I have spam your mailbox. Muahahaha");
} else {
echo(" Message delivery failed...go stand in a corner");
}
}
header('location:sent.php');
About Me
Sylph is a lady in her early twienties, and working as a software engineer and an animal lover. Used to write programs in PHP, C++, ASP, ASP.NET, VB, Lotus Notes but somehow now she has chosen PHP as her main focus.
Here, gonna share everything she knows about PHP and Javascript. Hopefully this information will be useful for some applications from time to time. In addition, there will be SEO tips every now and then when there is a new Google update.
Cheers!
www.alldogsworld.com
Here, gonna share everything she knows about PHP and Javascript. Hopefully this information will be useful for some applications from time to time. In addition, there will be SEO tips every now and then when there is a new Google update.
Cheers!
www.alldogsworld.com
Subscribe to:
Posts (Atom)
