Автоматическое добавление переменной ко всем ссылкам
<?php
output_add_rewrite_var('var', 'value');
4 ноября 2014, 07:12
<?php
output_add_rewrite_var('var', 'value');
function pipe_streams($in, $out)
{
$size = 0;
while (!feof($in)) $size += fwrite($out,fread($in,8192));
return $size;
}
Write failed: Broken pipe
ClientAliveInterval 15
ServerAliveInterval 120
Host * ServerAliveInterval 240 ServerAliveCountMax 3
setenforce Permissive
restorecon -R -v /root/.ssh
[CentALT] name=CentALT Packages for Enterprise Linux 6 - $basearch baseurl=http://centos.alt.ru/repository/centos/6/$basearch/ enabled=1 gpgcheck=0
yum install nginx
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/6/$basearch/ gpgcheck=0 enabled=1
yum install nginx
iptables -I INPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT iptables-save > /etc/sysconfig/iptables
chkconfig --levels 235 nginx on service nginx start
yum install ImageMagick yum install php-pear pecl install imagick echo "extension=imagick.so" > /etc/php.d/imagick.ini
Please make sure that SCP is installed on the server and path to it is included in PATH. You may also try SFTP instead of SCP.
yum -y install openssh-clients
pear clear-cache pear install phpunit/PHPUnit
<?php
if (!function_exists ("ssh2_connect")) {
die ("function ssh2_connect doesn't exist");
}
if(!($con = ssh2_connect("localhost", 22))){
die("unable to establish connection");
}
// авторизуемся по имени пользователя и паролю
if(!ssh2_auth_password($con, "root", "password")) {
die("unable to authenticate");
}
// выполняем комманду
if (!($stream = ssh2_exec($con, "ln -s" ))) {
die("unable to execute command");
}
// collect returning data from command
stream_set_blocking ($stream, true);
$data = "";
while ($buf = fread ($stream,4096)) {
$data .= $buf;
}
fclose ($stream);
echo $data;
?>
ifconfig em0 alias 85.12.17.30 netmask 0xffffffff echo 'ifconfig_em0_alias0="inet 85.12.17.30 netmask 255.255.255.0"' >> /etc/rc.conf
cd /usr/ports/devel/gitolite make install clean
su git cd ~ gitolite setup -pk ~/.ssh/id_rsa.pub
repo gitolite-admin
RW+ = id_rsa
repo testing
RW+ = @all
@admins = admin1 admin2
@developers = @admins developer1
@staff = @admins @developers
repo gitolite-admin
RW+ = @admins
repo project
RW+ = @developers
ssh root@localhost -p 22 -o StrictHostKeyChecking=no
insert into TableName default values
<?php
// создаем дочерний процесс
$child_pid = pcntl_fork();
if ($child_pid) {
// выходим из родительского, привязанного к консоли, процесса
exit;
}
// делаем основным процессом дочерний
// После этого он тоже cможет создавать процессы
posix_setsid();
//чтобы повторно не запустить демона, нужна функция для проверки его pid
function isDaemonActive($pid_file) {
if (is_file($pid_file)) {
$pid = file_get_contents($pid_file);
//проверяем на наличие процесса
if (posix_kill($pid, 0)) {
//демон уже запущен
return true;
} else {
//pid-файл есть, но процесса нет
if (!unlink($pid_file)) {
//не могу уничтожить pid-файл. ошибка
exit(-1);
}
}
}
return false;
}
//проверяем запущен ли демон
if (isDaemonActive(__DIR__ . '/daemon.pid')) {
echo 'Daemon already active';
exit;
}
//регистрируем обработчик сигналов
pcntl_signal(SIGTERM, "sigHandler");
//сама функция обработчика
function sigHandler($signo) {
global $stop_server;
switch ($signo) {
case SIGTERM: {
$stop_server = true;
break;
}
default: {
//все остальные сигналы
}
}
}
//говорим php принимать сигналы
pcntl_signal_dispatch();
//записываем pid процесса демона
file_put_contents(__DIR__ . '/daemon.pid', getmypid());
//будем держать не более 20 процессов одновременно
define('MAX_CHILD_PROCESSES', 20);
//задержка чтобы не гонять цикл постоянно
define('DELAY', 1);
//массив для хранения дочерних процессов
$child_processes = array();
//запускаем бесконечный цикл
while (!$stop_server) {
if (!$stop_server and (count($child_processes) < MAX_CHILD_PROCESSES)) {
//плодим дочерний процесс
$pid = pcntl_fork();
if ($pid == -1) {
//ошибка - не смогли создать процесс
} elseif ($pid) {
//процесс создан
$child_processes[$pid] = true;
} else {
$pid = getmypid();
//дочерний процесс - тут рабочая нагрузка
//для примера заснем на 100
//на этом месте может быть, например, команда конвертации видео
sleep(100);
exit;
}
} else {
//чтоб не гонять цикл постоянно
sleep(DELAY);
}
//проверяем, умер ли один из детей
while ($signaled_pid = pcntl_waitpid(-1, $status, WNOHANG)) {
if ($signaled_pid == -1) {
//детей не осталось
$child_processes = array();
break;
} else {
unset($child_processes[$signaled_pid]);
}
}
}
php daemon.php
<?php //НАПРИМЕР pid демона 56497 posix_kill(56497, 9);
sudo chmod -R g+ws * sudo chgrp -R git * git repo-config core.sharedRepository true
netstat -nptcp | egrep -v 'Active|Address' | awk '{print $5}' | cut -d. -f 1-4 | sort | uniq -c | sort -n
netstat -nptcp | egrep -v 'Active|Address' | awk '{print $5}' | cut -d. -f 1-4 | sort | uniq -c | sort -n | tail -n 10
<?php
$phrase = 'secret message';
$key = 'KEY';
$encrypt = encrypt($key, $phrase);
$phrase = decrypt($key, $encrypt);
echo $encrypt, ' = ', $phrase;
function encrypt($key, $text) {
$cipher = mcrypt_module_open(MCRYPT_BLOWFISH,'','cbc','');
mcrypt_generic_init($cipher, $key, '12345678');
$encrypted = mcrypt_generic($cipher,$text);
mcrypt_generic_deinit($cipher);
$encrypted = bin2hex($encrypted);
return $encrypted;
}
function decrypt($key, $encrypted) {
$encrypted = hex2bin($encrypted);
$cipher = mcrypt_module_open(MCRYPT_BLOWFISH,'','cbc','');
mcrypt_generic_init($cipher, $key, '12345678');
$decrypted = mdecrypt_generic($cipher,$encrypted);
mcrypt_generic_deinit($cipher);
return $decrypted;
}
cd /usr/ports/databases/phpmyadmin make install clean
location /pma {
alias /usr/local/www/phpMyAdmin;
}
location ~ ^/pma/(.+\.php)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/local/www/phpMyAdmin/$1;
fastcgi_param DOCUMENT_ROOT /usr/local/www/phpMyAdmin;
}
cd /usr/ports/graphics/ImageMagick make install clean
SELECT * FROM tbl ORDER BY LENGTH(name), name; ----------------------------------------- | id | name | ----------------------------------------- | 2 | Episode 1 | | 1 | Episode 2 | | 4 | Episode 11 | | 3 | Episode 112 | -----------------------------------------