DirectoryWeb DesignBlog Details for "Smash Scripts"

Smash Scripts

Smash Scripts
Java Scripts, Ajax Scripts, PHP Scripts, PHP Support, Web Developer Documentation and more.

Articles

PHP-Convert any HTML file into PDF
2007-06-29 08:22:00
######################################### ################################### Function to Convert any HTML file into PDF Can save into a pdf file on server, or stream to the user's browser If you want to stream to the browser: $objClass->fnURL2PDF("http://www.yahoo.co m", "pdf.pdf"); If you want to save on the server: $objClass->fnURL2PDF("http://www.yahoo.co m", "", "../folder/filename.pdf"); Usage: $objClass->fnURL2PDF("http://www.yahoo.co m", "pdf.pdf"); Default is USA ######################################### ################################### function fnURL2PDF($varURL, $varFile Name = "pdf.pdf", $varSavePath = "") { $varSocket = fsockopen("www.easysw.com", 80, $errno, $errstr, 1000); if (!$varSocket) die("$errstr ($errno) "); fwrite($varSocket, "GET /htmldoc/pdf-o-matic.php?URL=" . $varURL . "&FORMAT=.pdf HTTP/1.0 "); fwrite($varSocket, "Host: www.easysw.com "); fwrite($varSocket, "Referer: http://www.easysw.com/htmldoc/pdf-o-matic .php "); fwrite($varSocket, " ...
More About: Html , Vert
PHP-Get a Value from XML Settings file
2007-06-29 08:19:00
######################################### ################################### Function to Get a Value from XML Settings file provided as a second argument Default is ../main/settings.xml: standard for all of our current projects Usage: $objClass->fnGetProperty("SiteURL", "settings.xml"); ######################################### ################################### function fnGetProperty($varPropName, $varXMLFile = '../main/settings.xml') { $objXML = new clsXML($varXMLFile); $varValue = $objXML->evaluate("//" . $varPropName); $varRetValue = $objXML->get_content($varValue[0]); $objXML = NULL; return($varRetValue); }Disclaimer: Any code or advice given is for instructional purposes only. We will not be responsible for any loss or damage caused by using this script.
PHP-Generate Random Password
2007-06-29 08:09:00
######################################### ################### Function to Generate Random Password of length n, Default = 6 characters Usage: $objClass->fnRandomPasswordGenerator(16); ######################################### ################## function fnRandomPasswordGenerator($length = 6) { $pass = ''; $new = ''; // all the chars we want to use $all = explode(" ", "a b c d e f g h i j k l m n o p q r s t u v w x y z " ."A B C D E F G H I J K L M N O P Q R S T U V W X Y Z " ."0 1 2 3 4 5 6 7 8 9"); for($i=0; $i { srand((double)microtime()*1000000); $pass .= $all[rand(0,61)]; $arr[] = $all[rand(0,61)]; $new .= $arr[$i]; } return $new; }Disclaimer: Any code or advice given is for instructional purposes only. We will not be responsible for any loss or damage caused by using this script.
PHP- File Attachment
2007-06-29 08:06:00
$fileatt = "file.txt"; // Path to the file$fileatt_type = "application/octet-stream"; // File Type$fileatt_name = "Report"; // Filename that will be used for the file as the attachment$email_from = "test@hotmail.com"; // Who the email is from$email_subject = "attachment"; // The Subject of the email$email_txt = "attachment"; // Message that the email has in it$email_to = "test@hotmail.com"; // Who the email is too$headers = "From: ".$email_from;$file = fopen($fileatt,'rb');$data = fread($file,filesize($fileatt));fclose($f ile);$semi_rand = md5(time());$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";$he aders .= " MIME-Version: 1.0 " ."Content-Type: multipart/mixed; " ." boundary="{$mime_boundary}"";$email_messa ge .= "This is a multi-part message in MIME format. " ."--{$mime_boundary} " ."Content-Type:text/html; charset="iso-8859-1" " ."Content-Transfer-Encoding: 7bit " .$email_message . " ";$data = chunk_split(base64_encode($data));$email_ message .= "--{$mim...
More About: Attachment , Attach , Atta
PHP- Calculate Elapsed time (in seconds!)
2007-06-29 08:00:00
function calcElapsedTime ($time) { $diff = time()-$time; $yearsDiff = floor($diff/60/60/24/365); $diff -= $yearsDiff*60*60*24*365; $monthsDiff = floor($diff/60/60/24/30); $diff -= $monthsDiff*60*60*24*30; $weeksDiff = floor($diff/60/60/24/7); $diff -= $weeksDiff*60*60*24*7; $daysDiff = floor($diff/60/60/24); $diff -= $daysDiff*60*60*24; $hrsDiff = floor($diff/60/60); $diff -= $hrsDiff*60*60; $minsDiff = floor($diff/60); $diff -= $minsDiff*60; $secsDiff = $diff; return (''.$yearsDiff.' year'.(($yearsDiff 1) ? "s" : "").', '.$monthsDiff.' month'.(($monthsDiff 1) ? "s" : "").', '.$weeksDiff.' week'.(($weeksDiff 1) ? "s" : "").', '.$daysDiff.' day'.(($daysDiff 1) ? "s" : "").', '.$hrsDiff.' hour'.(($hrsDiff 1) ? "s" : "").', '.$minsDiff.' minute'.(($minsDiff 1) ? "s" : "").', '.$secsDiff.' second'.(($secsDiff 1) ? "s" : "").''); }Disclaimer: Any code or advice given is for instructional ...
More About: Calculate , Seconds
PHP- Read contents of a text file
2007-06-29 07:59:00
######################################### #################################### # Function to Read contents of a text file # Usage: $objClass->fnReadFromFile ('filename.txt') ;# ######################################### ################################### function fnReadFromFile($sFileName) { $sReturn = ''; $fHandle = fopen($sFileName, "r"); while (!feof($fHandle)) $sReturn .= fread($fHandle, 4096); fclose($fHandle); return($sReturn); }Disclaimer: Any code or advice given is for instructional purposes only. We will not be responsible for any loss or damage caused by using this script.
More About: Text , Contents , Tent
PHP-A Unique session id
2007-06-29 07:55:00
function MakeSessionId() { $day = date('d', time()); $month = date('m', time()); $year = date('Y', time()); $hour = date('H', time()); $min = date('i', time()); $sec = date('s', time()); return sprintf("%02d%04d%02d-%02d%02d%04d-%04d-% 02d%04d", $sec, rand(0, 9999), $hour, $month, $min, rand(0, 9999), rand(0, 9999), $day, $year);}?>Disclaimer: Any code or advice given is for instructional purposes only. We will not be responsible for any loss or damage caused by using this script.
More About: Unique
PHP- Upload and convert avi, wmv, mov and mpg videos to FLV
2007-05-31 08:33:00
Upload and convert avi, wmv, mov and mpg videos to FLV using PHP1.First you have to create a page from where the user will upload a video lets call it uploadvideo.php. follow the code below..<form name=”frm” action=http://smashscripts.blogspot.com/f eeds/posts/”uploadvideopro.php̶ 1; method =”post” enctype="multipart/form-data" > <input name="x_URL" type="file" > </form> 2.Secondly on the process page i.e. uploadvideopro.php . follow the following code.. /***************Load FFMPEG *********************************/ $extension = "ffmpeg"; $extension_soname = $extension . "." . PHP_SHLIB_SUFFIX; $extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname; // load extension if (!extension_loaded($extension)) { dl($extension_soname) or die("Can't load extension $extension_fullname "); } /**************************************** **...
More About: Videos , Convert , Upload , Vert , D and C
PHP-IP Logger
2007-05-28 13:16:00
/* SIMPLE IP LOGGERok. First off,start off by creating a text file named ip.txt. Upload that to your server,and CHMOD it to 777. We did that because that is where the IPS are going to be logged.We CHMODED it to 777 because thats read,write,and executr persmissions. So that the file is ab;le to write to it. Now, the actuall PHP script. Make a new document In it,type this:*/$log_file = "ip.txt"; $ip = getenv('REMOTE_ADDR'); $fp = fopen("$log_file", "a");fputs($fp, "$iprn");flock($fp, 3); fclose($fp);PRINT("Your Ip was logged.....$ip"); /*Now lets review some of this.The $logfile is just what is sounds like. The log file that the IPS will be logged to. The $ip variable is confusing in this.It should go like something like $ip = $REMOTE-ADDV.But in this case it goes like $ip = getenv('REMOTE_ADDR');Same thing. They both get the USERS IP.$fp = fopen("$log_file", "a");fputs($fp, "$iprn"); flock($fp, 3); fclose($fp);What that does is write to the script.$fp= fopen then the log filevari...
More About: Logger
PHP-Directories filenames to database
2007-05-25 09:20:00
// a sinple function to create a database connectionfunction db_connect() { $conn = mysql_connect("localhost", "user", "pass"); mysql_select_db("dbname", $conn);}// this function will open the chosen directory and returns and array with all filenamesfunction select_files($dir) { if (is_dir($dir)) { if ($handle = opendir($dir)) { $files = array(); while (false !== ($file = readdir($handle))) { if (is_file($dir.$file) && $file != basename($_SERVER['PHP_SELF'])) $files[] = $file; } closedir($handle); if (is_array($files)) sort($files); return $files; } }}// this function inserts the filename and the modification date of the current filefunction insert_record($name, $mod_date) { $sql = sprintf("INSERT INTO example SET filename = '%s', lastdate = '%s'", $name, $mod_date); if (mysql_query($sql)) { return true; } else { return false; }}// establish data...
More About: Database , Directories , Dire , Rect
PHP-Daily (random) banner
2007-05-25 09:19:00
mysql_connect("localhost", "user", "password");mysql_select_db("database_nam e");// create table for the bannersmysql_query("CREATE TABLE IF NOT EXISTS `banners` ( `id` int(11) NOT NULL auto_increment, `name` varchar(35) NOT NULL default '', `link` varchar(150) NOT NULL default '', `alt_title` varchar(100) NOT NULL default '', `image` varchar(35) NOT NULL default '', `ins_date` date NOT NULL default '0000-00-00', `status` enum('on','off') NOT NULL default 'on', PRIMARY KEY (`id`)) TYPE=MyISAM AUTO_INCREMENT=1");// create the table for storing todays banner idmysql_query("CREATE TABLE `rand_banner` ( `id` int(11) NOT NULL auto_increment, `date` date NOT NULL default '0000-00-00', `todays_id` int(11) NOT NULL default '0', PRIMARY KEY (`id`)) TYPE=MyISAM AUTO_INCREMENT=1");// first check if todays banner id is already stored$check_today_sql = "SELECT todays_id FROM rand_banner WHERE date = NOW()";$check_today_res = mysql_query($check_today_sql);if (mysq...
More About: Daily , Random , Banner
PHP-Get TemplateMonster data
2007-05-25 09:02:00
// For more information: visit http://www.templatemonster.com/webapi/$nu m_records = 4;$aff_link = "http://www.all4yourwebsite.com/";$tm_url = "http://www.templatemonster.com/";$tm_url .= "webapi/templates_screenshots4.php";$para m['last_added'] = "Yes"; // this value is case sensitive$param['full_path'] = "true";$param['order'] = "asc";$param['sort_by'] = "date";$param['filter'] = "1";// add additional filters / parameters here// building querystring from the parameters$qs = "?";foreach ($param as $key => $val) { $qs .= $key."=".$val."&";}$qs = rtrim($qs, "&");// now get the records from the TM webapi$request_from = $tm_url.$qs;$all_rows = file($request_from);// now split the data for each row into an multi dim. arrayfor ($i = 0; $i $data[$i] = explode(" ", $all_rows[$i]);}$t_row = " ";foreach ($data as $row) { // read the information about more attr. $id = $row[0]; $price = $row[1]; $all_images = explode(",", trim($row[15], "{}")); $t_row .= " ";...
More About: Data , Temp , Mons
PHP-Text wrapper plus
2007-05-25 08:51:00
function text_wrap($log_text, $limit, $divider=" ") { $words = explode($divider, $log_text); $word_count = count($words); $char_counter = 0; $block = ""; foreach ($words as $value) { $chars = strlen($value); $block .= $value; $char_counter = $char_counter + $chars; if ($char_counter >= $limit) { $block .= " \n "; $char_counter = 0; } else { $block .= " "; } } return rtrim($block);} ?>Disclaimer: Any code or advice given is for instructional purposes only. We will not be responsible for any loss or damage caused by using this script.
More About: Text , Rapper , Wrapper , Wrap
PHP-URL / domain name splitter
2007-05-25 08:48:00
$url_parts = parse_url("http://mail.finalwebsites.co.u k");$domain = $url_parts['']$res = mysql_query("SELECT tld FROM domain_info ORDER BY LENGTH(tld) DESC");// "ORDER BY LENGTH(tld)" will give first the co.uk and then the ukwhile ($arr = mysql_fetch_assoc($res)) { $tmp_tld = substr($domain, -strlen(".".$arr['tld'])); if ($tmp_tld == ".".$arr['tld']) { // You found the tld $tld = ltrim($arr['tld'], "."); $domainLeft = substr($domain, 0, -(strlen($tld) + 1)); // It will left the whatever, without the extension and the . if (strpos($domainLeft, ".") === false) { // It hasn't a subdomain $subDomain = ""; $finalDomain = $domainLeft; } else { $domain_parts = explode(".", $domainLeft); $finalDomain = array_pop($domain_parts); // select the domain and remove it from the array $subDomain = implode(".", $domain_parts); // a subdomain can more then one parts seperated with dot's } ...
More About: Domain Name , Splitter
PHP-Simple attachment mail script
2007-05-25 08:45:00
function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message) { $file = $path.$filename; $file_size = filesize($file); $handle = fopen($file, "r"); $content = fread($handle, $file_size); fclose($handle); $content = chunk_split(base64_encode($content)); $uid = md5(uniqid(time())); $name = basename($file); $header = "From: ".$from_name." "; $header .= "Reply-To: ".$replyto." "; $header .= "MIME-Version: 1.0 "; $header .= "Content-Type: multipart/mixed; boundary="".$uid."" "; $header .= "This is a multi-part message in MIME format. "; $header .= "--".$uid." "; $header .= "Content-type:text/plain; charset=iso-8859-1 "; $header .= "Content-Transfer-Encoding: 7bit "; $header .= $message." "; $header .= "--".$uid." "; $header .= "Content-Type: application/octet-stream; name="".$filename."" "; // use diff. tyoes here $header .= "Content-Tr...
More About: Mail , Script , Simple , Attachment , Attach
PHP- Client URL Library Function
2007-04-03 07:16:00
$ch = curl_init("http://www.example.com/");$fp = fopen("example_homepage.txt", "w");curl_setopt($ch, CURLOPT_FILE, $fp);curl_setopt($ch, CURLOPT_HEADER, 0);curl_exec($ch);curl_close($ch);fclose( $fp);?>Disclaimer: Any code or advice given is for instructional purposes only. We will not be responsible for any loss or damage caused by using this script.
More About: Library , Function , Libra , Client
Javascript-Sorting Dates in List Box
2007-03-31 07:52:00
<html><head><title>Java script-Sorting Dates in List Box</title><script language="JavaScript">function Sort_Dates() { var x, y, holder; var list_box = document.frm.list_dates; FirstDate = new Date(); SecondDate = new Date(); for(x = 0; x < list_box.options.length; x++) { for(y = 0; y < (list_box.options.length-1); y++) { array_first = list_box.options[y].value.split("/"); array_second = list_box.options[y+1].value.split("/"); FirstDate.setMonth(array_first[0]); FirstDate.setDate(array_first[1]); FirstDate.setYear(array_first[2]); SecondDate.setMonth(array_second[0]); SecondDate.setDate(array_second[1]); SecondDate.setYear(array_second[2]); if (FirstDate >SecondDate) //here you can modify the condition to work for ascending or descending { holder = list_box.options[y+1].value; list_box.options[y+1].value = list_box.options[y].value; list_box.options[y+1].text = list_box.options[y].value; list_box....
More About: Javascript
PHP-CURL and You
2007-03-31 07:19:00
The first step in using CURL is to create a new CURL resource, by calling the curl_init() function, like so:// create a new curl resource$ch = curl_init();?>Now that you've got a curl resource, it's possible to retrieve a URL, by first setting the URL you want to retrieve using the curl_setopt() function:// set URL and other appropriate optionscurl_setopt($ch, CURLOPT_URL, "http://www.google.com/");?>After that, to get the page, call the curl_exec() which will execute the retrieval, and automatically print the page:// grab URL and pass it to the browsercurl_exec($ch);?>Finally, it's probably wise to close the curl resource to free up system resources. This can be done with the curl_close() function, as follows:// close curl resource, and free up system resourcescurl_close($ch);?>That's all there is to it, and the above code snippets together form the following working demo:// create a new curl resource$ch = curl_init();// set URL and other appropriate optionscurl_setopt($ch, CUR...
More About: Curl
128465 blogs in the directory.
Statistics resets every week.


Contact | About
© Blog Toplist 2017