Пример #1
0
/**
 * Converts a title into an alias
 *
 * @param string $title Title
 * @param int $id Page ID
 * @param bool $duplicate TRUE if duplicate alias was previously detected
 * @return string
 */
function autoalias2_convert($title, $id = 0, $duplicate = false)
{
    global $cfg, $cot_translit, $cot_translit_custom;
    if ($cfg['plugin']['autoalias2']['translit'] && file_exists(cot_langfile('translit', 'core'))) {
        include cot_langfile('translit', 'core');
        if (is_array($cot_translit_custom)) {
            $title = strtr($title, $cot_translit_custom);
        } elseif (is_array($cot_translit)) {
            $title = strtr($title, $cot_translit);
        }
    }
    $title = preg_replace('#[^\\p{L}0-9\\-_ ]#u', '', $title);
    $title = str_replace(' ', $cfg['plugin']['autoalias2']['sep'], $title);
    if ($cfg['plugin']['autoalias2']['lowercase']) {
        $title = mb_strtolower($title);
    }
    if ($cfg['plugin']['autoalias2']['prepend_id'] && !empty($id)) {
        $title = $id . $cfg['plugin']['autoalias2']['sep'] . $title;
    } elseif ($duplicate) {
        switch ($cfg['plugin']['autoalias2']['on_duplicate']) {
            case 'ID':
                if (!empty($id)) {
                    $title .= $cfg['plugin']['autoalias2']['sep'] . $id;
                    break;
                }
            default:
                $title .= $cfg['plugin']['autoalias2']['sep'] . rand(2, 99);
                break;
        }
    }
    return $title;
}
Пример #2
0
/**
 * Send an email in the recipient's language
 *
 * @param string $rlang Recipient language
 * @param string $remail Recipient email
 * @param string $rusername Recipient name
 */
function cot_send_translated_mail($rlang, $remail, $rusername)
{
    global $cfg, $usr;
    require_once cot_langfile('pm', 'module', $cfg['defaultlang'], $rlang);
    if (!$L || !isset($L['pm_notify'])) {
        global $L;
    }
    $rsubject = $L['pm_notifytitle'];
    $rbody = sprintf($L['pm_notify'], $rusername, htmlspecialchars($usr['name']), $cfg['mainurl'] . '/' . cot_url('pm', '', '', true));
    cot_mail($remail, $rsubject, $rbody);
}
Пример #3
0
/**
 * Импортировать файл
 */
function brs_importFile($inputname, $oldvalue = '')
{
    global $lang, $cot_translit, $brs_allowed_ext, $brs_files_dir, $cfg;
    $import = !empty($_FILES[$inputname]) ? $_FILES[$inputname] : array();
    $import['delete'] = cot_import('del_' . $inputname, 'P', 'BOL') ? 1 : 0;
    // Если пришел файл или надо удалить существующий
    if (is_array($import) && !$import['error'] && !empty($import['name'])) {
        $fname = mb_substr($import['name'], 0, mb_strrpos($import['name'], '.'));
        $ext = mb_strtolower(mb_substr($import['name'], mb_strrpos($import['name'], '.') + 1));
        if (!file_exists($brs_files_dir)) {
            mkdir($brs_files_dir);
        }
        //check extension
        if (empty($brs_allowed_ext) || in_array($ext, $brs_allowed_ext)) {
            if ($lang != 'en') {
                require_once cot_langfile('translit', 'core');
                $fname = is_array($cot_translit) ? strtr($fname, $cot_translit) : '';
            }
            $fname = str_replace(' ', '_', $fname);
            $fname = preg_replace('#[^a-zA-Z0-9\\-_\\.\\ \\+]#', '', $fname);
            $fname = str_replace('..', '.', $fname);
            $fname = empty($fname) ? cot_unique() : $fname;
            $fname .= file_exists("{$brs_files_dir}/{$fname}.{$ext}") && $oldvalue != $fname . '.' . $ext ? date("YmjGis") : '';
            $fname .= '.' . $ext;
            $file['old'] = !empty($oldvalue) && ($import['delete'] || $import['tmp_name']) ? $oldvalue : '';
            $file['tmp'] = !$import['delete'] ? $import['tmp_name'] : '';
            $file['new'] = !$import['delete'] ? $brs_files_dir . $fname : '';
            if (!empty($file['old']) && file_exists($file['old'])) {
                unlink($file['old']);
            }
            if (!empty($file['tmp']) && !empty($file['tmp'])) {
                move_uploaded_file($file['tmp'], $file['new']);
            }
            return $file['new'];
        } else {
            cot_error(cot::$L['brs_err_inv_file_type'], $inputname);
            return '';
        }
    }
}
Пример #4
0
/**
 * Trashcan interface
 *
 * @package TrashCan
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') && defined('COT_ADMIN') or die('Wrong URL.');
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('plug', 'trashcan');
cot_block($usr['isadmin']);
require_once cot_incfile('users', 'module');
cot_module_active('page') && (require_once cot_incfile('page', 'module'));
cot_module_active('forums') && (require_once cot_incfile('forums', 'module'));
$cfg['comments'] && (require_once cot_incfile('comments', 'plug'));
require_once cot_incfile('trashcan', 'plug');
require_once cot_langfile('trashcan', 'plug');
$adminhelp = $L['adm_help_trashcan'];
$adminsubtitle = $L['Trashcan'];
$id = cot_import('id', 'G', 'INT');
$maxperpage = $cfg['maxrowsperpage'] && is_numeric($cfg['maxrowsperpage']) && $cfg['maxrowsperpage'] > 0 ? $cfg['maxrowsperpage'] : 15;
list($pg, $d, $durl) = cot_import_pagenav('d', $maxperpage);
$info = $a == 'info' ? 1 : 0;
/* === Hook === */
foreach (cot_getextplugins('trashcan.admin.first') as $pl) {
    include $pl;
}
/* ===== */
if ($a == 'wipe') {
    cot_check_xg();
    /* === Hook === */
    foreach (cot_getextplugins('trashcan.admin.wipe') as $pl) {
<?php

/**
 * [BEGIN_COT_EXT]
 * Hooks=users.register.add.validate
 * [END_COT_EXT]
 */
/**
 * plugin User Group Selector for Cotonti Siena
 * 
 * @package usergroupselector
 * @version 1.0.0
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 *  */
defined('COT_CODE') or die('Wrong URL.');
require_once cot_langfile('usergroupselector', 'plug');
$usergroup = cot_import('usergroup', 'G', 'ALP');
if (cot_error_found() && !empty($usergroup)) {
    cot_redirect(cot_url('users', 'm=register&usergroup=' . $usergroup, '', true));
}
Пример #6
0
<?php

/**
 * Content Internationalization API
 *
 * @package I18n
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') or die('Wrong URL');
require_once cot_langfile('i18n', 'plug');
require_once cot_incfile('i18n', 'plug', 'resources');
cot::$db->registerTable('i18n_locales');
cot::$db->registerTable('i18n_pages');
cot::$db->registerTable('i18n_structure');
/**
 * Builds internationalized category path
 *
 * @param string $area Area code
 * @param string $cat Category code
 * @param string $locale Locale code
 * @return string
 */
function cot_i18n_build_catpath($area, $cat, $locale)
{
    global $structure, $cfg, $i18n_structure;
    $tmp = array();
    $pathcodes = explode('.', $structure[$area][$cat]['path']);
    foreach ($pathcodes as $k => $x) {
        if ($x != 'system') {
            if (empty($i18n_structure[$x][$locale]['title'])) {
Пример #7
0
 *
 * @package Tags
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') && defined('COT_PLUG') or die('Wrong URL');
$a = cot_import('a', 'G', 'ALP');
$a = empty($a) ? 'all' : $a;
$qs = cot_import('t', 'G', 'TXT');
if (empty($qs)) {
    $qs = cot_import('t', 'P', 'TXT');
}
$qs = str_replace('-', ' ', $qs);
$tl = cot_import('tl', 'G', 'BOL');
if ($tl && file_exists(cot_langfile('translit', 'core'))) {
    include_once cot_langfile('translit', 'core');
    $qs = strtr($qs, $cot_translitb);
}
// Results per page
$maxperpage = $cfg['maxrowsperpage'] && is_numeric($cfg['maxrowsperpage']) && $cfg['maxrowsperpage'] > 0 ? $cfg['maxrowsperpage'] : 15;
list($pg, $d, $durl) = cot_import_pagenav('d', $maxperpage);
$dt = (int) cot_import('dt', 'G', 'INT');
// Tags displayed per page in standalone cloud
$perpage = $cfg['plugin']['tags']['perpage'];
// Array to register areas with tag functions provided
$tag_areas = array();
if (cot_module_active('page')) {
    require_once cot_incfile('page', 'module');
    $tag_areas[] = 'pages';
}
if (cot_module_active('forums')) {
<?php

/**
 * Payments module
 *
 * @package payments
 * @version 1.1.2
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru
 * @license BSD
 */
defined('COT_CODE') or die('Wrong URL');
// Requirements
require_once cot_langfile('payments', 'module');
// Global variables
global $db_payments, $db_payments_services, $db_x;
$db_payments = isset($db_payments) ? $db_payments : $db_x . 'payments';
$db_payments_outs = isset($db_payments_outs) ? $db_payments_outs : $db_x . 'payments_outs';
$db_payments_services = isset($db_payments_services) ? $db_payments_services : $db_x . 'payments_services';
/**
 * Удаление услуг с истекщим сроком действия (если установлен параметр service_expire)
 * 
 * @param string $area идентификатор услуги
 * @param int $userid id пользователя
 * @return bool
 */
function cot_payments_delete_expired_services($area, $userid = null)
{
    global $db_payments_services, $db, $sys;
    if ($userid > 0) {
        $query_string = "AND service_userid=" . $userid;
Пример #9
0
/**
 * Validates page data.
 * @param  array   $rpage Imported page data
 * @return boolean        TRUE if validation is passed or FALSE if errors were found
 */
function cot_page_validate($rpage)
{
    global $cfg, $structure;
    cot_check(empty($rpage['page_cat']), 'page_catmissing', 'rpagecat');
    if ($structure['page'][$rpage['page_cat']]['locked']) {
        global $L;
        require_once cot_langfile('message', 'core');
        cot_error('msg602_body', 'rpagecat');
    }
    cot_check(mb_strlen($rpage['page_title']) < 2, 'page_titletooshort', 'rpagetitle');
    cot_check(!empty($rpage['page_alias']) && preg_match('`[+/?%#&]`', $rpage['page_alias']), 'page_aliascharacters', 'rpagealias');
    $allowemptytext = isset($cfg['page']['cat_' . $rpage['page_cat']]['allowemptytext']) ? $cfg['page']['cat_' . $rpage['page_cat']]['allowemptytext'] : $cfg['page']['cat___default']['allowemptytext'];
    cot_check(!$allowemptytext && empty($rpage['page_text']), 'page_textmissing', 'rpagetext');
    return !cot_error_found();
}
<?php

/**
 * User Categories plugin
 *
 * @package usercategories
 * @version 2.5.6
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 */
defined('COT_CODE') or die('Wrong URL');
require_once cot_langfile('usercategories', 'plug');
// Global variables
function cot_cfg_usercategories()
{
    global $cfg;
    $tpaset = str_replace("\r\n", "\n", $cfg['plugin']['usercategories']['catslimit']);
    $tpaset = explode("\n", $tpaset);
    $paytopset = array();
    foreach ($tpaset as $lineset) {
        $lines = explode("|", $lineset);
        $lines[0] = trim($lines[0]);
        $lines[1] = trim($lines[1]);
        if ($lines[0] > 0 && $lines[1] > 0) {
            $catslimit[$lines[0]] = $lines[1];
        }
    }
    return $catslimit;
}
/**
Пример #11
0
 /**
  * Strips all unsafe characters from file base name and converts it to latin
  *
  * @param string $name File base name
  * @param string $ext File extension
  * @param string $savedirectory File path
  * @param string $unique_name File path 
  * @return string
  */
 function safename($name, $ext, $savedirectory = '', $unique_name = true)
 {
     global $lang, $cot_translit, $sys;
     if (!$cot_translit && $lang != 'en' && file_exists(cot_langfile('translit', 'core'))) {
         require_once cot_langfile('translit', 'core');
     }
     if ($lang != 'en' && is_array($cot_translit)) {
         $name = strtr($name, $cot_translit);
     }
     $name = str_replace(' ', '_', $name);
     $name = preg_replace('#[^a-zA-Z0-9\\-_\\.\\ \\+]#', '', $name);
     $name = str_replace('..', '.', $name);
     $name = mb_substr($name, 0, 200);
     if (empty($name)) {
         $name = cot_unique();
     }
     if ($unique_name && file_exists($this->file_path($savedirectory, $name, $ext))) {
         $name .= "_" . cot_date('dmY_His', $sys['now']);
     }
     if ($unique_name && file_exists($this->file_path($savedirectory, $name, $ext))) {
         $name .= "_" . rand(1, 999);
     }
     return $name;
 }
Пример #12
0
<?php

/**
 * PayPro plugin
 *
 * @package paypro
 * @version 1.0
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 */
defined('COT_CODE') or die('Wrong URL');
// Requirements
require_once cot_langfile('paypro', 'plug');
require_once cot_incfile('payments', 'module');
// Global variables
global $db_users_pro, $db_x;
$db_users_pro = isset($db_users_pro) ? $db_users_pro : $db_x . 'users_pro';
function cot_getuserpro($user = '')
{
    global $db, $db_users, $sys, $usr;
    if (empty($user) && $usr['profile']['user_pro'] > 0) {
        $upro = $usr['profile']['user_pro'];
        $userid = $usr['id'];
    } elseif (!empty($user) && !is_array($user)) {
        $upro = $db->query("SELECT user_pro FROM {$db_users} WHERE user_id=" . $user)->fetchColumn();
        $userid = $user;
    } elseif (is_array($user)) {
        $upro = $user['user_pro'];
        $userid = $user['user_id'];
    }
Пример #13
0
 }
 /* ===== */
 $rmsg['fp_text'] = cot_import('rmsgtext', 'P', 'HTM');
 $rtopic['ft_title'] = cot_import('rtopictitle', 'P', 'TXT', 255);
 $rtopic['ft_desc'] = cot_import('rtopicdesc', 'P', 'TXT', 255);
 $rtopic['ft_mode'] = (int) (cot_import('rtopicmode', 'P', 'BOL') && $cfg['forums']['cat_' . $s]['allowprvtopics']) ? 1 : 0;
 $rtopic['ft_preview'] = cot_string_truncate($rmsg['fp_text'], 120);
 if (mb_strlen($rtopic['ft_title']) < $cfg['forums']['mintitlelength']) {
     cot_error('forums_titletooshort', 'rtopictitle');
 }
 if (mb_strlen($rmsg['fp_text']) < $cfg['forums']['minpostlength']) {
     cot_error('forums_messagetooshort', 'rmsgtext');
 }
 if (!strpos($structure['forums'][$s]['path'], '.')) {
     // Attempting to create a topic in a root category
     include cot_langfile('message', 'core');
     cot_error($L['msg602_body']);
 }
 foreach ($cot_extrafields[$db_forum_topics] as $exfld) {
     $rtopic['ft_' . $exfld['field_name']] = cot_import_extrafields('rtopic' . $exfld['field_name'], $exfld);
 }
 foreach ($cot_extrafields[$db_forum_posts] as $exfld) {
     $rmsg['fp_' . $exfld['field_name']] = cot_import_extrafields('rmsg' . $exfld['field_name'], $exfld);
 }
 if (!cot_error_found()) {
     if (mb_substr($rtopic['ft_title'], 0, 1) == "#") {
         $rtopic['ft_title'] = str_replace('#', '', $rtopic['ft_title']);
     }
     $rtopic['ft_state'] = 0;
     $rtopic['ft_sticky'] = 0;
     $rtopic['ft_cat'] = $s;
Пример #14
0
<?php

/**
 * Ratings API
 *
 * @package Ratings
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') or die('Wrong URL');
// Requirements
require_once cot_incfile('users', 'module');
require_once cot_langfile('ratings', 'plug');
require_once cot_incfile('ratings', 'plug', 'resources');
// Table name globals
cot::$db->registerTable('ratings');
cot::$db->registerTable('rated');
/**
 * Generates ratings display for a given item
 *
 * @param string $ext_name Module or plugin code
 * @param string $code Item identifier
 * @param string $cat Item category code (optional)
 * @param bool $readonly Display as read-only
 * @return array Rendered HTML output for ratings and average integer value as an array with 2 elements
 * @global CotDB $db
 */
function cot_ratings_display($ext_name, $code, $cat = '', $readonly = false)
{
    global $db, $db_ratings, $db_rated, $db_users, $cfg, $usr, $sys, $L, $R;
    // Check permissions
Пример #15
0
<?php

defined('COT_CODE') or die('Wrong URL');
global $db_users;
require_once cot_langfile('karma', 'plug');
cot_extrafield_add($db_users, 'karma', 'input', $R['input_text'], '', '0', 0, 'HTML', $L['f_karma'], '', '1', false, 'float NOT NULL');
cot_extrafield_add($db_users, 'karma_auth', 'input', $R['input_text'], '', 'NULL', 0, 'HTML', 'karma auth', '', '1', false, 'varchar(255)  NULL');
Пример #16
0
/* ====================
[BEGIN_COT_EXT]
Hooks=tools
[END_COT_EXT]
==================== */
/**
 * Creates aliases in existing pages with empty alias
 *
 * @package AutoAlias
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') or die('Wrong URL');
require_once cot_incfile('autoalias2', 'plug');
require_once cot_langfile('autoalias2', 'plug');
$t = new XTemplate(cot_tplfile('autoalias2.admin', 'plug', true));
$adminsubtitle = $L['AutoAlias'];
if ($a == 'create') {
    $count = 0;
    $res = $db->query("SELECT page_id, page_title FROM {$db_pages} WHERE page_alias = ''");
    foreach ($res->fetchAll() as $row) {
        autoalias2_update($row['page_title'], $row['page_id']);
        $count++;
    }
    $res->closeCursor();
    cot_message(cot_rc('aliases_written', $count));
    cot_redirect(cot_url('admin', 'm=other&p=autoalias2', '', true));
}
$t->assign('AUTOALIAS_CREATE', cot_url('admin', 'm=other&p=autoalias2&a=create'));
cot_display_messages($t);
Пример #17
0
 if (!cot_url_check($myAdvsUrl)) {
     $myAdvsUrl = COT_ABSOLUTE_URL . $myAdvsUrl;
 }
 $tmpL = cot::$L;
 $text = $advert->description;
 if (empty($text)) {
     $text = $advert->text;
 }
 $user = null;
 $userLang = cot::$cfg['defaultlang'];
 $owner = $advert->getOwner();
 if ($owner['user_id'] > 0) {
     if (cot::$cfg['defaultlang'] != $owner['user_lang']) {
         $userLang = $owner['user_lang'];
         include cot_langfile('main', 'core', cot::$cfg['defaultlang'], $owner['user_lang']);
         include cot_langfile('advboard', 'module', cot::$cfg['defaultlang'], $owner['user_lang']);
     }
 }
 // Выдержка с поста
 //        $len_cut = 500;  // Длина выдержки с поста (символов)
 $advComText = cot_parse($comarray['com_text'], cot::$cfg['plugin']['comments']['markup']);
 //        $advComText = cot_string_truncate($advComText, $len_cut, true, false, '...');
 // /Выдержка с поста
 // Автор комментария
 $advCommenterName = cot::$L['Anonymous'];
 $advCommenterUrl = '';
 if (cot::$usr['id'] > 0) {
     $advCommenterName = cot_user_full_name(cot::$usr['profile']);
     $advCommenterUrl = cot_url('users', array('m' => 'details', 'id' => cot::$usr['id'], 'u' => htmlspecialchars(cot::$usr['name'])));
     if (!cot_url_check($advCommenterUrl)) {
         $advCommenterUrl = COT_ABSOLUTE_URL . $advCommenterUrl;
Пример #18
0
Hooks=tools
[END_COT_EXT]
==================== */
/**
 * Administration panel - Referers manager
 *
 * @package Referers
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') && defined('COT_ADMIN') or die('Wrong URL.');
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('plug', 'referers');
cot_block($usr['auth_read']);
$tt = new XTemplate(cot_tplfile('referers.admin', 'plug', true));
cot::$db->registerTable('referers');
require_once cot_langfile('referers', 'plug');
$adminhelp = $L['adm_help_referers'];
$adminsubtitle = $L['Referers'];
$maxperpage = $cfg['maxrowsperpage'] && is_numeric($cfg['maxrowsperpage']) && $cfg['maxrowsperpage'] > 0 ? $cfg['maxrowsperpage'] : 15;
list($pg, $d, $durl) = cot_import_pagenav('d', $maxperpage);
/* === Hook  === */
foreach (cot_getextplugins('referers.admin.first') as $pl) {
    include $pl;
}
/* ===== */
if ($a == 'prune' && $usr['isadmin']) {
    $db->query("TRUNCATE {$db_referers}") ? cot_message('adm_ref_prune') : cot_message('Error');
} elseif ($a == 'prunelowhits' && $usr['isadmin']) {
    $db->delete($db_referers, 'ref_count < 6') ? cot_message('adm_ref_prunelowhits') : cot_message('Error');
}
$totalitems = $db->countRows($db_referers);
Пример #19
0
<?php

defined('COT_CODE') or die('Wrong URL');
/* ====================
[BEGIN_COT_EXT]
Hooks=global
[END_COT_EXT]
==================== */
require_once cot_langfile('genderavatar', 'plug');
require_once cot_incfile('genderavatar', 'plug', 'resources');
Пример #20
0
<?php

/**
 * URL rewriting functions
 *
 * @package URLEditor
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') or die('Wrong URL');
require_once cot_langfile('urleditor', 'plug');
/**
 * Contains the list of URLeditor presets currently available.
 * Append items to it to add other presets
 * @var array
 */
$cot_urleditor_presets = array('handy', 'compat', 'custom', 'none');
/**
 * Applies Handly URLs rewrite to current script parameters
 * @global array $cfg
 */
function cot_apply_rwr()
{
    global $cfg, $structure;
    if (function_exists('cot_apply_rwr_custom')) {
        return cot_apply_rwr_custom();
    }
    $rwr = cot_import('rwr', 'G', 'TXT');
    if (isset($rwr) && !empty($rwr)) {
        // Ignore ending slash and split the path into parts
        $path = explode('/', mb_strrpos($rwr, '/') === mb_strlen($rwr) - 1 ? mb_substr($rwr, 0, -1) : $rwr);
Пример #21
0
<?php

/**
 * Polls functions
 *
 * @package Polls
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') or die('Wrong URL');
// Requirements
require_once cot_incfile('forms');
require_once cot_langfile('polls', 'module');
cot::$db->registerTable('polls');
cot::$db->registerTable('polls_options');
cot::$db->registerTable('polls_voters');
/**
 * Adds form for create/edit Poll
 *
 * @param int $id Poll ID or Poll Code if $type is not epmty or new for new Poll
 * @param XTemplate $t Template
 * @param string $block Poll block in Template
 * @param string $type Poll type
 * @return bool
 * @global CotDB $db
 */
function cot_poll_edit_form($id, $t = '', $block = 'MAIN', $type = '')
{
    $id = (int) $id;
    global $db, $cfg, $db_polls, $db_polls_options, $poll_id, $R, $L, $poll_options, $poll_multiple, $poll_state, $poll_text;
    if (gettype($t) != 'object') {
Пример #22
0
/**
 * Validates product data.
 * @param  array   $ritem Imported product data
 * @return boolean        TRUE if validation is passed or FALSE if errors were found
 */
function cot_folio_validate($ritem)
{
    global $cfg, $structure;
    cot_check(empty($ritem['item_cat']), 'folio_select_cat', 'rcat');
    if ($structure['folio'][$ritem['item_cat']]['locked']) {
        global $L;
        require_once cot_langfile('message', 'core');
        cot_error('msg602_body', 'rcat');
    }
    cot_check(mb_strlen($ritem['item_title']) < 2, 'folio_empty_title', 'rtitle');
    cot_check(!empty($ritem['item_alias']) && preg_match('`[+/?%#&]`', $ritem['item_alias']), 'folio_aliascharacters', 'ralias');
    $allowemptytext = isset($cfg['folio']['cat_' . $ritem['item_cat']]['allowemptytext']) ? $cfg['folio']['cat_' . $ritem['item_cat']]['allowemptytext'] : $cfg['folio']['cat___default']['allowemptytext'];
    cot_check(!$allowemptytext && empty($ritem['item_text']), 'folio_empty_text', 'rtext');
    return !cot_error_found();
}
Пример #23
0
<?php

/**
 * [BEGIN_COT_EXT]
 * Hooks=tools
 * [END_COT_EXT]
 */
defined('COT_CODE') or die('Wrong URL.');
require_once cot_langfile('paytop', 'plug');
$pt_cfg = cot_cfg_paytop();
$t = new XTemplate(cot_tplfile('paytop.admin', 'plug', true));
$id = cot_import('id', 'G', 'INT');
if ($a == 'add') {
    $username = cot_import('username', 'P', 'TXT', 100, TRUE);
    $area = cot_import('area', 'P', 'ALP');
    $times = cot_import('times', 'P', 'INT');
    $urr_id = $db->query("SELECT user_id FROM {$db_users} WHERE user_name='" . $username . "'")->fetchColumn();
    cot_check(empty($username), 'paytop_error_username');
    cot_check(empty($urr_id), 'paytop_error_userempty');
    cot_check(empty($times), 'paytop_error_timesempty');
    cot_check(empty($area), 'paytop_error_areaempty');
    if (!cot_error_found()) {
        cot_payments_userservice('paytop.' . $area, $urr_id, $times * $pt_cfg[$area]['period']);
        /* === Hook === */
        foreach (cot_getextplugins('paytop.done') as $pl) {
            include $pl;
        }
        /* ===== */
        /* === Hook === */
        foreach (cot_getextplugins('paytop.' . $area . '.done') as $pl) {
            include $pl;
Пример #24
0
/**
 * Parses extensions selection section
 *
 * @param string $ext_type Extension type: 'Module' or 'Plugin'
 * @param array $default_list A list of recommended extensions (checked by default)
 * @param array $selected_list A list of previously selected extensions
 */
function cot_install_parse_extensions($ext_type, $default_list = array(), $selected_list = array())
{
    global $t, $cfg, $L;
    $ext_type_lc = strtolower($ext_type);
    $ext_type_uc = strtoupper($ext_type);
    $ext_list = cot_extension_list_info($cfg["{$ext_type_lc}s_dir"]);
    $ext_type_lc == 'plugin' ? uasort($ext_list, 'cot_extension_catcmp') : ksort($ext_list);
    $prev_cat = '';
    $block_name = $ext_type_lc == 'plugin' ? "{$ext_type_uc}_CAT.{$ext_type_uc}_ROW" : "{$ext_type_uc}_ROW";
    foreach ($ext_list as $f => $info) {
        if (is_array($info)) {
            $code = $f;
            if ($ext_type_lc == 'plugin' && $prev_cat != $info['Category']) {
                if ($prev_cat != '') {
                    // Render previous category
                    $t->parse("MAIN.STEP_4.{$ext_type_uc}_CAT");
                }
                // Assign a new one
                $prev_cat = $info['Category'];
                $t->assign('PLUGIN_CAT_TITLE', $L['ext_cat_' . $info['Category']]);
            }
            if (!empty($info['Requires_modules']) || !empty($info['Requires_plugins'])) {
                $modules_list = empty($info['Requires_modules']) ? $L['None'] : implode(', ', explode(',', $info['Requires_modules']));
                $plugins_list = empty($info['Requires_plugins']) ? $L['None'] : implode(', ', explode(',', $info['Requires_plugins']));
                $requires = cot_rc('install_code_requires', array('modules_list' => $modules_list, 'plugins_list' => $plugins_list));
            } else {
                $requires = '';
            }
            if (!empty($info['Recommends_modules']) || !empty($info['Recommends_plugins'])) {
                $modules_list = empty($info['Recommends_modules']) ? $L['None'] : implode(', ', explode(',', $info['Recommends_modules']));
                $plugins_list = empty($info['Recommends_plugins']) ? $L['None'] : implode(', ', explode(',', $info['Recommends_plugins']));
                $recommends = cot_rc('install_code_recommends', array('modules_list' => $modules_list, 'plugins_list' => $plugins_list));
            } else {
                $recommends = '';
            }
            if (count($selected_list) > 0) {
                $checked = in_array($code, $selected_list);
            } else {
                $checked = in_array($code, $default_list);
            }
            $type = $ext_type == 'Module' ? 'module' : 'plug';
            $L['info_name'] = '';
            $L['info_desc'] = '';
            if (file_exists(cot_langfile($code, $type))) {
                include cot_langfile($code, $type);
            }
            $t->assign(array("{$ext_type_uc}_ROW_CHECKBOX" => cot_checkbox($checked, "install_{$ext_type_lc}s[{$code}]"), "{$ext_type_uc}_ROW_TITLE" => empty($L['info_name']) ? $info['Name'] : $L['info_name'], "{$ext_type_uc}_ROW_DESCRIPTION" => empty($L['info_desc']) ? $info['Description'] : $L['info_desc'], "{$ext_type_uc}_ROW_REQUIRES" => $requires, "{$ext_type_uc}_ROW_RECOMMENDS" => $recommends));
            $t->parse("MAIN.STEP_4.{$block_name}");
        }
    }
    if ($ext_type_lc == 'plugin' && $prev_cat != '') {
        // Render last category
        $t->parse("MAIN.STEP_4.{$ext_type_uc}_CAT");
    }
}
Пример #25
0
<?php

/**
 * Sbr plugin
 *
 * @package sbr
 * @version 1.0.0
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru
 * @license BSD
 */
defined('COT_CODE') or die('Wrong URL');
require_once cot_langfile('sbr', 'plug');
require_once cot_incfile('sbr', 'plug', 'resources');
// Global variables
global $db_sbr, $db_sbr_stages, $db_sbr_claims, $db_x;
$db_sbr = isset($db_sbr) ? $db_sbr : $db_x . 'sbr';
$db_sbr_stages = isset($db_sbr_stages) ? $db_sbr_stages : $db_x . 'sbr_stages';
$db_sbr_posts = isset($db_sbr_posts) ? $db_sbr_posts : $db_x . 'sbr_posts';
$db_sbr_claims = isset($db_sbr_claims) ? $db_sbr_claims : $db_x . 'sbr_claims';
$db_sbr_files = isset($db_sbr_files) ? $db_sbr_files : $db_x . 'sbr_files';
$cot_extrafields[$db_sbr] = !empty($cot_extrafields[$db_sbr]) ? $cot_extrafields[$db_sbr] : array();
function cot_generate_sbrtags($item_data, $tag_prefix = '', $admin_rights = null, $pagepath_home = false)
{
    global $db, $cot_extrafields, $cfg, $L, $Ls, $R, $db_sbr, $db_sbr_stages, $sys;
    static $extp_first = null, $extp_main = null;
    if (is_null($extp_first)) {
        $extp_first = cot_getextplugins('sbrtags.first');
        $extp_main = cot_getextplugins('sbrtags.main');
    }
    /* === Hook === */
Пример #26
0
/* === Hook === */
foreach (cot_getextplugins('admin.config.first') as $pl) {
    include $pl;
}
/* ===== */
switch ($n) {
    case 'edit':
        $o = cot_import('o', 'G', 'ALP');
        $p = cot_import('p', 'G', 'ALP');
        $v = cot_import('v', 'G', 'ALP');
        $o = empty($o) ? 'core' : $o;
        $p = empty($p) ? 'global' : $p;
        $optionslist = cot_config_list($o, $p, '');
        cot_die(!sizeof($optionslist), true);
        if ($o != 'core' && file_exists(cot_langfile($p, $o))) {
            require cot_langfile($p, $o);
        }
        if ($o != 'core' && file_exists(cot_incfile($p, $o))) {
            require_once cot_incfile($p, $o);
        }
        /* === Hook  === */
        foreach (cot_getextplugins('admin.config.edit.first') as $pl) {
            include $pl;
        }
        /* ===== */
        if ($a == 'update' && !empty($_POST)) {
            $updated = cot_config_update_options($p, $optionslist, $o);
            $errors = cot_get_messages('', 'error');
            if ($o == 'module' || $o == 'plug') {
                $dir = $o == 'module' ? $cfg['modules_dir'] : $cfg['plugins_dir'];
                // Run configure extension part if present
Пример #27
0
     $rd = 5;
     $ru = empty($redirect) ? '' : str_replace('&', '&amp;', base64_decode($redirect));
     break;
     /* ======== System messages ======== */
 /* ======== System messages ======== */
 case '916':
     $rd = 2;
     $ru = cot_url('admin');
     break;
 case '920':
     if (!empty($m)) {
         // Load module or plugin langfile
         if (file_exists(cot_langfile($m, 'module'))) {
             include cot_langfile($m, 'module');
         } elseif (file_exists(cot_langfile($m, 'plug'))) {
             include cot_langfile($m, 'plug');
         }
     }
     $lng = cot_import('lng', 'G', 'ALP');
     if (!empty($lng)) {
         // Assign custom message
         if (isset($L[$lng])) {
             $body = $L[$lng];
         }
     }
     $rc = '920';
     break;
 case '930':
     if ($usr['id'] > 0) {
         break;
     }
Пример #28
0
<?php

/**
 * market module
 *
 * @package market
 * @version 2.5.7
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 */
defined('COT_CODE') or die('Wrong URL');
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('market', 'any', 'RWA');
// Requirements
require_once cot_langfile('market', 'module');
require_once cot_incfile('forms');
require_once cot_incfile('extrafields');
// Tables and extras
cot::$db->registerTable('market');
cot_extrafields_register_table('market');
$structure['market'] = is_array($structure['market']) ? $structure['market'] : array();
/**
 * Update market categories counters
 *
 * @param string $cat Cat code
 * @return int
 * @global CotDB $db
 */
function cot_market_sync($cat)
{
    global $db, $db_structure, $db_market, $cache;
<?php

/**
 * [BEGIN_COT_EXT]
 * Hooks=users.auth.check.done
 * [END_COT_EXT]
 */
defined('COT_CODE') or die('Wrong URL.');
if ($cfg['plugin']['regpay']['summ'] > 0) {
    require_once cot_langfile('regpay', 'plug');
    $urr = $db->query("SELECT * FROM {$db_users} WHERE user_id=" . $ruserid)->fetch();
    if ($urr['user_logcount'] == 1) {
        $payinfo['pay_userid'] = $urr['user_id'];
        $payinfo['pay_area'] = 'balance';
        $payinfo['pay_code'] = 'register';
        $payinfo['pay_summ'] = $cfg['plugin']['regpay']['summ'];
        $payinfo['pay_cdate'] = $sys['now'];
        $payinfo['pay_pdate'] = $sys['now'];
        $payinfo['pay_adate'] = $sys['now'];
        $payinfo['pay_status'] = 'done';
        $payinfo['pay_desc'] = $L['regpay_payments_desc'];
        if ($db->insert($db_payments, $payinfo)) {
            cot_mail($urr['user_email'], $L['regpay_mail_subject'], sprintf($L['regpay_mail_body'], $urr['user_name']));
            cot_log("Payment for register");
        }
    }
}
Пример #30
0
    $prev_branch = 'genoa';
    require_once $cfg['system_dir'] . '/database.php';
    $dbc_port = empty($cfg['mysqlport']) ? '' : ';port=' . $cfg['mysqlport'];
    $db = new CotDB('mysql:host=' . $cfg['mysqlhost'] . $dbc_port . ';dbname=' . $cfg['mysqldb'], $cfg['mysqluser'], $cfg['mysqlpassword']);
    cot::init();
    $sql_install = @$db->query("SHOW TABLES LIKE '{$db_updates}'");
    if ($sql_install->rowCount() != 1) {
        define('COT_UPGRADE', true);
        $cfg['defaulttheme'] = 'nemesis';
        $cfg['defaultscheme'] = 'default';
    }
    require_once $cfg['system_dir'] . '/common.php';
}
require_once cot_incfile('forms');
require_once cot_incfile('extensions');
require_once cot_langfile('install', 'module');
require_once cot_langfile('users', 'core');
require_once cot_langfile('admin', 'core');
require_once cot_incfile('install', 'module', 'resources');
// Various Generic Vars needed to operate as Normal
$theme = $cfg['defaulttheme'];
$scheme = $cfg['defaultscheme'];
$out['meta_lastmod'] = gmdate('D, d M Y H:i:s');
$file['config'] = './datas/config.php';
$file['config_sample'] = './datas/config-sample.php';
$file['sql'] = './setup/install.sql';
if (!$cfg['new_install']) {
    include cot_incfile('install', 'module', 'update');
} else {
    include cot_incfile('install', 'module', 'install');
}