Jump to content

tomfmason

Staff Alumni
  • Posts

    1,693
  • Joined

  • Last visited

Everything posted by tomfmason

  1. tables are meant for tabular data. If your layout is in tabular format then it is fine to use them for the layout. Otherwise you are wrong. Here are a few reasons why you should never use tables for layout: 1) Your pages are difficult, if not almost impossible, to read for screen readers and other alternate browsing methods. 2) There tends to be 2-3x more markup(more work for you, slower load times ect) 3) It looks like crap Those are just three of many reasons why you should never use tables for layouts.
  2. That is pretty much exactly what I was meaning. ie. ajaxbase.php <?php //check for your defined variable class AjaxBase { private $action_prefix = "ajax_"; public function dispatch($action){ if(!empty($action) && !stristr($action, $this->action_prefix) && in_array($this->action_prefix . $action, get_class_methods($this))){ //now we call the requested action $this->{$this->action_prefix . $action}(); } else { //invalid action } } } ?> foo.php <?php //check for your defined variable include dirname(__FILE__) . '/ajaxbase.php'; class AjaxFoo extends AjaxBase { private function ajax_bar() { //something amazing } } ?> index.php <?php //defines here if(empty($_GET['page']) || empty($_GET['action'])) { //invalid action } else { $file = dirname(__FILE__) . '/' . basename($_GET['page'] . '.php'); $class = 'Ajax' . ucfirst(basename($_GET['page'])); if(file_exists($file)) { include $file; $ajax = new $class; $ajax->dispatch($_GET['action']); } else { //invalid action } } ?> now index.php?page=foo&action=bar would call the ajax_bar function of the AjaxFoo class.
  3. I normally take an approach more like: <?php //define here //include additional code class Ajax { private $action_prefix = "ajax_"; public function dispatch($action){ if(!empty($action) && !stristr($action, $this->action_prefix) && in_array($this->action_prefix . $action, get_class_methods($this))){ //now we call the requested action $this->{$this->action_prefix . $action}(); } else { //invalid action } } private function ajax_foo() { //do something amazing here } } $ajax = new Ajax(); $ajax->dispatch($_GET['action']); ?>
  4. I think the best method would be to keep your first code, make a single point of entry and then dispatch the requests as needed. An observant person could pick up on the fact that the ajax calls only work if ajax is posted.
  5. The best method that I know of is to set a cookie via javascript and then check it in php. If the variable isn't present and they aren't a search engine crawler redirect. That and noscript tags to notify them that javascript is required.
  6. You need an spf record in your dns. I use something like this for one of my domains using gmail: domain.tld. IN TXT "v=spf1 include:aspmx.googlemail.com ~all"
  7. some simple modifications to the example.php yielded the desired results <?php mysql_connect("localhost", "root", ""); require("class_mysqldump.php"); $dump = new MySQLDump(); $file_name = "MySQL_Database_Backup.sql"; Header("Content-type: application/octet-stream"); Header("Content-Disposition: attachment; filename=$file_name"); print $dump->dumpDatabase("db"); ?>
  8. A quick search of phpclasses shows http://www.phpclasses.org/browse/package/2527.html
  9. What is really odd is that if I place the rewrites in a .htaccess in the public directory and remove the rewrite/ProxyPass from the vhost it works as expected.
  10. I have done this particular setup many times and have never seen this before. Basically I want to proxy all requests to this vhost to an application running on a local port. This a default install of apache2 on debian etch with mod_proxy. I have both mod_proxy and mod_proxy_http loaded. Here are the configs in question: #proxy config <IfModule mod_proxy.c> ProxyRequests Off <Proxy *> AddDefaultCharset off Order deny,allow Deny from all ProxyFtpDirCharset UTF-8 </Proxy> ProxyVia On </IfModule> #example virtualhost <VirtualHost 127.0.0.1:80> ServerAdmin admin@domain ServerName domain DocumentRoot /path/to/app/public <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /path/to/app/public> Options Indexes FollowSymLinks MultiViews AllowOverride ALL Order allow,deny allow from all </Directory> <Proxy *> Order allow,deny Allow from all </Proxy> #RewriteEngine on #RewriteRule ^(.*)$ http://127.0.0.1:5000/$1 [P,L] ProxyPass / http://127.0.0.1:5000/ ProxyPassReverse / http://127.0.0.1:5000/ ProxyPreserveHost On CustomLog /var/log/apache2/access.log combined ErrorLog /var/log/apache2/error.log LogLevel warn ServerSignature On </VirtualHost> Both the rewrite and proxy pass are redirecting to 127.0.0.1:5000. I don't see anything at all in either the access or error logs. It doesn't even appear that the request ever touches apache. Any ideas or suggestions?
  11. It is bash. OP: you should look over http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
  12. Am I missing something or does that not make any sense at all?
  13. Did you try apt-cache search postgresql?
  14. It could be a variation of the proxy hack from a couple years ago - http://www.seofaststart.com/blog/google-proxy-hacking
  15. We might as well burn our own houses down. Not having anything and being homeless will make us tougher. Anything seem off with that logic?
  16. With the exception of number 4 what you have described is a "script kiddie". Also, the term hacker in that context is just plain wrong. To me hacking is the act of finding a way of accomplishing a goal that was not previously known. A real hacker doesn't do most of things commonly associated with the name. These includes security related intrusions and viruses. If they do participate in illegal security intrusions they are not hackers but are crackers. If you are going to stick with the assumptions made above I would change "Hackers" to "Script Kiddies" and remove #4 from your list.
  17. To be honest I think that code is a mess. I am seriously considering writing a good role based user authentication tutorial. I may even add some BDD to make it interesting
  18. The servers are located in the GMT - 5 timezone. But as revraz said that doesn't really matter for posting purposes.
  19. I don't really think that's the case... But well... we can only theorize, while in fact this topic should be put to rest... I agree.
  20. If you want to do it on windows you can do something like this using COM: <?php $dir = "C:\\path\\to\\"; $obj = new COM('WScript.Shell'); $obj->run("cmd /K CD $dir & php your_script.php", 0, false); ?>
  21. um.. good question. Maybe he meant "accidentally on purpose"
  22. 1) Figure out what the "project" is going to do and it's name 2) Determine what licence the "project" would be released under 3) Use something like gna, sourceforge or google code for development/distribution/issue tracking 4) Sit back and enjoy the glory that comes from developing free software
  23. 2 but that shouldn't matter. AS3 would require the same thing. Just use the same host in your socket connection from flash as the server is listening on and it should automagically work regardless of the AS version
  24. I got it working and I was indeed correct about the policy request. I noticed the following things. When setting the host for the xml socket from flash it must be connecting to the same host that the socket server is listening on e,g, localhost. The second is that you need to respond correctly to the policy request from flash. Here is the working code and the action script I used to test it(complied with mtasc) #!/usr/bin/php -q <?php /* Raymond Fain Used for PHP5 Sockets with Flash 8 Tutorial for Kirupa.com For any questions or concerns, email me at [email]ray@obi-graphics.com[/email] or simply visit the site, [url=http://www.php.net]www.php.net[/url], to see if you can find an answer. */ error_reporting(E_ALL); set_time_limit(0); ob_implicit_flush(); //$address = '192.168.1.75'; $address = 'localhost'; //$address = '127.0.0.1'; $port = 45063; $policyFile = '<cross-domain-policy><allow-access-from domain="*" to-ports="45063" /></cross-domain-policy>'; $policyRequest = '<policy-file-request/>'; //---- Function to Send out Messages to Everyone Connected ---------------------------------------- function send_Message($allclient, $socket, $buf) { foreach($allclient as $client) { socket_write($client, "$client talk: $buf"); } } //---- Start Socket creation for PHP 5 Socket Server ------------------------------------- if (($master = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) { echo "socket_create() failed, reason: " . socket_strerror($master) . " "; } socket_set_option($master, SOL_SOCKET,SO_REUSEADDR, 1); if (($ret = socket_bind($master, $address, $port)) < 0) { echo "socket_bind() failed, reason: " . socket_strerror($ret) . " "; } if (($ret = socket_listen($master, 5)) < 0) { echo "socket_listen() failed, reason: " . socket_strerror($ret) . " "; } $read_sockets = array($master); //---- Create Persistent Loop to continuously handle incoming socket messages --------------------- while (true) { $changed_sockets = $read_sockets; $num_changed_sockets = socket_select($changed_sockets, $write = NULL, $except = NULL, NULL); foreach($changed_sockets as $socket) { if ($socket == $master) { if (($client = socket_accept($master)) < 0) { echo "socket_accept() failed: reason: " . socket_strerror($msgsock) . " "; continue; } else { array_push($read_sockets, $client); } } else { $bytes = socket_recv($socket, $buffer, 2048, 0); if ($bytes == 0) { $index = array_search($socket, $read_sockets); unset($read_sockets[$index]); socket_shutdown($socket,2); socket_close($socket); }else{ $allclients = $read_sockets; array_shift($allclients); if($buffer == $policyRequest . "\0"){ print "received policy request and sending the policy file \n"; socket_write($client, $policyFile); } else { send_Message($allclients, $socket, $buffer); } } } } } ?> /* Compile using MTACS (http://www.mtasc.org/) mtasc -version 8 -header 1:1:1 -main -swf test.swf test.as */ import flash.external.ExternalInterface; class SocketServer { static var socket : XMLSocket; static var host:String = 'localhost'; static var port:Number = 45063; static var test:String; static function connect() { // Create new XMLSocket object System.security.loadPolicyFile('xmlsocket://' + host + ':' + port); log('Attempting to connect to' + host + ' on port ' + port); socket = new XMLSocket(); socket.connect(host, port); socket.onXML = newXML; socket.onConnect = onConnect; socket.onClose = onDisconnect; } static function log(data:String) { ExternalInterface.call("alert", "flash method log called") ExternalInterface.call('log', data); } static function onConnect(success:Boolean) { if (success) { log('Connected to ' + host + ' on port ' + port); log('connected'); } else { log('Error connecting to ' + host + ' on port ' + port); } } static function onDisconnect() { log('Diconnected from ' + host + ' on port ' + port); } static function sendData(data:String){ socket.send(data) } static function newXML(input:XML) { ExternalInterface.call('receiveData',input.toString()); } static function main() { ExternalInterface.addCallback("log", null, log); ExternalInterface.call("alert", "loaded flash flile"); connect(); } } Hope that works for you.
  25. I don't think that it will work as the very first thing flash will do is request the cross domain policy from the socket server.
×
×
  • 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.