This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ($modx->Event->name == 'OnPageNotFound') { | |
$uri = $_SERVER['REQUEST_URI']; | |
// Обычный ресурс | |
if (preg_match("#(\.*?[a-z0-9_\-]+)_p(\d+)\.html#si", $uri, $m)) { | |
$alias = preg_replace("#(\.*?[a-z0-9_\-]+)_p(\d+)(\.html)#si", "$1$3", $uri); | |
$alias = substr($alias, 1, strlen($alias)); | |
} | |
// Контейнер |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dir=/var/www/site | |
user=userofsite | |
echo "Set permissions for $dir..."; | |
echo "CHOWN files..."; | |
chown -R $user:$user "$dir"; | |
echo "CHMOD directories..."; | |
find "$dir" -type d -exec chmod 0755 '{}' \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function validEmail($email) { | |
$isValid = true; | |
$atIndex = strrpos($email, "@"); | |
if (is_bool($atIndex) && !$atIndex) { | |
$isValid = false; | |
} else { | |
$domain = substr($email, $atIndex+1); | |
$local = substr($email, 0, $atIndex); | |
$localLen = strlen($local); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$range=20; //Размер массива | |
$arrInt = range(0, $range); //Создаем массив array(0=>1, 1=>2 , 2=>3, ... (n-1)=>n); где n = $range | |
$arrNull=array_fill(0,$range,null); //Создаем массив с $range элементами значение которых null | |
$arr = array_merge($arrInt,$_SERVER,$arrNull); //Смешиваем все массивы | |
$find = (rand(0,1) ? 'несуществующий индекс' : array_rand($arr,1)); //Определяем какой индекс будем искать | |
echo "<h3>Поиск элемента с индексом <u>{$find}</u> в массиве \$arr</h3>"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$range = 200; //Размер массива | |
$run = 100; //Колличество поисков | |
$mode = isset($_GET['mode']) ? $_GET['mode'] : ''; | |
$time = 0; | |
$arr = getArr($range); //Создаем массив | |
for($i=$run; $i>0; $i--){ | |
$find = (mt_rand(0,1) ? 'несуществующий индекс' : array_rand($arr,1)); //Определяем какой индекс будем искать |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* parseChunk | |
* | |
* @category parser | |
* @version 0.1 | |
* @license GNU General Public License (GPL), http://www.gnu.org/copyleft/gpl.html | |
* @param string $ChunkName Имя чанка | |
* @return string распарсеный чанк | |
* @author Agel_Nash <Agel_Nash@xaker.ru> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* modProcessor | |
* | |
* @package modx | |
*/ | |
/** | |
* Abstracts a MODX processor, handling its response and error formatting. | |
* | |
* {@inheritdoc} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class keks { | |
private $keks; | |
public function getKeks() { | |
return $this->keks; | |
} | |
public function setKeks($keks) { | |
$this->keks = $keks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*DISPLAY HINTS FOR INPUTS*/ | |
$('input').on('focus', function() { | |
var hint = $(this).attr('hint'); | |
if(hint !== undefined){ | |
$(this).after('<div class="hint">'+hint+'</div>'); | |
$('.hint').fadeIn('fast'); | |
$(this).closest('.row').find('label.error').hide(); | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Получаем пользователя по его ID | |
$user = Sentry::findUserById(1); | |
# Получаем пользователя по его Email или логину | |
# $user = Sentry::findUserByLogin('email@email.com'); | |
# Добавляем пользователя в группу | |
$user->addGroup(Sentry::findGroupByName('Admins')); | |
# Удаляем пользователя из группы | |
$user->removeGroup(Sentry::findGroupByName('Users')); |
OlderNewer