public function Loaded()
 {
     $nb_banned_visitors = 0;
     foreach ($this->array_wsp_banned_users as $ip => $array_ip_info) {
         if ($array_ip_info['cnt'] >= MAX_BAD_URL_BEFORE_BANNED) {
             $btn_authorize = new Picture("img/wsp-admin/button_ok_16.png", 16, 16, 0, Picture::ALIGN_ABSMIDDLE, __(AUTHORIZE));
             $btn_authorize->onClick($this, "onAuthorizeVisitor", $ip)->setAjaxEvent();
             if (!$btn_authorize->isClicked()) {
                 $link_ip = new Link("http://www.infosniper.net/index.php?ip_address=" . $ip, Link::TARGET_BLANK, $ip);
                 $row = $this->table_ban->addRowColumns($link_ip, $array_ip_info['dte'], $array_ip_info['len'], $btn_authorize);
                 $row->setColumnAlign(3, RowTable::ALIGN_CENTER);
                 $nb_banned_visitors++;
             }
         }
     }
     if ($nb_banned_visitors == 0) {
         $this->table_ban->addRowColumns(" ", __(NO_BANNED_VISITORS), " ", " ");
     }
 }
Exemple #2
0
 /**
  * Method addRowLoadFromSqlDataView
  * @access private
  * @param mixed $row 
  * @param mixed $list_attribute 
  * @param mixed $list_attribute_type 
  * @param mixed $key_attributes 
  * @param mixed $ind 
  * @param boolean $is_delete_action [default value: false]
  * @param double $line_nb [default value: 0]
  * @return boolean
  * @since 1.1.6
  */
 private function addRowLoadFromSqlDataView($row, $list_attribute, $list_attribute_type, $key_attributes, $ind, $is_delete_action = false, $line_nb = null)
 {
     if ($this->from_sql_data_view_delete) {
         // create delete button if not already exists
         $bnt_del_id = $this->id . "_btndel__ind_" . $ind;
         $delete_pic = $this->getPage()->getObjectId($bnt_del_id);
         if ($delete_pic == null) {
             $delete_pic = new Picture("img/wsp-admin/delete_16.png", 16, 16, 0, Picture::ALIGN_ABSMIDDLE);
             $delete_pic->setId($bnt_del_id);
             $delete_pic->onClickJs("if (!confirm('" . __(TABLE_CONFIME_DEL_ROW) . "')) { return false; }");
             $delete_pic->onClick($this->getPage(), "onChangeTableFromSqlDataView")->setAjaxEvent()->disableAjaxWaitMessage();
         }
     }
     // create row
     $row_table = new RowTable();
     $row_table->setId($this->id . "_row_" . $ind);
     for ($i = 0; $i < sizeof($list_attribute); $i++) {
         // get field properties
         if (is_array($this->from_sql_data_view_properties[$list_attribute[$i]])) {
             $attribute_properties = $this->from_sql_data_view_properties[$list_attribute[$i]];
         } else {
             $attribute_properties = array();
         }
         // get property display
         if (isset($attribute_properties["display"]) && $attribute_properties["display"] == false) {
             continue;
         }
         // get property update
         $is_update_ok = true;
         if (isset($attribute_properties["update"]) && $attribute_properties["update"] == false) {
             $is_update_ok = false;
         }
         if ($this->from_sql_data_view_update && !in_array($list_attribute[$i], $key_attributes) && $is_update_ok) {
             $row_value = $row->getValue($list_attribute[$i]);
             if (gettype($row_value) == "object" && method_exists($row_value, "render")) {
                 $row_value = $row_value->render();
             }
             $edit_pic = new Picture("wsp/img/edit_16x16.png", 16, 16);
             $row_obj = new Object($edit_pic, trim($row_value) == "" ? "&nbsp;&nbsp;" : utf8encode($row_value));
             $row_obj->setId($this->id . "_" . $list_attribute[$i] . "_obj_" . $ind)->setStyle("cursor:pointer;border:1px solid gray;");
             $input_obj = $this->createDbAttributeObject($row, $list_attribute, $list_attribute_type, $i, $ind, $key_attributes);
             if (get_class($input_obj) == "ComboBox") {
                 // Get foreign key value
                 $row_obj->emptyObject();
                 $value = $input_obj->getText();
                 $row_obj->add($edit_pic, trim($value) == "" ? "&nbsp;&nbsp;" : $value);
             } else {
                 if (get_class($input_obj) == "Calendar") {
                     $row_obj->emptyObject();
                     $value = $input_obj->getValueStr();
                     $row_obj->add($edit_pic, trim($value) == "" ? "&nbsp;&nbsp;" : $value);
                     $row_table->setNowrap();
                 }
             }
             $row_obj_input = new Object($input_obj);
             $row_obj_input->setId($this->id . "_" . $list_attribute[$i] . "_input_obj_" . $ind);
             $cancel_pic = new Picture("wsp/img/cancel_12x12.png", 12, 12);
             $cancel_pic->setId($this->id . "_img_" . $ind . "_cancel_" . $list_attribute[$i]);
             $cancel_pic->onClickJs("\$('#" . $row_obj->getId() . "').css('display', 'inline');\$('#" . $row_obj_input->getId() . "').hide();" . ($this->from_sql_data_view_add_button != null ? "\$('#" . $this->from_sql_data_view_add_button->getId() . "').button({ disabled: false });" : ""));
             $cancel_pic_obj = new Object($cancel_pic);
             $row_obj_input->add($cancel_pic_obj->forceSpanTag()->setStyle("position:absolute;"));
             if (!$this->getPage()->isAjaxPage() || $is_delete_action || $this->from_sql_data_view_reload_pic != null && $this->from_sql_data_view_reload_pic->isClicked() || $this->from_sql_data_view_add_button != null && $this->from_sql_data_view_add_button->isClicked()) {
                 $this->getPage()->addObject(new JavaScript("\$(document).ready(function() { \$('#" . $row_obj_input->getId() . "').hide(); });"));
             }
             $row_obj->onClickJs("\$('#" . $row_obj->getId() . "').hide();\$('#" . $row_obj_input->getId() . "').show();" . ($this->from_sql_data_view_add_button != null ? "\$('#" . $this->from_sql_data_view_add_button->getId() . "').button({ disabled: true });" : ""));
             $row_table->add(new Object($row_obj, $row_obj_input));
             // get properties align
             if (isset($attribute_properties["align"])) {
                 $row_table->setColumnAlign($i + 1, $attribute_properties["align"]);
             }
         } else {
             $value = $row->getValue($list_attribute[$i]);
             if (isset($this->from_sql_data_view_properties[$list_attribute[$i]]['cmb_obj'])) {
                 $input_obj_tmp = $this->from_sql_data_view_properties[$list_attribute[$i]]['cmb_obj'];
                 $input_obj_tmp->setValue($value);
                 $value = $input_obj_tmp->getText();
             }
             if (get_class($value) == "DateTime") {
                 $value = $value->format("Y-m-d");
             }
             $row_table->add(utf8encode($value));
         }
     }
     if ($this->from_sql_data_view_delete) {
         $row_table->add($delete_pic);
     } else {
         if ($this->from_sql_data_view_insert) {
             $row_table->add();
         }
     }
     if ($is_table_defined_style) {
         $row_table->setBorderPredefinedStyle($this->class);
     }
     if ($this->is_advance_table) {
         if (isset($line_nb) && $line_nb !== null) {
             $row_table->setRowClass($line_nb % 2 == 0 ? "odd" : "even");
         } else {
             if (is_numeric($ind)) {
                 $row_table->setRowClass($ind % 2 == 0 ? "odd" : "even");
             } else {
                 $row_table->setRowClass("even");
             }
         }
     }
     $this->addRow($row_table);
 }
 public function Loaded()
 {
     $users_table = new Table();
     $users_table->setId("users_table")->activateAdvanceTable()->activateSort(1)->setWidth(400);
     $users_table->addRowColumns(__(LOGIN), __(RIGHTS), __(MODIFY), __(DELETE))->setHeaderClass(0);
     $this->old_passwd_row->hide();
     $this->validate_btn->show();
     $this->modify_btn->hide();
     $this->cancel_btn->hide();
     $is_modify_mode = false;
     $array_users = getAllWspUsers();
     for ($i = 0; $i < sizeof($array_users); $i++) {
         $edit_user = new Picture("img/wsp-admin/edit_16.png", 16, 16);
         $edit_user->onClick($this, "refresh")->setAjaxEvent()->disableAjaxWaitMessage();
         if ($edit_user->isClicked() && !$is_modify_mode) {
             $this->old_passwd_row->show();
             $this->validate_btn->hide();
             $this->modify_btn->show();
             $this->cancel_btn->show();
             $this->edt_login->setValue($array_users[$i]['login']);
             $this->edt_old_password->forceEmpty();
             $this->edt_password->forceEmpty();
             $this->edt_confirm_passwd->forceEmpty();
             $is_modify_mode = true;
         }
         if ($array_users[$i]['login'] == $_SESSION['wsp-login']) {
             $del_user = new Object();
         } else {
             $del_user = new Picture("img/wsp-admin/delete_16.png", 16, 16);
             $del_user->setId("user_" . $array_users[$i]['login']);
             $del_user->onClickJs("if (!confirm('" . __(DEL_CONFIRM) . "')) { return false; }");
             $del_user->onClick($this, "removeWspUser", $array_users[$i]['login'])->setAjaxEvent();
             if ($del_user->isClicked()) {
                 continue;
             }
         }
         $users_table->addRowColumns($array_users[$i]['login'], $array_users[$i]['rights'], $edit_user, $del_user)->setColumnAlign(3, RowTable::ALIGN_CENTER)->setColumnAlign(4, RowTable::ALIGN_CENTER);
     }
     $this->users_table_obj->add($users_table);
 }