Jump to content

tibberous

Members
  • Posts

    1,187
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by tibberous

  1. I want to resize an image to fit within a rectangle. Lets say my rectangle is 400 wide and 200 tall. My image is 300x300. It should take, and make the rectangle 200 tall, then scale the width accordingly. I wrote a function a while back that resizes inside a square, but that was a little easier, since you know to constrain by height if height is greater than width, and to constrain by width if width is greater than height. $w = $stats[0]; $h = $stats[1]; if($dim){ // constrain image if($w > $h){ $h = ($h / $w) * $dim; $w = $dim; } else { $w = ($w / $h) * $dim; $h = $dim; } } Thats my code to constrain inside a box. It gets the starting h and w from $stats, which is loaded from getimagesize. Then it sets a new h and w based on dim, which is the size of the box. The new version will need dimW and dimH, instead of just dim. Can anyone help me out?
  2. Happened to us - our designer got a virus that stole his FTP login. Whats weird is that it didn't show up right away. I think they steal the ftp passwords, the attack later on. Look through your files. You probably have something like thumbnail.php that's just an eval(base64_decode("gf46uy45h6n67n6rmrnw45h... or something similar.
  3. Or put logmein on the host computer, login as needed to get the new ip. Or create a service on the remote computer that posts it's IP to a server every couple minutes.
  4. I'm having a weird problem. We are using Google business email. I am using htmlMimeMail5 to send off gmail's smtp server off port 587. A client isn't getting email from the system, he has a Comcast business account. If I login to gmail, and send it from our account, he gets it. If I send it from the system, he doesn't. If I send it from the system, to me, it works. Only thing I can figure is that maybe htmlMimeMail is adding some headers that Comcast doesn't like, but that gmail doesn't care about. Anyone know how I can debug this? I'm not sure what to do from this point. htmlMineMail has been updated to Rmail. I'll update and hope it fixes everything - otherwise, I'm a little bit at a loss.
  5. I think what you want is something like basecamp, but with exams. Basecamp, if you didn't know, is a project colab too - you can share files, create timelines, create to-do lists, assign tasks ect. See if this list of basecamp alternatives doesn't help you out: http://pm-sherpa.com/features/basecamp-alternatives/ But like ignace said, it isn't that hard to do in straight PHP if you got a couple weeks.
  6. Does anyone have a good auto detect / update / install script? Right now, I just send people to : get.adobe.com/flashplayer, but even that seems too hard.
  7. I am looking for the little phone / fax icons that you put in put in front of the numbers on a website. I've seen them on a hundred sites, and now I can't find them. Just looking for little gray, 12x12 - 16x16 images. Anyone know what I'm talking about / have a set?
  8. I am making a CMS. I want the user to be able to enter their address and get a Google map to their location. http://maps.google.com/maps?oe=utf-8&ie=UTF8&q=$addr+$city+$state+$zip&fb=1&gl=us&hq=$addr&hnear=$city,+$state+$zip&source=embed&output=embed Using this as the iframe source works SOMETIMES. I think it only works if it matches exactly with Googles database. Does anyone know of a better way to do this?
  9. I got it, you do a foreach($matches[0] as $match), then you str_replace, but you send in count as 1, to match sure it one for one replaces. Edit: this doesn't work. Count returns the number of matches =/ I thought it worked like the limit param in the explode function.
  10. I'm trying to go through a document and replace all the UBB tags with different values. I can preg match the tags, but I don't quit remember how to do the replacement. Tags are like: ect. Anyone have a basic example I can go from? I know I've done it before, just can't think tonight.
  11. Always do OOP! That's what they taught me in into to Java!! Just kidding. Personally, I always use procedural, but this isn't a right or wrong type question. The one advantage to always doing procedural (besides performance) is that you don't have to spend much time worrying about how you are going to structure everything. Everything is a function. Utility functions take arguments and return a value or error code, 'action' functions just access globals and return the message they want to show up on the page. The important thing is to find a way that works and not get caught up in how some else says you should program. Java is a perfect example of how bad a language gets when you try to do everything through objects, but some people would swear it is the greatest language ever written. It's as much preference as anything.
  12. Fixed. The trick is to not include jqeury.js...
  13. function onButton(){ alert('here'); $.get('index.php', {}, function(j){ alert('j'); }); } Shouldn't this load index.php, pass no variables, and print the letter j once it succeeds? It is printing 'here', but the callback is never getting called.
  14. Yeah - an ex-coworker of mine had some kind of shitty, object-based mysql library he used. Thing made so many querys, and didn't work with anything more complex than a select or insert statement. I HATE when people try and wrap core features of the language. I have a general.php file I use in projects, but it's just general utility functions that PHP doesn't have.
  15. If your really interested in optimization, you might want to focus on the mysql end of it. Trying to improve 'general performance' is a waste of time. There are times where a huge database can cause you issues though, few things you might want to look at are: - MySQL database indexes - Proper hierarchical data storage (which is hard as fuck) http://dev.mysql.com/tech-resources/articles/hierarchical-data.html - Pre-caching / lookup table creation with and without cron scripts The key to good optimization is to only optimize the stuff that is slow enough to be an issue. Did you read xylex's sig? "The greatest inefficiencies come from solving problems you will never have. -Rasmus" PHP is fast, performance is only an issue in rare situations, and as servers become faster, optimization is only going to become less and less important.
  16. Do what I do - type with one hand and leave the other one on the mouse. You'd be amazed at how fast you will eventually be able to type with one hand - and since you rarely type long runs of text start-to-finish, the ability click more than makes up for the speed difference in typing.
  17. Use UEStudio instead - it doesn't even have CTRL+Tab, but you can click the tabs with your mouse.
  18. What does the script do that it's 2700 lines long? I can count on 1 hand the times I've actually needed to optimize something in PHP - and normally just by adding indexs to tables. Who cares that it takes .05 seconds? If it works, be happy.
  19. I'm looking for a library / database I can use to see if a user is a bot. I found this site, but it is a long way from what I need: http://www.botsvsbrowsers.com/category/1/index.html
  20. class OnePlusOneSimpleEchoInPhp { const STDOUT = 'php://output'; const OUTPUT = '1+1'; public static function output() { file_put_contents(self::STDOUT, self::OUTPUT); } } OnePlusOneSimpleEchoInPhp::output(); I think this is the simplest example I could think of how to do this effectively And yet still more efficient than java...
  21. Good thinking neil, but xylex got it right! Good job xylex!
  22. I have a cron script that is just supposed to send me an email every hour. I added this line to /etc/crontab 01 * * * * root run-parts php /daemons/hourly.php Then I reset cron. If I run the command: php /daemons/hourly.php in putty, I get the email. Any idea why the cron isn't sending it?
  23. Here is the same function, only setup to return an array of ids, rather than print. Little bit more useful, imo. function get_children($parent, $level) { // retrieve all children of $parent $children = array(); $result = mysql_query('SELECT `id` FROM `pages` WHERE `Owner`="'.$parent.'";'); while ($row = mysql_fetch_array($result)) { $children[] = $row['id']; $children = array_merge($children, get_children($row['id'], $level+1)); } return $children; } get_children($id, 0);
×
×
  • 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.