Jump to content

Drongo_III

Members
  • Posts

    579
  • Joined

  • Last visited

Everything posted by Drongo_III

  1. Hello I've recently been working with some JS code that has a return statement that will return one or other of a value. A terrible example... function blah(){ return 1==2 || 2==2; } console.log(blah()); Obviously this is just to illustrate the point. I have to admit this was new on me and I would usually do some evaluation before returning and I didn't realise you could do what the code above does. I cant really find anything on this so I have some basic questions: Does this simply return the first of the two that resolves to true? Can it only be used with boolean statements? Can this be used in other languages? And does it have a name?
  2. Hello I am trying to create a script that will animate the sizes of images based on the user scrolling up or down the page. My intention was to use the scroll values to increase and decrease the size of an image based on the scroll value. So if the user is going down then increase the size and if the user is scrolling up then decrease the image size. I've been trying to code below but the issue is that the scroll event seems to fire inconsistently. Scrolling down might fire 15 'down' events, but then scrolling up only triggers 7 'up' events. So when I apply this to an image the image ultimately grows and never shrinks back to it's original size. Hopefully someone can point me in the right direction or suggest a better method. $(document).ready(function(){ var start = 0; $(window).scroll(function() { var st = $(this).scrollTop(); clearTimeout(timeout); var timeout = setTimeout(function(){ if(st < start){ console.log('DOWN'); } else { console.log('UP'); } }, 100); start =$(this).scrollTop(); }); });
  3. The default.php file is in the card directory. So I tried RewriteEngine On RewriteRule ^card/somepage/otherpage/ /card/default.php [QSA] If I do this as a straight redirectMatch it works fine but I don't think the query string is presreved in that instance.
  4. Unfortunately this doesn't appear to work. I just get: The requested URL /card/somepage/otherpage/ was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. I assume the apach isn;t finding a match. Any suggestions?
  5. Hi Guys I wonder if someone can help. I need to rewrite a url that so a pretty url such as /card/somedir/somepage?id=345 will rewrite to the real script page with queries strings I have been trying the following to no avail: RewriteEngine On RewriteRule ^/card/somepage/otherpage/ http://www.mysite.com/card/default.php [QSA] I really need to bone up on this stuff because I find from one server to the next things seem a bit inconsistent. But anyway if anyone could point out where I am going wrong it would be appreciated. Drongo
  6. Hello Not sure if anyone can help but I am trying to setup cross domain tracking on Google analytics. Does anyone know of a particular cookie on analytics I should look out for to confirm cross site tracking is working. Is there a cookie that carries a particular id for instance ? Done a bit of searching around on this but to no avail. Thanks, Drobgo
  7. This is just a stab in the dark but you might want to try using the jquery method .prop() instead of attr(). I believe that since jquery 1.6 attr() gets the value set in the markup - which is likely undefined. Whereas .prop retrieves it from the dom. A way to test if this is the case would be to console.log or alert the value of var newscrollHeight and see what you're getting each time the ajax runs. You may have already done that tho!
  8. I might have misunderstood your issue but you can of course use something like .htaccess file to redirect requests for images - or indeed anything else. For example in a .htaccess file: RewriteEngine On redirectmatch .*\.(jpg|gif|png)$ http://www.google.com This will send any request for any file ending in those extensions to google. Very simplistic example but gives the idea.
  9. Few things to check: 1) make absolutely certain your connection exists -I.e mysql_error() 2) did u recreate the tables in the new database and r u sure the structure and naming is the same? Again running error reporting after your queries one by one will identify this. 3) Are you aware that mysql is deprecated ?
  10. I am not sure of your system as such but this might point u in the right direction . Pages have a fan table which can be queried to see if a particular user id exists ad a fan. I can't be much mote expansive I am afraid as I haven't tried it but know of it. So hope this points u in the right direction http://developers.facebook.com/docs/reference/fql/page_fan/
  11. Yeah as cyber said drop the quotes around your variable names when passing then to the fwrite. And also on the fopen line u r missing your closing quote around the 'w'.
  12. Can u post your code again? Based on the original I can't see why that error would be there. also your script currently won't actually write anything to the file as all it does now is open it for writing and then closes it again . Have you looked at php.net? U can pretty much copy their example herehttp://www.php.net/manual/en/function.fwrite.php Also take a look at the parameters for fopen because some of the modes will overwrite the file each time and some will append to it http://www.php.net/manual/en/function.fopen.php
  13. I am interested in understanding this better so apologies if I'm being slow. When you say use exec do you mean to execute a program on an external server? How would using exec on the same server get around the issue of using up memory since the server resource will be used just the same? Sorry i realise this is all a bit abstract but I can foresee a time in the future when I'll need to build something similar for a much higher volume website so I'd like to understand a good approach.
  14. Also passing in completely raw post data directly into a file makes me feel quite uneasy from a security perspective.
  15. You would be best to pick up mysql and try to work that out as it's just better for your purposes in a myriad of ways. However at a glance I would suggest the syntax error is the comma u have in Fopen line. Fopen usually requires two params so after that comma u should pass in parameter e.g. 'w' which opens the file ready for writing to it.
  16. Generally a connection to a database will close when the script stops executing. So exiting the script would in theory close the connection. However there are database specific functions for closing the connection which are more appropriate - e.g mysqli_close. Equivalents exist for pdo etc. http://php.net/manual/en/mysqli.close.php
  17. Hello I have recently been working with gd library as part of an image upload system. I noticed that one of my scripts was failing due to exceeding the available memory. Anyway researching this I discovered that gd library can be quite memory hungry and the pixel width height of even a small image can require a lot of memory - even when the file size is quite low. So my question is how do really big sites deal with this? If u have a high volume upload form for instance I could imagine the drain in memory being quite massive. So do they just throw hardware at it or are there more efficient image libraries than gd? Incidentally I corrected the memory issue by changing the ini setting for the script. Just in case anyone has that problem.
  18. Sorry I completely missed that when I was reading over php.net - and now it all makes perfect sense! Thank you
  19. Hi Guys I was trying to set a class property today in the same way I have for a long time but it didn't work and it made me wonder whether I have been doing something wrong for a while. When i try to set a session variable to a property of the class, as in $sessID below, i get a php error: "unexpected t_variable". I have been staring at the screen for some hours but I cant actually see anything wrong with the line. If I comment out the sessID line and instead set this property in the construct this works fine. So few questions spring to mind: 1) is there some reason you can't set a variable outside of the construct like this? 2) is it best practice to set such variables as part of the construct? 3) Why do all the other variables work fine but not the session one? It may yet transpire the answer to one of these questions is the answer to all Thanks, Drongo class user_admin extends login { public $errors = array(); private $userData = array(); private $changePassword = false; public $sessID = $_SESSION['user_logged']; public function __construct(){ //$this->sessID = $_SESSION['user_logged']; $this->getUserData(); include('/forms/user-admin.php'); } }
  20. Thanks Abra! I will try this tomorrow. See i knew one of clever peeps here would have it down Drongo
  21. Hi Guys This is a bit of a weird one and I wondered if perhaps someone here had experienced this and found a work around. I'm using zip archive on a project at the moment. Basic version of the code is below. When I zip a file and output it to the browser using headers it works fine in the example below. BUT if I try to add a file from another directory, as in the commented out line below, the resulting zipped folder can't be unzipped in windows. When I try I get a "The folder XXXX is invalid" message. I sent the same zipped folder to my htc phone and it opened the zipped folder no problem. The puzzling thing about windows is that it works fine if the image originates in the same directory as the executing script and can be opened no problem. So is this something anyone else has encountered? And how can you get around it? $zip = new ZipArchive(); if ($zip->open('./test2.zip',ZipArchive::CREATE) === TRUE) { //$zip->addFile('../fileUploadLocation/somefolder/image1.jpeg'); $zip->addFile('image3.jpeg'); $zip->close(); echo 'ok'; } else { echo 'failed'; }
  22. Hi Guys Working on a big multi-stage form. The form has multiple stages, each posting to the next. There is currently minimal validation - validation is done via a simple regex which as a minimum allows these chars: a-z A-Z 0-9 - £ As I need to store up all the user data until they complete and it can be passed to the database I am wondering if there is anything in particular I should do, besides the validation, to make sure the data being held in the session is safe? I've read about some exploits via user data in the session but can't say I have an exhaustive understanding of this so any tips are welcome. Drongo
  23. Sorry mate it is just stripping out the regex everytime I try and paste it. I have pasted the code into a temporary repository: http://codetidy.com/5995/ Go there and grab it and let me know how u get on
  24. Sry tried to respond to this post but its not saving my code in the code block. Might be because the line length of the regex I am trying to paste in. :/ I know this is frowned upon but going to try and paste this straight into the message window: <?php $STRING = 'This is a https://www.google.com link'; $linkReplace = "<a href=" . "$1" . " target='_blank'>$1</a>"; // Replacement pattern to create a link $text = preg_replace($RegExp, $linkReplace , $STRING); echo $text;
×
×
  • 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.