VarjuOrg

Linux / Windows – what’s the difference…

HOWTO

Good snippet for when You have to revalidate page on every load (sportnews etc.)

Add to Your .htaccess: FileETag None Header unset ETag Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" Header set Pragma "no-cache" Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"  

Fix for old code when GLOBALS are needed on newer PHP versions

Quickfix is: if (! isset($PXM_REG_GLOB)) { $PXM_REG_GLOB = 1; if (! ini_get('register_globals')) { foreach (array_merge($_GET, $_POST) as $key => $val) { global $$key; $$key = (get_magic_quotes_gpc()) ? $val : addslashes($val); } } if (! get_magic_quotes_gpc()) { foreach ($_POST as $key => $val) $_POST[$key] = addslashes($val); foreach ($_GET as $key => $val) $_GET[$key] = addslashes($val); } […]

How to install Symfony3 under shared webhosting in Developement mode

1. Log in to SSH 2. Install Composer (We assume that composer is not yet installed): export COMPOSERDIR=~/bin;mkdir bin curl -sS https://getcomposer.org/installer | php — –install-dir=$COMPOSERDIR –filename=composer (Composer will be installed under: /home/username/bin/composer ) 3. To test that installation was successful – You can run: ~/bin/composer 4. Make environment global INSTALLDIR: export INSTALLDIR=~/public_html/symfony mkdir $INSTALLDIR […]

, , ,

All local mail sent out via external smarthost (Exim4 on Ubuntu 16.04)

Steps to do: 1. First run (start basic exim conf): sudo dpkg-reconfigure exim4-config And use these config options: General type of mail configuration: mail sent by smarthost; received via SMTP or fetchmail System mail name: IP-address to listen on for incoming SMTP connections: 127.0.0.1, ::1 Other destinations for which mail is accepted: Machines to relay […]

unserialize() : Error at offset XX:XXX

Food for thought: 1. Probably Your charset is wrong (after PHP 5.5) – Set charset after open tag: header('Content-Type: text/html; charset=utf-8'); – And set charset utf8 in your database : mysql_query("SET NAMES 'utf8'"); 2. Your serialized array is faulty Could be fixed by: $fixed_data = preg_replace_callback ( '!s:(\d+):"(.*?)";!', function($match) { return ($match[1] == strlen($match[2])) ? […]

Bash script to run via command-line to lowercase all file- and folder names in current folder recursively

#!/bin/bash # first, rename all folders for f in `find . -depth ! -name CVS -type d`; do g=`dirname "$f"`/`basename "$f" | tr '[A-Z]' '[a-z]'` if [ "xxx$f" != "xxx$g" ]; then echo "Renaming folder $f" mv -f "$f" "$g" fi done # now, rename all files for f in `find . ! -type d`; […]

How to change Linux files/folders permissions under same directory recursively 644/755

One approach would be: find . -type d -print0 | xargs -0 chmod 0755 find . -type f -print0 | xargs -0 chmod 0644 Other approach: find /full/path/to/your/files -type f -exec chmod 644 {} \; find /full/path/to/your/files -type d -exec chmod 755 {} \; NB! Please do note that -f option is for files and […]

Nifty feature to change text inside large file over Linux commandline

sed -i 's/original/new/g' file.txt sed = Stream EDitor -i = in-place (i.e. save back to the original file) s = the substitute command original = a regular expression describing the word to replace (or just the word itself) new = the text to replace it with g = global (i.e. replace all and not just […]

Letsencrypt on Ubuntu 16.04 LAMP howto commandline

1. Install Letsencrypt with apache addon: sudo apt-get install python-letsencrypt-apache 2. Generate only cert for domain letsencrypt –apache certonly If above fails: 1. For different webroot letsencrypt certonly -a webroot –webroot-path=/var/www/ -d your.domain.name 2. If apache fails or port 443 fails – do manual over HTTP letsencrypt certonly –standalone-supported-challenges http-01 NB! Apache needs fullkeychain and […]

Restoring MySQL root user privileges when corrupt (in linux)

1. On commandline (shut down mysql and start mysqld_safe without grant tables): sudo /etc/init.d/mysql stop sudo mysqld_safe –skip-grant-tables & 2. On new terminal window (log on and execute code as shown): mysql UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root'; FLUSH PRIVILEGES; GRANT ALL ON *.* TO 'root'@'localhost'; FLUSH PRIVILEGES; 3. Kill mysqld_safe instance 4. Log […]

, , , ,

Previous Posts