本文整理汇总了PHP中cot_error函数的典型用法代码示例。如果您正苦于以下问题:PHP cot_error函数的具体用法?PHP cot_error怎么用?PHP cot_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cot_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cot_check_requirements
/**
* Checks all requirements defined for some Extension
*
* @param array $info Extension info array, from setup file header
* @param bool $mute_err_msg (optional) Disable error messages firing
* @param bool $mute_info_msg (optional) Disable success messages. Disabled by default.
* @return boolean Result of check
*
* @see cot_infoget() from `API - Extensions` package
* @uses cot_requirements_satisfied()
*/
function cot_check_requirements($info, $mute_err_msg = false, $mute_info_msg = false)
{
foreach ($info as $key => $constraint) {
if (strpos(trim($key), 'Requires') === 0) {
list(, $package) = explode('_', $key, 2);
$package = $package ?: 'Core';
$package = strtolower($package);
if (in_array($package, array('plugins', 'modules'))) {
// old style requirements check
$list = explode(',', $constraint);
foreach ($list as $extname) {
$extname = trim($extname);
$satisfied = cot_requirements_satisfied(substr($package, 0, -1), '*', $extname);
if (!$satisfied) {
break;
}
}
} else {
// new style constraints
$check_installed = strpos($constraint, '?') === false;
if (!$check_installed) {
$constraint = str_replace('?', '', $constraint);
}
$satisfied = cot_requirements_satisfied($package, $constraint, null, $check_installed);
}
$requirement_str = " {$package}: {$info[$key]}";
if ($satisfied === false) {
$mute_err_msg || cot_error(cot_rc('req_not_satisfied', array('req' => $requirement_str)));
} elseif ($satisfied !== true) {
// get error with constraint
$mute_err_msg || cot_message(cot_rc('req_not_valid', array('req' => $requirement_str, 'error_msg' => $satisfied)), 'warning');
} else {
$mute_info_msg || cot_message(cot_rc('req_satisfied', array('req' => $requirement_str)), 'ok');
}
if ($satisfied !== true) {
return false;
}
// #FIXME comment for test
}
}
//return false; // #FIXME uncomment for test
return true;
}
示例2: cfg_password_filter
function cfg_password_filter(&$input_value, $cfg_var, $minlength = 4)
{
if (!is_array($input_value)) {
return NULL;
}
if ($input_value[0] == $input_value[1]) {
if ($input_value[0] && mb_strlen($input_value[1]) < $minlength) {
cot_error('min length: ' . $minlength, $cfg_var['config_name']);
} else {
return $input_value[1];
}
} else {
if ($input_value[1]) {
cot_error('Password must match', $cfg_var['config_name']);
}
}
$input_value = $cfg_var['config_value'];
return NULL;
}
示例3: brs_importFile
/**
* Импортировать файл
*/
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: defined
<?php
/* ====================
[BEGIN_COT_EXT]
Hooks=comments.send.first
[END_COT_EXT]
==================== */
/**
* mCAPTCHA validation
*
* @package MathCaptcha
* @copyright (c) Cotonti Team
* @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
*/
defined('COT_CODE') or die("Wrong URL.");
if ($cfg['captchamain'] == 'mcaptcha' && $usr['id'] == '0') {
$rverify = cot_import('rverify', 'P', 'TXT');
if (!cot_captcha_validate($rverify)) {
cot_error('captcha_verification_failed', 'rverify');
}
}
示例5: array
$adminpath[] = array(cot_url('admin', array('m' => 'other', 'p' => 'configeditor', 'n' => 'set', 'c' => $c)), $info['configcat_title']);
$adminpath[] = $L['edit_cat'];
$types_array = array(COT_CONFIG_TYPE_TEXT => $L['ccfg_type_text'], COT_CONFIG_TYPE_STRING => $L['ccfg_type_string'], COT_CONFIG_TYPE_SELECT => $L['ccfg_type_select'], COT_CONFIG_TYPE_RADIO => $L['ccfg_type_radio'], COT_CONFIG_TYPE_CALLBACK => $L['ccfg_type_callback'], COT_CONFIG_TYPE_HIDDEN => $L['ccfg_type_hidden'], COT_CONFIG_TYPE_SEPARATOR => $L['ccfg_type_separator'], COT_CONFIG_TYPE_RANGE => $L['ccfg_type_range'], COT_CONFIG_TYPE_CUSTOM => $L['ccfg_type_custom']);
if ($a == 'add') {
$name = cot_import('rname', 'P', "ALP");
$title = cot_import('rtitle', 'P', "TXT");
$desc = cot_import('rdesc', 'P', "HTM");
$order = cot_import('rorder', 'P', "INT");
$variants = cot_import('rvariants', 'P', "HTM");
$default = cot_import('rdefault', 'P', "HTM");
$type = cot_import('rtype', 'P', "INT");
if (empty($name)) {
cot_error($L['err_no_name']);
}
if (cfg_editor::config_exists($name)) {
cot_error($L['err_exists_name']);
}
if (!cot_error_found()) {
cfg_editor::config_add($c, $name, $order, $title, $desc, $type, $default, $variants);
cot_message('added_success');
}
$cache && $cache->clear();
cot_redirect(cot_url('admin', array('m' => 'other', 'p' => 'configeditor', 'n' => 'edit', 'c' => $c), '', true));
}
if ($a == 'update') {
$titles = cot_import('rtitle', 'P', "ARR");
$descs = cot_import('rdesc', 'P', "ARR");
$orders = cot_import('rorder', 'P', "ARR");
$variantss = cot_import('rvariants', 'P', "ARR");
$defaults = cot_import('rdefault', 'P', "ARR");
$types = cot_import('rtype', 'P', "ARR");
示例6: cot_structure_add
}
/* ===== */
if (!cot_error_found()) {
$res = cot_structure_add($n, $rstructure, $is_module);
if ($res === true) {
cot_extrafield_movefiles();
/* === Hook === */
foreach (cot_getextplugins('admin.structure.add.done') as $pl) {
include $pl;
}
/* ===== */
cot_message('Added');
} elseif (is_array($res)) {
cot_error($res[0], $res[1]);
} else {
cot_error('Error');
}
}
cot_redirect(cot_url('admin', 'm=structure&n=' . $n . '&mode=' . $mode . '&d=' . $durl, '', true));
} elseif ($a == 'delete') {
cot_check_xg();
if (cot_structure_delete($n, $c, $is_module)) {
/* === Hook === */
foreach (cot_getextplugins('admin.structure.delete.done') as $pl) {
include $pl;
}
/* ===== */
cot_message('Deleted');
}
cot_redirect(cot_url('admin', 'm=structure&n=' . $n . '&mode=' . $mode . '&d=' . $durl, '', true));
} elseif ($a == 'resyncall') {
示例7: deleteAction
public function deleteAction()
{
$id = cot_import('id', 'G', 'INT');
$d = cot_import('d', 'G', 'INT');
$backUrlParams = array('m' => 'subscribe');
if (!empty($d)) {
$backUrlParams['d'] = $d;
}
// Фильтры из списка
$f = cot_import('f', 'G', 'ARR');
if (!empty($f)) {
foreach ($f as $key => $val) {
if ($key == 'id') {
continue;
}
$backUrlParams["f[{$key}]"] = $val;
}
}
$sort = cot_import('s', 'G', 'ALP');
// order field name
$way = cot_import('w', 'G', 'ALP', 4);
// order way (asc, desc)
if ($sort != 'title') {
$backUrlParams['s'] = $sort;
}
if ($way != 'asc') {
$backUrlParams['w'] = $way;
}
if (!$id) {
cot_error(cot::$L['subscribe_err_not_found']);
cot_redirect(cot_url('admin', $backUrlParams));
}
$item = subscribe_model_Subscribe::getById($id);
if (!$item) {
cot_error(cot::$L['subscribe_err_not_found']);
cot_redirect(cot_url('admin', $backUrlParams));
}
$title = $item->title;
$item->delete();
cot_message(sprintf(cot::$L['subscribe_deleted'], $title));
cot_redirect(cot_url('admin', $backUrlParams, '', true));
}
示例8: foreach
/* === Hook === */
foreach (cot_getextplugins('forums.editpost.update.first') as $pl) {
include $pl;
}
/* ===== */
$rtopic['ft_title'] = cot_import('rtopictitle', 'P', 'TXT', 255);
$rtopic['ft_desc'] = cot_import('rtopicdesc', 'P', 'TXT', 255);
$rmsg = array();
$rmsg['fp_text'] = cot_import('rmsgtext', 'P', 'HTM');
$rmsg['fp_updater'] = $rowpost['fp_posterid'] == $usr['id'] && $sys['now'] < $rowpost['fp_updated'] + 300 && empty($rowpost['fp_updater']) ? '' : $usr['name'];
$rmsg['fp_updated'] = $sys['now'];
if (isset($_POST['rtopictitle']) && 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');
}
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()) {
$db->update($db_forum_posts, $rmsg, "fp_id={$p}");
if (!empty($rtopic['ft_title']) && $db->query("SELECT fp_id FROM {$db_forum_posts} WHERE fp_topicid = {$q} ORDER BY fp_id ASC LIMIT 1")->fetchColumn() == $p) {
if (mb_substr($rtopic['ft_title'], 0, 1) == "#") {
$rtopic['ft_title'] = str_replace('#', '', $rtopic['ft_title']);
}
$rtopic['ft_preview'] = mb_substr(htmlspecialchars($rmsg['fp_text']), 0, 128);
$db->update($db_forum_topics, $rtopic, "ft_id = {$q}");
示例9: cot_error
cot_error(sprintf($L['adm_extrafield_not_updated'], $k));
}
}
}
}
//cot_redirect(cot_url('admin', "m=extrafields&n=$n&d=$durl", '', true));
} elseif ($a == 'del' && isset($name)) {
/* === Hook === */
foreach (cot_getextplugins('admin.extrafields.delete') as $pl) {
include $pl;
}
/* ===== */
if (cot_extrafield_remove($n, $name)) {
cot_message('adm_extrafield_removed');
} else {
cot_error('adm_extrafield_not_removed');
}
//cot_redirect(cot_url('admin', "m=extrafields&n=$n&d=$durl", '', true));
}
$cache && $cache->db->remove('cot_extrafields', 'system');
cot_load_extrafields(true);
$totalitems = $db->query("SELECT COUNT(*) FROM {$db_extra_fields} WHERE field_location = '{$n}'")->fetchColumn();
$res = $db->query("SELECT * FROM {$db_extra_fields} WHERE field_location = '{$n}' ORDER BY field_name ASC LIMIT {$d}, " . $maxperpage);
$pagenav = cot_pagenav('admin', 'm=extrafields&n=' . $n, $d, $totalitems, $maxperpage, 'd', '', $cfg['jquery'] && $cfg['turnajax']);
$field_types = array('input', 'inputint', 'currency', 'double', 'textarea', 'select', 'checkbox', 'radio', 'datetime', 'country', 'range', 'checklistbox', 'file');
$ii = 0;
/* === Hook - Part1 : Set === */
$extp = cot_getextplugins('admin.extrafields.loop');
/* ===== */
foreach ($res->fetchAll() as $row) {
$ii++;
示例10: Cache
// Enforce cache loading
require_once $cfg['system_dir'] . '/cache.php';
$cache = new Cache();
$cache->init();
}
if ($a == 'purge' && $cache) {
if (cot_check_xg() && $cache->clear()) {
$db->update($db_users, array('user_auth' => ''), "user_auth != ''");
cot_message('adm_purgeall_done');
} else {
cot_error('Error');
}
} elseif ($a == 'delete') {
cot_check_xg();
$name = $db->prep(cot_import('name', 'G', 'TXT'));
$db->delete($db_cache, "c_name = '{$name}'") ? cot_message('adm_delcacheitem') : cot_error('Error');
}
if ($cache && $cache->mem) {
$info = $cache->get_info();
if ($info['available'] < 0) {
$info['available'] = '?';
}
$t->assign(array('ADMIN_CACHE_MEMORY_DRIVER' => str_replace('_driver', '', $cache->mem_driver), 'ADMIN_CACHE_MEMORY_PERCENTBAR' => ceil($info['occupied'] / $info['max'] * 100), 'ADMIN_CACHE_MEMORY_AVAILABLE' => $info['available'], 'ADMIN_CACHE_MEMORY_MAX' => $info['max']));
$t->parse('MAIN.ADMIN_CACHE_MEMORY');
}
$sql = $db->query("SELECT * FROM {$db_cache} WHERE 1 ORDER by c_name ASC");
$cachesize = 0;
$ii = 0;
/* === Hook - Part1 : Set === */
$extp = cot_getextplugins('admin.cache.loop');
/* ===== */
示例11: foreach
$t->parse('MAIN.RESULTS.FORUMS.ITEM');
}
$jj++;
}
$sql->closeCursor();
if ($jj > 0) {
$t->parse('MAIN.RESULTS.FORUMS');
}
}
/* === Hook === */
foreach (cot_getextplugins('search.list') as $pl) {
include $pl;
}
/* ===== */
if (array_sum($totalitems) < 1) {
cot_error($L['plu_noneresult'] . $R['code_error_separator']);
}
if (!cot_error_found()) {
$t->parse('MAIN.RESULTS');
}
$rs_url_path = array();
foreach ($rs as $k => $v) {
if (is_array($v)) {
foreach ($v as $sk => $sv) {
$rs_url_path['rs[' . $k . '][' . $sk . ']'] = $sv;
}
} else {
$rs_url_path['rs[' . $k . ']'] = $v;
}
}
$pagenav = cot_pagenav('plug', array('e' => 'search', 'sq' => $sq, 'tab' => $tab) + $rs_url_path, $d, array_sum($totalitems), $cfg_maxitems);
示例12: defined
<?php
/**
* Administration panel - Home page for administrators
*
* @package Cotonti
* @copyright (c) Cotonti Team
* @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
*/
defined('COT_CODE') && defined('COT_ADMIN') or die('Wrong URL.');
$t = new XTemplate(cot_tplfile('admin.home', 'core'));
if (!$cfg['debug_mode'] && file_exists('install.php') && is_writable('datas/config.php')) {
cot_error('home_installable_error');
}
$adminsubtitle = '';
// Empty means just "Administration"
//Version Checking
if ($cfg['check_updates'] && $cache) {
$update_info = $cache->db->get('update_info');
if (!$update_info) {
if (ini_get('allow_url_fopen')) {
$update_info = @file_get_contents('http://www.cotonti.com/update-check');
if ($update_info) {
$update_info = json_decode($update_info, TRUE);
$cache->db->store('update_info', $update_info, COT_DEFAULT_REALM, 86400);
}
} elseif (function_exists('curl_init')) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://www.cotonti.com/update-check');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$update_info = curl_exec($curl);
示例13: foreach
foreach ($cot_extrafields[$db_com] as $exfld) {
$comarray['com_' . $exfld['field_name']] = cot_import_extrafields('rcomments' . $exfld['field_name'], $exfld);
}
/* == Hook == */
foreach (cot_getextplugins('comments.send.first') as $pl) {
include $pl;
}
/* ===== */
if (empty($rname) && $usr['id'] == 0) {
cot_error($L['com_authortooshort'], 'rname');
}
if (mb_strlen($rtext) < $cfg['plugin']['comments']['minsize']) {
cot_error($L['com_commenttooshort'], 'rtext');
}
if ($cfg['plugin']['comments']['commentsize'] && mb_strlen($rtext) > $cfg['plugin']['comments']['commentsize']) {
cot_error($L['com_commenttoolong'], 'rtext');
}
if (!cot_error_found()) {
$comarray['com_area'] = $area;
$comarray['com_code'] = $item;
$comarray['com_author'] = $usr['id'] == 0 ? $rname : $usr['name'];
$comarray['com_authorid'] = (int) $usr['id'];
$comarray['com_authorip'] = $usr['ip'];
$comarray['com_text'] = $rtext;
$comarray['com_date'] = (int) $sys['now'];
$sql = $db->insert($db_com, $comarray);
$id = $db->lastInsertId();
if ($cache && $area == 'page') {
if ($cfg['cache_page']) {
$cache->page->clear('page/' . str_replace('.', '/', $structure['page'][$url_params['c']]['path']));
}
示例14: cot_import
}
$rusergroupsms = cot_import('rusergroupsms', 'P', 'ARR');
if (mb_strlen($ruser['user_name']) < 2 || mb_strpos($ruser['user_name'], ',') !== false || mb_strpos($ruser['user_name'], "'") !== false) {
cot_error('aut_usernametooshort', 'rusername');
}
if ($ruser['user_name'] != $urr['user_name'] && $db->query("SELECT COUNT(*) FROM {$db_users} WHERE user_name = ?", array($ruser['user_name']))->fetchColumn() > 0) {
cot_error('aut_usernamealreadyindb', 'rusername');
}
if (!cot_check_email($ruser['user_email'])) {
cot_error('aut_emailtooshort', 'ruseremail');
}
if ($ruser['user_email'] != $urr['user_email'] && $db->query("SELECT COUNT(*) FROM {$db_users} WHERE user_email = ?", array($ruser['user_email']))->fetchColumn() > 0) {
cot_error('aut_emailalreadyindb', 'ruseremail');
}
if (!empty($rusernewpass) && mb_strlen($rusernewpass) < 4) {
cot_error('aut_passwordtooshort', 'rusernewpass');
}
if (!cot_error_found()) {
if (!empty($rusernewpass)) {
$ruser['user_passsalt'] = cot_unique(16);
$ruser['user_passfunc'] = empty($cfg['hashfunc']) ? 'sha256' : $cfg['hashfunc'];
$ruser['user_password'] = cot_hash($rusernewpass, $ruser['user_passsalt'], $ruser['user_passfunc']);
}
$ruser['user_name'] = $ruser['user_name'] == '' ? $urr['user_name'] : $ruser['user_name'];
$ruser['user_birthdate'] = is_null($ruser['user_birthdate']) ? '0000-00-00' : cot_stamp2date($ruser['user_birthdate']);
if (!$ruserbanned) {
$ruser['user_banexpire'] = 0;
}
if ($ruserbanned && $ruser['user_banexpire'] > 0) {
$ruser['user_banexpire'] += $sys['now'];
}
示例15: cot_import
}
}
if (cot::$usr['id'] == 0 && !empty($cot_captcha)) {
$rverify = cot_import('rverify', 'P', 'TXT');
if (!cot_captcha_validate($rverify)) {
cot_error('captcha_verification_failed', 'rverify');
}
}
if ($rcontact['contact_author'] == '') {
cot_error('contact_noname', 'ruser');
}
if (!cot_check_email($rcontact['contact_email'])) {
cot_error('contact_emailnotvalid', 'remail');
}
if (mb_strlen($rcontact['contact_text']) < cot::$cfg['plugin']['contact']['minchars']) {
cot_error('contact_entrytooshort', 'rtext');
}
if (!cot_error_found()) {
$rcontact['contact_authorid'] = (int) $usr['id'];
$rcontact['contact_date'] = (int) $sys['now'];
$rcontact['contact_val'] = 0;
if (in_array($cfg['plugin']['contact']['save'], array('db', 'both'))) {
$db->insert($db_contact, $rcontact);
}
$semail = !empty($cfg['plugin']['contact']['email']) ? $cfg['plugin']['contact']['email'] : $cfg['adminemail'];
if (cot_check_email($semail) && in_array($cfg['plugin']['contact']['save'], array('email', 'both'))) {
$headers = "From: \"" . $rcontact['contact_author'] . "\" <" . $rcontact['contact_email'] . ">\n";
$context = array('sitetitle' => $cfg["maintitle"], 'siteurl' => $cfg['mainurl'], 'author' => $rcontact['contact_author'], 'email' => $rcontact['contact_email'], 'subject' => $rcontact['contact_subject'], 'text' => $rcontact['contact_text']);
$rextras = '';
if (!empty(cot::$extrafields[cot::$db->contact])) {
foreach (cot::$extrafields[cot::$db->contact] as $exfld) {