Jump to content

roopurt18

Staff Alumni
  • Posts

    3,746
  • Joined

  • Last visited

    Never

Everything posted by roopurt18

  1. It was Ok. By far the best animal picture is this one [WARNING: Profanity]: http://moronail.net/img/1264_Why_am_I_in_the_Water_and_WTF
  2. Somewhere there is a file that defines your class: somefile.php class TPFolioHelper { /* ... */ } You need to require_once( 'somefile.php' ); in your script so that PHP knows what TPFolioHelper is.
  3. It looks like a regexp to filter a string before passing it to eval().
  4. return causes the function to end immediately. You need to build the list of results inside the function and issue return after the list is built.
  5. You also need to have a way to distinguish the various servers after they have been started. If you have 15 server.exes running, each tied to a different user, and you want to kill one for a specific user and the only information you have is: pid name 12 server.exe 22 server.exe 13 server.exe 44 server.exe 42 server.exe 52 server.exe 62 server.exe 67 server.exe Then how do you expect to accomplish this? You can't without other distinguishing factors.
  6. This line initializes $thumbArray into an empty array. $thumbArray = array();//THIS ARRAY RIGHT HERE You've placed it inside the loop. Do you see a problem with that?
  7. $thumbArray['image'] = $thumb = $row['image']; This will assign the value in $thumb to $thumbArray['image'] every time through the loop. In other words, you are storing the value in the same place every time through the loop and each successive time through the loop you are replacing the existing value. If you want to append items onto the end of an array you use empty braces, []: $arr = array(); $arr[] = 1; $arr[] = 'larry'; $arr[] = 3.14; // $arr is an array with: 1, 'larry', 3.14 $thumbArray[] = $thumb = $row['image']; // ~OR~ $thumbArray['image'][] = $thumb = $row['image']; And unless you're using it for something else, and I don't see that you are, the extra $thumb = is not needed.
  8. If the server is started with something like: samp02Xsvr -U someuser Then bash$ ps aux | grep samp02xSvr pid user command 1234 apache samp02Xsvr -U someuser 1223 apache samp02Xsvr -U anotheruser Basically ps aux should list the command that was issued to start the process and if the user name is a flag to the command, then you should be able to find it. Otherwise I really don't know how you expect to tell them apart.
  9. If you're bad at $_GET (and I'm not even sure what that means), then you're in a world of hurt. You add values to the URL after a ? in the form of param=value and separate them with an ampersand. Then you access them in your page with $_GET. What's so hard about that? That can be modified just as easily as GET.
  10. If you were running *nix you could do: ps aux | grep processname That will give you a listing of: pid (process_id) user ... user The pid column is what you're interested in; each process has a unique integer id. Once you know the pid you want to kill, like 5292: kill 5292 It's really the kill command you want to send through shell_exec(). I'm sure Windows has a similar functionality if you do some Googling.
  11. Opera, the company, was looking to buy more servers. Lots of them. Servers cost money. Lots of it. So everyone who sells servers was excited to send test servers to Opera so that Opera could perform internal testing on them. Typically each company provides an administrative interface for managing their servers, just like your web host gives you a cPanel / WHM / Plesk. Many of these administrative interfaces are web applications that require JavaScript. One of the larger server manufacturers had a piece of JavaScript code in their administrative software for the server that basically said, "We don't support Opera."
  12. No. None of the files will be executable. I guess the source of my question, as silly as the question is, came about from my impression that linux will happily do whatever you tell it to because it assumes you know what you're doing. But I guess it has some additional safeguards built in to ward off stupid administrator mistakes.
  13. So I guess it's just a built in security feature, forcing you to go out of your way to make files executable. It's a silly question, I know, but I'm vaguely familiar with *nix and this was unexpected behavior. Thanks
  14. This is a fresh install, the current umask is the default, and I will be changing it. But in the meantime I'd like to know what it is that causes files to drop the x permission when umask says they should have it?
  15. [rbredlau@localhost public_html]$ ls -l total 16 -rw-r--r-- 1 rbredlau rbredlau 93 Aug 19 14:49 index.html -rw-r--r-- 1 rbredlau rbredlau 19 Aug 20 11:37 index.php [rbredlau@localhost public_html]$ umask -S u=rwx,g=rwx,o=rx [rbredlau@localhost public_html]$ touch junk [rbredlau@localhost public_html]$ ls -l total 20 -rw-r--r-- 1 rbredlau rbredlau 93 Aug 19 14:49 index.html -rw-r--r-- 1 rbredlau rbredlau 19 Aug 20 11:37 index.php -rw-rw-r-- 1 rbredlau rbredlau 0 Aug 20 11:57 junk [rbredlau@localhost public_html]$ namei -m /home/rbredlau/public_html/ f: /home/rbredlau/public_html/ drwxr-xr-x / drwxr-xr-x home drwxr-xr-x rbredlau drwxr-xr-x public_html [rbredlau@localhost public_html]$ uname -a Linux localhost.localdomain 2.6.18-128.4.1.el5 #1 SMP Tue Aug 4 20:23:34 EDT 2009 i686 i686 i386 GNU/Linux [rbredlau@localhost public_html]$ cat /etc/redhat-release CentOS release 5.3 (Final) Can someone explain to me why junk is not picking up the permissions set by umask?
  16. From the manual: http://us2.php.net/manual/en/function.sha1.php
  17. roopurt18

    PHP CLI

    I don't recall anyone making those statements, so what exactly are you talking about?
  18. As added security, your page that sends the e-mail can also set a cookie on the user's machine. Then invite_user.php can check for the cookie as well to make sure the agent following the URL in the e-mail is the one that originated the request.
  19. Are you hashing the password or encrypting it? There is a BIG difference between the two. Hashing is one way and irreversible. Once hashed, you can never know what the original value was. md5() and sha1() are examples of hashes. Encryption is a two-way street. Values are encrypted, using a key, to produce random garbage. If you have the random garbage (or encrypted value) and the secret key, you can decrypt back to the original value. If you wrote this code in the first place and are using encryption, then you would probably know how to decrypt it as well. But since you're confused and having trouble, I'm guessing you've used a hash. In that case, what you can do is add a column to the users table: alter table `users` add column `invite_key` varchar(40) null default null; alter table `users` add column `invite_expiration_tm` timestamp null default null; When someone has lost their password, do the following: 1) Generate a unique 40 character string, something like: $invite_key = sha1( date('YmdHis') . 'r4nd0ms4l7' . $username ); 2) Update the user's row with $invite_key and the current time plus an offset, like 12 hours (something like [i]set invite_expiration_tm=now() + '12 hours') 3) Send the user an e-mail with a URL containing the invite key http://www.yoursite.com/invite_user.php?user=theUsername&key=19291fla91lofjaJsadlfjaweo!92387asldfjalfj 4) invite_user.php should attempt to look up the $_GET['user'] containing $_GET['key'] within the allotted amount of time. a) If invalid, send to error page b) If valid i) log user in ii) Update the database and set invite_key=NULL and invite_expiration_tm=NULL iii) Redirect user to change password page
  20. You might try this: http://www.phpclasses.org/browse/package/4628.html Following is a small bit of code I wrote to calculate probabilities. A probability is just a fraction, i.e. 1 out of 6 or 1 / 6. It may give you a couple hints of how you can construct your own if you can't find a pre-built solution: <?php class Probability { public $For = 0; public $Total = 0; /** * Returns NOT P * * @param Probability $a * @return Probability */ public static function NotP( Probability $a ) { return new Probability( $a->Total - $a->For, $a->Total ); } /** * Multiply two probabilities together * * @return Probability */ public static function Multiply() { $c = new Probability( 1, 1 ); $args = func_get_args(); foreach( $args as $arg ) { if( !($arg instanceof Probability) ) { throw new Exception( 'Argument is not a Probability instance ' . __METHOD__ ); } $c->For *= $arg->For; $c->Total *= $arg->Total; $c->Reduce(); } return $c->Reduce(); } public function __construct( $for, $total ) { $this->For = (int)$for; $this->Total = (int)$total; if( !$this->IsValid() ) { throw new Exception( 'Invalid probabiity: ' . $this ); } } public function IsValid() { return $this->Total !== 0 && $this->For >= 0 && $this->For <= $this->Total; } public function Reduce() { $gcd = calc_gcd( $this->For, $this->Total ); $this->For /= $gcd; $this->Total /= $gcd; return $this; } public function __toString() { $against = $this->Total - $this->For; return "P: {$this->For} / {$this->Total}, !P: {$against} / {$this->Total}"; } public function Value( $prec ) { $prec = (int)$prec; return round( 100 * $this->For / $this->Total, $prec ); } } /** * Reduce a fraction. * * @param integer $num * @param integer $den */ function frac_reduce( &$a, &$b ) { $gcd = calc_gcd( $a, $b ); $a /= $gcd; $b /= $gcd; } /** * Calculates the greatest common divisor of a bunch of numbers * * @return integer */ function calc_gcd() { $args = func_get_args(); foreach( $args as $k => $v ) { $v = (int)abs($v); if( $v === 0 ) { return 1; } $args[$k] = $v; } $min = call_user_func_array( 'min', $args ); while( $min > 1 ) { $t = true; foreach( $args as $v ) { $t = $t && ($v % $min === 0); if( $t === false ) { break; } } if( $t === true ) { break; } $min--; } return $min; } ?> It's not the best code as I wrote it as a quick side project, but it may help.
  21. First off abstract the friend's behavior into an encapsulated piece of PHP code with a consistent interface. Then you are free to change the underlying structure as much as you want with minimal impact to existing code that uses the interface. In regards to the database, MySQL is meant to handle millions of records and still be fast. If you get to the point of having millions of registered users, then you should be at a high enough point in ad (or some other type of) revenue that you can use a separate and more powerful database server. What you have is a many-to-many relationship and your first solution is the most common way to handle them. A small side note, make sure you use ints for your foreign keys and identifiers as ints will typically compare faster than strings.
  22. Eh. This might help then: http://searchoracle.techtarget.com/expert/KnowledgebaseAnswer/0,289625,sid41_cid580284,00.html (scroll to bottom) Looks like you may need multiple queries and / or temp tables.
  23. Make sure this isn't your problem: http://www.phpfreaks.com/forums/index.php/topic,167898.0.html
  24. Maybe: select * from pda_dbs a where a.meta_id in ( select b.meta_id from pda_dbs b where a.catcode=b.catcode order by b.meta_id desc limit 2 )
  25. <?php $result22 = mysql_query("SELECT * FROM `shelf 22` WHERE Item REGEXP '.*$item.*'"); $sqls = array(); for( $i = 1; $i <= 22; $i++ ) { $sqls[] = "SELECT * FROM `shelf {$i}` WHERE `Item` REGEXP '.*{$item}.*'"; } $sql = implode( PHP_EOL . 'UNION' . PHP_EOL, $sqls ); $result = mysql_query( $sql ); ?>
×
×
  • 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.