Browsing articles tagged with " PHP"
Aug
15
2014

Increase the max upload filesize in Apache/PHP

portada

Have you ever experienced with this message when you implement File upload function in to you PHP code ” Error:The uploaded file exceeds the maximum allowed size in your PHP configuration file “ Your php installation putting limits on upload file size. The default will restrict you to a max 2 MB upload file size.

Aug
4
2013

PHP validate XML against XSD for more detailed error.

download

This is the code to validate some XML against a XML schema using PHP5′s “schemaValidate();”

Jul
20
2013

How to Install Linux, Apache, MySQL, PHP on Ubuntu

download (5)

Step One—Install Apache Apache is a free open source software which runs over 50% of the world’s web servers. To install apache, open terminal and type in these commands: sudo apt-get update sudo apt-get install apache2 That’s it. To check if Apache is installed, direct your browser to your server’s IP address (eg. http://12.34.56.789). The page should display the words “It works!” like this. How to Find your Server’s IP address You can run the following […]

Jul
20
2013

How to Check Apache Module and Enable Apache Modules?

download (3)

We can use apache2ctl -M to the module that has been enabled on apache. Or if you have apache + PHP you can check it from phpinfo() function <?php echo phpinfo(); ?>   What if you want to enable the module you can use a2enmod “The module name”   for example “enable mod_rewrite” :: #a2enmod rewrite   Then restart the apache service #/etc/init.d/apache2 restart or #service apache2 restart

Jul
19
2013

PHP exec() Error Codes

images (2)

exec() error codes mean from the return at the third parameter. for example  exec($cmd.’ 2>&1′, $output, $return); 1 – Catchall for general errors. 2 – Misuse of shell builtins. 126 – Command invoked cannot execute. A permission or command not executable problem. 127 – Command not found. 128 – Invalid argument to exit. Exit takes only integer range 0 – 255. 128+n – Fatal error signal “n”. 130 – Script terminated by Control-C. 255* – […]

Feb
15
2013

Force PHP to show all errors or save them to a log for troubleshooting

Most servers are set to suppress PHP errors which can leave you guessing why something isn’t working and make troubleshooting code almost impossible. This is especially frustrating when you install a 3rd party module with errors. Luckily forcing PHP to display errors is very easy.  The most basic way to accomplish this is to just add the following 2 lines to the top of your PHP code.Copy this code… error_reporting(E_ALL); ini_set( ‘display_errors’,’1′);   You can […]

Feb
15
2013

PHP Shorthand If / Else Examples

Basic True / False Declaration $is_admin = ($user['permissions'] == ‘admin’ ? true : false); Conditional Welcome Message echo ‘Welcome ‘.($user['is_logged_in'] ? $user['first_name'] : ‘Guest’).’!’; Conditional Items Message echo ‘Your cart contains ‘.$num_items.’ item’.($num_items != 1 ? ‘s’ : ”).’.’; Conditional Error Reporting Level error_reporting($WEBSITE_IS_LIVE ? 0 : E_STRICT); Conditional Basepath echo ‘<base href=”http’.($PAGE_IS_SECURE ? ‘s’ : ”).’://mydomain.com” />’; Nested PHP Shorthand echo ‘Your score is: ‘.($score > 10 ? ($age > 10 ? ‘Average’ : […]

Feb
6
2013

PHP + SSH Authentication using a public key

  <?php $connection = ssh2_connect(‘shell.example.com’, 22, array(‘hostkey’=>’ssh-rsa’)); if (ssh2_auth_pubkey_file($connection, ‘username’, ‘/home/username/.ssh/id_rsa.pub’, ‘/home/username/.ssh/id_rsa’, ‘secret’)) { echo “Public Key Authentication Successful\n”; } else { die(‘Public Key Authentication Failed’); } ?>   This is a known bug in php: password protected private key cannot be used on certain combinaisons. See: https://bugs.php.net/bug.php?id=58573 ssh2_auth_pubkey_file() is broken when the public key file is protected with a password AND libssh2 is compiled with libgcrypt, which is what debian/ubuntu and probably others do. I’m working on a solution for this bug, but if you need this working rebuild libssh2 yourself with […]

Feb
6
2013

Installing PHP’s SSH2 extension on Ubuntu

    On Ubuntu 10.04 LTS, Do this (there’s no need to do any compiling anymore) 1 apt-get install libssh2-1-dev libssh2-php You can now test if PHP recognizes it’s new ssh2 extension by running: 1 php -m |grep ssh2 Don’t forget to restart Apache 1 service apache2 restart

Feb
1
2013

PHP FTP + Passive FTP Server

// create a basic connection $ftpconn = ftp_connect($ftp_ip, $ftp_port); // login with username and password ftp_login($ftpconn, $ftp_user, $ftp_pass); // Switch into passive mode (required for servers behind firewalls / NAT devices) ftp_pasv($ftpconn,true); // Print a directory listing print_r ftp_nlist($ftpconn, “/”);

Pages:12»



Member Area