0) { } else if (strlen($delete) > 0 && is_array($feedback_id) && ! $restricted) { ezin_admin_feedbacks_delete($feedback_id); } else if (strlen($resend) > 0 && is_array($feedback_id) && ! $restricted) { ezin_admin_feedbacks_resend($feedback_id); } else if (! is_array($feedback_id)) { $feedback_id = intval($feedback_id); if ($feedback_id > 0) { return ezin_admin_feedbacks_view($restricted, $feedback_id); } } } return ezin_admin_feedbacks_list($restricted); } /* }}} */ function ezin_admin_feedbacks_delete($ar) /* {{{ */ { global $ezin_cfg; global $ezin_sys; global $ezin_db_handle; foreach ($ar as $feedback_id) { $feedback_id = intval($feedback_id); if ($feedback_id <= 0) { continue; } $query = sprintf('DELETE FROM %s WHERE feedback_id = %d', $ezin_sys['db']['tables']['feedback_data'], $feedback_id); mysqli_query($ezin_db_handle, $query); $query = sprintf('DELETE FROM %s WHERE id = %d', $ezin_sys['db']['tables']['feedbacks'], $feedback_id); mysqli_query($ezin_db_handle, $query); } return true; } /* }}} */ function ezin_admin_feedbacks_resend($ar) /* {{{ */ { global $ezin_cfg; global $ezin_sys; global $ezin_db_handle; foreach ($ar as $feedback_id) { $feedback_id = intval($feedback_id); if ($feedback_id <= 0) { continue; } $query = sprintf('SELECT field, data FROM %s WHERE feedback_id = %d', $ezin_sys['db']['tables']['feedback_data'], $feedback_id); $result = mysqli_query($ezin_db_handle, $query); if ($result == false) { ezin_db_error('ezin_admin_feedbacks_resend() [1]'); return false; } $data = array(); while (($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) != null) { $data[$row['field']] = $row['data']; } mysqli_free_result($result); ezin_feedback_send_notify_email($data); } return true; } /* }}} */ function ezin_admin_feedbacks_view($restricted, $feedback_id) /* {{{ */ { global $ezin_cfg; global $ezin_sys; global $ezin_db_handle; $query = sprintf('SELECT' .' f.id, f.section_id, s.access_key AS section_key, f.datetime, f.ip, f.user_agent' .' FROM %s AS f LEFT JOIN %s AS s ON f.section_id = s.id' .' WHERE f.id = %d', $ezin_sys['db']['tables']['feedbacks'], $ezin_sys['db']['tables']['sections'], $feedback_id); $result = mysqli_query($ezin_db_handle, $query); if ($result == false) { ezin_db_error('ezin_admin_feedbacks_view() [1]'); return false; } $feedback = mysqli_fetch_array($result, MYSQLI_ASSOC); mysqli_free_result($result); $query = sprintf('SELECT * FROM %s WHERE feedback_id = %d', $ezin_sys['db']['tables']['feedback_data'], $feedback_id); $result = mysqli_query($ezin_db_handle, $query); if ($result == false) { ezin_db_error('ezin_admin_feedbacks_view() [2]'); return false; } $feedback_data = array(); while (($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) != null) { $feedback_data[$row['field']] = $row['data']; } mysqli_free_result($result); $limit = Platon::get_cgi_var('limit', ''); $PHP_SELF = htmlspecialchars($_SERVER['PHP_SELF']); echo '
',"\n"; echo ''."\n"; echo ''."\n"; if (stristr($ezin_cfg['admin_buttons_pos'], 'U')) { ezin_admin_feedbacks_view_button($restricted); echo '
',"\n"; } if (intval(@$feedback['section_id']) > 0) { $section_data = intval(@$feedback['section_id']); if (strlen(@$feedback['section_key']) > 0) { $section_data .= sprintf(' (%s)', htmlspecialchars(@$feedback['section_key'])); } } else { $section_data = 'unknown'; } $ip_address = ''.$feedback['ip'].''; ?> $val) { $val = strlen(@$val) > 0 ? nl2br(htmlspecialchars($val)) : ' '; $key = htmlspecialchars($key); printf('', $i, $i, $key, $i, $val); $i++; $i &= 1; } ?>
System data
ID
Section
Date & Time
IP
User Agent
Form data
%s%s
',"\n"; ezin_admin_feedbacks_view_button($restricted); } } /* }}} */ function ezin_admin_feedbacks_list($restricted) /* {{{ */ { global $ezin_cfg; global $ezin_sys; global $ezin_db_handle; $refresh_up = Platon::get_cgi_var('refresh_up'); $refresh_down = Platon::get_cgi_var('refresh_down'); if (isset($refresh_up)) { $limit = Platon::get_cgi_var('limit_up'); } elseif (isset($refresh_down)) { $limit = Platon::get_cgi_var('limit_down'); } else { $limit = Platon::get_cgi_var('limit'); } if (! isset($limit)) { $limit = 15; } else { $limit = intval($limit); } echo '',"\n"; if (stristr($ezin_cfg['admin_buttons_pos'], 'U')) { ezin_admin_feedbacks_limit_field($limit, 'up'); echo '
',"\n"; } /* * Database query for getting feedbacks */ $query = sprintf('SELECT' .' f.id, f.section_id, s.access_key AS section_key, f.datetime, f.ip, f.user_agent' .' FROM %s AS f LEFT JOIN %s AS s ON f.section_id = s.id' .' ORDER BY f.datetime DESC, id DESC', $ezin_sys['db']['tables']['feedbacks'], $ezin_sys['db']['tables']['sections']); if (intval($limit) > 0) $query .= ' LIMIT ' . intval($limit); //echo "$query
"; $result = mysqli_query($ezin_db_handle, $query); if ($result == false) { ezin_db_error('ezin_admin_feedbacks_list()'); return false; } echo '',"\n"; if (mysqli_num_rows($result) == 0) { echo ''; } else { ?> ', ''); while (($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) != null) { if (intval(@$row['section_id']) > 0) { $section_data = intval(@$row['section_id']); if (strlen(@$row['section_key']) > 0) { $section_data .= sprintf(' (%s)', htmlspecialchars(@$row['section_key'])); } } else { $section_data = 'unknown'; } $ip_address = ''.$row['ip'].''; echo $tr_data[$count & 1]; $td_nav = sprintf(''; } printf($td_nav.' [ %03d ] ' .$td_cell.'%s'.$td_cell.'%s'.$td_cell.'%s'.$td_cell.'%s', $_SERVER['PHP_SELF'], $row['id'], $limit, $row['id'], $section_data, $row['datetime'], $ip_address, $row['user_agent']); echo "\n"; $count++; } echo '
No feedbacks in database.
>ID Section Date & Time IP User Agent
'."\n", $count & 1); $td_cell = sprintf('' ."\n", $count & 1); if (! $restricted) { echo $td_nav,"\n"; echo ''; echo '
',"\n"; mysqli_free_result($result); if (stristr($ezin_cfg['admin_buttons_pos'], 'D') || ! stristr($ezin_cfg['admin_buttons_pos'], 'U')) { echo '
',"\n"; ezin_admin_feedbacks_limit_field($limit, 'down'); } echo '
',"\n"; return true; } /* }}} */ function ezin_admin_feedbacks_limit_field($limit, $pos) /* {{{ */ { $text_name = "limit_$pos"; $refresh_submit_name = "refresh_$pos"; echo '',"\n"; echo '',"\n",'
',"\n"; echo '',"\n"; echo '',"\n"; echo '',"\n"; echo '',"\n"; echo 'Rows count (0 = unlimited):'; echo '  '; echo '
',"\n"; } /* }}} */ function ezin_admin_feedbacks_view_button($restricted) /* {{{ */ { echo '',"\n"; echo '
',"\n"; if (! $restricted) { echo '',"\n"; echo '',"\n"; } echo '',"\n"; echo '
',"\n"; } /* }}} */ /* * Main stuff */ if (strstr($ezin_user['role_feedbacks'], 'C')) { ezin_check_db_handle(); ezin_admin_feedbacks_main(0); ezin_close_db_connection(); } elseif (ezin_admin_check_list_privileges($ezin_user['role_feedbacks'])) { ezin_check_db_handle(); ezin_admin_feedbacks_main(1); ezin_close_db_connection(); } /* Modeline for ViM {{{ * vim: set ts=4: * vim600: fdm=marker fdl=0 fdc=0: * }}} */ ?>