Jump to content

Adam

Moderators
  • Posts

    5,717
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Adam

  1. There's not a single period (".") in that bit of code you just posted?
  2. Your explanation makes no sense?
  3. file_put_contents is probably the easiest way to write to files. Given the data is already in binary format, you just need to write it to a file with a generated name. Can't really comment on how you will generate file names, given we don't know enough about the data. Essentially though all you need to do is write a script that will first create a new column for the file name, then loop through each record; writing the data to a file and storing the new file name back into the database, then at the end assuming all went well you can drop the column. Probably goes without saying it would be a wise idea to back-up the data before you run anything.
  4. There is no board for third party JS.
  5. Any custom HTTP response/request headers should start with "X-". Are you sure you don't mean to parse the "bb_sessionhash" cookie from the "Set-Cookie" response header? Bare in mind you will only be able to do that whenever the cookie is actually sent back. Why are you being forced to use a httpOnly cookie may I ask?
  6. Why don't you just use a different language? PHP is clearly not for you.
  7. No the code was a call to methodName(), equivalent to: var str = 'foo'; foo.methodName(); Given that a string is an object, you can still call methods on them even using the shorthand notation. JS provides a few other shorthand notations like that, for example: // Regex /^foo$/.test('bar') // Objects {foo: 'bar'} // Arrays ['foo', 'bar']
  8. .. Just change the src? Sorry, you need to post more information than that for us to help. Best bet would be to post the code with a reasonable explanation of what's happening.
  9. This topic has been moved to PHP Coding Help. http://forums.phpfreaks.com/index.php?topic=362143.0
  10. You can't really have overloading when the language is dynamically typed; C++, C# and Java are all statically typed languages. Might want to suggest static typing first, eh? No thank you, there's already enough magic going in PHP if you ask me. What?? How you can act like you're promoting 'good object orientated programming habits' and then say that?
  11. Prototype is used for extending objects. Every object in JS has prototype, and everything in JS is an object (even functions, strings, numbers, etc.) So essentially, you can use prototype to extend anything. There's a few pre-defined objects you're likely to be familiar with; String, Function, Number, Date, etc. It's also worth noting that unlike in PHP, objects only have properties. However you can assign those properties a Function, so it appears that they have methods, even though it's just a property containing a Function object. Also importantly, those objects - in-fact every object - extends Object. So to create a new, callable property for Strings, you would use: String.prototype.methodName = function() {} To create a new, callable property for every object, you would use: Object.prototype.methodName = function() {} These can only be used on constructed objects by the way, you couldn't call them directly like: String.methodName() It would have to be: 'foo'.methodName() The difference being that the methods are not added directly to the String object, they're added to instances of String objects as they're constructed -- that's prototype's job. Although if you chose you could drop "prototype." from the declaration and call it directly on String, like in my first call example. Making sense? You can also prototype your own, custom objects. For example: function Test() { } Test.prototype.returnFalse = function() { return false; } var test = new Test(); test.returnFalse(); // false Your calls to your example test() function don't do the same thing. The first, with the new keyword, creates a new instance of test() as an object, treating the function as a constructor. The second call just returns true and is stored in o. I'm not sure where you got it from that new is a bad habit? Behind the scenes you're always creating new objects in JS, it's perfectly fine if used right.
  12. Oh.. Ha. I just clicked the link and saw a pool table
  13. LOL fail.
  14. It's perfectly doable but it's not just about learning JavaScript, there's physics involved. You need to be able to determine the velocity of a ball, what effect a cushion would have, what angle you hit other balls at, etc. As mentioned, it's probably not a good starter project.
  15. You're echoing the line-feed in PHP, not JS. That means: ... Is the JS being sent to the browser, which is invalid syntax. Strings can't span over multiple lines without a backslash at the end of the previous line. In PHP you can send the literal string "\n" by escaping it with a backslash (so a double backslash really): echo "<script type=\"text/javascript\">alert('Hello\\n How are you?')</script>"; Or by using single quotes, because special characters aren't parsed in single quote strings: echo '<script type="text/javascript">alert("Hello\n How are you?")</script>'; Although there's no need at all to use PHP to echo the string, you could just close the PHP tag and re-open it after: { ?> <script type="text/javascript">alert('Hello\n How are you?')</script> <?php }
  16. Standard that it's blocked. You might not be seeing any errors because you have the display_errors config set to 0. Please open another thread if you want more help with that though.
  17. That's pretty much standard on a shared host.
  18. ?? Nothing seems to work?
  19. +1 -- there's no benefit in using namespaces the way you are doing.
  20. There's nothing wrong with the syntax. All you're doing is using the php binaries to execute the script, writing the output to nothingness (">/dev/null") and then telling the command to run in the background ("&"). I'm guessing there's a permissions issue or something along those lines, so I would add in the second parameter and remove the write to /dev/null so you can check the response.
  21. The code triggering a hook shouldn't define how the plug-ins work, they should just pass in some context like the blog object/array. Including "hi" within the event name, and using it like you are, forces the plug-in to define an object with a hi() method. Keep it flexible and allow the plug-ins to pass in any callback they want. The "blog.write" in my example was just an event named "write" within a "blog" event namespace by the way. Doing it that way allows you to be more flexible with what your hooks listen for.
  22. Yeah, you're just passing in an anonymous function, not an object. Where are you expecting the add() method to come from? You'd be much better off passing in the data like in my example though, as opposed to some random method names like "add()". That would get confusing, and if there's ever say two pieces of data in question, then how would that work?
  23. Your method is fine to include the plugin code, but as scootstah mentioned you would need to use something like hooks to expose the core functionality. Otherwise your plug-ins are going to be incredibly limited. Hooks are essentially just kind of events that the plug-ins listen for, and can alter what happens or modify some data/objects passed in. There's a load of ways you could implement them, but here's a very rudimentary example: $hooks->register('blog.write', function($blog) { // Do something with the blog return $blog; }); $this->hooks->trigger('blog.write', array($blog)); You'd probably want to allow a callback to be passed in (optionally instead of a function) to allow the plug-ins to become more robust. You would also need to think about error/exception handling, extending core objects, core dependencies, permissions and prioritisation, etc. Think about it before you publish anything; if you dramatically change the implementation after launch you'll annoy any plug-in writers. I can't really comment on some of the challenges you'll face, because I've never actually implemented anything to this level before. Been meaning to for a while though. I would imagine there's some code out there already you could use if you don't fancy writing it yourself.
  24. The main nav is now icons on the top right, letter searching is to the right of the searchbar. Which links return 404's? I still find the navigation a little pants to be honest. What about categories? A lot of the people who use a site like yours possibly won't know exactly what it is they're looking for (don't know the name), so will drill down into the categories looking for something along the same lines. What if you miss out on a really good snippet because the publisher used "DB" instead of "database" everywhere? It also just makes general browsing about a lot easier/possible. The 404s seem to have been fixed now by the way -- it has been nearly three weeks.
  25. Hmm.. Is there a reason you're writing all of the pop-up's contents using JS? Why not place it all in an HTML file you specify in open(), and then just use JS to add in the extra bits of data you need? Or perhaps even easier, pass the data in as parameters and build the HTML using PHP?
×
×
  • 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.