open wordpress only with access key

Open your template header.php file and add this to the top of the file

Then you can open your wordpress with url http://yourwordpress.com/?access=verysecretkey

<?php
if(!session_id()) {
session_start();
}
$access=“verysecretkey“;
if($_GET[‘access’]==$access){
$_SESSION[‘access’]=$_GET[‘access’];
}
elseif($_SESSION[‘access’]!=$access){
die(‘Im sorry you dont have permission to access this page, please login and try again.’);
}
?>

С етикет:
Публикувано в Без категория

php post with big array

Starting from php 5.3.9 there is brand new config option max_input_vars which is limiting the input variables to posted arrays and etc.

max_input_vars integer
How many input variables may be accepted (limit is applied to $_GET, $_POST and $_COOKIE superglobal separately). Use of this directive mitigates the possibility of denial of service attacks which use hash collisions. If there are more input variables than specified by this directive, an E_WARNING is issued, and further input variables are truncated from the request. This limit applies only to each nesting level of a multi-dimensional input array.

Default value is 1000, to set different value you need to add to your php.ini

max_input_vars = 3000

С етикет: , , , ,
Публикувано в linux

mysql import all sql files from directory

for SQL in *.sql; do  echo importing $SQL; mysql -u user  -ppassword table< $SQL;rm $SQL; done

С етикет: , , , , , ,
Публикувано в linux

mysql export every table in different file

#!/bin/bash

# dump-tables-mysql.sh
# Descr: Dump MySQL table data into separate SQL files for a specified database.
# Usage: Run without args for usage info.
# Author: @Trutane
# Ref: http://stackoverflow.com/q/3669121/138325
# Notes:
#  * Script will prompt for password for db access.
#  * Output files are compressed and saved in the current working dir, unless DIR is
#    specified on command-line.

[ $# -lt 3 ] && echo "Usage: $(basename $0) <DB_HOST> <DB_USER> <DB_NAME> [<DIR>]" && exit 1

DB_host=$1
DB_user=$2
DB=$3
DIR=$4

[ -n "$DIR" ] || DIR=.
test -d $DIR || mkdir -p $DIR

echo -n "DB password: "
read -s DB_pass
echo
echo "Dumping tables into separate SQL command files for database '$DB' into dir=$DIR"

tbl_count=0

for t in $(mysql -NBA -h $DB_host -u $DB_user -p$DB_pass -D $DB -e 'show tables') 
do 
    echo "DUMPING TABLE: $t"
    mysqldump -h $DB_host -u $DB_user -p$DB_pass $DB $t | gzip > $DIR/$t.sql.gz
    (( tbl_count++ ))
done

echo "$tbl_count tables dumped from database '$DB' into dir=$DIR"
С етикет: , ,
Публикувано в linux

301 .htaccess redirect

Sometimes we need to redirect old links to new pages, it`s very easy.

Redirect 301 /oldpage.php http://newlink/newpages.php

Публикувано в Joomla, linux