/** * 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; } }
$params['tag_keywords'] = prepare_input($_POST['tag_keywords']); } if (isset($_POST['tag_description'])) { $params['tag_description'] = prepare_input($_POST['tag_description']); } if (isset($_POST['page_title'])) { $params['page_title'] = prepare_input($_POST['page_title']); } if (isset($_POST['page_text'])) { $params['page_text'] = prepare_input($_POST['page_text'], false, 'low'); } if (isset($_POST['menu_link'])) { $params['menu_link'] = prepare_input($_POST['menu_link']); } $params['menu_id'] = isset($_POST['menu_id']) ? prepare_input($_POST['menu_id']) : '0'; $params['page_key'] = create_seo_url(prepare_input($_POST['page_title'])); $params['language_id'] = isset($_POST['language_id']) ? prepare_input($_POST['language_id']) : ''; $params['finish_publishing'] = isset($_POST['finish_publishing']) && check_date($_POST['finish_publishing']) ? prepare_input($_POST['finish_publishing']) : '0000-00-00'; if ($objPage->PageCreate($params, $copy_to_other_langs)) { $msg = draw_success_message(_PAGE_CREATED, false); $objSession->SetMessage('notice', $msg); header('location: index.php?admin=pages' . (Application::Get('type') != '' ? '&type=' . Application::Get('type') : '') . '&mg_language_id=' . $params['language_id']); exit; } else { $msg = draw_important_message($objPage->error, false); } } if ($msg == '') { $msg = draw_message(_ALERT_REQUIRED_FILEDS, false); } }
/** * Draws listings in category * @param $category_id * @param $draw */ public function DrawListings($category_id, $draw = true) { global $objLogin, $objSettings; $lang = Application::Get('lang'); $nl = "\n"; if (empty($lang)) { $lang = Languages::GetDefaultLang(); } $listings_locations = isset($_REQUEST['listings_locations']) ? prepare_input($_REQUEST['listings_locations']) : ''; $listings_sub_locations = isset($_REQUEST['listings_sub_locations']) ? prepare_input($_REQUEST['listings_sub_locations']) : ''; $listings_sort_by = isset($_REQUEST['listings_sort_by']) && $_REQUEST['listings_sort_by'] != '' ? prepare_input($_REQUEST['listings_sort_by']) : 'rating'; $listings_order_by = isset($_REQUEST['listings_order_by']) && $_REQUEST['listings_order_by'] != '' ? prepare_input($_REQUEST['listings_order_by']) : 'ASC'; $sort_by = ''; $order_by = ''; $output = ''; if ($listings_sort_by == 'name') { $sort_by = 'ld.business_name'; $order_by = $listings_order_by; } else { if ($listings_sort_by == 'date') { $sort_by = 'l.date_published'; $order_by = $listings_order_by; } else { if ($listings_sort_by == 'rating') { // rating according to advertising plans high rate = high advertising plan $sort_by = 'l.advertise_plan_id'; $order_by = ($listings_order_by == 'ASC' ? 'DESC' : 'ASC') . ', RAND()'; } else { $sort_by = 'l.priority_order'; $order_by = $listings_order_by; } } } if (!Application::Get('js_included', 'lytebox')) { $output .= '<!-- LyteBox v3.22 Author: Markus F. Hay Website: http://www.dolem.com/lytebox -->' . $nl; $output .= '<link rel="stylesheet" href="modules/lytebox/css/lytebox.css" type="text/css" media="screen" />' . $nl; $output .= '<script type="text/javascript" src="modules/lytebox/js/lytebox.js"></script>' . $nl; } // draw category description $category_info = Categories::GetCategoryInfo($category_id); if ($category_info['description'] != '') { $output .= draw_message($category_info['description'], false); } // draw result $sql_from = TABLE_LISTINGS . ' l INNER JOIN ' . TABLE_LISTINGS_DESCRIPTION . ' ld ON l.id = ld.listing_id INNER JOIN ' . TABLE_LISTINGS_LOCATIONS . ' ll ON l.listing_location_id = ll.id WHERE ' . (!empty($listings_locations) ? 'l.listing_location_id = \'' . $listings_locations . '\' AND ' : '') . ' ' . (!empty($listings_sub_locations) ? 'l.listing_sub_location_id = \'' . $listings_sub_locations . '\' AND ' : '') . ' ' . (!$objLogin->IsLoggedIn() ? 'l.access_level=\'public\' AND ' : '') . ' l.is_published = 1 AND ' . ($this->show_expired_listings != 'yes' ? ' ((l.finish_publishing = \'0000-00-00 00:00:00\') OR (l.finish_publishing > \'' . date('Y-m-d H:i:s') . '\')) AND ' : '') . ' ld.language_id = \'' . $lang . '\' ' . ($category_id != '' ? ' AND l.id IN (SELECT listing_id FROM ' . TABLE_LISTINGS_CATEGORIES . ' lc WHERE category_id = ' . (int) $category_id . ')' : '') . ' ORDER BY ' . $sort_by . ' ' . $order_by; // pagination prepare $page_size = ModulesSettings::Get('listings', 'listings_per_page'); $start_row = '0'; $total_pages = '1'; pagination_prepare($page_size, $sql_from, $start_row, $total_pages); $sql = 'SELECT l.id, l.image_file, l.image_file_thumb, l.priority_order, l.date_published, l.website_url, l.business_email, l.advertise_plan_id, ll.name as listing_location_name, ld.language_id, ld.business_name, ld.business_address, ld.business_description FROM ' . $sql_from . ' LIMIT ' . $start_row . ', ' . $page_size; $result = database_query($sql, DATA_AND_ROWS, ALL_ROWS); if ($result[1] > 0 || !empty($listings_locations)) { $output .= '<form id="frmCategoryView" action="index.php?page=category&cid=' . $category_id . '" method="post">'; $output .= draw_token_field(false); $output .= draw_hidden_field('p', '1', false); $output .= '<table width="98%" border="0" align="center">'; $output .= '<tr><th colspan="3" nowrap="nowrap" height="5px"></th></tr>'; $output .= '<tr><th colspan="2" align="' . Application::Get('defined_left') . '" valign="middle">'; $output .= ' ' . _FILTER_BY . ': '; $output .= ListingsLocations::DrawAllLocations(array('tag_name' => 'listings_locations', 'selected_value' => $listings_locations, 'javascript_event' => 'onchange="jQuery(\'#frmCategoryView\').submit();"'), false) . ' '; $output .= ListingsSubLocations::DrawAllSubLocations($listings_locations, array('tag_name' => 'listings_sub_locations', 'selected_value' => $listings_sub_locations, 'javascript_event' => 'onchange="jQuery(\'#frmCategoryView\').submit();"'), false); $output .= '</th>'; $output .= '<th colspan="2" align="' . Application::Get('defined_right') . '" valign="middle">'; $output .= _SORT_BY . ': <select name="listings_sort_by" onchange="jQuery(\'#frmCategoryView\').submit();"> <option value="rating" ' . ($listings_sort_by == 'rating' ? ' selected="selected"' : '') . '>' . _RATING . '</option> <option value="name" ' . ($listings_sort_by == 'name' ? ' selected="selected"' : '') . '>' . _NAME . '</option> <option value="date" ' . ($listings_sort_by == 'date' ? ' selected="selected"' : '') . '>' . _DATE_PUBLISHED . '</option> </select> <select name="listings_order_by" onchange="jQuery(\'#frmCategoryView\').submit();"> <option value="ASC" ' . ($listings_order_by == 'ASC' ? ' selected="selected"' : '') . '>' . _ASCENDING . '</option> <option value="DESC" ' . ($listings_order_by == 'DESC' ? ' selected="selected"' : '') . '>' . _DESCENDING . '</option> </select> </th> </tr> </table> </form>'; } if ($result[1] > 0) { $output .= '<table width="99%" border="0" align="center">'; $output .= '<tr><th colspan="2" nowrap="nowrap" height="5px"></th></tr> <tr> <th align="' . Application::Get('defined_left') . '"> ' . _LISTINGS . ' </th> <th align="center">' . _IMAGE . '</th> </tr>'; for ($i = 0; $i < $result[1]; $i++) { $image_file = $result[0][$i]['image_file'] != '' ? $result[0][$i]['image_file'] : 'no_image.png'; ///$result[0][$i]['advertise_plan_id'] > 1 && $image_file_thumb = $result[0][$i]['image_file_thumb'] != '' ? $result[0][$i]['image_file_thumb'] : 'no_image.png'; $output .= '<tr><td colspan="2" style="padding:7px;">' . draw_line('no_margin_line', IMAGE_DIRECTORY, false) . '</td></tr> <tr valign="top"> <td>'; $link_1 = prepare_link('listing', 'lid', $result[0][$i]['id'], '', $result[0][$i]['business_name'], '', _CLICK_TO_SEE_DESCR); $link_2 = prepare_link('listing', 'lid', $result[0][$i]['id'], '', _MORE_INFO, '', _CLICK_TO_SEE_DESCR); $output .= '<div class="listing_info">'; $output .= '<div class="header">' . $link_1 . '</div>'; $output .= '<div class="address">' . substr_by_word(strip_tags($result[0][$i]['business_address']), 300, true, Application::Get('lang')) . ' ' . $result[0][$i]['listing_location_name'] . '</div>'; $output .= '<div class="description">' . substr_by_word(strip_tags($result[0][$i]['business_description']), 180, true, Application::Get('lang')) . '</div>'; $output .= '<div class="links"> ' . $link_2 . ' ' . ($result[0][$i]['website_url'] != '' ? ' : <a href="' . $result[0][$i]['website_url'] . '" target="_new">' . _WEBSITE_URL . '</a>' : '') . ' ' . ($result[0][$i]['business_email'] != '' ? ' : <a href="mailto:' . $result[0][$i]['business_email'] . '">' . _EMAIL . '</a>' : '') . ' ' . ($result[0][$i]['date_published'] != '0000-00-00 00:00:00' ? '<div class="published">' . _PUBLISHED . ': ' . format_datetime($result[0][$i]['date_published'], get_datetime_format(false), _UNKNOWN) . '<div>' : '') . ' </div>'; $output .= '</div>'; $output .= ' </td> <td width="130px" align="center"> <div class="listing_icon">'; if ($image_file != 'no_image.png') { $output .= '<a href="images/listings/' . $image_file . '" rel="lyteshow_' . $result[0][$i]['id'] . '">'; } $output .= '<img class="listings_image' . ($image_file == 'no_image.png' ? ' no_hover' : '') . '" src="images/listings/' . $image_file_thumb . '" width="120px" height="90px" title="' . ($image_file != 'no_image.png' ? _CLICK_TO_INCREASE : '') . '" alt="" />'; if ($image_file != 'no_image.png') { $output .= '</a>'; } $output .= ' </div> </td> </tr>'; } // draw pagination links if ($total_pages > 1) { $output .= '<tr><td colspan="2" style="padding:7px;">' . draw_line('no_margin_line', IMAGE_DIRECTORY, false) . '</td></tr>'; } $output .= '<tr><td colspan="2">'; $output .= pagination_get_links($total_pages, ''); $output .= '</td></tr>'; $output .= '<tr><td colspan="2"> </td></tr>'; $output .= '</table>'; } else { // draw message only if this is a last-level empty category $categories = Categories::GetAllActive('c.parent_id = ' . (int) $category_id); if (!$categories[1]) { $output .= draw_message(_NO_LISTINGS_FOUND, false, true); } } if ($draw) { echo $output; } else { return $output; } }
} } } } } if ($mode == 'view' || $mode == 'add') { $objLogin->LoadListings(); } // Start main content draw_title_bar(prepare_breadcrumbs(array(_MY_ACCOUNT => '', _LISTINGS_MANAGEMENT => '', ucfirst($action) => ''))); //if($objSession->IsMessage('notice')) echo $objSession->GetMessage('notice'); if (!empty($msg)) { echo $msg; } else { if (Modules::IsModuleInstalled('payments') && ModulesSettings::Get('payments', 'is_active') == 'yes') { draw_message(str_replace('_LISTINGS_COUNT_', $objLogin->GetAvailableListings(), _AVAILABLE_LISTINGS_ALERT)); } } //draw_content_start(); echo '<div class="pages_contents">'; if ($mode == 'view') { $objListings->DrawViewMode(); } else { if ($mode == 'add') { $objListings->DrawAddMode(); } else { if ($mode == 'edit') { $objListings->DrawEditMode($rid); } else { if ($mode == 'details') { $objListings->DrawDetailsMode($rid);
echo _REMOVE_ACCOUNT_ALERT; ?> ');"> <?php draw_hidden_field('submit', 'remove'); ?> <?php draw_token_field(); ?> <br /> <?php echo $msg; if ($account_deleted) { echo '<script type="text/javascript">setTimeout(function(){appFormSubmit("frmLogout")}, 5000);</script>'; } else { draw_message(_REMOVE_ACCOUNT_WARNING); } ?> <?php if (!$account_deleted) { ?> <table align="center" border="0" cellspacing="1" cellpadding="2" width="98%"> <tr><td colspan="3"> </td></tr> <tr> <td align="left" colspan="2"> <input type="button" class="form_button" value="<?php echo _BUTTON_CANCEL; ?> " onclick="javascript:appGoTo('customer=my_account');" /> </td> <td align="right">
} else { if ($payment_type == '2co') { $title_desc = _2CO_ORDER; } else { if ($payment_type == 'authorize') { $title_desc = _AUTHORIZE_NET_ORDER; } else { $title_desc = _ONLINE_ORDER; } } } if (Modules::IsModuleInstalled('payments') && ModulesSettings::Get('payments', 'is_active') == 'yes') { draw_title_bar(prepare_breadcrumbs(array(_MY_ACCOUNT => '', _ADVERTISE => '', $title_desc => '')), prepare_permanent_link('index.php?customer=advertise', _BUTTON_BACK)); // test mode alert if (ModulesSettings::Get('payments', 'mode') == 'TEST MODE') { draw_message(_TEST_MODE_ALERT_SHORT, true, true); } if ($task == "do_order") { if (AdvertisePlans::DoOrder($payment_type)) { AdvertisePlans::DrawPrepayment(); } else { draw_important_message(AdvertisePlans::$message); } } else { if ($task == "repeat_order") { draw_important_message($msg_text); AdvertisePlans::ReDrawPrepayment(); } else { draw_important_message(_WRONG_PARAMETER_PASSED); } }
public function DrawViewMode() { $this->IncludeJSFunctions(); $this->BeforeViewRecords(); $sorting_fields = self::GetParameter('sorting_fields'); $sorting_types = self::GetParameter('sorting_types'); $page = self::GetParameter('page'); $total_pages = $page; $rid = self::GetParameter('rid'); $action = self::GetParameter('action'); $operation = self::GetParameter('operation'); $operation_type = self::GetParameter('operation_type'); $operation_field = self::GetParameter('operation_field'); $search_status = self::GetParameter('search_status'); $concat_sign = preg_match('/\\?/', $this->formActionURL) ? '&' : '?'; $colspan = count($this->arrViewModeFields) + 1; $start_row = 0; $total_records = 0; $sort_by = ''; $export_content = array(); $calendar_fields = array(); $nl = "\n"; // prepare changing of language //---------------------------------------------------------------------- if ($operation == 'change_language' && $operation_type != '' && strlen($operation_type) == 2) { $this->languageId = $operation_type; // added to prevent search with entered word on changing language $search_status = ''; } // prepare sorting data //---------------------------------------------------------------------- if ($this->isSortingAllowed) { if ($operation == 'sorting') { if ($sorting_fields != '') { if ($action == 'delete') { // $sorting_types } else { if (strtolower($sorting_types) == 'asc') { $sorting_types = 'DESC'; } else { $sorting_types = 'ASC'; } } $sort_type = isset($this->arrViewModeFields[$sorting_fields]['sort_type']) ? $this->arrViewModeFields[$sorting_fields]['sort_type'] : 'string'; $sort_by = isset($this->arrViewModeFields[$sorting_fields]['sort_by']) ? $this->arrViewModeFields[$sorting_fields]['sort_by'] : $sorting_fields; if ($sort_type == 'numeric') { $this->ORDER_CLAUSE = ' ORDER BY ABS(' . $sort_by . ') ' . $sorting_types . ' '; } else { $this->ORDER_CLAUSE = ' ORDER BY ' . $sort_by . ' ' . $sorting_types . ' '; } } else { $sorting_types = 'ASC'; } } else { if ($sorting_fields != '' && $sorting_types != '') { $this->ORDER_CLAUSE = ' ORDER BY ' . $sorting_fields . ' ' . $sorting_types . ' '; } } } // prepare filtering data //---------------------------------------------------------------------- if ($this->isFilteringAllowed) { if ($search_status == 'active') { if ($this->WHERE_CLAUSE == '') { $this->WHERE_CLAUSE .= ' WHERE 1=1 '; } $count = 0; foreach ($this->arrFilteringFields as $key => $val) { $custom_handler = isset($val['custom_handler']) ? $val['custom_handler'] : false; if (!$custom_handler && self::GetParameter('filter_by_' . $val['table'] . $val['field'], false) !== '') { $sign = '='; $sign_start = ''; $sign_end = ''; if ($val['sign'] == '=') { $sign = '='; } else { if ($val['sign'] == '>=') { $sign = '>='; } else { if ($val['sign'] == '<=') { $sign = '<='; } else { if ($val['sign'] == 'like%') { $sign = 'LIKE'; $sign_end = '%'; } else { if ($val['sign'] == '%like') { $sign = 'LIKE'; $sign_start = '%'; } else { if ($val['sign'] == '%like%') { $sign = 'LIKE'; $sign_start = '%'; $sign_end = '%'; } } } } } } $key_value = self::GetParameter('filter_by_' . $val['table'] . $val['field'], false); if (isset($val['table']) && $val['table'] != '') { $field_name = $val['table'] . '.' . $val['field']; } else { $field_name = $val['field']; } $date_format = isset($val['date_format']) ? $val['date_format'] : ''; $type = isset($val['type']) ? $val['type'] : ''; if ($type == 'calendar') { $key_value = $this->PrepareDateTime($key_value, $date_format); } if ($this->IsSecureField($key, $val)) { $field_name = $this->UncryptValue($field_name, $val, false); } $this->WHERE_CLAUSE .= ' AND ' . $field_name . ' ' . $sign . ' \'' . $sign_start . mysql_real_escape_string($key_value) . $sign_end . '\' '; } } } } // prepare paging data //---------------------------------------------------------------------- if ($this->isPagingAllowed) { if (!is_numeric($page) || (int) $page <= 0) { $page = 1; } // set sql_mode to empty if you have Mixing of GROUP columns SQL issue - in connection.php file /// database_void_query('SET sql_mode = ""'); $sql = preg_replace('/SELECT\\b/i', 'SELECT COUNT(*) as mg_total_records, ', $this->VIEW_MODE_SQL, 1) . ' ' . $this->WHERE_CLAUSE . ' LIMIT 0, 1'; if ($this->debug) { $start_time = $this->GetFormattedMicrotime(); } $result = database_query($sql, DATA_AND_ROWS, FIRST_ROW_ONLY); if ($this->debug) { $finish_time = $this->GetFormattedMicrotime(); } $total_records = isset($result[0]['mg_total_records']) ? (int) $result[0]['mg_total_records'] : '1'; if ($this->debug) { if (!mysql_error()) { $this->arrSQLs['total_records_sql'] = '<i>Total Records</i> | T: ' . round((double) $finish_time - (double) $start_time, 4) . ' sec. <br>' . $sql; } else { $this->arrErrors['total_records_sql'] = $sql . '<br>' . mysql_error(); } } if ($this->pageSize == 0) { $this->pageSize = '10'; } $total_pages = (int) ($total_records / $this->pageSize); // when you back from other languages where more pages than on current if ($page > $total_pages + 1) { $page = 1; } if ($total_records % $this->pageSize != 0) { $total_pages++; } $start_row = ($page - 1) * $this->pageSize; } // check if there is move operation and perform it //---------------------------------------------------------------------- if ($operation == 'move') { // block if this is a demo mode if (strtolower(SITE_MODE) == 'demo') { $this->error = _OPERATION_BLOCKED; } else { $operation_field_p = explode('#', $operation_field); $operation_field_p0 = explode('-', $operation_field_p[0]); $operation_field_p1 = explode('-', $operation_field_p[2]); $of_first = isset($operation_field_p0[0]) ? $operation_field_p0[0] : ''; $of_second = isset($operation_field_p0[1]) ? $operation_field_p0[1] : ''; $of_name = $operation_field_p[1]; $of_first_value = isset($operation_field_p1[0]) ? $operation_field_p1[0] : ''; $of_second_value = isset($operation_field_p1[1]) ? $operation_field_p1[1] : ''; if ($of_first_value != '' && $of_second_value != '') { $sql = 'UPDATE ' . $this->tableName . ' SET ' . $of_name . ' = \'' . $of_second_value . '\' WHERE ' . $this->primaryKey . ' = \'' . $of_first . '\''; database_void_query($sql); if ($this->debug) { $this->arrSQLs['select_move_1'] = $sql; } $sql = 'UPDATE ' . $this->tableName . ' SET ' . $of_name . ' = \'' . $of_first_value . '\' WHERE ' . $this->primaryKey . ' = \'' . $of_second . '\''; database_void_query($sql); if ($this->debug) { $this->arrSQLs['select_move_2'] = $sql; } } } } $arrRecords = $this->GetAll($this->ORDER_CLAUSE, 'LIMIT ' . $start_row . ', ' . (int) $this->pageSize); if ($this->allowLanguages) { $arrLanguages = Languages::GetAllActive(); } if (!$this->isPagingAllowed) { $total_records = $arrRecords[1]; } echo '<form name="frmMicroGrid_' . $this->tableName . '" id="frmMicroGrid_' . $this->tableName . '" action="' . $this->formActionURL . '" method="post">' . $nl; draw_hidden_field('mg_prefix', $this->uPrefix); echo $nl; draw_hidden_field('mg_action', 'view'); echo $nl; draw_hidden_field('mg_rid', ''); echo $nl; draw_hidden_field('mg_sorting_fields', $sorting_fields); echo $nl; draw_hidden_field('mg_sorting_types', $sorting_types); echo $nl; draw_hidden_field('mg_page', $page); echo $nl; draw_hidden_field('mg_operation', $operation); echo $nl; draw_hidden_field('mg_operation_type', $operation_type); echo $nl; draw_hidden_field('mg_operation_field', $operation_field); echo $nl; draw_hidden_field('mg_search_status', $search_status); echo $nl; draw_hidden_field('mg_language_id', $this->languageId); echo $nl; draw_hidden_field('mg_operation_code', self::GetRandomString(20)); echo $nl; draw_token_field(); echo $nl; if ($this->actions['add'] || $this->allowLanguages || $this->allowRefresh || $this->isExportingAllowed) { echo '<table width="100%" border="0" cellspacing="0" cellpadding="2" class="mgrid_table"> <tr>'; echo '<td align="' . Application::Get('defined_left') . '" valign="middle">'; if ($this->actions['add']) { echo '<input class="mgrid_button" type="button" name="btnAddNew" value="' . _ADD_NEW . '" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'add\');"> '; } if ($this->operationLinks != '') { echo $this->operationLinks; } echo '</td>'; echo '<td align="' . Application::Get('defined_right') . '" valign="middle">'; if ($this->isExportingAllowed) { if (strtolower(SITE_MODE) == 'demo' || !$arrRecords[1]) { echo '<span class="gray">[ ' . _EXPORT . ' ]</span> '; } else { if ($operation == 'switch_to_export') { echo '[ <a href="javascript:void(\'export|cancel\');" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', null, null, null, null, \'switch_to_normal\');" title="' . _SWITCH_TO_NORMAL . '">' . _BUTTON_CANCEL . '</a> | ' . _DOWNLOAD . ' - <a href="javascript:void(\'csv\');" onclick="javascript:appGoToPage(\'index.php?admin=export&file=export.csv\')"><img src="images/microgrid_icons/csv.gif" alt="' . _DOWNLOAD . ' CSV"></a> ] '; } else { echo '<a href="javascript:void(\'export\');" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', null, null, null, null, \'switch_to_export\');" title="' . _SWITCH_TO_EXPORT . '">[ ' . _EXPORT . ' ]</a> '; } } } if ($this->allowRefresh) { echo '<a href="javascript:void(\'refresh\');" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\');" title="' . _REFRESH . '"><img src="images/microgrid_icons/refresh.gif" alt="' . _REFRESH . '"></a>'; } echo '</td>'; if ($this->allowLanguages) { echo '<td align="' . Application::Get('defined_right') . '" width="80px">'; $this->allowLanguages ? draw_languages_box('mg_language_id', $arrLanguages[0], 'abbreviation', 'lang_name', $this->languageId, '', 'onchange="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', null, null, null, null, \'change_language\', this.value, \'language_id\');"') : ''; echo '</td>'; } echo ' </tr> <tr><td nowrap height="10px"></td></tr> </table>'; } if ($this->isFilteringAllowed) { echo '<table width="100%" border="0" cellspacing="0" cellpadding="2" class="mgrid_table"> <tr> <td align="' . Application::Get('defined_left') . '">'; echo '<b>' . _FILTER_BY . '</b>: '; foreach ($this->arrFilteringFields as $key => $val) { if (!$this->IsVisible($val)) { continue; } $filter_field_value = $search_status == 'active' ? self::GetParameter('filter_by_' . $val['table'] . $val['field'], false) : ''; if ($val['type'] == 'text') { echo $key . ': <input type="text" class="mgrid_text" name="filter_by_' . $val['table'] . $val['field'] . '" value="' . $this->GetDataDecoded($filter_field_value) . '" style="width:' . $val['width'] . '" maxlength="125"> '; } else { if ($val['type'] == 'dropdownlist') { if (is_array($val['source'])) { echo $key . ': <select class="mgrid_text" name="filter_by_' . $val['table'] . $val['field'] . '" style="width:' . $val['width'] . '">'; echo '<option value="">-- ' . _SELECT . ' --</option>'; foreach ($val['source'] as $key => $val) { echo '<option ' . ($filter_field_value !== '' && $filter_field_value == $key ? ' selected="selected"' : '') . ' value="' . $this->GetDataDecoded($key) . '">' . $val . '</option>'; } echo '</select> '; } } else { if ($val['type'] == 'calendar') { $date_format = isset($val['date_format']) ? $val['date_format'] : ''; if ($date_format == 'mm/dd/yyyy') { $calendar_date_format = '%m-%d-%Y'; $placeholder_date_format = 'mm-dd-yyyy'; } else { if ($date_format == 'dd/mm/yyyy') { $calendar_date_format = '%d-%m-%Y'; $placeholder_date_format = 'dd-mm-yyyy'; } else { $calendar_date_format = '%Y-%m-%d'; $placeholder_date_format = 'yyyy-dd-mm'; } } echo $key . ': <input type="text" id="filter_cal' . $val['field'] . '" class="mgrid_text" name="filter_by_' . $val['table'] . $val['field'] . '" value="' . $this->GetDataDecoded($filter_field_value) . '" style="width:' . $val['width'] . '" maxlength="19" placeholder="' . $placeholder_date_format . '"> '; echo '<img id="filter_cal' . $val['field'] . '_img" src="images/microgrid_icons/cal.gif" alt="" title="' . _SET_TIME . '" style="cursor:pointer;">'; echo ' '; $calendar_fields[] = array('field' => 'filter_cal' . $val['field'], 'format' => $calendar_date_format); } } } } if (count($this->arrFilteringFields) > 0) { echo ' '; if ($search_status == 'active') { echo ' <input type="button" class="mgrid_button" name="btnReset" value="' . _BUTTON_RESET . '" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', \'\', \'\', \'\', \'\', \'reset_filtering\');">'; } echo ' <input type="button" class="mgrid_button" name="btnSearch" value="' . _SEARCH . '" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', \'\', \'\', \'\', \'\', \'filtering\')">'; } echo ' </td> </tr> <tr><td nowrap height="10px"></td></tr> </table>'; } // draw rows if ($arrRecords[1] > 0) { echo '<table width="100%" border="' . ($this->debug ? '1' : '0') . '" cellspacing="0" cellpadding="2" class="mgrid_table">'; // draw column headers echo '<tr>'; foreach ($this->arrViewModeFields as $key => $val) { $width = isset($val['width']) ? ' width="' . $val['width'] . '"' : ''; if (isset($val['align']) && $val['align'] == 'left' && Application::Get('defined_left') == 'right') { $align = ' align="right"'; } else { if (isset($val['align']) && $val['align'] == 'right' && Application::Get('defined_right') == 'left') { $align = ' align="left"'; } else { if (isset($val['align'])) { $align = ' align="' . $val['align'] . '"'; } else { $align = ''; } } } $visible = isset($val['visible']) && $val['visible'] !== '' ? $val['visible'] : true; $sortable = isset($val['sortable']) && $val['sortable'] !== '' ? $val['sortable'] : true; $th_class = $key == $sort_by ? ' class="th_sorted"' : ''; $title = isset($val['title']) ? $val['title'] : ''; if ($visible) { echo '<th' . $width . $align . $th_class . '>'; if ($this->isSortingAllowed && $sortable) { $field_sorting = 'DESC'; $sort_icon = ''; if ($key == $sorting_fields) { if (strtolower($sorting_types) == 'asc') { $sort_icon = ' <img src="images/microgrid_icons/up.png" alt="" title="asc">'; } else { if (strtolower($sorting_types) == 'desc') { $sort_icon = ' <img src="images/microgrid_icons/down.png" alt="" title="desc">'; } } $field_sorting = $sorting_types; } echo '<a href="javascript:void(\'sort\');" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', \'\', \'' . $key . '\', \'' . $field_sorting . '\', \'' . $page . '\', \'sorting\')"><b>' . $title . '</b></a>' . $sort_icon; $this->DrawHeaderTooltip($val); } else { echo '<label>' . $title . '</label>'; } echo '</th>'; if ($operation == 'switch_to_export' && strtolower(SITE_MODE) != 'demo') { $export_content[0][] = $val['title']; } } } if ($this->actions['details'] || $this->actions['edit'] || $this->actions['delete']) { echo '<th width="8%">' . _ACTIONS . '</th>'; } echo '</tr>'; echo '<tr><td colspan="' . $colspan . '" height="3px" nowrap="nowrap">' . draw_line('no_margin_line', IMAGE_DIRECTORY, false) . '</td></tr>'; for ($i = 0; $i < $arrRecords[1]; $i++) { echo '<tr ' . ($this->isAlterColorsAllowed ? highlight(0) : '') . '>'; foreach ($this->arrViewModeFields as $key => $val) { if (isset($val['align']) && $val['align'] == 'left' && Application::Get('defined_left') == 'right') { $align = ' align="right"'; } else { if (isset($val['align']) && $val['align'] == 'right' && Application::Get('defined_right') == 'left') { $align = ' align="left"'; } else { if (isset($val['align'])) { $align = ' align="' . $val['align'] . '"'; } else { $align = ''; } } } $wrap = isset($val['nowrap']) && $val['nowrap'] == 'nowrap' ? ' nowrap="' . $val['nowrap'] . '"' : ' wrap'; $visible = isset($val['visible']) && $val['visible'] !== '' ? $val['visible'] : true; $movable = isset($val['movable']) && $val['movable'] !== '' ? $val['movable'] : false; if (isset($arrRecords[0][$i][$key])) { $field_value = $this->DrawFieldByType('view', $key, $val, $arrRecords[0][$i], false); if ($this->isAggregateAllowed && isset($this->arrAggregateFields[$key])) { $key_agreg = isset($this->arrAggregateFields[$key]['aggregate_by']) && $this->arrAggregateFields[$key]['aggregate_by'] !== '' ? $this->arrAggregateFields[$key]['aggregate_by'] : $key; if (!isset($this->arrAggregateFieldsTemp[$key])) { $this->arrAggregateFieldsTemp[$key] = array('sum' => $arrRecords[0][$i][$key_agreg], 'count' => 1); } else { $this->arrAggregateFieldsTemp[$key]['sum'] += $arrRecords[0][$i][$key_agreg]; $this->arrAggregateFieldsTemp[$key]['count']++; } } } else { if ($this->debug) { $this->arrWarnings['wrong_' . $key] = 'Field <b>' . $key . '</b>: wrong definition in View mode or at least one field has no value in SQL! Please check currefully your code.'; } $field_value = ''; } if ($visible) { $move_link = ''; if ($movable) { $move_prev_id = $arrRecords[0][$i]['id'] . '-' . (isset($arrRecords[0][$i - 1]['id']) ? $arrRecords[0][$i - 1]['id'] : '') . '#'; $move_prev_id .= $key . '#'; $move_prev_id .= $arrRecords[0][$i][$key] . '-' . (isset($arrRecords[0][$i - 1][$key]) ? $arrRecords[0][$i - 1][$key] : ''); $move_next_id = $arrRecords[0][$i]['id'] . '-' . (isset($arrRecords[0][$i + 1]['id']) ? $arrRecords[0][$i + 1]['id'] : '') . '#'; $move_next_id .= $key . '#'; $move_next_id .= $arrRecords[0][$i][$key] . '-' . (isset($arrRecords[0][$i + 1][$key]) ? $arrRecords[0][$i + 1][$key] : ''); if (isset($arrRecords[0][$i - 1]['id'])) { $move_link .= ' <a href="javascript:void(\'move|up\');" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', \'' . $arrRecords[0][$i]['id'] . '\', \'\', \'\', \'\', \'move\', \'up\', \'' . $move_prev_id . '\')">'; $move_link .= $this->actionIcons ? '<img src="images/microgrid_icons/up.png" style="margin-bottom:2px" alt="" title="' . _UP . '">' : _UP; $move_link .= '</a>'; } else { $move_link .= ' <span style="width:11px;height:11px;"></span>'; } if (isset($arrRecords[0][$i + 1]['id'])) { $move_link .= '<a href="javascript:void(\'move|down\');" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', \'' . $arrRecords[0][$i]['id'] . '\', \'\', \'\', \'\', \'move\', \'down\', \'' . $move_next_id . '\')">'; $move_link .= $this->actionIcons ? '<img src="images/microgrid_icons/down.png" style="margin-top:2px" alt="" title="' . _DOWN . '">' : (isset($arrRecords[0][$i - 1]['id']) ? '/' : '') . _DOWN; $move_link .= '</a>'; } else { $move_link .= '<span style="width:11px;height:11px;"></span>'; } } echo '<td' . $align . $wrap . '>' . $field_value . $move_link . '</td>'; if ($operation == 'switch_to_export' && strtolower(SITE_MODE) != 'demo') { $export_content[$i + 1][] = str_replace(',', '', strip_tags($field_value)); } } } if ($this->actions['details'] || $this->actions['edit'] || $this->actions['delete']) { echo '<td align="center" nowrap="nowrap">'; if ($this->actions['details']) { echo '<a href="javascript:void(\'details|' . $arrRecords[0][$i][$this->primaryKey] . '\');" title="' . _VIEW_WORD . '" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'details\', \'' . $arrRecords[0][$i]['id'] . '\')">' . ($this->actionIcons ? '<img src="images/microgrid_icons/details.gif" title="' . _VIEW_WORD . '" alt="" border="0" style="margin:0px; padding:0px;" height="16px">' : _VIEW_WORD) . '</a>'; } if ($this->actions['edit']) { if ($this->actions['details']) { echo ' ' . ($this->actionIcons ? ' ' : '') . draw_divider(false) . ' '; } echo '<a href="javascript:void(\'edit|' . $arrRecords[0][$i][$this->primaryKey] . '\')" title="' . _EDIT_WORD . '" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'edit\', \'' . $arrRecords[0][$i]['id'] . '\')">' . ($this->actionIcons ? '<img src="images/microgrid_icons/edit.gif" title="' . _EDIT_WORD . '" alt="" border="0" style="margin:0px;padding:0px;" height="16px">' : _EDIT_WORD) . '</a>'; } if ($this->actions['delete']) { if ($this->actions['edit'] || $this->actions['details']) { echo ' ' . ($this->actionIcons ? ' ' : '') . draw_divider(false) . ' '; } echo '<a href="javascript:void(\'delete|' . $arrRecords[0][$i][$this->primaryKey] . '\')" title="' . _DELETE_WORD . '" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'delete\', \'' . $arrRecords[0][$i]['id'] . '\')">' . ($this->actionIcons ? '<img src="images/microgrid_icons/delete.gif" title="' . _DELETE_WORD . '" alt="" border="0" style="margin:0px;padding:0px;" height="16px">' : _DELETE_WORD) . '</a>'; } echo ' </td>'; } echo '</tr>'; } // for // draw aggregate fields row if ($this->isAggregateAllowed) { echo '<tr><td colspan="' . $colspan . '" height="5px" nowrap="nowrap">' . draw_line('no_margin_line', IMAGE_DIRECTORY, false) . '</td></tr>'; echo '<tr>'; foreach ($this->arrViewModeFields as $key => $val) { $visible = isset($val['visible']) && $val['visible'] !== '' ? $val['visible'] : true; if ($visible) { $ag_field_total = isset($this->arrAggregateFieldsTemp[$key]) ? $this->arrAggregateFieldsTemp[$key]['sum'] : 0; $ag_field_count = isset($this->arrAggregateFieldsTemp[$key]) ? $this->arrAggregateFieldsTemp[$key]['count'] : 0; $ag_field_function = strtoupper(isset($this->arrAggregateFields[$key]['function']) ? $this->arrAggregateFields[$key]['function'] : ''); $ag_field_align = strtoupper(isset($this->arrAggregateFields[$key]['align']) ? $this->arrAggregateFields[$key]['align'] : 'center'); $ag_decimal_place = isset($this->arrAggregateFields[$key]['decimal_place']) ? (int) $this->arrAggregateFields[$key]['decimal_place'] : 2; $ag_field_value = ''; if ($ag_field_function == 'SUM') { $ag_field_value = $ag_field_count != 0 ? number_format($ag_field_total, $ag_decimal_place) : ''; } else { if ($ag_field_function == 'AVG') { $ag_field_value = $ag_field_count != 0 ? number_format($ag_field_total / $ag_field_count, $ag_decimal_place) : ''; } } echo '<td align="' . $ag_field_align . '">' . ($ag_field_function != '' ? $ag_field_function . '=' : '') . $ag_field_value . '</td>'; } } echo '</tr>'; echo '<tr><td colspan="' . $colspan . '" height="5px" nowrap="nowrap">' . draw_line('no_margin_line', IMAGE_DIRECTORY, false) . '</td></tr>'; } else { echo '<tr><td colspan="' . $colspan . '" height="15px" nowrap="nowrap">' . draw_line('no_margin_line', IMAGE_DIRECTORY, false) . '</td></tr>'; } echo '</table>'; echo '<table width="100%" border="0" cellspacing="0" cellpadding="2" class="mgrid_table">'; echo '<tr valign="top">'; echo '<td>'; if ($this->isPagingAllowed) { echo '<b>' . _PAGES . ':</b> '; for ($i = 1; $i <= $total_pages; $i++) { echo '<a class="paging_link" href="javascript:void(\'paging\')" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', \'\', \'\', \'\', \'' . $i . '\', \'\')">' . ($i == $page ? '<b>[' . $i . ']</b>' : $i) . '</a> '; } } echo '</td>'; echo '<td align="' . Application::Get('defined_right') . '">'; $row_from = $start_row + 1; $row_to = $start_row + $this->pageSize < $total_records ? $start_row + $this->pageSize : $total_records; echo '<b>' . _TOTAL . '</b>: ' . ($row_from < $row_to ? $row_from . ' - ' . $row_to : $row_from) . ' / ' . $total_records; echo '</td>'; echo '</tr>'; echo '</table>'; // prepare export file //---------------------------------------------------------------------- if ($operation == 'switch_to_export') { if (strtolower(SITE_MODE) == 'demo') { $this->error = _OPERATION_BLOCKED; } else { $export_content_count = count($export_content); $fe = @fopen('tmp/export/export.csv', 'w+'); @fwrite($fe, ""); for ($i = 0; $i < $export_content_count; $i++) { @fputcsv($fe, $export_content[$i]); } @fclose($fe); } } } else { draw_message(_NO_RECORDS_FOUND, true, true, false, 'width:100%'); //if($this->debug) $this->arrSQLs['select'] = $this->VIEW_MODE_SQL.' '.$this->WHERE_CLAUSE.' '.$this->ORDER_CLAUSE.' LIMIT '.$start_row.', '.(int)$this->pageSize; } echo '</form>'; $this->CalendarSetupFields($calendar_fields); $this->AfterViewRecords(); $this->DrawVersionInfo(); $this->DrawRunningTime(); $this->DrawErrors(); $this->DrawWarnings(); $this->DrawSQLs(); $this->DrawPostInfo(); }
</tr> <tr><td colspan="6" height="3px" nowrap><?php draw_line(); ?> </td></tr> <?php for ($i = 0; $i < $all_menus[1]; $i++) { echo '<tr ' . highlight(0) . ' onmouseover="oldColor=this.style.backgroundColor;this.style.backgroundColor=\'#e1e1e1\';" onmouseout="this.style.backgroundColor=oldColor"> <td align="' . Application::Get('defined_left') . '">' . $all_menus[0][$i]['menu_name'] . '</td> <td align="center">' . ucfirst($all_menus[0][$i]['access_level']) . '</td> <td align="center">' . ($all_menus[0][$i]['menu_placement'] == 'hidden' ? '- ' . $all_menus[0][$i]['menu_placement'] . ' -' : ucfirst($all_menus[0][$i]['menu_placement'])) . '</td> <td align="center">' . $all_menus[0][$i]['menu_order'] . '</td> <td align="center"> ' . prepare_permanent_link('index.php?admin=menus&act=move&mid=' . $all_menus[0][$i]['id'] . '&mo=' . $all_menus[0][$i]['menu_order'] . '&dir=up&language_id=' . $language_id, _UP) . '/' . prepare_permanent_link('index.php?admin=menus&act=move&mid=' . $all_menus[0][$i]['id'] . '&mo=' . $all_menus[0][$i]['menu_order'] . '&dir=down&language_id=' . $language_id, _DOWN) . ' </td> <td align="center" nowrap="nowrap"> ' . ($objLogin->HasPrivileges('edit_menus') ? prepare_permanent_link('index.php?admin=menus_edit&mid=' . $all_menus[0][$i]['id'] . '&language_id=' . $language_id, _EDIT_WORD) : '') . ' ' . ($objLogin->HasPrivileges('edit_menus') && $objLogin->HasPrivileges('delete_menus') ? ' ' . draw_divider(false) . ' ' : '') . ' ' . ($objLogin->HasPrivileges('delete_menus') ? '<a href="javascript:confirmDelete(\'' . $all_menus[0][$i]['id'] . '\',\'' . $all_menus[0][$i]['menu_order'] . '\');">' . _DELETE_WORD . '</a>' : '') . ' </td> </tr>'; } echo '</table>'; } else { draw_message(_MENU_NOT_FOUND); } draw_content_end(); } else { draw_title_bar(_ADMIN); draw_important_message(_NOT_AUTHORIZED); }
draw_success_message(_NEWSLETTER_SUBSCRIBE_SUCCESS); } else { draw_important_message($objNews->error); $focus_field = 'subscribe_email'; } } else { if ($task == 'unsubscribe') { if ($objNews->ProcessUnsubscription($email)) { draw_success_message(_NEWSLETTER_UNSUBSCRIBE_SUCCESS); } else { draw_important_message($objNews->error); $focus_field = 'unsubscribe_email'; } } else { if ($task == 'pre_subscribe') { draw_message(_NEWSLETTER_PRE_SUBSCRIBE_ALERT); $focus_field = 'subscribe_email'; } else { if ($task == 'pre_unsubscribe') { draw_message(_NEWSLETTER_PRE_UNSUBSCRIBE_ALERT); $focus_field = 'unsubscribe_email'; } } } } echo '<div class="pages_contents">'; $objNews->DrawSubscribeBlockMain($focus_field, $email); echo '</div>'; } else { draw_important_message(_PAGE_UNKNOWN); }
} else { if ($reg_confirmation == 'by admin') { $email_template = 'new_account_created_confirm_by_admin'; } else { $email_template = 'new_account_created'; } } send_email($email, $objSettings->GetParameter('admin_email'), $email_template, array('{FIRST NAME}' => $first_name, '{LAST NAME}' => $last_name, '{USER NAME}' => $user_name, '{USER PASSWORD}' => $user_password1, '{WEB SITE}' => $_SERVER['SERVER_NAME'], '{REGISTRATION CODE}' => $registration_code, '{BASE URL}' => APPHP_BASE, '{YEAR}' => date('Y'))); if ($admin_alert_new_registration == 'yes') { send_email($objSettings->GetParameter('admin_email'), $objSettings->GetParameter('admin_email'), 'new_account_created_notify_admin', array('{FIRST NAME}' => $first_name, '{LAST NAME}' => $last_name, '{USER NAME}' => $user_name, '{USER EMAIL}' => $email, '{WEB SITE}' => $_SERVER['SERVER_NAME'], '{BASE URL}' => APPHP_BASE, '{YEAR}' => date('Y'))); } //////////////////////////////////////////////////////////// if ($reg_confirmation == 'by email') { $msg = draw_success_message(_ACCOUNT_CREATED_CONF_BY_EMAIL_MSG, false); $msg .= '<br />' . draw_message(_ACCOUT_CREATED_CONF_LINK, false); } else { if ($reg_confirmation == 'by admin') { $msg = draw_success_message(_ACCOUNT_CREATED_CONF_BY_ADMIN_MSG, false); $msg .= '<br />' . draw_message(_ACCOUT_CREATED_CONF_LINK, false); } else { $msg = draw_success_message(_ACCOUNT_CREATED_NON_CONFIRM_MSG, false); $msg .= '<br />' . draw_message(_ACCOUNT_CREATED_NON_CONFIRM_LINK, false); } } $account_created = true; } else { $msg = draw_important_message(_CREATING_ACCOUNT_ERROR, false); } } } }
<?php /** * @project ApPHP Business Directory * @copyright (c) 2011 ApPHP * @author ApPHP <*****@*****.**> * @license http://www.gnu.org/licenses/ */ // *** Make sure the file isn't accessed directly defined('APPHP_EXEC') or die('Restricted Access'); //-------------------------------------------------------------------------- if ($objLogin->IsLoggedInAs('owner', 'mainadmin') && Modules::IsModuleInstalled('inquiries')) { // Start main content draw_title_bar(prepare_breadcrumbs(array(_LISTINGS_MANAGEMENT => '', _SETTINGS => '', _INTEGRATION => ''))); draw_message(_INTEGRATION_TOP_MESSAGE); draw_content_start(); ?> <table> <tr> <td> <?php echo _INTEGRATION_MESSAGE; ?> <br> <textarea cols="60" style="height:140px;margin-top:5px;" onclick="this.select()" readonly="readonly"><?php echo '<script type="text/javascript">' . "\n"; echo 'var hsJsHost = "' . APPHP_BASE . '";' . "\n"; echo 'var hsJsKey = "' . INSTALLATION_KEY . '";' . "\n"; echo 'document.write(unescape(\'%3Cscript src="\' + hsJsHost + \'widgets/ipanel-left/main.js" type="text/javascript"%3E%3C/script%3E\'));' . "\n"; echo '</script>' . "\n"; ?>
$msg = ''; // change password if ($submit_type == '1') { $msg = $objAdmin->ChangeLang($preferred_language); } else { if ($submit_type == '2') { $msg = $objAdmin->SavePersonalInfo($admin_email, $first_name, $last_name); } else { if ($submit_type == '3') { $msg = $objAdmin->ChangePassword($password_one, $password_two); } } } draw_title_bar(prepare_breadcrumbs(array(_ACCOUNTS => '', _MY_ACCOUNT => ''))); if ($msg == '') { draw_message(_ALERT_REQUIRED_FILEDS); } else { echo $msg; } draw_content_start(); $arr_account_types = array('owner' => _OWNER, 'admin' => _ADMIN, 'mainadmin' => _MAIN_ADMIN); ?> <?php draw_sub_title_bar(_GENERAL_INFO); ?> <form action="index.php?admin=my_account" method="post"> <?php draw_hidden_field('submit_type', '1'); ?> <?php
$tabs->SetSubmissionType('post'); /// $tabs->Disable($tab2); /// $tabs->SetDefaultTab($tab3); /// $tab4->SetDefaultTab($subtab4); echo '<script type="text/javascript"> function cleanCacheSubmit(){ if(confirm("' . _PERFORM_OPERATION_COMMON_ALERT . '")){ appGoToPage(\'index.php?admin=settings\', \'submition_type=clean_cache&token=' . Application::Get('token') . '\', \'post\'); return true; } return false; } function sendTestEmail(el){ el.disabled=true; el.value=\'' . _SENDING . '...\'; document.getElementById(\'frmEmailSettings\').submition_type.value=\'test_smtp_connection\'; document.getElementById(\'frmEmailSettings\').submit(); } </script>'; draw_title_bar(prepare_breadcrumbs(array(_GENERAL => '', _SITE_SETTINGS => ''))); echo $msg == '' ? draw_message(_ALERT_REQUIRED_FILEDS, false) : $msg; draw_content_start(); $tabs->Display(); if ($focus_on_field) { echo '<script type="text/javascript">appSetFocus("' . $focus_on_field . '")</script>'; } draw_content_end(); } else { draw_title_bar(_ADMIN); draw_important_message(_NOT_AUTHORIZED); }
$actions_msg[] = str_replace('_COUNT_', $awaiting_listings, _LISTINGS_AWAITING_MODERATION_ALERT); } } if (count($actions_msg) > 0) { if ($alert_state == '') { $msg = '<div id="divAlertRequired"> <img src="images/close.png" alt="" style="cursor:pointer;float:' . Application::Get('defined_right') . ';margin-right:-3px;" title="' . _HIDE . '" onclick="javascript:appGoTo(\'admin=home\',\'&task=close_alert\')" /> <img src="images/action_required.png" alt="" style="margin-bottom:-3px;" /> <b>' . _ACTION_REQUIRED . '</b>: <ul style="margin-top:7px;margin-bottom:7px;">'; foreach ($actions_msg as $single_msg) { $msg .= '<li>' . $single_msg . '</li>'; } $msg .= '</ul></div>'; draw_important_message($msg, true, false); } else { echo '<div id="divAlertRequired" style="padding:5px 17px;float:right;"><a href="javascript:void(0);" onclick="javascript:appGoTo(\'admin=home\',\'&task=open_alert\')">' . _OPEN_ALERT_WINDOW . '</a></div>'; } } // draw welcome message $msg = '<div style="padding:9px;"> <div class="site_version">' . _VERSION . ': ' . CURRENT_VERSION . '</div> <p>' . _TODAY . ': <b>' . format_datetime(@date('Y-m-d H:i:s'), '', '', true) . '</b></p> <p>' . _LAST_LOGIN . ': <b>' . format_datetime($objLogin->GetLastLoginTime(), '', _NEVER, true) . '</b></p>'; $msg .= _HOME_PAGE_WELCOME_TEXT . ' </div>'; draw_message($msg, true, false); echo '<div style="text-align:right;padding:80px 18px 0 0;vertical-align:bottom;">' . $objSiteDescription->DrawFooter(false) . '</div>'; } else { draw_title_bar(_ADMIN); draw_important_message(_NOT_AUTHORIZED); }
/** * Draws sub categories * @param $category_id * @param $show_on * @param $draw */ public function DrawSubCategories($category_id = '0', $show_on = '', $draw = true) { global $objLogin; $listings_count_field = !$objLogin->IsLoggedIn() ? 'listings_count_public' : 'listings_count'; $lang = Application::Get('lang'); $output = ''; $categories_images = false; $categories_columns = '3'; if (Modules::IsModuleInstalled('listings')) { if (ModulesSettings::Get('listings', 'show_categories_images') == 'yes') { $categories_images = true; } $categories_columns = ModulesSettings::Get('listings', 'columns_number_on_page'); } $category_info = $this->GetInfoByID($category_id); $sql = 'SELECT c.id, c.icon, c.icon_thumb, c.listings_count, c.listings_count_public, c.priority_order, cd.language_id, cd.name, cd.description FROM ' . TABLE_CATEGORIES . ' c LEFT OUTER JOIN ' . TABLE_CATEGORIES_DESCRIPTION . ' cd ON c.id = cd.category_id WHERE c.parent_id = ' . (int) $category_id . ' AND cd.language_id = \'' . $lang . '\''; $result = database_query($sql, DATA_AND_ROWS, ALL_ROWS, FETCH_ASSOC); if ($result[1] > 0) { $output .= '<table class="sub_categories_table" width="100%" align="center" border="0" style="margin:10px auto">'; $output .= '<tr>'; for ($i = 0; $i < $result[1]; $i++) { if ($i > 0 && $i % $categories_columns == 0) { $output .= '</tr><tr>'; } $output .= '<td align="left" valign="top" width="32px">'; $icon_file_thumb = $result[0][$i]['icon_thumb'] != '' ? $result[0][$i]['icon_thumb'] : ''; if ($categories_images && $icon_file_thumb != '') { $output .= '<img src="images/categories/' . $icon_file_thumb . '" width="24px" height="24px" alt="' . $result[0][$i]['name'] . '" title="' . $result[0][$i]['name'] . '" />'; } else { $directory_icon = $result[0][$i][$listings_count_field] > 0 ? 'not_empty_directory.gif' : 'empty_directory.gif'; $output .= '<img src="images/categories/' . $directory_icon . '" width="24px" height="24px" alt="' . $result[0][$i]['name'] . '" title="' . $result[0][$i]['name'] . '" />'; } $output .= '</td>'; $output .= '<td>'; $output .= prepare_link('category', 'cid', $result[0][$i]['id'], '', $result[0][$i]['name'], '', '') . ' (' . $result[0][$i][$listings_count_field] . ')'; //$output .= ' '; //$output .= prepare_link('category', 'cid', $result[0][$i]['id'], '', '<img src=images/external_link.gif>', '', _VIEW_LISTINGS); $output .= '</td>'; } $output .= '</tr>'; $output .= '</table>'; } else { if ($show_on == '') { $output .= draw_message(_NO_SUBCATEGORIES, false, true) . '<br />'; } } if ($draw) { echo $output; } else { return $output; } }
if (ModulesSettings::Get('customers', 'allow_registration') == 'yes' && ModulesSettings::Get('customers', 'reg_confirmation') == 'by email') { echo prepare_permanent_link('index.php?customer=resend_activation', _RESEND_ACTIVATION_EMAIL); } ?> </td> </tr> <tr><td colspan="2" nowrap="nowrap" height="5px"></td></tr> </table> </form> </div> <script type="text/javascript"> appSetFocus("txt_user_name");</script> <?php } else { if ($objLogin->IsLoggedInAsCustomer()) { echo '<div class="pages_contents">'; draw_message(_ALREADY_LOGGED, true, true, false, 'width:100%'); echo '</div>'; ?> <div class='pages_contents'> <form action="index.php?page=logout" method="post"> <?php draw_hidden_field('submit_logout', 'logout'); ?> <?php draw_token_field(); ?> <input class="form_button" type="submit" name="submit" value="<?php echo _BUTTON_LOGOUT; ?> "> </form>
*/ // *** Make sure the file isn't accessed directly defined('APPHP_EXEC') or die('Restricted Access'); //-------------------------------------------------------------------------- if ($objLogin->IsLoggedInAs('owner') && Modules::IsModuleInstalled('backup')) { $submition_type = isset($_POST['submition_type']) ? prepare_input($_POST['submition_type']) : ''; $backup_file = isset($_POST['backup_file']) ? prepare_input($_POST['backup_file']) : ''; $st = isset($_GET['st']) ? prepare_input($_GET['st']) : ''; $fname = isset($_GET['fname']) ? prepare_input($_GET['fname']) : ''; $msg = ''; $objBackup = new Backup(); if ($st == 'restore') { // restore previouse backup if ($objBackup->RestoreBackup($fname)) { $msg = draw_success_message(str_replace('_FILE_NAME_', $fname, _BACKUP_WAS_RESTORED), false); } else { $msg = draw_important_message($objBackup->error, false); } } else { $msg = draw_message(_BACKUP_RESTORE_NOTE, false); } // draw title bar and message draw_title_bar(prepare_breadcrumbs(array(_MODULES => '', _BACKUP => '', _BACKUP_RESTORE => '')), prepare_permanent_link('index.php?admin=mod_backup_installation', _BACKUP_INSTALLATION)); echo $msg; draw_content_start(); $objBackup->DrawRestoreForm(); draw_content_end(); } else { draw_title_bar(_ADMIN); draw_important_message(_NOT_AUTHORIZED); }
//-------------------------------------------------------------------------- if (!$objLogin->IsLoggedIn() && ModulesSettings::Get('customers', 'allow_registration') == 'yes') { $code = isset($_REQUEST['c']) ? prepare_input($_REQUEST['c']) : ''; $task = isset($_POST['task']) ? prepare_input($_POST['task']) : ''; $msg = ''; $confirmed = false; if ($code != '') { $sql = 'SELECT * FROM ' . TABLE_CUSTOMERS . ' WHERE registration_code = \'' . encode_text($code) . '\' AND is_active = 0'; $result = database_query($sql, DATA_AND_ROWS, FIRST_ROW_ONLY); if ($result[1] > 0) { $sql = 'UPDATE ' . TABLE_CUSTOMERS . ' SET is_active = 1, registration_code = \'\' WHERE registration_code = \'' . encode_text($code) . '\' AND is_active = 0'; database_void_query($sql); $msg = draw_success_message(_CONFIRMED_SUCCESS_MSG, false); $confirmed = true; $msg .= '<script type="text/javascript">setTimeout(\'appGoTo("customer=login")\', 15000);</script>'; } else { if (strlen($code) == 20) { $confirmed = true; $msg = draw_message(_CONFIRMED_ALREADY_MSG, false); } else { $msg = draw_important_message(_WRONG_CONFIRMATION_CODE, false); } } } else { if ($task == 'post_submission') { $msg = draw_important_message(str_replace('_FIELD_', _CONFIRMATION_CODE, _FIELD_CANNOT_BE_EMPTY), false); } } }
/** * Sends mass mail */ public function SendMassMail() { global $objSettings; $template_name = isset($_POST['template_name']) ? prepare_input($_POST['template_name']) : ''; $email_from = isset($_POST['email_from']) ? prepare_input($_POST['email_from']) : ''; $email_to_req = isset($_POST['email_to']) ? prepare_input($_POST['email_to']) : ''; $subject = isset($_POST['subject']) ? prepare_input($_POST['subject']) : ''; $message = isset($_POST['message']) ? prepare_input($_POST['message']) : ''; $package_size = isset($_POST['package_size']) ? prepare_input($_POST['package_size']) : ''; $duration = isset($_POST['duration']) ? (int) $_POST['duration'] : '5'; $send_copy_to_admin = isset($_POST['send_copy_to_admin']) ? prepare_input($_POST['send_copy_to_admin']) : ''; $admin_email = $objSettings->GetParameter('admin_email'); $email_session_code = Session::Get('email_random_code'); $email_post_code = isset($_POST['email_random_code']) ? prepare_input($_POST['email_random_code']) : ''; $msg = ''; $emails_total = '0'; $emails_sent = '0'; if (strtolower(SITE_MODE) == 'demo') { draw_important_message(_OPERATION_BLOCKED); return false; } if ($email_post_code != '' && $email_session_code == $email_post_code) { $this->error = true; draw_message(_OPERATION_WAS_ALREADY_COMPLETED); return false; } // handle emails sending if ($subject != '' && $message != '') { $message = str_ireplace('{YEAR}', date('Y'), $message); $message = str_ireplace('{WEB SITE}', $_SERVER['SERVER_NAME'], $message); $message = str_ireplace('{BASE URL}', APPHP_BASE, $message); $email_to_parts = explode('|', $email_to_req); $email_to = isset($email_to_parts[0]) ? $email_to_parts[0] : ''; $email_to_subtype = isset($email_to_parts[1]) ? $email_to_parts[1] : ''; if ($email_to_subtype == 'all') { $member_where_clause = ''; } else { if ($email_to_subtype == 'uncategorized') { $member_where_clause = 'group_id=0 AND'; } else { if ($email_to_subtype != '') { $member_where_clause = 'group_id=' . $email_to_subtype . ' AND'; } else { $member_where_clause = ''; } } } if ($email_to == 'test') { $emails_total = '1'; if (send_email_wo_template($admin_email, $admin_email, $subject, $message)) { $emails_sent = '1'; } } else { $result = database_query('SELECT COUNT(*) as cnt FROM ' . $this->TABLE_NAME . ' WHERE is_active = 1 AND ' . $member_where_clause . ' email_notifications = 1 AND email != \'\'', DATA_ONLY, FIRST_ROW_ONLY); $members_emails_total = $result['cnt']; $result = database_query('SELECT COUNT(*) as cnt FROM ' . TABLE_ACCOUNTS . ' WHERE is_active = 1 AND email != \'\'', DATA_ONLY, FIRST_ROW_ONLY); $admins_emails_total = $result['cnt']; $result = database_query('SELECT COUNT(*) as cnt FROM ' . TABLE_NEWS_SUBSCRIBED . ' WHERE email != \'\'', DATA_ONLY, FIRST_ROW_ONLY); $newsletter_email_total = $result['cnt']; if ($email_to == 'members') { $emails_total = $members_emails_total; } else { if ($email_to == 'admins') { $emails_total = $admins_emails_total; } else { if ($email_to == 'all') { $emails_total = $members_emails_total + $admins_emails_total; } else { if ($email_to == 'newsletter_subscribers') { $emails_total = $newsletter_email_total; } } } } if ($email_to == 'members' || $email_to == 'all') { $sql = 'SELECT id, first_name, last_name, email, user_name FROM ' . $this->TABLE_NAME . ' WHERE is_active = 1 AND ' . $member_where_clause . ' email_notifications = 1 AND email != \'\' ORDER BY id ASC'; $result = database_query($sql, DATA_AND_ROWS, ALL_ROWS); for ($i = 0; $i < $result[1]; $i++) { $body_middle = str_ireplace('{FIRST NAME}', $result[0][$i]['first_name'], $message); $body_middle = str_ireplace('{LAST NAME}', $result[0][$i]['last_name'], $body_middle); $body_middle = str_ireplace('{USER NAME}', $result[0][$i]['user_name'], $body_middle); $body_middle = str_ireplace('{USER EMAIL}', $result[0][$i]['email'], $body_middle); if (send_email_wo_template($result[0][$i]['email'], $admin_email, $subject, $body_middle)) { $emails_sent++; } } } if ($email_to == 'admins' || $email_to == 'all') { $sql = 'SELECT id, first_name, last_name, email, user_name FROM ' . TABLE_ACCOUNTS . ' WHERE is_active = 1 AND email != \'\' ORDER BY id ASC'; $result = database_query($sql, DATA_AND_ROWS, ALL_ROWS); for ($i = 0; $i < $result[1]; $i++) { $body_middle = str_ireplace('{FIRST NAME}', $result[0][$i]['first_name'], $message); $body_middle = str_ireplace('{LAST NAME}', $result[0][$i]['last_name'], $body_middle); $body_middle = str_ireplace('{USER NAME}', $result[0][$i]['user_name'], $body_middle); $body_middle = str_ireplace('{USER EMAIL}', $result[0][$i]['email'], $body_middle); if (send_email_wo_template($result[0][$i]['email'], $admin_email, $subject, $body_middle)) { $emails_sent++; } } } if ($email_to == 'newsletter_subscribers') { $sql = 'SELECT email FROM ' . TABLE_NEWS_SUBSCRIBED . ' WHERE email != \'\' ORDER BY id ASC'; $result = database_query($sql, DATA_AND_ROWS, ALL_ROWS); for ($i = 0; $i < $result[1]; $i++) { $body_middle = $message; if (send_email_wo_template($result[0][$i]['email'], $admin_email, $subject, $body_middle)) { $emails_sent++; } } } if ($send_copy_to_admin == '1') { send_email_wo_template($admin_email, $admin_email, $subject . ' (admin copy)', $message); } } if ($emails_sent) { Session::Set('email_random_code', $email_post_code); $msg = str_replace('_SENT_', $emails_sent, _EMAILS_SUCCESSFULLY_SENT); $msg = str_replace('_TOTAL_', $emails_total, $msg); $this->error = false; draw_success_message($msg); } else { $this->error = true; draw_important_message(_EMAILS_SENT_ERROR); } } else { draw_important_message(_EMAIL_FIELDS_EMPTY_ALERT); } }
$email = isset($_POST['email']) ? prepare_input($_POST['email']) : ''; $msg = ''; if ($act == 'send') { if (!check_email_address($email)) { $msg = draw_important_message(_EMAIL_IS_WRONG, false); } else { if (!$password_sent) { $objAdmin = new Admins($objSession->GetSessionVariable('session_account_id')); if ($objAdmin->SendPassword($email)) { $msg = draw_success_message(_PASSWORD_SUCCESSFULLY_SENT, false); Session::Set('password_sent', true); } else { $msg = draw_important_message($objAdmin->error, false); } } else { $msg = draw_message(_PASSWORD_ALREADY_SENT, false); } } } // Draw title bar draw_title_bar(prepare_breadcrumbs(array(_ADMIN => '', _PASSWORD_FORGOTTEN => ''))); // Check if user is logged in if (!$objLogin->IsLoggedIn()) { echo $msg; ?> <div class="pages_contents"> <form action="index.php?admin=password_forgotten" method="post"> <?php draw_hidden_field('act', 'send'); ?> <?php
defined('APPHP_EXEC') or die('Restricted Access'); //-------------------------------------------------------------------------- $act = isset($_POST['act']) ? prepare_input($_POST['act']) : ''; $password_sent = (bool) Session::Get('activation_email_resent'); $email = isset($_POST['email']) ? prepare_input($_POST['email']) : ''; $msg = ''; if ($act == 'resend') { if (!$password_sent) { if (Customers::Reactivate($email)) { $msg = draw_success_message(str_replace('_EMAIL_', $email, _ACTIVATION_EMAIL_WAS_SENT), false); Session::Set('activation_email_resent', true); } else { $msg = draw_important_message(Customers::GetStaticError(), false); } } else { $msg = draw_message(_ACTIVATION_EMAIL_ALREADY_SENT, false); } } // Draw title bar draw_title_bar(_RESEND_ACTIVATION_EMAIL); // Check if customer is logged in if (!$objLogin->IsLoggedIn() && ModulesSettings::Get('customers', 'allow_registration') == 'yes') { echo $msg; ?> <div class="pages_contents"> <form action="index.php?customer=resend_activation" method="post"> <?php draw_hidden_field('act', 'resend'); ?> <?php draw_hidden_field('type', 'customer');
} else { if ($action == 'cancel_edit') { $mode = 'view'; } } } } } } } } // Start main content draw_title_bar(prepare_breadcrumbs(array(_PAYMENTS => '', _CURRENCIES_MANAGEMENT => '', ucfirst($action) => ''))); //if($objSession->IsMessage('notice')) echo $objSession->GetMessage('notice'); if ($mode == 'view' && $msg == '') { $msg = draw_message(_CURRENCIES_DEFAULT_ALERT, false); } echo $msg; draw_content_start(); if ($mode == 'view') { $objCurrencies->DrawViewMode(); } else { if ($mode == 'add') { $objCurrencies->DrawAddMode(); } else { if ($mode == 'edit') { $objCurrencies->DrawEditMode($rid); } else { if ($mode == 'details') { $objCurrencies->DrawDetailsMode($rid); }
<?php // *** Make sure the file isn't accessed directly defined('APPHP_EXEC') or die('Restricted Access'); //-------------------------------------------------------------------------- if (Modules::IsModuleInstalled('payments') && ModulesSettings::Get('payments', 'is_active') == 'yes') { draw_title_bar(prepare_breadcrumbs(array(_MY_ACCOUNT => '', _ADVERTISE => '', _ORDER_CANCELED => ''))); draw_content_start(); draw_message(_ORDER_WAS_CANCELED_MSG, true, true); draw_content_end(); } else { draw_important_message(_NOT_AUTHORIZED); }
/** * Draws Contact Us form * @param $draw */ public function DrawContactUsForm($draw = true) { global $objSettings, $objSiteDescription, $objLogin; $align_left = Application::Get('defined_left'); $align_right = Application::Get('defined_right'); if (!Modules::IsModuleInstalled('contact_us')) { return ''; } $output = ''; $from_email = $objSettings->GetParameter('admin_email'); $admin_email = ModulesSettings::Get('contact_us', 'email'); $delay_length = ModulesSettings::Get('contact_us', 'delay_length'); $is_send_delay = ModulesSettings::Get('contact_us', 'is_send_delay'); $image_verification = ModulesSettings::Get('contact_us', 'image_verification_allow'); $focus_element = ''; // post fields $task = isset($_POST['task']) ? prepare_input($_POST['task']) : ''; $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']) : ''; $subject = isset($_POST['subject']) ? prepare_input($_POST['subject']) : ''; $message = isset($_POST['message']) ? prepare_input($_POST['message']) : ''; $captcha_code = isset($_POST['captcha_code']) ? prepare_input($_POST['captcha_code']) : ''; $msg = ''; $contact_mail_sent = (bool) Session::Get('contact_mail_sent'); $contact_mail_sent_time = Session::Get('contact_mail_sent_time'); if ($image_verification == 'yes') { include_once 'modules/captcha/securimage.php'; $objImg = new Securimage(); } if ($task == 'contact') { $time_elapsed = time_diff(date('Y-m-d H:i:s'), $contact_mail_sent_time); if ($contact_mail_sent && $is_send_delay == 'yes' && $time_elapsed < $delay_length) { $msg = draw_message(str_replace('_WAIT_', $delay_length - $time_elapsed, _CONTACT_US_ALREADY_SENT), false); } else { 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 ($subject == '') { $msg = draw_important_message(_SUBJECT_EMPTY_ALERT, false); $focus_element = 'subject'; #}else if($phone == ''){ # $msg = draw_important_message(str_replace('_FIELD_', _PHONE, _FIELD_CANNOT_BE_EMPTY), false); # $focus_element = 'phone'; } else { if ($message == '') { $msg = draw_important_message(_MESSAGE_EMPTY_ALERT, false); $focus_element = 'message'; } else { if (strlen($message) > 1024) { $msg = draw_important_message(str_replace(array('_FIELD_', '_LENGTH_'), array('<b>' . _MESSAGE . '</b>', 1024), _FIELD_LENGTH_EXCEEDED), false); $focus_element = 'message'; } else { if ($image_verification == 'yes' && !$objImg->check($captcha_code)) { $msg = draw_important_message(_WRONG_CODE_ALERT, false); $focus_element = 'captcha_code'; } } } } } } } } // deny all operations in demo version if (strtolower(SITE_MODE) == 'demo') { $msg = draw_important_message(_OPERATION_BLOCKED, false); } if ($msg == '') { //////////////////////////////////////////////////////////// send_email_wo_template($admin_email, $from_email, 'Question from visitor (via Contact Us - ' . $objSiteDescription->GetParameter('header_text') . ')', _FIRST_NAME . ': ' . str_replace('\\', '', $first_name) . '<br />' . _LAST_NAME . ': ' . str_replace('\\', '', $last_name) . '<br />' . _EMAIL_ADDRESS . ': ' . str_replace('\\', '', $email) . '<br />' . _PHONE . ': ' . str_replace('\\', '', $phone) . '<br />' . _SUBJECT . ': ' . str_replace('\\', '', $subject) . '<br />' . _MESSAGE . ': ' . str_replace('\\', '', $message)); //////////////////////////////////////////////////////////// $msg = draw_success_message(_CONTACT_US_EMAIL_SENT, false); Session::Set('contact_mail_sent', true); Session::Set('contact_mail_sent_time', date('Y-m-d H:i:s')); $first_name = $last_name = $email = $phone = $subject = $message = ''; } } } $output .= ($msg != '' ? $msg . '<br />' : '') . ' <form method="post" name="frmContactUs" id="frmContactUs"> ' . draw_hidden_field('task', 'contact', false) . ' ' . draw_token_field(false) . ' <table class="tblContactUs" border="0" width="99%"> <tbody> <tr> <td width="25%" align="' . $align_right . '">' . _FIRST_NAME . ':</td> <td><span class="mandatory_star">*</span></td> <td nowrap="nowrap" align="' . $align_left . '"><input type="text" id="first_name" name="first_name" size="34" maxlength="40" value="' . decode_text($first_name) . '" autocomplete="off" /></td> </tr> <tr> <td align="' . $align_right . '">' . _LAST_NAME . ':</td> <td><span class="mandatory_star">*</span></td> <td nowrap="nowrap" align="' . $align_left . '"><input type="text" id="last_name" name="last_name" size="34" maxlength="40" value="' . decode_text($last_name) . '" autocomplete="off" /></td> </tr> <tr> <td align="' . $align_right . '">' . _EMAIL_ADDRESS . ':</td> <td><span class="mandatory_star">*</span></td> <td nowrap="nowrap" align="' . $align_left . '"><input type="text" id="email" name="email" size="34" maxlength="70" value="' . decode_text($email) . '" autocomplete="off" /></td> </tr> <tr> <td align="' . $align_right . '">' . _PHONE . ':</td> <td></td> <td nowrap="nowrap" align="' . $align_left . '"><input type="text" id="phone" name="phone" size="22" maxlength="40" value="' . decode_text($phone) . '" autocomplete="off" /></td> </tr> <tr> <td align="' . $align_right . '">' . _SUBJECT . ':</td> <td><span class="mandatory_star">*</span></td> <td nowrap="nowrap" align="' . $align_left . '"><input type="text" id="subject" name="subject" style="width:385px;" maxlength="128" value="' . decode_text($subject) . '" autocomplete="off" /></td> </tr> <tr valign="top"> <td align="' . $align_right . '">' . _MESSAGE . ':</td> <td><span class="mandatory_star">*</span></td> <td nowrap="nowrap" align="' . $align_left . '"> <textarea id="message" name="message" style="width:385px;" maxlength="1024" rows="8">' . $message . '</textarea> </td> </tr> <tr> <td colspan="2"></td> <td>'; if ($image_verification == 'yes') { $output .= '<table border="0"> <tr> <td> <img id="captcha_image" src="' . APPHP_BASE . 'modules/captcha/securimage_show.php?sid=' . md5(uniqid(time())) . '" /> </td> <td width="30px" align="center"> <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 align="left"> ' . _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="25" nowrap colspan="3"></td></tr> <tr> <td colspan="3" align="center"> <input type="submit" ' . ($objLogin->IsLoggedInAsAdmin() ? 'disabled' : '') . ' class="form_button" name="btnSubmitPD" id="btnSubmitPD" value="' . _SEND . '" /> </td> </tr> <tr><td height="25" nowrap colspan="3"></td></tr> </table> </form>'; if ($focus_element != '') { $output .= '<script type="text/javascript">appSetFocus(\'' . $focus_element . '\');</script>'; } if ($draw) { echo $output; } else { return $output; } }