Esempio n. 1
0
 protected function addAdditionalElements()
 {
     // Init info
     $this->addElement('Select', 'type', array('label' => '*Type of ban', 'multiOptions' => array('0' => 'Email', '1' => 'Username', '2' => 'Ip'), 'onchange' => "updateTextFields()", 'value' => $this->_type));
     $user = Engine_Api::_()->user()->getViewer();
     //ADD AUTH STUFF HERE
     // Init Email
     $this->addElement('Textarea', 'email', array('label' => '*Email Address Ban', 'description' => 'YNBANMEM_FORM_EMAILBANS_DESCRIPTION'));
     $this->email->getDecorator("Description")->setOption("placement", "append");
     // Init Username
     // Init Email
     $this->addElement('Textarea', 'username', array('label' => '*Username Address Ban', 'description' => 'YNBANMEM_FORM_USERNAMEBANS_DESCRIPTION'));
     $this->username->getDecorator("Description")->setOption("placement", "append");
     $translator = $this->getTranslator();
     if ($translator) {
         $description = sprintf($translator->translate('YNBANMEM_FORM_IPBANS_DESCRIPTION'), Engine_IP::normalizeAddress(Engine_IP::getRealRemoteAddress()));
     } else {
         $description = 'YNBANMEM_FORM_IPBANS_DESCRIPTION';
     }
     // Init Ip
     $this->addElement('Textarea', 'ip', array('label' => '*IP Address Ban', 'description' => $description));
     $this->ip->getDecorator("Description")->setOption("placement", "append");
     // init Email Message
     $value = "Your account has been banned.";
     $this->addElement('textarea', 'email_message', array('label' => '*Message', 'style' => 'width: 430px; height: 200px', 'value' => $value));
     $this->email_message->getDecorator("Description")->setOption("placement", "append");
 }
Esempio n. 2
0
 public function init()
 {
     $maindescription = $this->getTranslator()->translate('Social networks are often the target of aggressive spam tactics. This most often comes in the form of fake user accounts and spam in comments. On this page, you can manage various anti-spam and censorship features. Note: To turn on the signup image verification feature (a popular anti-spam tool), see the Signup Progress page. <br>');
     $settings = Engine_Api::_()->getApi('settings', 'core');
     if ($settings->getSetting('user.support.links', 0) == 1) {
         $moreinfo = $this->getTranslator()->translate('More Info: <a href="%1$s" target="_blank"> KB Article</a>');
     } else {
         $moreinfo = $this->getTranslator()->translate('');
     }
     $maindescription = vsprintf($maindescription . $moreinfo, array('http://support.socialengine.com/questions/183/Admin-Panel-Settings-Spam-and-Banning-Tools'));
     // Decorators
     $this->loadDefaultDecorators();
     $this->getDecorator('Description')->setOption('escape', false);
     // Set form attributes
     //$this->setTitle('Spam & Banning Tools');
     $this->setDescription($maindescription);
     // init ip-range ban
     $translator = $this->getTranslator();
     if ($translator) {
         $description = sprintf($translator->translate('CORE_FORM_ADMIN_SETTINGS_SPAM_IPBANS_DESCRIPTION'), Engine_IP::normalizeAddress(Engine_IP::getRealRemoteAddress()));
     } else {
         $description = 'CORE_FORM_ADMIN_SETTINGS_SPAM_IPBANS_DESCRIPTION';
     }
     $this->addElement('Textarea', 'bannedips', array('label' => 'IP Address Ban', 'description' => $description));
     // init email bans
     $this->addElement('Textarea', 'bannedemails', array('label' => 'Email Address Ban', 'description' => 'CORE_FORM_ADMIN_SETTINGS_SPAM_EMAILBANS_DESCRIPTION'));
     // init username bans
     $this->addElement('Textarea', 'bannedusernames', array('label' => 'Profile Address Ban', 'description' => 'CORE_FORM_ADMIN_SETTINGS_SPAM_USERNAMEBANS_DESCRIPTION'));
     // init censored words
     $this->addElement('Textarea', 'bannedwords', array('label' => 'Censored Words', 'description' => 'CORE_FORM_ADMIN_SETTINGS_SPAM_CENSOR_DESCRIPTION'));
     $this->addElement('Radio', 'signup', array('label' => 'Require new users to enter validation code when signing up?', 'multiOptions' => $this->_captcha_options, 'value' => 0));
     $this->addElement('Radio', 'invite', array('label' => 'Require users to enter validation code when inviting others?', 'multiOptions' => $this->_captcha_options, 'value' => 0));
     $this->addElement('Radio', 'login', array('label' => 'Require users to enter validation code when signing in?', 'multiOptions' => $this->_captcha_options, 'value' => 0));
     $this->addElement('Radio', 'contact', array('label' => 'Require users to enter validation code when using the contact form?', 'multiOptions' => array(2 => 'Yes, make everyone complete the CAPTCHA form.', 1 => 'Yes, make visitors complete CAPTCHA, but members are exempt.', 0 => 'No, do not show a CAPTCHA form to anyone.'), 'value' => 0));
     // init profile
     $this->addElement('Radio', 'comment', array('label' => 'Require users to enter validation code when commenting?', 'multiOptions' => $this->_captcha_options, 'value' => 0));
     // recaptcha
     if ($translator) {
         $description = sprintf($translator->translate('You can obtain API credentials at: %1$s'), $this->getView()->htmlLink('https://www.google.com/recaptcha', 'https://www.google.com/recaptcha'));
     } else {
         $description = null;
     }
     $this->addElement('Text', 'recaptchapublic', array('label' => 'ReCaptcha Public Key', 'description' => $description, 'filters' => array('StringTrim')));
     $this->getElement('recaptchapublic')->getDecorator('Description')->setOption('escape', false);
     $this->addElement('Text', 'recaptchaprivate', array('label' => 'ReCaptcha Private Key', 'description' => $description, 'filters' => array('StringTrim')));
     $this->getElement('recaptchaprivate')->getDecorator('Description')->setOption('escape', false);
     // tokens
     //    $this->addElement('Radio', 'tokens', array(
     //      'label' => 'Use Tokens?',
     //      'multiOptions' => array(
     //        1 => 'Yes, use security tokens.',
     //        0 => 'No, do not use security tokens.',
     //      ),
     //    ));
     // comment html
     $this->addElement('Text', 'commenthtml', array('label' => 'Allow HTML in Comments?', 'description' => 'CORE_ADMIN_FORM_SETTINGS_SPAM_COMMENTHTML_DESCRIPTION'));
     // init submit
     $this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true));
 }
Esempio n. 3
0
 public function onUserLoginAfter($event)
 {
     $viewer = Engine_Api::_()->user()->getViewer();
     // Save Ip
     if ($viewer->getIdentity() > 0) {
         if (is_string($viewer->lastlogin_ip)) {
             $ip = Engine_IP::normalizeAddress($viewer->lastlogin_ip);
             $prefix = Engine_Api::_()->getDbTable('ips', 'ynbanmem')->getTablePrefix();
             $q = "\t\t\t\n\t\t\t\tSELECT *\n\t  \t\t\tFROM `{$prefix}ynbanmem_ips` WHERE user_id = {$viewer->user_id} and ip = '{$ip}';\t\n\t\t\t\t";
             $results = Engine_Db_Table::getDefaultAdapter()->fetchRow($q);
             if (!$results) {
                 $date = date('Y-m-d H:i:s');
                 $q = "\t\t\t\n\t\t\t\t\tINSERT INTO `{$prefix}ynbanmem_ips` (user_id , ip, creation_date)\n\t\t\t\t\tVALUES ( {$viewer->user_id} , '{$ip}', '{$date}')\t  \t\t\t\n\t\t\t\t\t";
                 Engine_Db_Table::getDefaultAdapter()->query($q);
             }
         }
     }
 }
 public function getAddresses()
 {
     $data = $this->select()->from($this, array('start', 'stop'))->order('start ASC')->query()->fetchAll();
     $addresses = array();
     foreach ($data as $datum) {
         if ($datum['start'] == $datum['stop']) {
             $addresses[] = Engine_IP::normalizeAddress($datum['start']);
         } else {
             $startStr = Engine_IP::normalizeAddress($datum['start']);
             $stopStr = Engine_IP::normalizeAddress($datum['stop']);
             //$addresses[] = $startStr . ' - ' . $stopStr;
             if ($startStr && $stopStr) {
                 $addresses[] = array($startStr, $stopStr);
             }
         }
     }
     return array_filter($addresses);
 }
Esempio n. 5
0
 public function getAddresses()
 {
     $extraInfoTable = Engine_Api::_()->getDbTable('extrainfo', 'ynbanmem');
     $data = $this->select()->from($this, array('banned_id' => 'bannedip_id', 'start', 'stop'))->order('start ASC')->query()->fetchAll();
     $addresses = array();
     foreach ($data as $datum) {
         if ($datum['start'] == $datum['stop']) {
             $startStr = Engine_IP::normalizeAddress($datum['start']);
             $extraInfo = $extraInfoTable->getExtraInfo($datum['banned_id'], 1);
             $bannedip['banned_id'] = $datum['banned_id'];
             $bannedip['start'] = $startStr;
             $bannedip['stop'] = "";
             $bannedip['extra_info'] = $extraInfo;
             //$addresses[] = $startStr . ' - ' . $stopStr;
             if ($startStr) {
                 $addresses[] = $bannedip;
             }
         } else {
             $startStr = Engine_IP::normalizeAddress($datum['start']);
             $stopStr = Engine_IP::normalizeAddress($datum['stop']);
             //Get extra info
             $extraInfo = $extraInfoTable->getExtraInfo($datum['banned_id'], 1);
             $bannedip['banned_id'] = $datum['banned_id'];
             $bannedip['start'] = $startStr;
             $bannedip['stop'] = $stopStr;
             $bannedip['extra_info'] = $extraInfo;
             //$addresses[] = $startStr . ' - ' . $stopStr;
             if ($startStr && $stopStr) {
                 $addresses[] = $bannedip;
             }
         }
     }
     return array_filter($addresses);
 }