Jump to content

werty37

Members
  • Posts

    49
  • Joined

  • Last visited

    Never

Everything posted by werty37

  1. Ah yes! That is a good idea. I ll try to implement it. Thanks a lot for the suggestion... Cheers Sujith
  2. Hi Rhodesa, I am using json_d/encode() functions instead of un/serialize() and it does the job quiet well. I dont know why it wouldnt work for me. I am using PHP 5.2.3 on ubuntu (Apache/2.2.4). Thanks Sujith
  3. Hi Just a reminder. Simplexml returns objects instead of strings/integers or mixed values. echo is_object($xml->file->allowedfiles); // will print 1 That is why i do type cast before i print echo unserialize((string) $xml->file->allowedfiles); //doesnt print any output I think the problem has something to do with this behaviour. or maybe i have found a bug in php
  4. Hi Barand, $xml = simplexml_load_file('conf.xml'); echo (string) $xml->file->allowedfiles; //prints out the serialized data $data = unserialize((string) $xml->file->allowedfiles); echo '<pre>', print_r($data, 1), '</pre>'; // dosent print anything It outputs nothing. The < pre > tag is printed but not the unserialized content.. Sujith
  5. Hi Barand, Sorry the code i posted had errors. I did try echo unserialize((string) $xml->file->allowedfiles); //doesnt print any output which ofcourse does not work. Thanks Sujith
  6. HI Can anyone help me out with this please. I am trying to print out serialized data stored in a xml file using simplexml. $xml = simplexml_load_file($conf); echo (string) $xml->file->allowedfiles; //prints out the serialized data unserialize((string) $xml->file->allowedfiles); //doesnt print any output Thanks Sujith
  7. Hi There are no spaces around <?php ?> tags.... Didnt help
  8. Hi I guess you might have to change your logic a bit. You can create a temp table to hold the values and then move the data to the actual "members" table once the userid is confirmed. Hope that helps Regards
  9. Hi ILYAS415, I am trying to create png thumbnails from jpg or png images. Hope the code now makes sense Thanks
  10. Hi INSERT INTO `itemtable` SET `itemnum1` = $_GET['1'], `itemnum2` = $_GET['2'] , `itemnum3` = $_GET['3'] , `itemnum4` = $_GET['4'], `itemnum5` = $_GET['5'] AND `memberid` = $_SESSION['idnum'] make sure itemnum1, itemnum2, itemnum3, itemnum4, itemnum5 all have default values as 0.
  11. Hi I am trying to resize an uploaded image and save it as png. I always get corrupted png thumbnails. Can somebody check the function and tell where i ve gone wrong. function image_thumb($file, $tnfilename) { //maximum width: 225px //maximum height 225px $imageInfo = getimagesize($file); if ($imageInfo["mime"] == 'image/jpeg') $fullImage = imagecreatefromjpeg($file); elseif ($imageInfo["mime"] == 'image/png') $fullImage = imagecreatefrompng($file); $imageWidth = $imageInfo[0]; $imageHeight = $imageInfo[1]; $imageRatio = $imageWidth/$imageHeight; if ($imageRatio < 1) { $newHeight = 225; $newWidth = (225/$imageHeight) * $imageWidth; echo $newWidth;} else { $newWidth = 225; $newHeight = (225/$imageWidth) * $imageHeight;} $tnImage = imagecreatetruecolor($newWidth, $newHeight); imagealphablending($tnImage, true); imagecopyresampled($tnImage, $fullImage, 0, 0, 0, 0, $newWidth, $newHeight, $imageWidth, $imageHeight); imagesavealpha($tnImage, true); imagepng($tnImage, $tnfilename, 70, PNG_ALL_FILTERS); imagedestroy($fullImage); imagedestroy($tnImage); return $tnfilename; }
  12. Hi Barand Thanks a lot. I had \n characters after ?> in one of my includes. Have a nice day Cheers Sujith
  13. Hi Sometimes webhosting companies disable mail() function by default. You might have to contact your hosting company to enable them... Regards Sujith
  14. Hi mike, I am using this in one of my scripts and it seems to work for me. This should work for you hopefully if (!preg_match('/^[\w\d\_\.]{8,15}$/',$var)) { // code } Regards Sujith
  15. Hi everyone, Update: I edited the downloaded binary file (jpg) using vi. And removed the newline characters. Now i am able to view the file. It seems that the addition of \n characters make the downloaded files to be corrupt. I dont understand how the \n characters are added to the file contents. Any pointers would be helpful. Regards Sujith
  16. Hi You want blah.php to be accessed by say index.php and not by others right.... put the above code in blah.php at the top. Regards Sujith
  17. Hi Ken2k7, Add this code to the beginning of the file and others wont be able to access the file directly. Hope this is what you needed Cheers Sujith
  18. Hi toplay, When i upload the file, i copy the filename and mime to database and rename the file with a unique name (d7497f3e-8496-428f-b573-ac9f1a0d7f3d) with no extension. And when i download the file from the remote server. I get the filename and mime type from the database for the corresponding file name (d7497f3e-8496-428f-b573-ac9f1a0d7f3d) Download is working except for the fact that the file is corrupted on download. I tried binary files (jpg, gif) and they all seem to be corrupt as \n characters are added to the beginning of the files. (which i found out by using text files) I hope that would explain the code a bit. The problem is - \n characters are added to the files during download which makes the data to be corrupt! Best Regards Sujith
  19. Hi Dont know if this would fit your need. Check out http://www.mycontactform.com Try searching if this is not what you wanted Cheers Sujith
  20. Hi Try this. if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) exit('You cannot access this file directly'); Cheers Sujith
  21. Hi sorry i missed $... I tried you method. The downloaded file still has the newline.... Any other way? Thanks for your time Sujith
  22. Hi $imgdata = file_get_contents($_FILES['replacewithfieldname']['tmp_name']); $query = "INSERT INTO users (displayname, displaytype, description, address, address2, city, state, postal, country, website, imagefile) VALUES ('$displayname', '$displaytype', '$description', '$address', '$address2', '$city', '$state', '$postal', '$country', '$website', '$imgdata')"; mysql_query($query) or die (mysql_error()); Sujith
  23. Hi, I guess this should do. Use the following in the insert.... file_get_contents($_FILES['uname']['tmp_name']) Cheers Sujith
  24. Hi Guys, I am trying to download a file from remote ftp server. When i am trying to download binary data (jpg, gif) it appears to be corrupt. I tried downloading txt files. They seem to have extra space at the top of the file. The upload script is working fine and there is no change in the file contents. When i am uploading i strip off the the extension and assign a unique name to the file. <?php //$filename = from db; //$mime = from db; //$size = from db; url = $GLOBALS['FILESERVER'] . $_SESSION['getfile']; $fp = fopen($url, 'rb'); $contents = stream_get_contents($fp, -1, 0); fclose($fp); header("Content-Transfer-Encoding: binary"); //header("Content-Type: application/force-download; charset=windows-1251"); header("Content-Type: $mime"); header("Content-Length: $size"); header("Content-Disposition: attachment; filename=$filename"); header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); header("Pragma: no-cache"); echo $contents; exit; } ?> I have been stuck with this problem for the past 2 days. Any help will be appreciated. Thanks for your time, Sujith
×
×
  • 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.