Jump to content

pedromau

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

pedromau's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey guys! I'm having trouble in getting this code to create proportional square images. I just need someone to take a look and tell me what's wrong in there... I'm a damn noob... A friend of mine gave me that code, but I don't know what to change so it works! Please, help! <?php $storage = 'img'; $today = date("d-m-Y"."-"); // full path/filename to save $uploadfile = "$storage/".$today . basename( $_FILES['Filedata']['name'] ); //$uploadfile = basename( $_FILES['Filedata']['name'] ); // move the file from the http request to storage $success = move_uploaded_file( $_FILES['Filedata']['tmp_name'] , $uploadfile ); //---resizing uploaded image to a thumb in dir Thumb--- $sizew = 190;$sizeh = 190; // the thumbnail's maximal width and height $size2w = 190;$size2h = 190;//the picture's maximal width and height (requested) $filedir = 'img/'; // the directory for the original image $picdir = 'img/'; //the directory for the resized image $thumbdir = 'img/'; // the directory for the thumbnail image $maxfile = '150000'; $mode = '0666'; $userfile_name = $_FILES['Filedata']['name']; $userfile_tmp = $_FILES['Filedata']['tmp_name']; $userfile_size = $_FILES['Filedata']['size']; $userfile_type = $_FILES['Filedata']['type']; if (isset($_FILES['Filedata']['name'])) { $prod_img = $filedir.$userfile_name; $prod_img_thumb = $thumbdir.$userfile_name; move_uploaded_file($userfile_tmp, $prod_img); chmod ($prod_img, octdec($mode)); $sizes = getimagesize($prod_img); //compare orig w and h to create thumbs if (($sizes[1] <= $sizeh) && ($sizes[0] <=$sizew)) { $new_width = $sizes[0]; $new_height = $sizes[1]; } if ($sizes[0] > $sizes[1]) { $aspect_ratio = $sizes[1]/$sizes[0]; $new_width = $sizew; $new_height = abs($new_width*$aspect_ratio); } else{ $aspect_ratio = $sizes[0]/$sizes[1]; $new_height = $sizeh; $new_width = $sizew; abs($new_height*$aspect_ratio); } $destimg=ImageCreateTrueColor($new_width,$new_height) or die('Problem In Creating image'); $srcimg=ImageCreateFromJPEG($prod_img) or die('Problem In opening Source Image'); ImageCopyResized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing'); ImageJPEG($destimg,$prod_img_thumb,100) or die('Problem In saving'); imagedestroy($destimg); } //------added resizing of actual picture----------------------- if (isset($_FILES['Filedata']['name'])) { $prod_img = $filedir.$userfile_name; $prod_img_pic = $picdir.$userfile_name; move_uploaded_file($userfile_tmp, $prod_img); chmod ($prod_img, octdec($mode)); $sizes = getimagesize($prod_img); //compare orig w and h to create actual picture if (($sizes[1] <= $size2h) && ($sizes[0] <=$size2w)) { $new_width = $sizes[0]; $new_height = $sizes[1]; } if ($sizes[0] > $sizes[1]) { $aspect_ratio = $sizes[1]/$sizes[0]; $new_width = $size2w; $new_height = abs($new_width*$aspect_ratio); } else{ $aspect_ratio = $sizes[0]/$sizes[1]; $new_height = $size2h; $new_width = $size2w; abs($new_height*$aspect_ratio); } $destimg=ImageCreateTrueColor($new_width,$new_height) or die('Problem In Creating image'); $srcimg=ImageCreateFromJPEG($prod_img) or die('Problem In opening Source Image'); ImageCopyResized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing'); ImageJPEG($destimg,$prod_img_pic,100) or die('Problem In saving'); imagedestroy($destimg); } //-------till here------------------ $pref = '&err='; if( $success ) { $cor = 'Successfully moved uploaded/resized file '; } // else failed else { $cor = 'Failed to move uploaded file '; } // ------------------- // updating date txt file // ------------------- $filename = "check.txt"; // text file name (CHMOD 777); // Opens up the file declared above for reading and emptying chmod ($filename, 0777); $fp = fopen( $filename,"w+"); ftruncate($fp, '0'); fclose( $fp ); $New = "$pref$cor$uploadfile"; $fp = fopen($filename, "w+"); fwrite($fp, $New, 40000); fclose($fp); ?>
  2. hello people! I'm using a flash system that allows user to upload images to pimp their news... but there's something wrong with my script... Here's what's happening (I need to create a thumb exactly 283 x 150 px): - The original image is uploaded into the originals folder...no problem here; - If it is an horizontal image, it creates and upload the images, but the dimensions aren't correct... only width match! - If it is a vertical image, no thumb is created, but original image is uploaded to originals... Here's the script: <?php $storage = 'originals';//create this dir and chmod to 777, here the uoloaded files are stored in original dimensions; // full path/filename to save $uploadfile = "$storage/" . basename( $_FILES['Filedata']['name'] ); // move the file from the http request to storage $success = move_uploaded_file( $_FILES['Filedata']['tmp_name'] , $uploadfile ); //---resizing uploaded image and transferto dir news_img ----- $sizew = 283;$sizeh = 150;//the picture's maximal width and height (requested) $picdir = 'news_img/'; //create this directory for the resized image and chmod to 777; $maxfile = '50000';//the picture's maximal size in KB $mode = '0666'; $userfile_name = $_FILES['Filedata']['name']; $userfile_tmp = $_FILES['Filedata']['tmp_name']; $userfile_size = $_FILES['Filedata']['size']; $userfile_type = $_FILES['Filedata']['type']; if (isset($_FILES['Filedata']['name'])) { $prod_img = $storage.$userfile_name; $prod_img_pic = $picdir.$userfile_name; move_uploaded_file($userfile_tmp, $prod_img); chmod ($prod_img, octdec($mode)); $sizes = getimagesize($prod_img); //compare orig w and h to create actual picture if (($sizes[1] <= $sizeh) && ($sizes[0] <=$sizew)){ //if both smaller or equal than resp 283(w) 150(h) do NOTHING $new_width = $sizes[0]; $new_height = $sizes[1]; } if (($sizes[0] > $sizew) && ($sizes[1]>$sizeh)) {// if width > 283 and height>150 $ratio_0=$sizes[0]/$sizew;//ratio width<>283 $ratio_1=$sizes[1]/$sizeh;//ratio height<>150 if($ratio_0>=$ratio_1){ $new_height = $sizeh; $new_width = abs($new_height*$sizes[0]/$sizes[1]); } if($ratio_1>$ratio_0){ $new_width = $sizew; $new_height = abs($new_width*$sizes[1]/$sizes[0]); } } if (($sizes[0] > $sizew) && ($sizes[1]<=$sizeh)){ // width is >283 and height<=150 $aspect_ratio = $sizes[1]/$sizes[0]; $new_width = $sizew; $new_height = abs($new_width*$aspect_ratio); } if (($sizes[0] <= $sizew) && ($sizes[1]>$sizeh)){ // width is <=283 and height>150 $aspect_ratio = $sizes[0]/$sizes[1]; $new_height = $sizeh; $new_width = abs($new_height*$aspect_ratio); } $destimg=ImageCreateTrueColor($new_width,$new_height) or die('Problem In Creating image'); $srcimg=ImageCreateFromJPEG($prod_img) or die('Problem In opening Source Image'); ImageCopyResized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing'); ImageJPEG($destimg,$prod_img_pic,90) or die('Problem In saving'); imagedestroy($destimg); } ?> It should work linke this: Can someone help me out?
  3. Hello people! I'm pretty new to php language... I'm using some software for a mailing list, and it have some online form so people can subscribe/unsubcribe... All the software runs fine... except the online form... I can't get it to work... All SMTP configurations are fine so I don't know what can be wrong... Here's the error I get when submiting to subscribe.php Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: hostname nor servname provided, or not known in /mnt/w0300/d33/s30/b02782d4/www/moreagency/form/class.smtp.php on line 37 Warning: fsockopen() [function.fsockopen]: unable to connect to :25 (Unknown error) in /mnt/w0300/d33/s30/b02782d4/www/moreagency/form/class.smtp.php on line 37 SMTP Error: Could not connect to SMTP host. (it uses some "preferences.ini" to get the variables.. and I guess all is correct there...) Here's the start of class.phpmailer.php (default) class PHPMailer { var $Priority = 3; var $CharSet = "iso-8859-1"; var $ContentType = "text/plain"; var $Encoding = "8bit"; var $ErrorInfo = ""; var $From = "root@localhost"; var $FromName = "Root User"; var $Sender = ""; var $Subject = ""; var $Body = ""; var $AltBody = ""; var $WordWrap = 0; var $Mailer = "mail"; var $Sendmail = "/usr/sbin/sendmail"; var $PluginDir = ""; var $Version = "1.73"; var $ConfirmReadingTo = ""; var $Hostname = ""; var $Host = "localhost"; var $Port = 25; var $Helo = ""; var $SMTPAuth = false; var $Username = ""; var $Password = ""; var $Timeout = 30; var $SMTPDebug = false; var $SMTPKeepAlive = false; (...) Can someone tell me what can be wrong?! Thanks in advance!
  4. Yes... the events show up something like this description: 07 - 07 - 2007 - RCA @ Vila do Conde - M.C. Vila do Conde --> date / event / local if I use the search form, and search for "2007" I see only the events for the year 2007... and that exactly what I need, but in a button, or a list menu with the years... You can check the agenda @ http://www.moreagencygroup.com/agenda Thanks for trying to help!!! really!
  5. Please help... this is kindda urgent and I'm starting to freak out! ??? PLEASE help!
  6. Hmmm... I suck at php... ... can you provide a real example so I see what you mean?! Thanks!
  7. Hello people! I'm trying to do something for about 3 days and I really see no way out on this... can be something simple, but I really suck at php... I have this php agenda that uses mysql DB... Then I have a search option that looks for event name, description of the event and date. this is my query $result = @mysql_query("SELECT DATE_FORMAT(event_date, '%d - %m - %Y') as event_time, subject, event_id, local, DAYOFMONTH(event_date) as `day`, MONTH(event_date) as `month`, YEAR(event_date) as `year` FROM calendar_event WHERE DATE_FORMAT(event_date, '%Y') LIKE '%".$this->search."%' OR subject LIKE '%".$this->search."%' OR local LIKE '%".$this->search."%' OR detail LIKE '%".$this->search."%' AND queue_flag = 0 ORDER BY event_date DESC"); What I need to do is to create some links (or list menu) that shows all the events from a year (if I use the search form and look for "2006" all the events from 2006 show up, but I need to have direct links - menus - to list the events from that year). Can someone PLEASE help before I get my grandfather's shotgun?! Thank you!
  8. :(:(:(:(:(:(:(:( that should be simple for a php freak!!! I'm not one of those for sure!
  9. PLease guys!!! I'm in BIG trouble!! ???
  10. Hi people! I'm pretty new to php, so I'm a little blind right now! I'm using a login system (in flash that loads variables) to show some content in a page, in this case, a mailing list sender. The user and pass are defined in the php. Ok... till here everything goes fine! But then, after the content is shown, when I press the button to send the mailing list, I get the error as if I failed in the log in, instead of showing the echo that confirms the malinglist send. Can someone take a look and tell me what is wrong?! If I use the content hidden in the php by it self, it works fine. Sorry the English...I'm Portuguese here's the code: <?php $username[1] = "user"; $password[1] = "userpass"; $username[2] = ""; $password[2] = ""; $username[3] = ""; $password[3] = ""; $username[4] = ""; $password[4] = ""; $username[5] = ""; $password[5] = ""; $username[6] = ""; $password[6] = ""; $username[7] = ""; $password[7] = ""; $username[8] = ""; $password[8] = ""; $username[9] = ""; $password[9] = ""; $username[10] = ""; $password[10] = ""; $user = $HTTP_POST_VARS['name']; $pass = $HTTP_POST_VARS['pass']; function error ($error_message) { echo $error_message."<BR>"; exit; } if ($user == null || $pass == null) { header("HTTP/1.0 401 Unauthorized"); error("Não tem permissão para aceder a esta área!!!"); } else { if ( $user == $username[1] && $pass == $password[1] || $user == $username[2] && $pass == $password[2] || $user == $username[3] && $pass == $password[3] || $user == $username[4] && $pass == $password[4] || $user == $username[5] && $pass == $password[5] || $user == $username[6] && $pass == $password[6] || $user == $username[7] && $pass == $password[7] || $user == $username[8] && $pass == $password[8] || $user == $username[9] && $pass == $password[9] || $user == $username[10] && $pass == $password[10] ) { }else { header("HTTP/1.0 401 Unauthorized"); error("Não tem permissão para aceder a esta área!!!"); } } ?> <!-- Add code of your web page here --> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Freira Bar - Mailing List - Envio de Mensagem</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="author" content="TheXL (2006)"> <meta name="description" content="Very simple Mailscript"> <style type="text/css"> .style8 {background-color: inherit; color: #ff0000; font-size: 9px; font-family: Verdana, Arial, Helvetica, sans-serif; } body { background-color: #990000; } .style12 { color: #000000; font-size: 9px; font-family: Verdana, Arial, Helvetica, sans-serif; } .style14 {background-color: inherit; color: #ff0000; font-size: 9px; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; } </style> </head> <body topmargin="0"> <table width="424" border="0" align="center"> <tr> <td width="526"> <? $openmail = fopen("freira_maillist.txt", "r"); $bcc = fgets($openmail); $to2 = eregi_replace(" ","<br>",$bcc); $subject = $_REQUEST["subject"]; $data = $_REQUEST["content"]; $sig = $_REQUEST["sig"]; $content = $data."\n\n\n".$sig; $content2 = eregi_replace("\n","<br>",$content); $header2 = "From: freirabar@hotmail.com"."\r\n"."Bcc: ".$bcc; if (!isset($_POST['submit2'])) { ?> <br> <br> <form action="<?php echo $PHP_SELF;?>" method="POST"> <table width="100%"> <tr valign="top"> <td class="rightAlgn"> <span class="style8">De: </span> </td> <td class="style12"> &nbsp;<input name="from" type="text" disabled="disabled" class="style12" value="freirabar@hotmail.com" size="50"> </td> </tr> <tr valign="top"> <td class="rightAlgn"> <span class="style8">Para:</span> </td> <td class="style12"> &nbsp;<input name="to" type="text" disabled="disabled" class="style12" value="Mailing List Freira Bar" size="50"> </td> </tr> <tr valign="top"> <td class="rightAlgn"> <span class="style8">Assunto: </span> </td> <td class="style12"> &nbsp;<input name="subject" type="text" class="style12" size="50"> </td> </tr> <tr valign="top"> <td class="rightAlgn"> <span class="style8">Mensagem:</span> </td> <td class="style12"> &nbsp;<textarea name="content" cols="46" rows="15" class="style12"></textarea> </td> </tr> <tr valign="top"> <td class="rightAlgn"> <span class="style8">Ass</span><span class="style8">inat</span><span class="style8">ura:</span> </td> <td class="style12"> &nbsp;<textarea name="sig" cols="46" rows="5" class="style12">Freira Bar --------------------------------- http://www.freirabar.com</textarea> <br> <br> <span class="style10"> <input name="submit2" type="submit" class="style8" value="Enviar"> </span></td> </tr> <tr valign="top"> <td colspan="2" class="rightAlgn"><div align="center"><span class="style10"><span class="style14"><br> ATEN&Ccedil;&Atilde;O!!!</span> <span class="style12">Clique apenas uma vez no bot&atilde;o &quot;</span></span><span class="style14">Enviar</span><span class="style10"><span class="style12">&quot; e aguarde confirma&ccedil;&atilde;o.</span><br> </span></div></td> </tr> </table> </form> <? } else { mail('no-reply@freirabar.com', $subject, $content, $header2); echo '<span class="style8"><br><br>Mensagem enviada com sucesso para:</span><br>'.$to2; echo '<span class="style8"><br><br>Assunto:<br></span>'.$subject; echo '<span class="style8"><br><br>Mensagem:<br></span>'.$content2; } ?> </table> </BODY></HTML>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.