taith
Members-
Posts
1,514 -
Joined
-
Last visited
Everything posted by taith
-
HA! i wish i could get mac addresses... unfortunatly their not sent along with the headers... :-( what i do, is set an autoincreasing id on the users(log/password), and have that also put into each database also, for added security, put a security field in your users and put in (0.0.0.0) then explode it into $security[];... if that makes any sence...
-
as far as i know... only by putting it there [code] <a href="#?op=<?=$_COOKIE[var]?>"> [/code]
-
Sending html email with attachment in php problem
taith replied to netlovers's topic in PHP Coding Help
enjoy. [code] <? function email($to, $subject, $text, $from="", $file=""){ if(is_array($to)) $to = implode(", ",$to); if(empty($to)) return FALSE; if(empty($subject)) $subject="N/A"; $subject=strip_tags($subject); $text = wordwrap($text, 77, "<br />\n"); if(file_exists($file)){ switch(get_filetype($file,3)){ case ".rm": $type="audio/x-realaudio"; break; case ".qt": $type="video/quicktime"; break; } switch(get_filetype($file)){ case ".avi": $type="video/avi"; break; case ".doc": $type="application/msword"; break; case ".gif": $type="image/gif"; break; case ".jpg": $type="image/jpeg"; break; case ".mov": $type="video/mov"; break; case ".mpg": $type="video/mpeg"; break; case ".pdf": $type="application/pdf"; break; case ".png": $type="image/png"; break; case ".ram": $type="audio/x-pn-realaudio"; break; case ".tar": $type="application/x-tar"; break; case ".wav": $type="audio/wav"; break; case ".zip": $type="application/x-zip-compressed"; break; } switch(get_filetype($file,5)){ case ".html": $type="text/html"; break; case ".mpeg": $type="video/mpeg"; break; } if(!isset($type)) $type="text/plain"; $content = fread(fopen($file,"r"),filesize($file)); $content = chunk_split(base64_encode($content)); $name = basename($file); } $uid = strtoupper(md5(uniqid(time()))); $header = "From: $from\nReply-To: $from\n"; $header .= "MIME-Version: 1.0\n"; $header .= "Content-Type: multipart/mixed; boundary=$uid\n"; $header .= "--$uid\n"; $header .= "Content-Type: text/html\n"; $header .= "--$uid\n"; if(file_exists($file)){ $header .= "Content-Type: $type; name=\"$name\"\n"; $header .= "Content-Transfer-Encoding: base64\n"; $header .= "Content-Disposition: attachment; filename=\"$name\"\n\n"; $header .= "$content\n"; $header .= "--$uid--"; } if(mail($to, $subject, $text, $header)) return TRUE; else return FALSE; } ?> [/code] -
look into a game by the name of "legend of the green dragon"... it has pretty swell coding... i learned quite a few many things from it :-)
-
location is derived from an ip address. from complex(big) functions and arrays. http://www.geobytes.com/IpLocator.htm there are also a few free ones out there...(i have one) ;-)
-
Retrieve a whole URL via GET (or is there a better way?)
taith replied to closet geek's topic in PHP Coding Help
heres what i use to return the full url... its quick... and simple... also listens to querys... [code] <? function get_url(){ if(!empty($_SERVER[QUERY_STRING])) return 'http://'.$_SERVER[SERVER_NAME].$_SERVER[PHP_SELF].'?'.$_SERVER[QUERY_STRING]; else return 'http://'.$_SERVER[SERVER_NAME].$_SERVER[PHP_SELF]; } echo get_url(); ?> [/code] -
[code] function tempvar($variable, $testvariable) { if($variable == $testvariable) return 'selected="selected"'; } [/code]
-
. <-- same folder .. <-- parent folder so yes... "../../link.jpg" would send you 2 folders down and directed to that jpg
-
what i usually use is a random key, stored in database, and updated ever time the page loads... or just force them to login every time they reopen... [code] <? function randomkeys($length){ $pattern = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; for($i=0;$i<$length;$i++) $key .= $pattern{rand(0,62)}; return $key; } ?> [/code] and before puting ANYTHING into a database... use [code] <? function stripalltags($string){ $tam=strlen($string); $newstring=""; $tag=0; for($i=0; $i<$tam; $i++){ if($string{$i} == '<'){ $tag++; continue; } if($string{$i} == '>'){ if($tag) $tag--; continue; } if($tag==0) $newstring .= $string{$i}; } return $newstring; } ?> [/code]
-
yes... good read... however the code completly conflicts with the rest of my programming...
-
they are linking to the folder, not to the file, when you link to a folder, the index.php is automatically retrieved, but is not shown in the addressbar.
-
[code] if(!isset($_POST['field'])) [/code]
-
[code] function bignumbers($i){ if(strlen($i)<=3) return $i; if(strpos(",",$i)===false) $i=number_format($i); $a=array('','K','M'); $i=explode(",", $i); $c=count($i); return $i[0].$a[$c-1]; } echo bignumbers('100000'); echo bignumbers('100,000'); [/code]
-
instead of $_SESSION[var]="val"; you'd want [code] setcookie($var,$val,$time); [/code] cookies are not browser dependant, so you can store any invaluable information there... however... if you know what your doing and can alter cookies... they CAN be insecure...
-
how can i make sn number start from 1 when the new year is start.
taith replied to khs555's topic in PHP Coding Help
[code] echo date(z).'/'.date(Y); [/code] date(z) counts from 0-365 (includes leap year) -
you need to change the permisson on the folder your moving to to 777
-
no idea about books... but try www.tizag.com
-
here ya go... i just made this for ya... [code] <? function bignumbers($i){ if(strlen($i)<=3) return $i; $a=array('','K','Mil'); $i=explode(",", $i); $c=count($i); return $i[0].$a[$c-1]; } echo bignumbers('1,000,000'); echo bignumbers('1,000'); echo bignumbers('1'); ?> [/code]
-
try this... see if it gives you any errors... [code]mysql_query("UPDATE users SET `status`='1' WHERE `hash`='$hash'") or die(mysql_error);[/code]
-
$_SESSION is tied to the browser specifically... if you close/open it, all $_SESSION are back to defaults... if you want to have something persistant... use cookies...
-
[code] <?php $images=array('vulgare.png', 'blueberry.png' ,'kantarell.png',); echo "<table class=\"sidebartable\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" >"; for($counter = 0; $counter <= 4; $counter++){ $image=$images[rand(0,3)]; echo "<tr><td>"; echo"<img src=$image>"; echo "</td></tr>"; } ?> </table> [/code] EDITED BY thorpe; Please use long <?php tags within the [ code ] blocks, this enables syntax highlghting. You should be using it within your code anyway!
-
[code] <? $target_folder = "gallery"; $filename = basename($_FILES['newfile']['name']); $target_path = "$target_folder/$filename"; $filetype = pathinfo("$filename"); $filetype = $filetype['extension']; if(($filetype=="jpg")||($filetype=="jpeg")||($filetype=="gif")||($filetype=="png")||($filetype=="bmp")||($filetype=="tiff")||($filetype=="tga")||($filetype=="pub")){ if(move_uploaded_file($_FILES['newfile']['tmp_name'], $target_path)) echo "The file $filename has been uploaded"; } ?> [/code] old script of mine... but i'm sure you can customize...
-
[code] <INPUT TYPE=file NAME="html_file"> [/code]
-
[code] <? function dbconnect($host, $username, $password, $database){ global $link; $link = mysql_connect("$host","$username","$password"); mysql_select_db("$database"); } ?> [/code] that way you can call the function, it will connect, and your user/password dont leave the function.
-
How To Send Image In Web Page To A Pop-Up Window?
taith replied to phpBeginner06's topic in PHP Coding Help
$text can be a thumbnail or text $link can be to a file, or a picture [code]<? function popup($text, $link, $name="myWindow", $height="300", $width="300", $resizable="0", $status="0", $class=""){ return '<a href="#" onclick=\'javascript: window.open("'.$link.'", "'.$name.'", "status='.$status.', height='.$height.', width='.$width.', resizable='.$resizable.'")\' class='.$class.'>'.$text.'</a>'; } ?>[/code]