Jump to content

tibberous

Members
  • Posts

    1,187
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by tibberous

  1. 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.

     

     

  2. 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.

  3. 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.

  4. 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?

  5. 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.

  6. 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.

  7. 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.

  8. function getOne($query){
         $sql = mysql_query($query);
         $row = mysql_fetch_array($sql);
         return $row[0];
    }
    
    $sql = mysql_query("SELECT COUNT(*) FROM members"); // Returns 15,000 Rows
    echo '<table>';
    echo "<tr>
         <th>First Name</th>
         <th>Last Name</th>
         <th>Email</th>
    </tr>";
    while($row = mysql_fetch_assoc($sql)){
         $member_id = $row['member_id'];
         $firstName = getOne("SELECT first_name FROM members WHERE member_id = $member_id");
         $lastName = getOne("SELECT last_name FROM members WHERE member_id = $member_id");
         $email = getOne("SELECT email FROM members WHERE member_id = $member_id");
         echo "<tr>
              <td>$firstName</td>
              <td>$lastName</td>
              <td>$email</td>
         </tr>";
    }
    echo '</table>';

     

    After this is run, you just ran over 45,000 queries. This could have been run with one query.

     

    One of my co-workers wrote something just like this.

     

    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.

  9. 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.

  10. @tibberous

    When I am programming, my hands are on the keyboard. It is a waste of time to reach for the mouse for a simple operation that can be done from the keyboard.

     

    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.

  11. 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.

     

     

  12. Sorry, I should clarify. I actually mean how to echo the string '1+1' in php?

     

    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...

  13. 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?

  14. 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);
    

  15. id Name Owner
    1 Root 0
    2 Child 1
    3 Child 1
    4 Level-2-Child 2
    

     

    So, I want to get an element, then get all elements that are either direct or indirect children of it.

     

    So - getChildren(2) should return 2 and 4, because 4 is a direct child of 2.

     

    And getChildren(1) should return 1, 2, 3, 4 because all items are a child of root.

     

    I'm pretty sure it needs to be done with a recursive function. Can someone help me out?

×
×
  • 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.