Jump to content

irken

Members
  • Posts

    94
  • Joined

  • Last visited

    Never

Everything posted by irken

  1. Yes. But isn't that a bit weird.. why is something enclosed in pings treatet as a numeric? Maybe I got the whole what's a string and what's not wrong : ). You learn every day - thanks! Edit: Perhaps it's safe to use is_int() on the $var instead? If you're just checking for 12345.. Edit again again: Oh, I just read the manual. "To test if a variable is a number or a numeric string (such as form input, which is always a string), you must use is_numeric()." - that makes sense.
  2. Well. Doing, as per Barand's snippet: $numer = '12345678'; if (!is_numeric($number)) echo "Not numeric"; Does actually not output "Not nummeric". I thought that ' (pings) got treatet as a string?
  3. Hello. I have the following piece of code: if (isset($_GET['q'])) { $params = explode('/', trim(stripslashes($_GET['q']))); @list($plugin, $function) = $params; # index.php?q=test/add # index.php?q=test/del if (isset($plugin) && isset($function)) { $plugin_path = './plugins/' . strtolower($plugin) . '/' . strtolower($function) . '.php'; if (is_file($plugin_path)) { @include_once $plugin_path; exit; } } # index.php?q=test if (isset($plugin) && !isset($function)) { $plugin_path = './plugins/' . strtolower($plugin) . '.php'; if (is_file($plugin_path)) { @include_once $plugin_path; exit; } } } else { // Show front page.. } What this does is allow me to write for example: index.php?q=test - to include the file located at ./plugins/test.php index.php?q=test/add - to include the file located at ./plugins/test/add.php And so forth. I'm looking for a more dynamic way of doing this. What if I need to have yet another parameter for articles perhaps. index.php?q=article/view/01 That would require me to make yet another if expression and expand the list statement: @list($plugin, $function) = $params; if (isset($plugin) && isset($function) && isset($article_id)) { .. } Is there a way around this? Perhaps even a better way. It's not very dynamic if I have to change my functions each time I need to add a feature and/or module and would result in like 50 if checks. Thanks for reading.
  4. Ah, I should've noticed that. The array should be: ('testvar' => 'something elseeee') rather than ('testvar', 'something elseeee') Thanks, now I can finally get on with it : ).
  5. Hello. I was attemping to make an array of configuration variables for Smarty when I ran into this little problem. Here's some example code first of all: <?php class Testclass { var $testvar = 'something'; } $test = new Testclass; echo "before foreach: $test->testvar\n"; # echos 'something' $arr = array('testvar', 'something elseeeee'); foreach ($arr as $key => $value) { $test->$key = $value; # set $test->[variable] to $value } echo "after foreach: $test->testvar\n"; #echos 'something' Problem. This outputs "something" in both places, while I expected it to echo "something elseeee" after the foreach is done. Setting $test->testvar manually and outputting it workes fine, but breaks in the foreach. To me this seems weird, but might just be how PHP workes. If that's the case, how do I work around this? Thanks for reading.
  6. Hello. Correct me if I'm wrong, but isn't a persistent mysql connection supposed to return the previous connection resource once I do mysql_pconnect() again, with the same parameters? Here's my very simple test class.. <?php class Mysql { var $hostname = 'localhost'; var $username = 'gateway'; var $password = ''; var $database = 'somedatabase'; var $connection = NULL; public function __construct() { } public function connect() { if (!$this->connection) { $this->connection = mysql_pconnect($this->hostname, $this->username, $this->password); mysql_select_db($this->database); return $this->connection; } // resource exists ? return $this->connection; } } ?> And some test script <?php include('mysql.php'); $myMysql = new Mysql; $myMysql->connect(); ?> Acording to mysql's SHOW processlist the result is this: mysql> show processlist; +-----+---------+-----------+----------------+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +-----+---------+-----------+----------------+---------+------+-------+------------------+ | 151 | root | localhost | NULL | Query | 0 | NULL | show processlist | | 159 | gateway | localhost | somedatabase | Sleep | 984 | | NULL | | 160 | gateway | localhost | somedatabase | Sleep | 963 | | NULL | | 161 | gateway | localhost | somedatabase | Sleep | 809 | | NULL | | 162 | gateway | localhost | somedatabase | Sleep | 3 | | NULL | +-----+---------+-----------+----------------+---------+------+-------+------------------+ 5 rows in set (0.00 sec) As you can see there are 4 connections? This is from refreshing the test.php script 4 times. Am I to undertand that it's pooling up connections and when it reaches max, it will return one of them to the PHP script? Thanks for reading.
  7. Please provide a solution for future reference .
  8. The only reason to do anything along the lines of "obfuscating" your Javascript could, is to decrease size. You will always be able to see the source, your browser can. I pack my scripts using http://dean.edwards.name/packer/ - it makes it somewhat "hard" for the average user to look through it (could just "unpack") - but then again, the average user has no reason to look at my code - so I do it to decrease size as a priority.
  9. Not sure I understand fully, but then again I diden't read it all ;s. Try using a POST request instead, it seems as if it's caching the information somehow, but then not doing the request again maybe because the page is already cached, or something. Always good practise to use POST requests, as nothing will get cached (in IE).
  10. Frameworks are great, but weather or not you should use one is up to you, and what you can do. Couple of posts at the bottom of this thread which might interrest you: http://www.phpfreaks.com/forums/index.php/topic,119739.0.html
  11. [quote author=Darkstar link=topic=124453.msg516199#msg516199 date=1170089360] as it turns out, IE has another flaw when it comes to AJAX.  it refuses to fetch the actual content on the fetched page but will instead use the last cache of it.  I searched google for a minute or two and came up with the following: [code]setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");[/code] i just inserted it into: [code]  xmlHttp.open("GET",urlFetch,true);   xmlHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");   xmlHttp.send(null);[/code] and voila!  no more cache [/quote] That's not an actual flaw. IE will cache all GET requests, AJAX or no ajax. If you use POST instead (even if you don't have anything that requires POST), the page should not get cached.
  12. Ok. Well, then there's something to work with atleast. What exactly are you trying to archieve? What does the HTMLDivElement object contain? Kind of weird because HTMLDivElement inherits functions from HTMLElement, which contains the getElementById function, yet it errors saying it doesn't.
  13. Try doing an alert on obj.firstChild in your htmlDom function.. does it return blank? If it does, then the property getElementById is going to error. Error: wootCache.getElementById is not a function It looks as if it's returning a blank object.
  14. One idea would be to comment out everything that's not needed for the vhost to run. You don't need to specifiy error logs for example. Comment all that out, write only things like: ServerAdmin DocumentRoot ServerName ScriptAlias Does that work at all? If it does, start by appending each of your other lines until it errors.
  15. [quote author=acp26b link=topic=124447.msg515614#msg515614 date=1170014715] Always got to one up everyone huh jesirose? :P [/quote] It comes with the title: [b]PHPFreaks Recommended - Proficient[/b]  ;D
  16. [quote author=bobafett24 link=topic=124438.msg515559#msg515559 date=1170012153] Firstly, thanks for all the help man. Do you think I should re-install some Apache myself? ??? Just one more point, when i for example change the database from test to test1, this should really cause an error coz no database called test1 exists but all I still get is a blank screen still :-\ [/quote] You could try setting the debug and warning's to on in your php settings file. It kind of seems that you don't have mysql working, from PHP, and that you don't have any error/debug output so it's not going to display an error.
  17. That's kinda strange. Hmm.. let me just finish setting up PHP on apache and I'll try this. Just looking at it I don't see anything wrong.
  18. [quote author=GreenDude link=topic=124431.msg515541#msg515541 date=1170010530] oh... the esc() function is just for filtering data (mysql_real_escape_string and others) So... I gave the id "victim" to a table... you're saying I should replace with divs right? [code]<table cellpadding="0" cellspacing="0" class="table_edit" width="800" id="victim"> </table>[/code] forgot to mention the table, sorry  :-X [/quote] It might be what's causing it. Not sure if table has a innerHTML property. Just use a DIV and you'll be safe.
  19. One thing I see, which might be causing some issues is the last comment at the bottom of the file. [quote] / /Close the connection [/quote] You have a space after the first / - could that break the whole PHP script? Other than that, I believe you could also do like this: [code] mysql_select_db($db_database) or die('Message.......'); [/code] rather than doing: [code] $select_database = mysql_select_db($db_database); if (!$database) { ..... } [/code] It's shorter and much cleaner. [code] <?php     // login information     $db_host='localhost';     $db_database='test';     $db_username='root';     $db_password='orlaith';     // Connect $connection = mysql_connect( $db_host, $db_username, $db_password ) or die('Could not connect to the database: ' . mysql_error());     // Select the database     mysql_select_db($db_database)     or die('Could not select the database: ' . mysql_error());     echo "I am connected? This should, I believe, return the resource id: " . $connection;         // Close the connection     mysql_close($connection); ?> [/code] Try the above.
  20. Well, yes, there is. And a whole lot of ways to do it aswell. You could just make a counter script of some sorts. http://www.yoursite.com/count.php?urlid=4 Then have a small database or text file containing the id's and the url itself. The count script should redirect to the specified URL upon entering an id. Something like http://php.about.com/od/finishedphp1/qt/track_links.htm You could.. just count hits when the page you're linking to is loaded, altho that's probably a bad way as the user could just open the page without clicking the link itself hehe. There's alot of ways!
  21. Rather than actually trying to decrypt it (altho It's partially decrypted already? Remember reading that some years ago) you could do a dictionary based attempt, like the guy above suggested. Read through a wordlist, line by line and MD5 it, then match it against the password provided by the site you're talking about. Let's say the md5 provided by the site is f44152ed4438e5c60ffd0d5e67f7aae7 - if you'd run through the wordlist in your php script (you're going to have to make that yourself tho): wordlist.txt hello world my name is earl md5("earl") = "f44152ed4438e5c60ffd0d5e67f7aae7" last entry would match. I guess it's a quick and dirty way.. you can find alot of "public" wordlists around. Another thing is to use JTR (John the ripper), found here: www.openwall.com/john/ - you'll also find various tutorials on this specific application. Just note that it has issues with some hashes. Oh, there's more ;). GData - http://gdataonline.com/seekhash.php - it's a database of user-submitted MD5 hashes, and their plaintext value. [quote] RESULTS: Hash Pass 52 [1] => ed [2] => 44 ) --!> f44152ed4438e5c60ffd0d5e67f7aae7 earl [/quote] It has quite alot. [b]EDIT:[/b] Oh, 3 people replied while I was writing this.. it's the same information as the above posts.
  22. Well. I believe IE has some issues doing the whole injecting html code into the page. What's the type of element you're trying to put the data into? "victim".. some elements have a read-only innerHTML property, and would most likely result in the above error if you attempt to use it. Last time I did innerHTML on a span for example, IE freaked out. Changing that to a div container solved it.
  23. If you download the MSI installer for PHP (5?), it will configure Apache for you. It includes some modules, but you can download the others seperate and extract.
  24. Omg. I'm sorry for wasting your time.. the "left" property of the first tile should be 225, not 255. Someone please shoot me. I just spent hours trying to figure it out, diden't really think of looking at the data itself, just figured it might've been something with the JSON reply.  ::)
  25. Oops, old JSON document posted (tho nothing but the names have changed).. looks like this: [code] {     "world":     {         "name": "Default",                 "tiles":         [             {                 "id": "1",                 "background": "earth_6.gif",                 "top": "0",                 "left": "255"             },             {                 "id": "2",                 "background": "earth_6.gif",                 "top": "16",                 "left": "193"             }         ]     } } [/code]
×
×
  • 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.