/** * 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; }
mkdir($cfg['cache_dir'] . '/' . $sub, $cfg['dir_perms']); } } // Run SQL patches for core $script = file_get_contents("./setup/{$branch}/patch-{$prev_branch}.sql"); $error = $db->runScript($script); if (empty($error)) { cot_message(cot_rc('install_update_patch_applied', array('f' => "setup/{$branch}/patch-{$prev_branch}.sql", 'msg' => 'OK'))); } else { cot_error(cot_rc('install_update_patch_error', array('f' => "setup/{$branch}/patch-{$prev_branch}.sql", 'msg' => $error))); } // Run PHP patches $ret = (include "./setup/{$branch}/patch-{$prev_branch}.inc"); if ($ret !== false) { $msg = $ret == 1 ? 'OK' : $ret; cot_message('install_update_patch_applied', array('f' => "setup/{$branch}/patch-{$prev_branch}.inc", 'msg' => $ret)); } else { cot_error('install_update_patch_error', array('f' => "setup/{$branch}/patch-{$prev_branch}.inc", 'msg' => $L['Error'])); } // Unregister modules which have no registration anymore $db->delete($db_core, "ct_code IN ('comments', 'ratings', 'trash')"); // Set Module versions to Genoa version before upgrade $db->update($db_core, array('ct_version' => '0.8.99'), '1'); // Update modules foreach (array('forums', 'index', 'page', 'pfs', 'pm', 'polls', 'users') as $code) { $ret = cot_extension_install($code, true, true); if ($ret === false) { cot_error(cot_rc('ext_update_error', array('type' => $L['Module'], 'name' => $code))); } } // Update installed Siena plugins and uninstall Genoa plugins
foreach (cot_getextplugins('trashcan.admin.wipeall') as $pl) { include $pl; } /* ===== */ $sql = $db->query("TRUNCATE {$db_trash}"); cot_message('adm_trashcan_prune'); cot_redirect(cot_url('admin', 'm=other&p=trashcan', '', true)); } elseif ($a == 'restore') { cot_check_xg(); /* === Hook === */ foreach (cot_getextplugins('trashcan.admin.restore') as $pl) { include $pl; } /* ===== */ cot_trash_restore($id); cot_message('adm_trashcan_restored'); cot_redirect(cot_url('admin', 'm=other&p=trashcan', '', true)); } $tr_t = new XTemplate(cot_tplfile($info ? 'trashcan.info.admin' : 'trashcan.admin', 'plug', true)); $totalitems = (int) $db->query("SELECT COUNT(*) FROM {$db_trash} WHERE tr_parentid=0")->fetchColumn(); $pagenav = cot_pagenav('admin', 'm=other&p=trashcan', $d, $totalitems, $maxperpage, 'd', '', $cfg['jquery'] && $cfg['turnajax']); $sql_query = $info ? "AND tr_id={$id} LIMIT 1" : "ORDER by tr_id DESC LIMIT {$d}, " . $maxperpage; $sql = $db->query("SELECT t.*, u.user_name FROM {$db_trash} AS t\n\tLEFT JOIN {$db_users} AS u ON t.tr_trashedby=u.user_id\n\tWHERE tr_parentid=0 {$sql_query}"); $ii = 0; /* === Hook - Part1 : Set === */ $extp = cot_getextplugins('trashcan.admin.loop'); /* ===== */ foreach ($sql->fetchAll() as $row) { $ii++; switch ($row['tr_type']) { case 'comment':
foreach ($cot_extrafields[$db_contact] as $exfld) { cot_extrafield_unlinkfiles($row_contact_delete['contact_' . $exfld['field_name']], $exfld); } cot_message('Deleted'); } } elseif ($a == 'val') { $db->update($db_contact, array('contact_val' => 1), "contact_id = {$id}"); cot_message('Updated'); } elseif ($a == 'unval') { $db->update($db_contact, array('contact_val' => 0), "contact_id = {$id}"); cot_message('Updated'); } elseif ($a == 'send' && $rtext != '') { $row = $db->query("SELECT contact_email FROM {$db_contact} WHERE contact_id = {$id}")->fetch(); cot_mail($row['contact_email'], $cfg['mainurl'], $rtext); $db->update($db_contact, array('contact_reply' => $rtext), "contact_id = {$id}"); cot_message('Done'); } $adminsubtitle = $L['contact_title']; $tuman = new XTemplate(cot_tplfile('contact.tools', 'plug', true)); $totallines = $db->query("SELECT COUNT(*) FROM {$db_contact}")->fetchColumn(); $sql = $db->query("SELECT * FROM {$db_contact} ORDER BY contact_val ASC, contact_id DESC LIMIT {$d}, " . $cfg['maxrowsperpage']); $pagnav = cot_pagenav('admin', 'm=other&p=contact', $d, $totallines, $cfg['maxrowsperpage'], 'd', '', $cfg['jquery'] && $cfg['turnajax']); $i = 0; foreach ($sql->fetchAll() as $row) { $i++; $shorttext = $row['contact_text']; $shorttext = cot_string_truncate($shorttext, 150); $shorttext .= '...'; $val = $row['contact_val'] == 1 ? 'unval' : 'val'; $urlParams = array('m' => 'other', 'p' => 'contact'); $tmp = $urlParams;
} /* ===== */ if (!empty($offer_post['post_text']) && (in_array($usr['id'], array($offer['offer_userid'], $item['item_userid'])) || $usr['isadmin']) && !cot_error_found()) { $db->insert($db_projects_posts, $offer_post); if ($usr['id'] == $offer['offer_userid']) { $urlparams = empty($item['item_alias']) ? array('c' => $item['item_cat'], 'id' => $item['item_id']) : array('c' => $item['item_cat'], 'al' => $item['item_alias']); $rsubject = cot_rc($L['project_added_post_header'], array('prtitle' => $item['item_title'])); $rbody = cot_rc($L['project_added_post_body'], array('user_name' => $item['user_name'], 'postuser_name' => $usr['profile']['user_name'], 'prj_name' => $item['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . cot_url('projects', $urlparams, '', true))); cot_mail($item['user_email'], $rsubject, $rbody); } else { $urlparams = empty($item['item_alias']) ? array('c' => $item['item_cat'], 'id' => $item['item_id']) : array('c' => $item['item_cat'], 'al' => $item['item_alias']); $rsubject = cot_rc($L['project_added_post_header'], array('prtitle' => $item['item_title'])); $rbody = cot_rc($L['project_added_post_body'], array('user_name' => $offer['user_name'], 'postuser_name' => $usr['profile']['user_name'], 'prj_name' => $item['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . cot_url('projects', $urlparams, '', true))); cot_mail($offer['user_email'], $rsubject, $rbody); } cot_message($L['offers_add_post'], 'ok'); /* === Hook === */ foreach (cot_getextplugins('projects.offers.addpost.done') as $pl) { include $pl; } /* ===== */ } cot_redirect(cot_url('projects', 'id=' . $id, '', true)); exit; } $t_o = new XTemplate(cot_tplfile(array('projects', 'offers', $structure['projects'][$item['item_cat']]['tpl']))); // Вычисление выбранного исполнителя по проекту if ($item['item_performer']) { $t_o->assign(cot_generate_usertags($item['item_performer'], 'PRJ_PERFORMER_')); } $where = array();
// Run configure extension part if present if (file_exists($dir . "/" . $p . "/setup/" . $p . ".configure.php")) { include $dir . "/" . $p . "/setup/" . $p . ".configure.php"; } } /* === Hook === */ foreach (cot_getextplugins('admin.config.edit.update.done') as $pl) { include $pl; } /* ===== */ $cache && $cache->clear(); if ($updated) { $errors ? cot_message('adm_partially_updated', 'warning') : cot_message('Updated'); } else { if (!$errors) { cot_message('adm_already_updated'); } } } elseif ($a == 'reset' && !empty($v)) { cot_config_reset($p, $v, $o, ''); $optionslist = cot_config_list($o, $p, ''); /* === Hook === */ foreach (cot_getextplugins('admin.config.edit.reset.done') as $pl) { include $pl; } /* ===== */ $cache && $cache->clear(); cot_redirect(cot_url('admin', array('m' => 'config', 'n' => 'edit', 'o' => $o, 'p' => $p), '', true)); } if ($o == 'core') { $adminpath[] = array(cot_url('admin', 'm=config'), $L['Configuration']);
if ($a == 'update' && !empty($_POST)) { cot_config_update_options($p, $optionslist, $o); if ($o == 'module' || $o == 'plug') { $dir = $o == 'module' ? $cfg['modules_dir'] : $cfg['plugins_dir']; // Run configure extension part if present if (file_exists($dir . "/" . $p . "/setup/" . $p . ".configure.php")) { include $dir . "/" . $p . "/setup/" . $p . ".configure.php"; } } /* === Hook === */ foreach (cot_getextplugins('admin.config.edit.update.done') as $pl) { include $pl; } /* ===== */ $cache && $cache->clear(); cot_message('Updated'); } elseif ($a == 'reset' && !empty($v)) { cot_config_reset($p, $v, $o, ''); $optionslist = cot_config_list($o, $p, ''); $optionslist[$v]['config_name'] = $optionslist[$v]['config_defaul']; /* === Hook === */ foreach (cot_getextplugins('admin.config.edit.reset.done') as $pl) { include $pl; } /* ===== */ $cache && $cache->clear(); } if ($o == 'core') { $adminpath[] = array(cot_url('admin', 'm=config'), $L['Configuration']); $adminpath[] = array(cot_url('admin', 'm=config&n=edit&o=' . $o . '&p=' . $p), $L['core_' . $p]); } else {
/** * Records an error message to be displayed on results page * * @global int $cot_error Global error counter * @param string $message Message lang string code or full text * @param string $src Error source identifier, such as field name for invalid input * @see cot_message() */ function cot_error($message, $src = 'default') { global $cot_error; $cot_error ? $cot_error++ : ($cot_error = 1); cot_message($message, 'error', $src); }
} // Write the rule to urltrans.dat fputs($fp, $ut_area[$i] . "\t" . $ut_params[$i] . "\t" . $ut_format[$i] . "\n"); if ($ut_area[$i] == '*' && $ut_params[$i] == '*' && $ut_format[$i] == '{$_area}.php') { // Default rule doesn't need any rewrite rules continue; } $has_callbacks = false; if (preg_match('#\\{[\\w_]+\\(\\)\\}#', $ut_format[$i])) { // Rule with callback, requires custom rewrite cot_message($L['adm_urls_callbacks'] . ': ' . htmlspecialchars($ut_format[$i]), 'warning'); $has_callbacks = true; continue; } if ($has_callbacks) { cot_message('adm_urls_errors'); } // Remove unsets $ut_format[$i] = preg_replace('#\\{\\!\\$.+?\\}#', '', $ut_format[$i]); // Set some defaults $hta_line = $hta_rule . ' ' . $rb; $format = $ut_format[$i]; $area = $ut_area[$i] == '*' ? $var_pattern : $ut_area[$i]; mb_parse_str($ut_params[$i], $params); $j = 0; $k = 0; $m_count = 0; $qs = ''; $area_sub = ''; if (preg_match('#^https?\\://([^/]+)/(.*)$#', $format, $mt)) { // Subdomains support
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)); }
// Empty resource consolidation cache $db->delete($db_cache, "c_name = 'cot_rc_html'"); } else { cot_message('Error'); } } elseif ($a == 'delete') { $is_id = mb_strpos($id, '/') === false && mb_strpos($id, '\\') === false && $id != '.' && $id != '..'; $is_onlyf = $id == COT_DISKCACHE_ONLYFILES; if (cot_check_xg() && $is_id && cot_diskcache_clear($cfg['cache_dir'] . ($is_onlyf ? '' : "/{$id}"), !$is_onlyf)) { cot_message('adm_delcacheitem'); if ($id == 'static' || $is_onlyf) { // Empty resource consolidation cache $db->delete($db_cache, "c_name = 'cot_rc_html'"); } } else { cot_message('Error'); } } $row = cot_diskcache_list(); $cachefiles = $cachesize = 0; $ii = 0; /* === Hook - Part1 : Set === */ $extp = cot_getextplugins('admin.cache.disk.loop'); /* ===== */ foreach ($row as $i => $x) { $cachefiles += $x[0]; $cachesize += $x[1]; $t->assign(array('ADMIN_DISKCACHE_ITEM_DEL_URL' => cot_url('admin', 'm=cache&s=disk&a=delete&id=' . $i . '&' . cot_xg()), 'ADMIN_DISKCACHE_ITEM_NAME' => $i, 'ADMIN_DISKCACHE_FILES' => $x[0], 'ADMIN_DISKCACHE_SIZE' => $x[1], 'ADMIN_DISKCACHE_ROW_ODDEVEN' => cot_build_oddeven($ii))); /* === Hook - Part2 : Include === */ foreach ($extp as $pl) { include $pl;
$ruser['user_birthdate'] = 'NULL'; } else { unset($ruser['user_birthdate']); } } else { $ruser['user_birthdate'] = cot_stamp2date($ruser['user_birthdate']); } $ruser['user_auth'] = ''; $db->update($db_users, $ruser, "user_id='" . $usr['id'] . "'"); cot_extrafield_movefiles(); /* === Hook === */ foreach (cot_getextplugins('users.profile.update.done') as $pl) { include $pl; } /* ===== */ cot_message('Profile_updated'); cot_redirect(cot_url('users', 'm=profile', '', true)); } } $sql = $db->query("SELECT * FROM {$db_users} WHERE user_id='" . $usr['id'] . "' LIMIT 1"); $urr = $sql->fetch(); $out['subtitle'] = $L['Profile']; $out['head'] .= $R['code_noindex']; $mskin = cot_tplfile(array('users', 'profile'), 'module'); /* === Hook === */ foreach (cot_getextplugins('users.profile.main') as $pl) { include $pl; } /* ===== */ require_once $cfg['system_dir'] . '/header.php'; $t = new XTemplate($mskin);
public function deleteAction() { $id = cot_import('id', 'G', 'INT'); // id Объявления $b = cot_import('b', 'G', 'HTM'); // Куда вернуться /* === Hook === */ foreach (cot_getextplugins('advboard.delete.first') as $pl) { include $pl; } /* ===== */ // Права на любую категорию доски объявлений list(cot::$usr['auth_read'], cot::$usr['auth_write'], cot::$usr['isadmin']) = cot_auth('advboard', 'any'); cot_block(cot::$usr['auth_write']); $advert = advboard_model_Advert::getById($id); if (!$advert) { cot_die_message(404, TRUE); } if (!cot::$usr['isadmin']) { if ($advert->user != cot::$usr['id']) { cot_die_message(404, TRUE); } } $title = $advert->title; $userId = $advert->user; $advert->delete(); /* === Hook === */ foreach (cot_getextplugins('advboard.delete.done') as $pl) { include $pl; } /* ===== */ if (!empty($b)) { $b = unserialize(base64_decode($b)); } elseif (!empty($_SESSION['cot_com_back']) && !empty($_SESSION['cot_com_back']['advboard'])) { $b = $_SESSION['cot_com_back']['advboard']; unset($_SESSION['cot_com_back']['advboard']); } if (empty($b)) { $b = array('m' => 'user'); if ($userId != cot::$usr['id']) { $b['uid'] = $userId; } } cot_message(sprintf(cot::$L['advboard_deleted'], $title)); cot_redirect(cot_url('advboard', $b, '', true)); }
} } // Done /* === Hook === */ foreach (cot_getextplugins('i18n.structure.update.done') as $pl) { include $pl; } /* =============*/ if ($inserted_cnt > 0) { cot_message(cot_rc('i18n_items_added', array('cnt' => $inserted_cnt))); } if ($updated_cnt > 0) { cot_message(cot_rc('i18n_items_updated', array('cnt' => $updated_cnt))); } if ($removed_cnt > 0) { cot_message(cot_rc('i18n_items_removed', array('cnt' => $removed_cnt))); } cot_redirect(cot_url('plug', "e=i18n&m=structure&l={$i18n_locale}&d={$durl}", '', true)); } $t = new XTemplate(cot_tplfile('i18n.structure', 'plug')); // Render table $ii = 0; $k = -1; /* === Hook - Part1 : Set === */ $extp = cot_getextplugins('i18n.structure.loop'); /* ===== */ foreach ($structure['page'] as $code => $row) { if (cot_i18n_enabled($code)) { $k++; if ($k < $d || $ii == $maxperpage) { continue;
/** * Imports data for config values from outer world * * @param string|array $name Name of value or array of names for list of values * @param string $source Source type * @param string $filter Filter type * @param string $defvalue Default value for filtered data * @see cot_import() * @return mixed Filtered value of array of values */ function cot_config_import($name, $source = 'POST', $filter = 'NOC', $defvalue = null) { global $cot_import_filters; if (!$name) { return null; } if (!is_array($name)) { $name = array($name); $single_value = true; } $res = array(); foreach ($name as $idx => $value_name) { $filter_type = is_array($filter) ? $filter[$value_name] ? $filter[$value_name] : ($filter[$idx] ? $filter[$idx] : 'NOC') : $filter; $not_filtered = cot_import($value_name, $source, 'NOC'); $value = cot_import($value_name, $source, $filter_type); // addition filtering by varname if (sizeof($cot_import_filters[$value_name])) { $value = cot_import($value, 'DIRECT', $value_name); } // if invalid value is used if (is_null($value)) { $warning_msg = cot_rc('adm_invalid_input', array('value' => $not_filtered, 'field_name' => $value_name)); if (!is_null($defvalue)) { $value = !is_array($defvalue) ? $defvalue : (isset($defvalue[$value_name]) ? $defvalue[$value_name] : (isset($defvalue[$idx]) ? $defvalue[$idx] : null)); $warning_msg .= '. ' . cot_rc('adm_set_default', $value); } cot_message($warning_msg, 'warning', $name . '_int_filter'); } $res[$value_name] = $value; } return $single_value ? $value : $res; }
public function deleteAction() { $id = cot_import('id', 'G', 'INT'); $d = cot_import('d', 'G', 'INT'); $backUrlParams = array('m' => 'subscribe', 'n' => 'queue'); 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; } } if (!$id) { cot_error(cot::$L['nf']); cot_redirect(cot_url('admin', $backUrlParams)); } $item = subscribe_model_Queue::getById($id); if (!$item) { cot_error(cot::$L['nf']); cot_redirect(cot_url('admin', $backUrlParams)); } $item->delete(); cot_message(cot::$L['Deleted']); cot_redirect(cot_url('admin', $backUrlParams, '', true)); }
foreach (cot_getextplugins('page.add.add.error') as $pl) { include $pl; } /* ===== */ if (!cot_error_found()) { $id = cot_page_add($rpage, $usr); switch ($rpage['page_state']) { case 0: $urlparams = empty($rpage['page_alias']) ? array('c' => $rpage['page_cat'], 'id' => $id) : array('c' => $rpage['page_cat'], 'al' => $rpage['page_alias']); $r_url = cot_url('page', $urlparams, '', true); break; case 1: $r_url = cot_url('message', 'msg=300', '', true); break; case 2: cot_message('page_savedasdraft'); $r_url = cot_url('page', 'm=edit&id=' . $id, '', true); break; } cot_redirect($r_url); } else { cot_redirect(cot_url('page', 'm=add&c=' . $c, '', true)); } } // Page cloning support $clone = cot_import('clone', 'G', 'INT'); if ($clone > 0) { $rpage = $db->query("SELECT * FROM {$db_pages} WHERE page_id = ?", $clone)->fetch(); } if (empty($rpage['page_cat']) && !empty($c)) { $rpage['page_cat'] = $c;
cot_message(sprintf($L['adm_extrafield_updated'], $k)); } elseif (!$fieldresult) { 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'); /* ===== */
$desc = cot_import($descs[$name], 'D', "HTM"); $order = cot_import($orders[$name], 'D', "INT"); $variants = cot_import($variantss[$name], 'D', "HTM"); $default = cot_import($defaults[$name], 'D', "HTM"); $type = cot_import($types[$name], 'D', "INT"); cfg_editor::config_edit($c, $name, $order, $title, $desc, $type, $default, $variants); } cot_message('updated_success'); $cache && $cache->clear(); cot_redirect(cot_url('admin', array('m' => 'other', 'p' => 'configeditor', 'n' => 'edit', 'c' => $c), '', true)); } if ($a == 'delete') { cot_check_xg(); $name = cot_import('rname', 'G', "ALP"); cfg_editor::config_delete($c, $name); cot_message('deleted_success'); $cache && $cache->clear(); cot_redirect(cot_url('admin', array('m' => 'other', 'p' => 'configeditor', 'n' => 'edit', 'c' => $c), '', true)); } $rows = cfg_editor::config_list($c); foreach ($rows as $row) { $readonly = array(); if ($row['config_donor'] != 'configeditor') { $readonly = array('readonly' => 'readonly', 'disabled' => 'disabled'); } $t->assign(array('FORM_EDIT_NAME' => $row['config_name'], 'FORM_EDIT_TITLE' => cot_inputbox('text', 'rtitle[' . $row['config_name'] . ']', isset($L['cfg_' . $row['config_name']]) ? $L['cfg_' . $row['config_name']] : $row['config_text'], array('maxlength' => '255') + $readonly), 'FORM_EDIT_DESC' => cot_textarea('rdesc[' . $row['config_name'] . ']', isset($L['cfg_' . $row['config_name'] . '_hint']) ? $L['cfg_' . $row['config_name'] . '_hint'] : $row['config_desc'], 2, 60, array('maxlength' => '255') + $readonly), 'FORM_EDIT_ORDER' => cot_inputbox('text', 'rorder[' . $row['config_name'] . ']', $row['config_order'], array('maxlength' => '2') + $readonly), 'FORM_EDIT_VARIANTS' => cot_textarea('rvariants[' . $row['config_name'] . ']', $row['config_variants'], 2, 60, array('maxlength' => '255') + $readonly), 'FORM_EDIT_DEFAULT' => cot_textarea('rdefault[' . $row['config_name'] . ']', $row['config_default'], 2, 60, array('maxlength' => '255') + $readonly), 'FORM_EDIT_TYPE' => cot_selectbox($row['config_type'], 'rtype[' . $row['config_name'] . ']', array_keys($types_array), array_values($types_array), false, $readonly), 'FORM_EDIT_DELETE_URL' => $row['config_donor'] != 'configeditor' ? '' : cot_url('admin', array('m' => 'other', 'p' => 'configeditor', 'n' => 'edit', 'c' => $c, 'a' => 'delete', 'rname' => $row['config_name'], 'x' => $sys['xk'])))); $t->parse('MAIN.ROW'); } if (!count($rows)) { $t->parse('MAIN.NOROW'); }
if (!empty(cot::$extrafields[cot::$db->contact])) { foreach (cot::$extrafields[cot::$db->contact] as $exfld) { $exfld_title = cot_extrafield_title($exfld, 'contact_'); $ex_body = cot_build_extrafields_data('contact', $exfld, $rcontact['contact_' . $exfld['field_name']]); $rextras .= "\n" . $exfld_title . ": " . $ex_body; $context['extra' . $exfld['field_name']] = $ex_body; $context['extra' . $exfld['field_name'] . '_title'] = $exfld_title; $context['extra' . $exfld['field_name'] . '_value'] = $rcontact['contact_' . $exfld['field_name']]; } } $context['extra'] = $rextras; $rtextm = cot_rc(empty(cot::$cfg['plugin']['contact']['template']) ? cot::$R['contact_message'] : cot::$cfg['plugin']['contact']['template'], $context); cot_mail($semail, $rcontact['contact_subject'], $rtextm, $headers); } $sent = true; cot_message('contact_message_sent'); cot_extrafield_movefiles(); } } cot::$out['subtitle'] = cot::$L['contact_title']; cot_display_messages($t); if (!$sent) { $t->assign(array('CONTACT_FORM_SEND' => cot_url('plug', 'e=contact&tpl=' . $tplfile), 'CONTACT_FORM_AUTHOR' => cot::$usr['id'] == 0 ? cot_inputbox('text', 'ruser', $rcontact['contact_author'], 'size="24" maxlength="24"') : cot_inputbox('text', 'ruser', cot::$usr['name'], 'size="24" maxlength="24" readonly="readonly"'), 'CONTACT_FORM_EMAIL' => cot_inputbox('text', 'remail', $rcontact['contact_email'], 'size="24"'), 'CONTACT_FORM_SUBJECT' => cot_inputbox('text', 'rsubject', $rcontact['contact_subject'], 'size="24"'), 'CONTACT_FORM_TEXT' => cot_textarea('rtext', $rcontact['contact_text'], 8, 50, 'style="width:90%"'))); // Extra fields if (!empty(cot::$extrafields[cot::$db->contact])) { foreach (cot::$extrafields[cot::$db->contact] as $exfld) { $uname = strtoupper($exfld['field_name']); $exfld_val = cot_build_extrafields('rcontact' . $exfld['field_name'], $exfld, $rcontact[$exfld['field_name']]); $exfld_title = cot_extrafield_title($exfld, 'contact_'); $t->assign(array('CONTACT_FORM_' . $uname => $exfld_val, 'CONTACT_FORM_' . $uname . '_TITLE' => $exfld_title, 'CONTACT_FORM_EXTRAFLD' => $exfld_val, 'CONTACT_FORM_EXTRAFLD_TITLE' => $exfld_title)); $t->parse('MAIN.FORM.EXTRAFLD');
$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); $pagenav = cot_pagenav('admin', 'm=other&p=referers', $d, $totalitems, $maxperpage, 'd', '', $cfg['jquery'] && $cfg['turnajax']); $sql = $db->query("SELECT * FROM {$db_referers} ORDER BY ref_count DESC LIMIT {$d}, " . $maxperpage); if ($sql->rowCount() > 0) { while ($row = $sql->fetch()) { preg_match("#//([^/]+)/#", $row['ref_url'], $a); $host = preg_replace('#^www\\.#i', '', $a[1]); $referers[$host][$row['ref_url']] = $row['ref_count']; } $sql->closeCursor(); $ii = 0; /* === Hook - Part1 : Set === */ $extp = cot_getextplugins('referers.admin.loop'); /* ===== */
} if ($ruser['user_maingrp'] == COT_GROUP_MEMBERS && $urr['user_maingrp'] == COT_GROUP_INACTIVE) { $rsubject = $L['useed_accountactivated']; $rbody = $L['Hi'] . " " . $urr['user_name'] . ",\n\n"; $rbody .= $L['useed_email']; $rbody .= $L['auth_contactadmin']; cot_mail($urr['user_email'], $rsubject, $rbody); } /* === Hook === */ foreach (cot_getextplugins('users.edit.update.done') as $pl) { include $pl; } /* ===== */ cot_auth_clear($id); cot_log("Edited user #" . $id, 'adm'); cot_message('User_data_updated'); cot_redirect(cot_url('users', "m=edit&id=" . $id, '', true)); } else { cot_redirect(cot_url('users', "m=edit&id={$id}", '', true)); } } $sql = $db->query("SELECT * FROM {$db_users} WHERE user_id={$id} LIMIT 1"); $urr = $sql->fetch(); $title_params = array('EDIT' => $L['Edit'], 'NAME' => $urr['user_name']); $out['subtitle'] = cot_title('{EDIT} - {NAME}', $title_params); $out['head'] .= $R['code_noindex']; $mskin = cot_tplfile(array('users', 'edit', $usr['maingrp']), 'module'); /* === Hook === */ foreach (cot_getextplugins('users.edit.main') as $pl) { include $pl; }
[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); $t->parse(); $plugin_body = $t->text('MAIN');
if ($cfg['plugin']['comments']['mail']) { $sql = $db->query("SELECT * FROM {$db_users} WHERE user_maingrp=5"); $email_title = $L['plu_comlive']; $email_body = $L['User'] . ' ' . preg_replace('#[^\\w\\p{L}]#u', '', $usr['id'] == 0 ? $rname : $usr['name']) . ' ' . $L['plu_comlive2']; $email_body .= COT_ABSOLUTE_URL . cot_url($url_area, $url_params, '#c' . $id, true) . "\n\n"; while ($adm = $sql->fetch()) { cot_mail($adm['user_email'], $email_title, $email_body); } $sql->closeCursor(); } /* == Hook == */ foreach (cot_getextplugins('comments.send.new') as $pl) { include $pl; } /* ===== */ cot_message($L['com_commentadded']); cot_shield_update(20, 'New comment'); cot_redirect(cot_url($url_area, $url_params, '#c' . $id, true)); } if ($usr['id'] == 0 && $area == 'page' && $cache) { if ($cfg['cache_page']) { $cache->page->clear('page/' . str_replace('.', '/', $structure['page'][$url_params['c']]['path'])); } } cot_redirect(cot_url($url_area, $url_params, '#comments', true)); } elseif ($a == 'delete' && $usr['isadmin']) { cot_check_xg(); $sql = $db->query("SELECT * FROM {$db_com} WHERE com_id={$id} AND com_area='{$area}' LIMIT 1"); if ($row = $sql->fetch()) { $sql->closeCursor(); $sql = $db->delete($db_com, "com_id={$id}");
/** * Imports data for config values from outer world * * @param string|array $name Name of value or array of names for list of values * @param string $source Source type * @param string $filter Filter type * @param string $defvalue Default value for filtered data * @see cot_import() * @return mixed Filtered value of array of values */ function cot_config_import($name, $source = 'POST', $filter = 'NOC', $defvalue = null) { global $cot_import_filters; if (!$name) { return null; } if (!is_array($name)) { $name = array($name); $single_value = true; } $res = array(); foreach ($name as $idx => $var_name) { $filter_type = is_array($filter) ? $filter[$var_name] ? $filter[$var_name] : ($filter[$idx] ? $filter[$idx] : 'NOC') : $filter; $not_filtered = cot_import($var_name, $source, 'NOC'); $value = cot_import($var_name, $source, $filter_type); // addition filtering by varname if (sizeof($cot_import_filters[$var_name])) { $value = cot_import($value, 'DIRECT', $var_name); } // if invalid value is used if (is_null($value)) { $value_to_show = in_array($filter_type, array('INT', 'NUM', 'TXT', 'ALP')) ? htmlspecialchars(cot_cutstring(strip_tags($not_filtered), 15)) : ''; list($field_title) = cot_config_titles($var_name); $error_msg = cot_rc('adm_invalid_input', array('value' => $value_to_show, 'field_name' => $field_title)); if (!is_null($defvalue)) { $value = !is_array($defvalue) ? $defvalue : (isset($defvalue[$var_name]) ? $defvalue[$var_name] : (isset($defvalue[$idx]) ? $defvalue[$idx] : null)); $error_msg .= $value_to_show ? '. ' . cot_rc('adm_set_default', htmlspecialchars(strip_tags($value))) : ''; } cot_message($error_msg, 'error', $var_name); } $res[$var_name] = $value; } return $single_value ? $value : $res; }
foreach (cot_getextplugins('page.admin.delete.done') as $pl) { include $pl; } /* ===== */ $perelik .= '#' . $id . ', '; } else { $notfoundet .= '#' . $id . ' - ' . $L['Error'] . '<br />'; } } } $cache && $cache->db->remove('structure', 'system'); if ($cache && $cfg['cache_index']) { $cache->page->clear('index'); } if (!empty($perelik)) { cot_message($notfoundet . $perelik . ' - ' . $L['adm_queue_deleted']); } } } $totalitems = $db->query("SELECT COUNT(*) FROM {$db_pages} WHERE " . $sqlwhere)->fetchColumn(); $pagenav = cot_pagenav('admin', $common_params, $d, $totalitems, $cfg['maxrowsperpage'], 'd', '', $cfg['jquery'] && $cfg['turnajax']); $sql_page = $db->query("SELECT p.*, u.user_name\n\tFROM {$db_pages} as p\n\tLEFT JOIN {$db_users} AS u ON u.user_id=p.page_ownerid\n\tWHERE {$sqlwhere}\n\t\tORDER BY {$sqlsorttype} {$sqlsortway}\n\t\tLIMIT {$d}, " . $cfg['maxrowsperpage']); $ii = 0; /* === Hook - Part1 : Set === */ $extp = cot_getextplugins('page.admin.loop'); /* ===== */ foreach ($sql_page->fetchAll() as $row) { $sql_page_subcount = $db->query("SELECT SUM(structure_count) FROM {$db_structure} WHERE structure_path LIKE '" . $db->prep($structure['page'][$row["page_cat"]]['rpath']) . "%' "); $sub_count = $sql_page_subcount->fetchColumn(); $row['page_file'] = intval($row['page_file']); $t->assign(cot_generate_pagetags($row, 'ADMIN_PAGE_', 200));
if (function_exists($area_sync)) { $res = true; $sql = $db->query("SELECT structure_code FROM {$db_structure} WHERE structure_area='" . $db->prep($n) . "'"); foreach ($sql->fetchAll() as $row) { $cat = $row['structure_code']; $items = $area_sync($cat); $db->update($db_structure, array("structure_count" => (int) $items), "structure_code='" . $db->prep($cat) . "' AND structure_area='" . $db->prep($n) . "'"); } $sql->closeCursor(); } /* === Hook === */ foreach (cot_getextplugins('admin.structure.resync.done') as $pl) { include $pl; } /* ===== */ $res ? cot_message('Resynced') : cot_message("Error: function {$area_sync} doesn't exist."); // TODO i18n $cache && $cfg['cache_' . $n] && $cache->page->clear($n); cot_redirect(cot_url('admin', 'm=structure&n=' . $n . '&mode=' . $mode . '&d=' . $durl, '', true)); } $ext_info = cot_get_extensionparams($n, true); $adminpath[] = array(cot_url('admin', 'm=extensions'), $L['Extensions']); $adminpath[] = array($is_module ? cot_url('admin', 'm=' . $n) : cot_url('admin', 'm=extensions&a=details&pl=' . $n), $ext_info['name']); $adminpath[] = array(cot_url('admin', 'm=structure&n=' . $n), $L['Structure']); if ($id > 0 || !empty($al)) { $where = $id > 0 ? 'structure_id=' . (int) $id : "structure_code='" . $db->prep($al) . "'"; $sql = $db->query("SELECT * FROM {$db_structure} WHERE {$where} LIMIT 1"); cot_die($sql->rowCount() == 0); } elseif ($mode && ($mode == 'all' || $structure[$n][$mode])) { $sqlmask = $mode == 'all' ? "structure_path NOT LIKE '%.%'" : "structure_path LIKE '" . $db->prep($structure[$n][$mode]['rpath']) . ".%' AND structure_path NOT LIKE '" . $db->prep($structure[$n][$mode]['rpath']) . ".%.%'"; $sql = $db->query("SELECT * FROM {$db_structure} WHERE structure_area='" . $db->prep($n) . "' AND {$sqlmask} ORDER BY structure_path ASC, structure_code ASC LIMIT {$d}, " . $maxrowsperpage);
// 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'); /* ===== */
cot_redirect(cot_url('page', $page_urlp, '', true, false, true)); } $out['subtitle'] = $L['i18n_editing']; $t = new XTemplate(cot_tplfile('i18n.page', 'plug')); $t->assign(array('I18N_ACTION' => cot_url('plug', "e=i18n&m=page&a=edit&id={$id}&l={$i18n_locale}"), 'I18N_TITLE' => $L['i18n_editing'], 'I18N_ORIGINAL_LANG' => $i18n_locales[$cfg['defaultlang']], 'I18N_LOCALIZED_LANG' => $i18n_locales[$i18n_locale], 'I18N_PAGE_TITLE' => htmlspecialchars($pag['page_title']), 'I18N_PAGE_DESC' => htmlspecialchars($pag['page_desc']), 'I18N_PAGE_TEXT' => cot_parse($pag['page_text'], $cfg['page']['markup']), 'I18N_IPAGE_TITLE' => htmlspecialchars($pag_i18n['ipage_title']), 'I18N_IPAGE_DESC' => htmlspecialchars($pag_i18n['ipage_desc']), 'I18N_IPAGE_TEXT' => cot_textarea('translate_text', $pag_i18n['ipage_text'], 32, 80, '', 'input_textarea_editor'))); cot_display_messages($t); /* === Hook === */ foreach (cot_getextplugins('i18n.page.edit.tags') as $pl) { include $pl; } /* =============*/ } elseif ($a == 'delete' && ($i18n_admin || $usr['id'] == $pag['ipage_translatorid'])) { // Send to trashcan if available if ($cfg['plugin']['trashcan']['trash_page']) { require_once cot_incfile('trashcan', 'plug'); $row = $db->query("SELECT * FROM {$db_i18n_pages}\n\t\t\t\tWHERE ipage_id = {$id} AND ipage_locale = '{$i18n_locale}'")->fetch(); cot_trash_put('i18n_page', $L['i18n_translation'] . " #{$id} ({$i18n_locale}) " . $row['ipage_title'], $id, $row); } $db->delete($db_i18n_pages, "ipage_id = {$id} AND ipage_locale = '{$i18n_locale}'"); /* === Hook === */ foreach (cot_getextplugins('i18n.page.delete.done') as $pl) { include $pl; } /* =============*/ cot_message('Deleted'); $page_urlp = empty($pag['page_alias']) ? 'c=' . $pag['page_cat'] . "id={$id}" : 'c=' . $pag['page_cat'] . 'al=' . $pag['page_alias']; cot_redirect(cot_url('page', $page_urlp, '', true)); } } else { cot_die(true, true); }
break; case 'pause': cot_extension_pause($code); cot_message('adm_paused'); break; case 'unpause': cot_extension_resume($code); cot_message('adm_running'); break; case 'pausepart': cot_plugin_pause($code, $part); cot_message('adm_partstopped'); break; case 'unpausepart': cot_plugin_resume($code, $part); cot_message('adm_partrunning'); break; } if (!empty($b)) { $db->update($db_users, array('user_auth' => ''), "user_auth != ''"); if ($cache) { $cache->clear(); } cot_redirect(cot_url('admin', "m=extensions&a=details&{$arg}={$code}", '', true)); } if ($exists) { $parts = array(); // Collect all parts from extension directory $handle = opendir($dir . '/' . $code); while ($f = readdir($handle)) { if (preg_match("#^{$code}(\\.([\\w\\.]+))?.php\$#", $f, $mt) && !in_array($mt[2], $cot_ext_ignore_parts)) {