Jump to content

Joshua4550

Members
  • Posts

    148
  • Joined

  • Last visited

    Never

Everything posted by Joshua4550

  1. Figured. Created a PHP script which grabs the url defined in a _GET parameter, and used file_get_contents() to display the script output. This made me able to request a post to that script on the same domain. I posted back just to allow any future people looking for the answer to this to find. Thanks anyway
  2. Hey, So. I wanted to post to an external script (cross-domain) in JavaScript. This is not my domain, though it's a partner. I figured it would be SO MUCH easier to just post using jQuery's $.post() method, and problem solved. Well done! The problem was solved, until I ran it in IE - uh oh, IE doesn't like it? I researched this problem, and it seems it's an IE security problem with cross-domain blahblah. My question? How would I go about achieving the exact same result (just to post to the script, without actually making the user run it?) - I am not actually posting any _POST or _GET variables, I was only using $.post() because it was a convenient solution. My old attempt, which IE didn't like? $.post('http://External_Site.com/External_Script.php'); (Obviously that isn't the real URL) Any help? Much appreciation for all help =)
  3. Is that how scripts such as forums normally do it? Yes. When they log in, it stores username/user id in a session (Eg: $_SESSION['mysite_logid']) and then providing you start sessions for the relative page, you can use that session to tell your next script the logged in user's username/ID.
  4. That code works, so if you're fine with when they're setting.. I'd say it's fine to use them that way.
  5. I'm guessing you don't understand that i'm not uploading. I'm using the GD library to create an image resource stored in a variable from two existing images. But yeah.. I need to make it construct on the www but then save the image to a subdomain such as images.example.com (saving using the imagepng() function btw) Guessing I should pass the image resource through to another script located on the subdomain, just not sure how I would go about passing it through. Thanks in advance to anyone who helps
  6. Depends what you're putting in makeimage.php and which subdomain (www or images) each script goes on. Explain (BTW: I meant subdomain, not subdirectory -.-)
  7. Hey. I'm just wondering what would be the most logical or most efficient way to save an image resource that has been constructed on say the www. to a subdirectory or on another webserver? For eg The script on www.example.com constructs an image using the GD library from image1.png and image2.png. It has now got the final image resource for what's been constructed. I now want to save this image onto images.example.com How would you suggest?
  8. lolol nvm i did it all.
  9. Right, so I got the code to work - but the background isn't transparrent, anyone know why? function fitToCanvas($img) { $size = getimagesize($img); $width = $size[0]; $height = $size[1]; $img_resource = imagecreatefrompng($img); $widths = array(); $heights = array(); $count = 0; for ($i = 0; $i < $height; $i++) { for ($j = 0; $j < $width; $j++) { $colorAt = imagecolorat($img_resource, $j, $i); $colorIndex = imagecolorsforindex($img_resource, $colorAt); if ($colorIndex['alpha']!=127) { // Not transparrent, load this pixel into the array $count++; $widths[$count] = $j; $heights[$count] = $i; } } } $bottom_right = array(max($widths), max($heights)); $top_left = array(min($widths), min($heights)); $image_size = array($bottom_right[0]-$top_left[0], $bottom_right[1]-$top_left[1]); $img2 = imagecreatetruecolor($image_size[0], $image_size[1]); $im = imagecopy($img2, $img_resource, 0, 0, $top_left[0], $top_left[1], $image_size[0], $image_size[1]); imagedestroy($img_resource); return $img2; }
  10. Ookay, I got the image to print - but now it's a black canvas. I'll work on fixing this atm, but does anyone see where my method code goes wrong?
  11. Okay, I tried this before - but it gave me the following error: The image “http://mysite.com/test/” cannot be displayed, because it contains errors. Atm, here's my codes: (I've tried multiple ways around this, but not found a working one) function fitToCanvas($img) { $size = getimagesize($img); $width = $size[0]; $height = $size[1]; $img_resource = imagecreatefrompng($img); $widths = array(); $heights = array(); $count = 0; for ($i = 0; $i < $height; $i++) { for ($j = 0; $j < $width; $j++) { $colorAt = imagecolorat($img_resource, $j, $i); $colorIndex = imagecolorsforindex($img_resource, $colorAt); if ($colorIndex['alpha']!=127) { // Not transparrent, load this pixel into the array $count++; $widths[$count] = $j; $heights[$count] = $i; } } } $bottom_right = array(max($widths), max($heights)); $top_left = array(min($widths), min($heights)); $image_size = array($bottom_right[0]-$top_left[0], $bottom_right[1]-$top_left[1]); $img2 = imagecreatetruecolor($image_size[0], $image_size[1]); imagecopy($img2, $img_resource, 0, 0, 0, 0, $image_size[0], $image_size[1]); imagedestroy($img_resource); return $img2; } header('Content-type: image/png'); echo '<img src="lolhi.png" title="" />'; $img = fitToCanvas("lolhi.png"); imagepng($img); echo '<br /><br />'; echo '<img src="fgt.png" title="" />'; $img = fitToCanvas("fgt.png"); imagepng($img); echo '<br /><br />'; I know the method isn't most efficient, was going to go and seek help with improving it if it runs slow, later on. Any idea how to move this around to make the header not give me errors, and not give the "headers already sent" error?
  12. Hey, I was recently refferred to a few of the GD functions to complete a task I asked if was possible or not - and i'm SO close to finishing. I have the method polished up, I just need to find out why my image is not outputting. I made the script crop the image and copy it onto the blank canvas, but when I try to output it, it simply outputs: ‰PNG ��� IHDR���ƒ���i���– Õ���?IDATxœíÁ1��� õOm ? ����������������������������������������^¡š�$û����IEND®B`‚ Does anyone know the general/most common causes of this? Just need to fix and I'm done =)
  13. Thank you so much, i'll start looking into it right now =)
  14. Does no one know if this is possible?
  15. Oh, and I forgot to mention:- I know I could crop it and output it, but I don't ALWAYS want those exact dimensions - they were just an example. I need a method which would work on all sizes. Is this possible??
  16. Hi, I have recently been reading through some of the functions in the GD library, and custom functions people have built off of that. I was wondering if there's a way, with or without the GD library, to get an image and crop it for "fit to canvas"? Such a feature would remove unnecessary transparrent canvas. For example if you had a 500x500 canvas, but the image inside of it was only 200x300, it would crop the image down to 200x300. Is this possible? Thanks.
  17. D.w I resolved it. Used part of your regex though, so thanks.
  18. Well I used that expression, and it didn't work. I made it print the results to: [quote="You"]Hello[/quote] Lol hi The result was: [quote="You":2dxs0gq9]Hello[/quote:2dxs0gq9] Lol hi
  19. Thanks for the pointers for skipline and case insensitive I used the pattern on this: [quote="NAME_HERE"] QUOTE_HERE[/quote] Nice quote But apparently, this did not match?
  20. Thanks a LOT. Although, neither of the RegEx worked? :S
  21. Thanks. Although, now my RegEx doesn't work (I expected this lol) Something about backslashes?
  22. str_replace("\[quote.*\].*\[/quote\]", "", $myvar); Basically trying to strip "[ quote=text ]message[ /quote ]" from $myvar (obviously no spaces) Why doesn't it work? By the way, I'm not a fan of RegEx - and I'm shit with them. I used RegExBuddy but this still doesn't work. Pointers?
  23. Okay, i'm going to keep this short and simple - i'm sure theres a funtion for what I need. User enteres data => Data is stored in database User visits page => Data from database is displayed Atm,if they enter: Hello, next line here. When they visit the page, it will display: Hello,next line here. how can I convert the break lines, etc, into html? so that it will display as they entered it? I realise the best way would be to use the function when the page displays it, but is there even a function for this?? Much appreciated! Ps, sorry if I made tying errors - wireless keyboard playing up!
×
×
  • 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.