当前位置: 首页>>代码示例>>PHP>>正文


PHP cot_shield_protect函数代码示例

本文整理汇总了PHP中cot_shield_protect函数的典型用法代码示例。如果您正苦于以下问题:PHP cot_shield_protect函数的具体用法?PHP cot_shield_protect怎么用?PHP cot_shield_protect使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cot_shield_protect函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cot_shield_hammer

/**
 * Anti-hammer protection
 *
 * @param int $hammer Hammer rate
 * @param string $action Action type
 * @param int $lastseen User last seen timestamp
 * @return int
 */
function cot_shield_hammer($hammer, $action, $lastseen)
{
    global $cfg, $sys;
    if ($action == 'Hammering') {
        cot_shield_protect();
        cot_shield_clearaction();
        cot_plugin_active('hits') && cot_stat_inc('totalantihammer');
    }
    if ($sys['now'] - $lastseen < 4) {
        $hammer++;
        if ($hammer > $cfg['shieldzhammer']) {
            cot_shield_update(180, 'Hammering');
            cot_log('IP banned 3 mins, was hammering', 'sec');
            $hammer = 0;
        }
    } else {
        if ($hammer > 0) {
            $hammer--;
        }
    }
    return $hammer;
}
开发者ID:Andreyjktl,项目名称:Cotonti,代码行数:30,代码来源:functions.php

示例2: cot_import

$c = cot_import('c', 'G', 'TXT');
if (!empty($c) && !isset($structure['projects'][$c])) {
    $c = '';
}
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('projects', 'any', 'RWA');
cot_block($usr['auth_write']);
/* === Hook === */
$extp = cot_getextplugins('projects.add.first');
foreach ($extp as $pl) {
    include $pl;
}
/* ===== */
$sys['parser'] = $cfg['projects']['parser'];
$parser_list = cot_get_parsers();
if ($a == 'add') {
    cot_shield_protect();
    $ritem = array();
    /* === Hook === */
    foreach (cot_getextplugins('projects.add.add.first') as $pl) {
        include $pl;
    }
    /* ===== */
    $ritem = cot_projects_import('POST', array(), $usr);
    list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('projects', $ritem['item_cat']);
    cot_block($usr['auth_write']);
    /* === Hook === */
    foreach (cot_getextplugins('projects.add.add.import') as $pl) {
        include $pl;
    }
    /* ===== */
    cot_projects_validate($ritem);
开发者ID:ASDAFF,项目名称:cot-freelance,代码行数:31,代码来源:projects.add.php

示例3: editAction

 public function editAction()
 {
     global $structure, $cot_extrafields, $db_structure;
     $id = cot_import('id', 'G', 'INT');
     // id Объявления
     $c = cot_import('c', 'G', 'TXT');
     $act = cot_import('act', 'G', 'ALP');
     if (empty($act)) {
         $act = cot_import('act', 'P', 'ALP');
     }
     /* === Hook === */
     foreach (cot_getextplugins('advboard.edit.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']);
     if (!$c || !isset($structure['advboard'][$c])) {
         cot_die_message(404, TRUE);
     }
     $category = $structure['advboard'][$c];
     $category['config'] = cot::$cfg['advboard']['cat_' . $c];
     $category['code'] = $c;
     // Extra fields for structure
     foreach ($cot_extrafields[$db_structure] as $exfld) {
         $uname = $exfld['field_name'];
         $val = $structure['advboard'][$c][$exfld['field_name']];
         $category[$uname . '_title'] = isset(cot::$L['structure_' . $exfld['field_name'] . '_title']) ? cot::$L['structure_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
         $category[$uname] = cot_build_extrafields_data('structure', $exfld, $val);
         $category[$uname . '_value'] = $val;
     }
     $published = 0;
     if (!$id) {
         $advert = new advboard_model_Advert();
         $advert->category = $c;
         $advert->user = cot::$usr['id'];
     } else {
         $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);
             }
         }
         if ($c != $advert->category && isset($structure['advboard'][$advert->category])) {
             $tmp = array('c' => $advert->category, 'a' => 'edit', 'id' => $advert->id);
             if (!empty($act)) {
                 $tmp['act'] = $act;
             }
             cot_redirect(cot_url('advboard', array('c' => $advert->category, 'a' => 'edit', 'id' => $advert->id), '', true));
         }
         if ($act == 'clone') {
             $id = null;
             $advert = clone $advert;
             // Установить статус и пользователя нового объекта
             $advert->user = cot::$usr['id'];
             $advert->state = advboard_model_Advert::DRAFT;
         }
         $published = $advert->state < 2 ? 1 : 0;
     }
     //Проверим права на категорию:
     list(cot::$usr['auth_read'], cot::$usr['auth_write'], cot::$usr['isadmin'], cot::$usr['auth_upload']) = cot_auth('advboard', $c, 'RWA1');
     if ($structure['advboard'][$c]['locked'] && !cot::$usr['isadmin']) {
         cot_die_message(602, TRUE);
     } elseif ($advert->id == 0) {
         // Если у пользователя нет прав на подачу объявления, то ищем категорию куда он может подать оьбъявление
         if (!cot::$usr['auth_write']) {
             foreach ($structure['advboard'] as $catCode => $catRow) {
                 $auth_write = cot_auth('advboard', $catCode, 'W');
                 if ($auth_write) {
                     cot_redirect(cot_url('advboard', array('c' => $catCode, 'a' => 'edit'), '', true));
                 }
             }
         }
         cot_block(cot::$usr['auth_write']);
     }
     // Владелец объявления
     $user = array();
     if ($advert->user > 0) {
         $user = cot_user_data($advert->user);
     }
     $periodItems = adv_periodItems($c);
     // Сохранение
     if ($act == 'save') {
         unset($_POST['id'], $_POST['user']);
         cot_shield_protect();
         /* === Hook === */
         foreach (cot_getextplugins('advboard.save.first') as $pl) {
             include $pl;
         }
         /* ===== */
         // импортировать даты
         $begin = (int) cot_import_date('begin');
         $expire = (int) cot_import_date('expire');
         if ($begin == 0) {
             $begin = !empty($advert->begin) ? $advert->begin : cot::$sys['now'];
         }
//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:advboard,代码行数:101,代码来源:Main.php


注:本文中的cot_shield_protect函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。