private function UpdateAccountInfo($account_information) { if ($this->accountType == 'admin') { $sql = 'UPDATE ' . TABLE_ACCOUNTS . ' SET date_lastlogin = \'' . @date('Y-m-d H:i:s') . '\' WHERE id = ' . (int) $account_information['id']; } else { $sql = 'UPDATE ' . TABLE_CUSTOMERS . ' SET date_lastlogin = \'' . @date('Y-m-d H:i:s') . '\', last_logged_ip = \'' . get_current_ip() . '\' WHERE id = ' . (int) $account_information['id']; } return database_void_query($sql); }
/** * Draws article comments * @param $article_id * @param $draw */ public function DrawArticleComments($article_id = '', $draw = true) { if (!$article_id) { return ''; } global $objLogin; $delete_pending_time = ModulesSettings::Get('comments', 'delete_pending_time'); $user_type = ModulesSettings::Get('comments', 'user_type'); $comment_length = ModulesSettings::Get('comments', 'comment_length'); $image_verification = ModulesSettings::Get('comments', 'image_verification_allow'); $comments_on_page = ModulesSettings::Get('comments', 'page_size'); $is_published = ModulesSettings::Get('comments', 'pre_moderation_allow') == 'yes' ? '0' : '1'; if ($image_verification == 'yes') { include_once 'modules/captcha/securimage.php'; $objImg = new Securimage(); } //echo '<pre>'; //print_r($_SERVER); //echo '</pre>'; $task = isset($_POST['task']) ? prepare_input($_POST['task']) : ''; $comment_id = isset($_POST['comment_id']) ? (int) $_POST['comment_id'] : ''; $init_state = 'closed'; $user_id = isset($_POST['user_id']) ? (int) $_POST['user_id'] : ''; $user_name = isset($_POST['comment_user_name']) ? prepare_input($_POST['comment_user_name']) : ''; $user_email = isset($_POST['comment_user_email']) ? prepare_input($_POST['comment_user_email']) : ''; $comment_text = isset($_POST['comment_text']) ? prepare_input($_POST['comment_text']) : ''; $captcha_code = isset($_POST['captcha_code']) ? prepare_input($_POST['captcha_code']) : ''; $msg = ''; $task_completed = false; $focus_field = ''; $current_page = isset($_GET['p']) ? abs((int) $_GET['p']) : '1'; if ($task == 'publish_comment') { $init_state = 'opened'; if ($user_name == '') { $msg = draw_important_message(_USERNAME_EMPTY_ALERT, false); $focus_field = 'comment_user_name'; } else { if (!check_email_address($user_email) && !$objLogin->IsLoggedInAs($this->user_type_name)) { $msg = draw_important_message(_EMAIL_IS_WRONG, false); $focus_field = 'comment_user_email'; } else { if ($comment_text == '') { $msg = draw_important_message(_MESSAGE_EMPTY_ALERT, false); $focus_field = 'comment_text'; } else { if ($comment_text != '' && strlen($comment_text) > $comment_length) { $msg = draw_important_message(str_replace('_LENGTH_', $comment_length, _COMMENT_LENGTH_ALERT), false); $focus_field = 'comment_text'; } else { if ($image_verification == 'yes' && !$objImg->check($captcha_code)) { $msg = draw_important_message(_WRONG_CODE_ALERT, false); $focus_field = 'captcha_code'; } else { // Block operation in demo mode if (strtolower(SITE_MODE) == 'demo') { $msg = draw_important_message(_OPERATION_BLOCKED, false); } else { if ($objLogin->IpAddressBlocked(get_current_ip())) { $msg = draw_important_message(_IP_ADDRESS_BLOCKED, false); } else { if ($objLogin->EmailBlocked($user_email)) { $msg = draw_important_message(_EMAIL_BLOCKED, false); } else { $sql = 'INSERT INTO ' . TABLE_COMMENTS . '( id, article_id, user_id, user_name, user_email, comment_text, date_created, date_published, is_published )VALUES( NULL, ' . (int) $article_id . ', ' . (int) $user_id . ', \'' . encode_text($user_name) . '\', \'' . encode_text($user_email) . '\', \'' . encode_text(strip_tags($comment_text, '<b><i><u><br>')) . '\', \'' . date('Y-m-d H:i:s') . '\', \'' . ($is_published == '1' ? date('Y-m-d H:i:s') : '0000-00-00 00:00:00') . '\', \'' . $is_published . '\' )'; if (database_void_query($sql)) { if ($is_published == '1') { $msg = draw_success_message(_COMMENT_POSTED_SUCCESS, false); } else { $msg = draw_success_message(_COMMENT_SUBMITTED_SUCCESS, false); } $task_completed = true; } else { $msg = draw_important_message(_TRY_LATER, false); } } } } } } } } } } else { if ($task == 'delete_comment') { $init_state = 'opened'; $sql = 'DELETE FROM ' . $this->tableName . ' WHERE TIMESTAMPDIFF(MINUTE, date_published, \'' . date('Y-m-d H:i:s') . '\') < ' . $delete_pending_time . ' AND id = ' . (int) $comment_id; if (database_void_query($sql)) { $msg = draw_success_message(_COMMENT_DELETED_SUCCESS, false); } else { $msg = draw_important_message(_TRY_LATER, false); } } } // -------- pagination $total_comments = 0; $page_size = $comments_on_page; $sql = 'SELECT COUNT(*) as cnt FROM ' . TABLE_COMMENTS . ' WHERE is_published = 1 AND article_id = ' . (int) $article_id; $comments_result = database_query($sql, DATA_ONLY, FIRST_ROW_ONLY); $total_comments = $comments_result['cnt']; $total_pages = (int) ($total_comments / $page_size); if ($current_page > $total_pages + 1) { $current_page = 1; } if ($total_comments % $page_size != 0) { $total_pages++; } if ($task_completed) { $current_page = $total_pages; } if (!is_numeric($current_page) || (int) $current_page <= 0) { $current_page = 1; } $start_row = ($current_page - 1) * $page_size; if (isset($_GET['p'])) { $init_state = 'opened'; } // -------- $sql = 'SELECT * FROM ' . TABLE_COMMENTS . ' WHERE article_id = ' . (int) $article_id . ' AND is_published = 1 ORDER BY date_published ASC LIMIT ' . $start_row . ', ' . $page_size; $result = database_query($sql, DATA_AND_ROWS); $output = '<script type="text/javascript">function deleteComment(cid) { if(confirm(\'' . _PERFORM_OPERATION_COMMON_ALERT . '\')){ jQuery(\'#comment_task\').val(\'delete_comment\'); jQuery(\'#comment_id\').val(cid); jQuery(\'#frmComments\').submit(); return true; } return false; } </script>'; $output .= '<div id="commentsLink"><a href="javascript:void(0);" onclick="javascript:jQuery(\'#commentsWrapper\').slideToggle(\'fast\');">' . str_replace('_COUNT_', $total_comments, _COMMENTS_LINK) . '</a><br /><br /></div>'; $output .= '<div id="commentsWrapper" style="display:' . ($init_state == 'opened' ? '' : 'none') . ';">'; $output .= '<div id="commentsPublished">'; if ($result[1] > 0) { for ($i = 0; $i < $result[1]; $i++) { $output .= '<div class="comment">'; $output .= '<div class="comment_user_name"><b>' . $result[0][$i]['user_name'] . '</b> ' . _SAID . '...</div>'; $output .= '<div class="comment_test">' . $result[0][$i]['comment_text'] . '</div>'; $output .= '<div class="comment_date">'; if ($result[0][$i]['user_id'] == $objLogin->GetLoggedID() && floor(time_diff(date('Y-m-d H:i:s'), $result[0][$i]['date_published']) / 60) < $delete_pending_time) { $output .= '<img src="images/published_x.gif" alt="" style="cursor:pointer;margin-bottom:-3px;margin-right:3px;" onclick="deleteComment(\'' . $result[0][$i]['id'] . '\');">'; } $output .= '<i>' . _PUBLISHED . ': ' . format_datetime($result[0][$i]['date_published']) . '</i></div>'; $output .= '</div>'; } // draw pagination links if ($total_pages > 1) { $output .= '<div class="paging">'; for ($page_ind = 1; $page_ind <= $total_pages; $page_ind++) { $output .= prepare_permanent_link('index.php?page=' . Application::Get('page') . '&pid=' . Application::Get('page_id') . '&p=' . $page_ind, $page_ind == $current_page ? '<b>[' . $page_ind . ']</b>' : $page_ind, '', 'paging_link') . ' '; } $output .= '</div>'; } } else { $output .= '<div class="comment">'; $output .= '<b>' . _NO_COMMENTS_YET . '</b><br /><br />'; $output .= '</div>'; } $output .= '</div>'; $output .= $msg != '' ? $msg . '<br />' : ''; if ($user_type == 'registered' && !$objLogin->IsLoggedInAs($this->user_type_name)) { $output .= draw_message(_POST_COM_REGISTERED_ALERT, false); } else { $output .= $this->DrawCommentsForm($article_id, $image_verification, $focus_field, $task_completed, false); } $output .= '</div>'; if ($draw) { echo $output; } else { return $output; } }
/** * Draws registration form * @param $news_id * @param $event_title * @param $draw */ public function DrawRegistrationForm($news_id = '0', $event_title = '', $draw = true) { if (!$news_id) { return ''; } global $objSettings, $objLogin; $lang = Application::Get('lang'); $focus_element = 'first_name'; // post fields $task = isset($_POST['task']) ? prepare_input($_POST['task']) : ''; $event_id = isset($_POST['event_id']) ? (int) $_POST['event_id'] : '0'; $first_name = isset($_POST['first_name']) ? prepare_input($_POST['first_name']) : ''; $last_name = isset($_POST['last_name']) ? prepare_input($_POST['last_name']) : ''; $email = isset($_POST['email']) ? prepare_input($_POST['email']) : ''; $phone = isset($_POST['phone']) ? prepare_input($_POST['phone']) : ''; $message = isset($_POST['message']) ? substr(prepare_input($_POST['message']), 0, 2048) : ''; $captcha_code = isset($_POST['captcha_code']) ? prepare_input($_POST['captcha_code']) : ''; $admin_email = $objSettings->GetParameter('admin_email'); $msg = ''; if ($task == 'register_to_event') { include_once 'modules/captcha/securimage.php'; $objImg = new Securimage(); if ($first_name == '') { $msg = draw_important_message(_FIRST_NAME_EMPTY_ALERT, false); $focus_element = 'first_name'; } else { if ($last_name == '') { $msg = draw_important_message(_LAST_NAME_EMPTY_ALERT, false); $focus_element = 'last_name'; } else { if ($email == '') { $msg = draw_important_message(_EMAIL_EMPTY_ALERT, false); $focus_element = 'email'; } else { if ($email != '' && !check_email_address($email)) { $msg = draw_important_message(_EMAIL_VALID_ALERT, false); $focus_element = 'email'; } else { if ($phone == '') { $msg = draw_important_message(str_replace('_FIELD_', _PHONE, _FIELD_CANNOT_BE_EMPTY), false); $focus_element = 'phone'; } else { if (!$objImg->check($captcha_code)) { $msg = draw_important_message(_WRONG_CODE_ALERT, false); $focus_element = 'captcha_code'; } else { $sql = 'SELECT * FROM ' . TABLE_EVENTS_REGISTERED . ' WHERE event_id = \'' . (int) $event_id . '\' AND email = \'' . $email . '\''; if (database_query($sql, ROWS_ONLY, FIRST_ROW_ONLY) > 0) { $msg = draw_important_message(_EVENT_USER_ALREADY_REGISTERED, false); } } } } } } } // deny all operations in demo version if (strtolower(SITE_MODE) == 'demo') { $msg = draw_important_message(_OPERATION_BLOCKED, false); } if ($msg == '') { if ($objLogin->IpAddressBlocked(get_current_ip())) { $msg = draw_important_message(_IP_ADDRESS_BLOCKED, false); } else { if ($objLogin->EmailBlocked($email)) { $msg = draw_important_message(_EMAIL_BLOCKED, false); } else { $sql = 'INSERT INTO ' . TABLE_EVENTS_REGISTERED . ' (id, event_id, first_name, last_name, email, phone, message, date_registered) VALUES (NULL, ' . (int) $event_id . ', \'' . encode_text($first_name) . '\', \'' . encode_text($last_name) . '\', \'' . encode_text($email) . '\', \'' . encode_text($phone) . '\', \'' . encode_text($message) . '\', \'' . @date('Y-m-d H:i:s') . '\')'; if (database_void_query($sql)) { $msg = draw_success_message(_EVENT_REGISTRATION_COMPLETED, false); //////////////////////////////////////////////////////////// send_email($email, $admin_email, 'events_new_registration', array('{FIRST NAME}' => $first_name, '{LAST NAME}' => $last_name, '{EVENT}' => '<b>' . $event_title . '</b>'), '', $admin_email, 'Events - new user was registered (admin copy)'); //////////////////////////////////////////////////////////// $first_name = $last_name = $email = $phone = $message = ''; } else { ///echo mysql_error(); $msg = draw_important_message(_TRY_LATER, false); } } } } } $output = ' ' . ($msg != '' ? $msg : '') . '<br /> <fieldset style="border:1px solid #cccccc;padding-left:10px;margin:0px 12px 12px 12px;"> <legend><b>' . _REGISTRATION_FORM . '</b></legend> <form method="post" name="frmEventRegistration" id="frmEventRegistration"> ' . draw_hidden_field('task', 'register_to_event', false) . ' ' . draw_hidden_field('event_id', $news_id, false) . ' ' . draw_token_field(false); $output .= ' <table cellspacing="1" cellpadding="2" border="0" width="100%"> <tbody> <tr> <td width="25%" align="' . Application::Get('defined_right') . '">' . _FIRST_NAME . ':</td> <td><span class="mandatory_star">*</span></td> <td nowrap="nowrap" align="' . Application::Get('defined_left') . '"><input type="text" id="first_name" name="first_name" size="34" maxlength="32" value="' . decode_text($first_name) . '" autocomplete="off" /></td> </tr> <tr> <td align="' . Application::Get('defined_right') . '">' . _LAST_NAME . ':</td> <td><span class="mandatory_star">*</span></td> <td nowrap="nowrap" align="' . Application::Get('defined_left') . '"><input type="text" id="last_name" name="last_name" size="34" maxlength="32" value="' . decode_text($last_name) . '" autocomplete="off" /></td> </tr> <tr> <td align="' . Application::Get('defined_right') . '">' . _EMAIL_ADDRESS . ':</td> <td><span class="mandatory_star">*</span></td> <td nowrap="nowrap" align="' . Application::Get('defined_left') . '"><input type="text" id="email" name="email" size="34" maxlength="70" value="' . decode_text($email) . '" autocomplete="off" /></td> </tr> <tr> <td align="' . Application::Get('defined_right') . '">' . _PHONE . ':</td> <td><span class="mandatory_star">*</span></td> <td nowrap="nowrap" align="' . Application::Get('defined_left') . '"><input type="text" id="phone" name="phone" size="22" maxlength="32" value="' . decode_text($phone) . '" autocomplete="off" /></td> </tr> <tr valign="top"> <td align="' . Application::Get('defined_right') . '">' . _MESSAGE . ':</td> <td></td> <td nowrap="nowrap" align="' . Application::Get('defined_left') . '"> <textarea id="message" name="message" style="width:390px;" rows="4" maxlength="2048">' . $message . '</textarea> </td> </tr> <tr> <td colspan="2"></td> <td colspan="2">'; $output .= '<table border="0" cellspacing="2" cellpadding="2"> <tr> <td> <img id="captcha_image" src="modules/captcha/securimage_show.php?sid=' . md5(uniqid(time())) . '" /> </td> <td> <img style="cursor:pointer; padding:0px; margin:0px;" id="captcha_image_reload" src="modules/captcha/images/refresh.gif" style="cursor:pointer;" onclick="document.getElementById(\'captcha_image\').src = \'modules/captcha/securimage_show.php?sid=\' + Math.random(); appSetFocus(\'captcha_code\'); return false" title="' . _REFRESH . '" alt="' . _REFRESH . '" /><br /> <a href="modules/captcha/securimage_play.php"><img border="0" style="padding:0px; margin:0px;" id="captcha_image_play" src="modules/captcha/images/audio_icon.gif" title="' . _PLAY . '" alt="' . _PLAY . '" /></a> </td> <td> ' . _TYPE_CHARS . '<br /> <input type="text" name="captcha_code" id="captcha_code" style="width:175px;margin-top:5px;" value="" maxlength="20" autocomplete="off" /> </td> </tr> </table>'; $output .= '</td> </tr> <tr><td height="20" colspan="3"> </td></tr> <tr> <td colspan="3" align="center"> <input type="submit" class="form_button" name="btnSubmitPD" id="btnSubmitPD" value=" ' . _SEND . ' "> </td> </tr> <tr><td colspan="3"> </td></tr> </table> </form> </form> </fieldset>'; if ($focus_element != '') { $output .= '<script type="text/javascript">appSetFocus(\'' . $focus_element . '\');</script>'; } if ($draw) { echo $output; } else { return $output; } }
function __construct() { parent::__construct(); $this->params = array(); if (isset($_POST['group_id'])) { $this->params['group_id'] = (int) prepare_input($_POST['group_id']); } if (isset($_POST['first_name'])) { $this->params['first_name'] = prepare_input($_POST['first_name']); } if (isset($_POST['last_name'])) { $this->params['last_name'] = prepare_input($_POST['last_name']); } if (isset($_POST['birth_date']) && $_POST['birth_date'] != '') { $this->params['birth_date'] = prepare_input($_POST['birth_date']); } else { $this->params['birth_date'] = '0000-00-00'; } if (isset($_POST['company'])) { $this->params['company'] = prepare_input($_POST['company']); } if (isset($_POST['b_address'])) { $this->params['b_address'] = prepare_input($_POST['b_address']); } if (isset($_POST['b_address_2'])) { $this->params['b_address_2'] = prepare_input($_POST['b_address_2']); } if (isset($_POST['b_city'])) { $this->params['b_city'] = prepare_input($_POST['b_city']); } if (isset($_POST['b_state'])) { $this->params['b_state'] = prepare_input($_POST['b_state']); } if (isset($_POST['b_country'])) { $this->params['b_country'] = prepare_input($_POST['b_country']); } if (isset($_POST['b_zipcode'])) { $this->params['b_zipcode'] = prepare_input($_POST['b_zipcode']); } if (isset($_POST['phone'])) { $this->params['phone'] = prepare_input($_POST['phone']); } if (isset($_POST['fax'])) { $this->params['fax'] = prepare_input($_POST['fax']); } if (isset($_POST['email'])) { $this->params['email'] = prepare_input($_POST['email']); } if (isset($_POST['url'])) { $this->params['url'] = prepare_input($_POST['url'], false, 'medium'); } if (isset($_POST['user_name'])) { $this->params['user_name'] = prepare_input($_POST['user_name']); } if (isset($_POST['user_password'])) { $this->params['user_password'] = prepare_input($_POST['user_password']); } if (isset($_POST['preferred_language'])) { $this->params['preferred_language'] = prepare_input($_POST['preferred_language']); } if (isset($_POST['date_created'])) { $this->params['date_created'] = prepare_input($_POST['date_created']); } if (isset($_POST['date_lastlogin'])) { $this->params['date_lastlogin'] = prepare_input($_POST['date_lastlogin']); } if (isset($_POST['registered_from_ip'])) { $this->params['registered_from_ip'] = prepare_input($_POST['registered_from_ip']); } if (isset($_POST['last_logged_ip'])) { $this->params['last_logged_ip'] = prepare_input($_POST['last_logged_ip']); } if (isset($_POST['email_notifications'])) { $this->params['email_notifications'] = prepare_input($_POST['email_notifications']); } else { $this->params['email_notifications'] = '0'; } if (isset($_POST['notification_status_changed'])) { $this->params['notification_status_changed'] = prepare_input($_POST['notification_status_changed']); } if (isset($_POST['is_active'])) { $this->params['is_active'] = (int) $_POST['is_active']; } else { $this->params['is_active'] = '0'; } if (isset($_POST['is_removed'])) { $this->params['is_removed'] = (int) $_POST['is_removed']; } else { $this->params['is_removed'] = '0'; } if (isset($_POST['comments'])) { $this->params['comments'] = prepare_input($_POST['comments']); } if (isset($_POST['registration_code'])) { $this->params['registration_code'] = prepare_input($_POST['registration_code']); } if (isset($_POST['plan1_listings'])) { $this->params['plan1_listings'] = prepare_input($_POST['plan1_listings']); } if (isset($_POST['plan2_listings'])) { $this->params['plan2_listings'] = prepare_input($_POST['plan2_listings']); } if (isset($_POST['plan3_listings'])) { $this->params['plan3_listings'] = prepare_input($_POST['plan3_listings']); } if (isset($_POST['plan4_listings'])) { $this->params['plan4_listings'] = prepare_input($_POST['plan4_listings']); } $rid = MicroGrid::GetParameter('rid'); $action = MicroGrid::GetParameter('action'); $this->email_notifications = ''; $this->user_password = ''; $this->allow_adding_by_admin = ModulesSettings::Get('customers', 'allow_adding_by_admin'); $this->allow_changing_password = ModulesSettings::Get('customers', 'password_changing_by_admin'); $this->reg_confirmation = ModulesSettings::Get('customers', 'reg_confirmation'); $allow_adding = $this->allow_adding_by_admin == 'yes' ? true : false; $this->primaryKey = 'id'; $this->tableName = TABLE_CUSTOMERS; $this->dataSet = array(); $this->error = ''; ///$this->languageId = (isset($_REQUEST['language_id']) && $_REQUEST['language_id'] != '') ? $_REQUEST['language_id'] : Languages::GetDefaultLang(); $this->formActionURL = 'index.php?admin=mod_customers_management'; $this->actions = array('add' => $allow_adding, 'edit' => true, 'details' => true, 'delete' => true); $this->actionIcons = true; $this->allowRefresh = true; $this->allowTopButtons = true; $this->allowLanguages = false; $this->WHERE_CLAUSE = ''; $this->ORDER_CLAUSE = 'ORDER BY id DESC'; $this->isAlterColorsAllowed = true; $this->isPagingAllowed = true; $this->pageSize = 20; $this->isSortingAllowed = true; $total_countries = Countries::GetAllCountries('priority_order DESC, name ASC'); $arr_countries = array(); foreach ($total_countries[0] as $key => $val) { $arr_countries[$val['abbrv']] = $val['name']; } // prepare plans array $total_plans = AdvertisePlans::GetAllPlans(); $arr_plans = array(); foreach ($total_plans[0] as $key => $val) { $arr_plans[$val['id']] = $val['plan_name']; } // prepare groups array $total_groups = CustomerGroups::GetAllGroups(); $arr_groups = array(); foreach ($total_groups[0] as $key => $val) { $arr_groups[$val['id']] = $val['name']; } // prepare languages array $total_languages = Languages::GetAllActive(); $arr_languages = array(); foreach ($total_languages[0] as $key => $val) { $arr_languages[$val['abbreviation']] = $val['lang_name']; } $this->isFilteringAllowed = true; // define filtering fields $this->arrFilteringFields = array(_FIRST_NAME => array('table' => 'c', 'field' => 'first_name', 'type' => 'text', 'sign' => 'like%', 'width' => '80px'), _LAST_NAME => array('table' => 'c', 'field' => 'last_name', 'type' => 'text', 'sign' => 'like%', 'width' => '80px'), _EMAIL => array('table' => 'c', 'field' => 'email', 'type' => 'text', 'sign' => 'like%', 'width' => '90px'), _ACTIVE => array('table' => 'c', 'field' => 'is_active', 'type' => 'dropdownlist', 'source' => array('0' => _NO, '1' => _YES), 'sign' => '=', 'width' => '85px'), _GROUP => array('table' => 'c', 'field' => 'group_id', 'type' => 'dropdownlist', 'source' => $arr_groups, 'sign' => '=', 'width' => '85px')); $customer_ip = get_current_ip(); $datetime_format = get_datetime_format(); $date_format_view = get_date_format('view'); $date_format_edit = get_date_format('edit'); $default_plan_info = AdvertisePlans::GetDefaultPlanInfo(); $default_plan_id = isset($default_plan_info['id']) ? (int) $default_plan_info['id'] : 0; $default_plan_lc = isset($default_plan_info['listings_count']) ? (int) $default_plan_info['listings_count'] : 0; //---------------------------------------------------------------------- // VIEW MODE //---------------------------------------------------------------------- $this->VIEW_MODE_SQL = 'SELECT c.' . $this->primaryKey . ', c.*, CONCAT(c.first_name, " ", c.last_name) as full_name, IF(c.is_active, "<span class=yes>' . _YES . '</span>", "<span class=no>' . _NO . '</span>") as customer_active, cg.name as group_name FROM ' . $this->tableName . ' c LEFT OUTER JOIN ' . TABLE_CUSTOMER_GROUPS . ' cg ON c.group_id = cg.id '; // define view mode fields $this->arrViewModeFields = array('full_name' => array('title' => _NAME, 'type' => 'label', 'align' => 'left', 'width' => '', 'maxlength' => '20'), 'user_name' => array('title' => _USERNAME, 'type' => 'label', 'align' => 'left', 'width' => '', 'maxlength' => '20'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'link', 'href' => 'mailto:{email}', 'align' => 'left', 'width' => '', 'maxlength' => '36'), 'b_country' => array('title' => _COUNTRY, 'type' => 'enum', 'align' => 'left', 'width' => '', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'source' => $arr_countries), 'customer_active' => array('title' => _ACTIVE, 'type' => 'label', 'align' => 'center', 'width' => '90px'), 'group_name' => array('title' => _GROUP, 'type' => 'label', 'align' => 'left', 'width' => '90px'), 'id' => array('title' => 'ID', 'type' => 'label', 'align' => 'center', 'width' => '50px')); //---------------------------------------------------------------------- // ADD MODE //---------------------------------------------------------------------- // define add mode fields $this->arrAddModeFields = array('separator_1' => array('separator_info' => array('legend' => _PERSONAL_DETAILS), 'first_name' => array('title' => _FIRST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'last_name' => array('title' => _LAST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'birth_date' => array('title' => _BIRTH_DATE, 'type' => 'date', 'width' => '210px', 'required' => false, 'readonly' => false, 'default' => '', 'validation_type' => 'date', 'unique' => false, 'visible' => true, 'min_year' => '90', 'max_year' => '0', 'format' => 'date', 'format_parameter' => $date_format_edit), 'url' => array('title' => _URL, 'type' => 'textbox', 'width' => '270px', 'required' => false, 'maxlength' => '255', 'validation_type' => 'text')), 'separator_2' => array('separator_info' => array('legend' => _BILLING_ADDRESS), 'company' => array('title' => _COMPANY, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '128', 'validation_type' => 'text'), 'b_address' => array('title' => _ADDRESS, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text'), 'b_address_2' => array('title' => _ADDRESS_2, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '64', 'validation_type' => 'text'), 'b_city' => array('title' => _CITY, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text'), 'b_zipcode' => array('title' => _ZIP_CODE, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'b_country' => array('title' => _COUNTRY, 'type' => 'enum', 'width' => '', 'source' => $arr_countries, 'required' => true), 'b_state' => array('title' => _STATE_PROVINCE, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text')), 'separator_3' => array('separator_info' => array('legend' => _CONTACT_INFORMATION), 'phone' => array('title' => _PHONE, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '32', 'validation_type' => 'text'), 'fax' => array('title' => _FAX, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '32', 'validation_type' => 'text'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'textbox', 'width' => '230px', 'required' => false, 'maxlength' => '70', 'validation_type' => 'email', 'unique' => true, 'autocomplete' => 'off')), 'separator_4' => array('separator_info' => array('legend' => _ACCOUNT_DETAILS), 'user_name' => array('title' => _USERNAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'validation_type' => 'text', 'maxlength' => '32', 'validation_minlength' => '4', 'readonly' => false, 'unique' => true), 'user_password' => array('title' => _PASSWORD, 'type' => 'password', 'width' => '210px', 'required' => true, 'validation_type' => 'password', 'maxlength' => '20', 'cryptography' => PASSWORDS_ENCRYPTION, 'cryptography_type' => PASSWORDS_ENCRYPTION_TYPE, 'aes_password' => PASSWORDS_ENCRYPT_KEY), 'group_id' => array('title' => _CUSTOMER_GROUP, 'type' => 'enum', 'required' => false, 'readonly' => false, 'width' => '', 'source' => $arr_groups), 'preferred_language' => array('title' => _PREFERRED_LANGUAGE, 'type' => 'enum', 'required' => true, 'readonly' => false, 'width' => '120px', 'default' => Application::Get('lang'), 'source' => $arr_languages)), 'separator_5' => array('separator_info' => array('legend' => _OTHER), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => date('Y-m-d H:i:s')), 'registered_from_ip' => array('title' => _REGISTERED_FROM_IP, 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $customer_ip), 'last_logged_ip' => array('title' => _LAST_LOGGED_IP, 'type' => 'hidden', 'width' => '210px', 'required' => false, 'default' => ''), 'email_notifications' => array('title' => _EMAIL_NOTIFICATION, 'type' => 'checkbox', 'true_value' => '1', 'false_value' => '0'), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'readonly' => false, 'default' => '1', 'true_value' => '1', 'false_value' => '0', 'unique' => false), 'is_removed' => array('title' => _REMOVED, 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => '0'), 'comments' => array('title' => _COMMENTS, 'type' => 'textarea', 'width' => '420px', 'height' => '70px', 'required' => false, 'readonly' => false, 'validation_type' => 'text', 'validation_maxlength' => '2048'), 'registration_code' => array('title' => _REGISTRATION_CODE, 'type' => 'hidden', 'width' => '210px', 'required' => false, 'default' => ''), 'plan1_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[1], 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $default_plan_id == '1' ? (int) $default_plan_lc : '0'), 'plan2_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[2], 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $default_plan_id == '2' ? (int) $default_plan_lc : '0'), 'plan3_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[3], 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $default_plan_id == '3' ? (int) $default_plan_lc : '0'), 'plan4_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[4], 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $default_plan_id == '4' ? (int) $default_plan_lc : '0'))); //---------------------------------------------------------------------- // EDIT MODE // * password field must be written directly in SQL!!! //---------------------------------------------------------------------- $this->EDIT_MODE_SQL = 'SELECT ' . $this->tableName . '.' . $this->primaryKey . ', ' . $this->tableName . '.*, ' . $this->tableName . '.user_password, ' . $this->tableName . '.date_created, ' . $this->tableName . '.date_lastlogin, ' . $this->tableName . '.notification_status_changed FROM ' . $this->tableName . ' WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_'; // define edit mode fields $this->arrEditModeFields = array('separator_1' => array('separator_info' => array('legend' => _PERSONAL_DETAILS), 'first_name' => array('title' => _FIRST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'last_name' => array('title' => _LAST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'birth_date' => array('title' => _BIRTH_DATE, 'type' => 'date', 'width' => '210px', 'required' => false, 'readonly' => false, 'default' => '', 'validation_type' => 'date', 'unique' => false, 'visible' => true, 'min_year' => '90', 'max_year' => '0', 'format' => 'date', 'format_parameter' => $date_format_edit), 'url' => array('title' => _URL, 'type' => 'textbox', 'width' => '270px', 'required' => false, 'maxlength' => '255', 'validation_type' => 'text')), 'separator_2' => array('separator_info' => array('legend' => _BILLING_ADDRESS), 'company' => array('title' => _COMPANY, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '128', 'validation_type' => 'text'), 'b_address' => array('title' => _ADDRESS, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text'), 'b_address_2' => array('title' => _ADDRESS_2, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '64', 'validation_type' => 'text'), 'b_city' => array('title' => _CITY, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text'), 'b_zipcode' => array('title' => _ZIP_CODE, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'b_country' => array('title' => _COUNTRY, 'type' => 'enum', 'width' => '', 'source' => $arr_countries, 'required' => true), 'b_state' => array('title' => _STATE_PROVINCE, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '64', 'validation_type' => 'text')), 'separator_3' => array('separator_info' => array('legend' => _CONTACT_INFORMATION), 'phone' => array('title' => _PHONE, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '32', 'validation_type' => 'text'), 'fax' => array('title' => _FAX, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '32', 'validation_type' => 'text'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'textbox', 'width' => '230px', 'required' => true, 'maxlength' => '70', 'readonly' => false, 'validation_type' => 'email', 'unique' => true, 'autocomplete' => 'off')), 'separator_4' => array('separator_info' => array('legend' => _ACCOUNT_DETAILS), 'user_name' => array('title' => _USERNAME, 'type' => 'label'), 'user_password' => array('title' => _PASSWORD, 'type' => 'password', 'width' => '210px', 'maxlength' => '20', 'required' => true, 'validation_type' => 'password', 'cryptography' => PASSWORDS_ENCRYPTION, 'cryptography_type' => PASSWORDS_ENCRYPTION_TYPE, 'aes_password' => PASSWORDS_ENCRYPT_KEY, 'visible' => $this->allow_changing_password == 'yes' ? true : false), 'group_id' => array('title' => _CUSTOMER_GROUP, 'type' => 'enum', 'required' => false, 'readonly' => false, 'width' => '', 'source' => $arr_groups), 'preferred_language' => array('title' => _PREFERRED_LANGUAGE, 'type' => 'enum', 'required' => true, 'readonly' => false, 'width' => '120px', 'source' => $arr_languages)), 'separator_5' => array('separator_info' => array('legend' => _OTHER), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'date_lastlogin' => array('title' => _LAST_LOGIN, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'registered_from_ip' => array('title' => _REGISTERED_FROM_IP, 'type' => 'label'), 'last_logged_ip' => array('title' => _LAST_LOGGED_IP, 'type' => 'label'), 'email_notifications' => array('title' => _EMAIL_NOTIFICATION, 'type' => 'checkbox', 'true_value' => '1', 'false_value' => '0'), 'notification_status_changed' => array('title' => _NOTIFICATION_STATUS_CHANGED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'true_value' => '1', 'false_value' => '0'), 'is_removed' => array('title' => _REMOVED, 'type' => 'checkbox', 'true_value' => '1', 'false_value' => '0'), 'comments' => array('title' => _COMMENTS, 'type' => 'textarea', 'width' => '420px', 'height' => '70px', 'required' => false, 'readonly' => false, 'validation_type' => 'text', 'validation_maxlength' => '2048'), 'registration_code' => array('title' => _REGISTRATION_CODE, 'type' => 'hidden', 'width' => '210px', 'required' => false, 'default' => '')), 'separator_6' => array('separator_info' => array('legend' => _LISTINGS), 'orders_count' => array('title' => _ORDERS_COUNT, 'type' => 'label'), 'plan1_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[1], 'type' => 'label'), 'plan2_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[2], 'type' => 'label'), 'plan3_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[3], 'type' => 'label'), 'plan4_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[4], 'type' => 'label'))); //---------------------------------------------------------------------- // DETAILS MODE //---------------------------------------------------------------------- $this->DETAILS_MODE_SQL = 'SELECT c.' . $this->primaryKey . ', c.*, IF(c.email_notifications, "<span class=yes>' . _YES . '</span>", "<span class=no>' . _NO . '</span>") as email_notifications, IF(c.is_active, "<span class=yes>' . _YES . '</span>", "<span class=no>' . _NO . '</span>") as customer_active, IF(c.is_removed, "<span class=yes>' . _YES . '</span>", "<span class=no>' . _NO . '</span>") as customer_removed, c.date_created, c.date_lastlogin, c.notification_status_changed, cg.name as group_name FROM ' . $this->tableName . ' c LEFT OUTER JOIN ' . TABLE_CUSTOMER_GROUPS . ' cg ON c.group_id = cg.id WHERE c.' . $this->primaryKey . ' = _RID_'; $this->arrDetailsModeFields = array('separator_1' => array('separator_info' => array('legend' => _PERSONAL_DETAILS), 'first_name' => array('title' => _FIRST_NAME, 'type' => 'label'), 'last_name' => array('title' => _LAST_NAME, 'type' => 'label'), 'birth_date' => array('title' => _BIRTH_DATE, 'type' => 'date', 'format' => 'date', 'format_parameter' => $date_format_view), 'url' => array('title' => _URL, 'type' => 'label')), 'separator_2' => array('separator_info' => array('legend' => _BILLING_ADDRESS), 'company' => array('title' => _COMPANY, 'type' => 'label'), 'b_address' => array('title' => _ADDRESS, 'type' => 'label'), 'b_address_2' => array('title' => _ADDRESS_2, 'type' => 'label'), 'b_city' => array('title' => _CITY, 'type' => 'label'), 'b_zipcode' => array('title' => _ZIP_CODE, 'type' => 'label'), 'b_country' => array('title' => _COUNTRY, 'type' => 'enum', 'source' => $arr_countries), 'b_state' => array('title' => _STATE_PROVINCE, 'type' => 'label')), 'separator_3' => array('separator_info' => array('legend' => _CONTACT_INFORMATION), 'phone' => array('title' => _PHONE, 'type' => 'label'), 'fax' => array('title' => _FAX, 'type' => 'label'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'label')), 'separator_4' => array('separator_info' => array('legend' => _ACCOUNT_DETAILS), 'user_name' => array('title' => _USERNAME, 'type' => 'label'), 'group_name' => array('title' => _CUSTOMER_GROUP, 'type' => 'label'), 'preferred_language' => array('title' => _PREFERRED_LANGUAGE, 'type' => 'enum', 'source' => $arr_languages)), 'separator_5' => array('separator_info' => array('legend' => _OTHER), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'date_lastlogin' => array('title' => _LAST_LOGIN, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'registered_from_ip' => array('title' => _REGISTERED_FROM_IP, 'type' => 'label'), 'last_logged_ip' => array('title' => _LAST_LOGGED_IP, 'type' => 'label'), 'email_notifications' => array('title' => _EMAIL_NOTIFICATION, 'type' => 'label'), 'notification_status_changed' => array('title' => _NOTIFICATION_STATUS_CHANGED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'customer_active' => array('title' => _ACTIVE, 'type' => 'label'), 'customer_removed' => array('title' => _REMOVED, 'type' => 'label'), 'comments' => array('title' => _COMMENTS, 'type' => 'label')), 'separator_6' => array('separator_info' => array('legend' => _LISTINGS), 'orders_count' => array('title' => _ORDERS_COUNT, 'type' => 'label'), 'plan1_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[1], 'type' => 'label'), 'plan2_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[2], 'type' => 'label'), 'plan3_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[3], 'type' => 'label'), 'plan4_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[4], 'type' => 'label'))); }
$company = isset($_POST['company']) ? prepare_input($_POST['company']) : ''; $b_address = isset($_POST['b_address']) ? prepare_input($_POST['b_address']) : ''; $b_address_2 = isset($_POST['b_address_2']) ? prepare_input($_POST['b_address_2']) : ''; $b_city = isset($_POST['b_city']) ? prepare_input($_POST['b_city']) : ''; $b_zipcode = isset($_POST['b_zipcode']) ? prepare_input($_POST['b_zipcode']) : ''; $b_country = isset($_POST['b_country']) ? prepare_input($_POST['b_country']) : ''; $b_state = isset($_POST['b_state']) ? prepare_input($_POST['b_state']) : ''; $phone = isset($_POST['phone']) ? prepare_input($_POST['phone']) : ''; $fax = isset($_POST['fax']) ? prepare_input($_POST['fax']) : ''; $email = isset($_POST['email']) ? prepare_input($_POST['email']) : ''; $url = isset($_POST['url']) ? prepare_input($_POST['url'], false, 'medium') : ''; $user_name = isset($_POST['user_name']) ? prepare_input($_POST['user_name']) : ''; $user_password1 = isset($_POST['user_password1']) ? prepare_input($_POST['user_password1']) : ''; $user_password2 = isset($_POST['user_password2']) ? prepare_input($_POST['user_password2']) : ''; $agree = isset($_POST['agree']) ? prepare_input($_POST['agree']) : ''; $user_ip = get_current_ip(); $focus_field = ''; $reg_confirmation = ModulesSettings::Get('customers', 'reg_confirmation'); $image_verification_allow = ModulesSettings::Get('customers', 'image_verification_allow'); $admin_alert_new_registration = ModulesSettings::Get('customers', 'admin_alert_new_registration'); $msg_default = draw_message(_ACCOUNT_CREATE_MSG, false); $msg = ''; $account_created = false; if ($act == 'create') { $captcha_code = isset($_POST['captcha_code']) ? prepare_input($_POST['captcha_code']) : ''; if ($first_name == '') { $msg = draw_important_message(_FIRST_NAME_EMPTY_ALERT, false); $focus_field = 'first_name'; } else { if ($last_name == '') { $msg = draw_important_message(_LAST_NAME_EMPTY_ALERT, false);