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 | |
/** | |
* PHP: Detect location by IP | |
* http://www.catswhocode.com/blog/10-super-useful-php-snippets-you-probably-havent-seen | |
*/ | |
function detect_city($ip) { | |
$default = 'UNKNOWN'; | |
if (!is_string($ip) || strlen($ip) < 1 || $ip == '127.0.0.1' || $ip == 'localhost') |
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 | |
/** | |
* TagPopular | |
* | |
* [[TagPopular? &tpl=`TagCloudItem` &tv=`7` &count=`15`]] | |
* | |
* TagCloudItem: | |
* <a href="/[~11~]?tag=[[urlencode? &input=`[+name+]`]]" title="Статьи с тегом [+name+]" class="label">[+name+] ([+count+])</a> | |
* | |
* @category snippet |
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 | |
/** | |
* TagList | |
* | |
* [[TagList? &data=`[*tag*]` &sep=`,` &tpl=`PostTagList` &outSep=`, `]] | |
* | |
* PostTagList: | |
* <a href="/[~11~]?tag=[+encode+]" title="Все статьи с тегом [+tag+]">[+tag+]</a> | |
* | |
* @category snippet |
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 close_tag_html($text) { | |
preg_match_all("/<[^>]*>/", $text, $bal); | |
$liste = array(); | |
foreach($bal[0] as $balise) { | |
if ($balise{1} != "/") { // opening tag | |
preg_match("/<([a-z]+)/i", $balise, $type); | |
// add the tag | |
$liste[] = $type[1]; | |
} else { // closing tag |
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 | |
$DOC = 270400; | |
switch($modx->event->name){ | |
case 'OnPageNotFound':{ | |
$brand = ''; | |
$q = explode('/', ltrim($_SERVER['REQUEST_URI'], '/')); | |
if(!isset($modx->motoDocID) && count($q)==2 && isset($q[0],$q[1])){ | |
$motoID = (int)rtrim($q[1],$modx->config['friendly_url_suffix']); | |
if($motoID.$modx->config['friendly_url_suffix'] == $q[1]){ | |
include_once(MODX_BASE_PATH.'assets/lib/modResource.php'); |
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 | |
/** | |
* MailNotify | |
* | |
* Отправка уведомлений на почту пользователю при публикации документа | |
* | |
* @license GNU General Public License (GPL), http://www.gnu.org/copyleft/gpl.html | |
* @author Agel_Nash <Agel_Nash@xaker.ru> | |
* @version 0.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 | |
$data = array( | |
array( | |
'id' => '8', //ID TV параметра с числом просмотров | |
'name' => 'hitts', | |
'key' => 'hitspage', | |
'int' => true | |
), | |
array( | |
'id' => '15', //ID TV параметра с числом комментариев |
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 | |
/** | |
* Onetable Route | |
* | |
* Плагин для кастомной маршрутизации | |
* | |
* @license GNU General Public License (GPL), http://www.gnu.org/copyleft/gpl.html | |
* @author Agel_Nash <Agel_Nash@xaker.ru> | |
* @version 0.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 | |
/** | |
* Вырезание текста между HTML тэгов | |
* | |
* @author Agel_Nash <Agel_Nash@xaker.ru> | |
* @version 0.1 | |
* | |
* @param string $html HTML текст | |
* @param string $tag HTML тэг в котором производить поиск | |
* @return array |