Skip to content

Instantly share code, notes, and snippets.

View softsolution's full-sized avatar
💭
Рассматриваю предложения

soft-solution softsolution

💭
Рассматриваю предложения
  • Александр Гаврилюк
  • Russia, Irkutsk
View GitHub Profile
@softsolution
softsolution / gist:d65974d22a1daaacc117
Created January 25, 2016 12:03
places extended file
$model = cmsCore::getModel('places');
$model_ext_file = 'system/controllers/places/model_ext.php';
cmsCore::includeFile($model_ext_file);
$model_ext = new modelPlacesExt();
//model_ext.php
class modelPlacesExt extends modelPlaces {
/* ============================================================== */
@softsolution
softsolution / patch.php
Created January 23, 2016 04:27
добавление вкладки объектов в InstantMaps 2
1. manifest.php:
'user_tab_info',
'user_tab_show'
2. sql query
INSERT INTO `cms_users_tabs` (`title`, `controller`, `name`, `is_active`, `ordering`) VALUES
('Объекты', 'places', 'objects', 1, 8);
@softsolution
softsolution / html
Created December 11, 2015 16:55
Генерация пароля или кода на js
<form id="addform" name="addform">
<input name="code" type="text" id="code" style="width:200px" value="" />
<a href="javascript:" onclick="generateCode()">Сгенерировать</a>
</form>
<script type="text/javascript">
function generateCode(){
//config
var upper = 1;//Заглавные буквы
var lower = 1;//Маленькие буквы
var digit = 1;//Цифры
@softsolution
softsolution / user.class.php
Last active October 9, 2015 05:28
Проверка возможности для пользователя правила - дополнительный метод в user.class.php InstantCMS
<?php
// ============================================================================ //
// ============================================================================ //
/**
* Проверяет досуп пользователь с USER_ID к правилу $access_type
* $access_type like "comments/delete" or "photo/edit"
* @param string $access_type
* @return bool
@softsolution
softsolution / cron.php
Last active October 7, 2015 11:31
cron
php -f C:/Cloudmailru/OpenServer/domains/instantshop.loc/cron.php > /dev/null
php -f /var/www/aworlds/data/www/aworlds.com/cron.php >/dev/null 2>&1
<?php
mail("joecool@example.com", "My Subject", "Line 1\nLine 2\nLine 3");
?>
@softsolution
softsolution / get_status.php
Last active September 12, 2015 15:26
get status object
<?php
//определяем статус для нового объекта при редактировании модератором (админ может задать это поле вручную)
if($is_manager && $old['status'] == 0){
//получаем обновленную запись
$item = $model->getItem($id);
//определяем в какой статус можно перевести объект
$sql = "SELECT c.id, c.title, c.seolink,
IFNULL(cc.climit, 0) as climit
@softsolution
softsolution / php_str_replace cena
Created July 30, 2015 16:07
выделение цены при парсинге html
$cena=str_replace(",",'.',$cena);
$cena=preg_replace("/[^x\d|*\.]/","",$cena);
<?php
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=file.csv");
header("Pragma: no-cache");
header("Expires: 0");
$array = array( // данные которые мы будем выводить в csv файл
0 => array('Nikolay','nikolay@email.ru'),
1 => array('Maria', 'maria@email.ru')
);
@softsolution
softsolution / Перегруппировка многомерного массива
Last active August 29, 2015 14:23
Перегруппировка многомерного массива
<?php
$cats_full = $model->getCategories();
if(!$cats_full) { return false; }
foreach ($cats_full as $cat) {
$cats[] = $cat;
$nsl[] = $cat['NSLeft'];
$ord[] = $cat['ordering'];
}
@softsolution
softsolution / MySQL запросы
Last active August 29, 2015 14:23
MySQL запросы
--копирование значений из одной таблицы в другую - связывание таблиц
UPDATE cms_blog_posts p, cms_hits h
SET h.owner_id = p.blog_id
WHERE h.target_id = p.id AND h.target = 'blogpost'
--расстояние до геоточек
--еще нужна функция MYSQL - позже добавлю
SET @src := Point('56.85479147340446','60.59969435180665');
SELECT i.*, DATE_FORMAT(i.pubdate, '%H:%i') as ftime, c.title as category, c.marker as marker, c.zoom as zoom , geodist(X(@src), Y(@src), i.lat, i.lng) AS distantion FROM cms_map_cats c, cms_map_items i WHERE i.published = 1 AND ((i.category_id = c.id) AND (c.NSLeft>=3 AND c.NSRight<=4)) AND (i.city_id = '5106')
GROUP BY i.id