function get_time_n_query($line)
{
    include 'config.php';
    $pos_log = strpos($line, $delimiter_for_query);
    $pos_log = $pos_log + strlen($delimiter_for_query);
    $trimmed_line = substr($line, $pos_log);
    $time = substr($trimmed_line, 0, strpos($trimmed_line, ' '));
    //first occurence of select
    $query = substr($trimmed_line, strpos($trimmed_line, 'SELECT'));
    $query = substr($query, 0, $max_query_len);
    $sql_token = tokenize_query($query);
    $where_tokens = count_where_str_token($sql_token['where']);
    $assigned_grp = get_group_name($where_tokens);
    $hash = create_hash($sql_token['select'] . $sql_token['table'] . $assigned_grp);
    $response = array('group' => $assigned_grp, 'time' => $time, 'hash' => $hash, 'query' => $query, 'token' => $sql_token, 'where_tokens' => $where_tokens);
    return $response;
}
예제 #2
0
 function do_detail($info = array(), $info_lang = array())
 {
     global $ttH;
     $data = array_merge($info, $info_lang);
     $data["link_action"] = $ttH->site->get_link('product', '', $info_lang['friendly_link']);
     $data["picture"] = $ttH->func->get_src_mod('product/' . $info["picture"], 300, 300, 1, 0, array('fix_width' => 1));
     $data["brand_name"] = get_brand_name($info["brand_id"], 'link');
     $data["group_name"] = get_group_name($info["group_id"], 'link');
     $data["price"] = $ttH->func->get_price_format($info["price"]);
     $sql = "select option_id,title  \n\t\t\t\t\t\tfrom product_option \n\t\t\t\t\t\twhere is_show=1 \n\t\t\t\t\t\torder by show_order desc, date_create asc";
     //echo $sql;
     $result = $ttH->db->query($sql);
     $html_row = "";
     while ($row = $ttH->db->fetch_row($result)) {
         if (isset($data['arr_option'][$row['option_id']])) {
             $row['content'] = $data['arr_option'][$row['option_id']];
             $ttH->temp_act->assign('row', $row);
             $ttH->temp_act->parse("detail.info_row");
         }
     }
     $ttH->temp_act->assign('data', $data);
     $ttH->temp_act->parse("detail.btn_add_cart");
     $data['other'] = list_other(" and a.item_id!='" . $data['item_id'] . "'");
     $ttH->temp_act->assign('data', $data);
     $ttH->temp_act->parse("detail");
     $nd = array('title' => $data['title'], 'content' => $ttH->temp_act->text("detail"));
     return $ttH->html->temp_box("box_main", $nd);
 }
예제 #3
0
    function main($id, $mode)
    {
        global $config, $db, $user, $auth, $template, $cache;
        global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
        $user->add_lang('acp/email');
        $this->tpl_name = 'acp_email';
        $this->page_title = 'ACP_MASS_EMAIL';
        $form_key = 'acp_email';
        add_form_key($form_key);
        // Set some vars
        $submit = isset($_POST['submit']) ? true : false;
        $error = array();
        $usernames = request_var('usernames', '', true);
        $group_id = request_var('g', 0);
        $subject = utf8_normalize_nfc(request_var('subject', '', true));
        $message = utf8_normalize_nfc(request_var('message', '', true));
        // Do the job ...
        if ($submit) {
            // Error checking needs to go here ... if no subject and/or no message then skip
            // over the send and return to the form
            $use_queue = isset($_POST['send_immediately']) ? false : true;
            $priority = request_var('mail_priority_flag', MAIL_NORMAL_PRIORITY);
            if (!check_form_key($form_key)) {
                $error[] = $user->lang['FORM_INVALID'];
            }
            if (!$subject) {
                $error[] = $user->lang['NO_EMAIL_SUBJECT'];
            }
            if (!$message) {
                $error[] = $user->lang['NO_EMAIL_MESSAGE'];
            }
            if (!sizeof($error)) {
                if ($usernames) {
                    // If giving usernames the admin is able to email inactive users too...
                    $sql = 'SELECT username, user_email, user_jabber, user_notify_type, user_lang
						FROM ' . USERS_TABLE . '
						WHERE ' . $db->sql_in_set('username_clean', array_map('utf8_clean_string', explode("\n", $usernames))) . '
							AND user_allow_massemail = 1
						ORDER BY user_lang, user_notify_type';
                    // , SUBSTRING(user_email FROM INSTR(user_email, '@'))
                } else {
                    if ($group_id) {
                        $sql_ary = array('SELECT' => 'u.user_email, u.username, u.username_clean, u.user_lang, u.user_jabber, u.user_notify_type', 'FROM' => array(USERS_TABLE => 'u', USER_GROUP_TABLE => 'ug'), 'WHERE' => 'ug.group_id = ' . $group_id . '
								AND ug.user_pending = 0
								AND u.user_id = ug.user_id
								AND u.user_allow_massemail = 1
								AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')', 'ORDER_BY' => 'u.user_lang, u.user_notify_type');
                    } else {
                        $sql_ary = array('SELECT' => 'u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'u.user_allow_massemail = 1
								AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')', 'ORDER_BY' => 'u.user_lang, u.user_notify_type');
                    }
                    // Mail banned or not
                    if (!isset($_REQUEST['mail_banned_flag'])) {
                        $sql_ary['WHERE'] .= ' AND (b.ban_id IS NULL
						        OR b.ban_exclude = 1)';
                        $sql_ary['LEFT_JOIN'] = array(array('FROM' => array(BANLIST_TABLE => 'b'), 'ON' => 'u.user_id = b.ban_userid'));
                    }
                    $sql = $db->sql_build_query('SELECT', $sql_ary);
                }
                $result = $db->sql_query($sql);
                $row = $db->sql_fetchrow($result);
                if (!$row) {
                    $db->sql_freeresult($result);
                    trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                $i = $j = 0;
                // Send with BCC, no more than 50 recipients for one mail (to not exceed the limit)
                $max_chunk_size = 50;
                $email_list = array();
                $old_lang = $row['user_lang'];
                $old_notify_type = $row['user_notify_type'];
                do {
                    if ($row['user_notify_type'] == NOTIFY_EMAIL && $row['user_email'] || $row['user_notify_type'] == NOTIFY_IM && $row['user_jabber'] || $row['user_notify_type'] == NOTIFY_BOTH && ($row['user_email'] || $row['user_jabber'])) {
                        if ($i == $max_chunk_size || $row['user_lang'] != $old_lang || $row['user_notify_type'] != $old_notify_type) {
                            $i = 0;
                            if (sizeof($email_list)) {
                                $j++;
                            }
                            $old_lang = $row['user_lang'];
                            $old_notify_type = $row['user_notify_type'];
                        }
                        $email_list[$j][$i]['lang'] = $row['user_lang'];
                        $email_list[$j][$i]['method'] = $row['user_notify_type'];
                        $email_list[$j][$i]['email'] = $row['user_email'];
                        $email_list[$j][$i]['name'] = $row['username'];
                        $email_list[$j][$i]['jabber'] = $row['user_jabber'];
                        $i++;
                    }
                } while ($row = $db->sql_fetchrow($result));
                $db->sql_freeresult($result);
                // Send the messages
                include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
                include_once $phpbb_root_path . 'includes/functions_user.' . $phpEx;
                $messenger = new messenger($use_queue);
                $errored = false;
                for ($i = 0, $size = sizeof($email_list); $i < $size; $i++) {
                    $used_lang = $email_list[$i][0]['lang'];
                    $used_method = $email_list[$i][0]['method'];
                    for ($j = 0, $list_size = sizeof($email_list[$i]); $j < $list_size; $j++) {
                        $email_row = $email_list[$i][$j];
                        $messenger->{sizeof($email_list[$i]) == 1 ? 'to' : 'bcc'}($email_row['email'], $email_row['name']);
                        $messenger->im($email_row['jabber'], $email_row['name']);
                    }
                    $messenger->template('admin_send_email', $used_lang);
                    $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
                    $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
                    $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
                    $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
                    $messenger->subject(htmlspecialchars_decode($subject));
                    $messenger->set_mail_priority($priority);
                    $messenger->assign_vars(array('CONTACT_EMAIL' => $config['board_contact'], 'MESSAGE' => htmlspecialchars_decode($message)));
                    if (!$messenger->send($used_method)) {
                        $errored = true;
                    }
                }
                unset($email_list);
                $messenger->save_queue();
                if ($usernames) {
                    $usernames = explode("\n", $usernames);
                    add_log('admin', 'LOG_MASS_EMAIL', implode(', ', utf8_normalize_nfc($usernames)));
                } else {
                    if ($group_id) {
                        $group_name = get_group_name($group_id);
                    } else {
                        // Not great but the logging routine doesn't cope well with localising on the fly
                        $group_name = $user->lang['ALL_USERS'];
                    }
                    add_log('admin', 'LOG_MASS_EMAIL', $group_name);
                }
                if (!$errored) {
                    $message = $use_queue ? $user->lang['EMAIL_SENT_QUEUE'] : $user->lang['EMAIL_SENT'];
                    trigger_error($message . adm_back_link($this->u_action));
                } else {
                    $message = sprintf($user->lang['EMAIL_SEND_ERROR'], '<a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=logs&amp;mode=critical') . '">', '</a>');
                    trigger_error($message . adm_back_link($this->u_action), E_USER_WARNING);
                }
            }
        }
        // Exclude bots and guests...
        $sql = 'SELECT group_id
			FROM ' . GROUPS_TABLE . "\n\t\t\tWHERE group_name IN ('BOTS', 'GUESTS')";
        $result = $db->sql_query($sql);
        $exclude = array();
        while ($row = $db->sql_fetchrow($result)) {
            $exclude[] = $row['group_id'];
        }
        $db->sql_freeresult($result);
        $select_list = '<option value="0"' . (!$group_id ? ' selected="selected"' : '') . '>' . $user->lang['ALL_USERS'] . '</option>';
        $select_list .= group_select_options($group_id, $exclude);
        $s_priority_options = '<option value="' . MAIL_LOW_PRIORITY . '">' . $user->lang['MAIL_LOW_PRIORITY'] . '</option>';
        $s_priority_options .= '<option value="' . MAIL_NORMAL_PRIORITY . '" selected="selected">' . $user->lang['MAIL_NORMAL_PRIORITY'] . '</option>';
        $s_priority_options .= '<option value="' . MAIL_HIGH_PRIORITY . '">' . $user->lang['MAIL_HIGH_PRIORITY'] . '</option>';
        $template->assign_vars(array('S_WARNING' => sizeof($error) ? true : false, 'WARNING_MSG' => sizeof($error) ? implode('<br />', $error) : '', 'U_ACTION' => $this->u_action, 'S_GROUP_OPTIONS' => $select_list, 'USERNAMES' => $usernames, 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser&amp;form=acp_email&amp;field=usernames'), 'SUBJECT' => $subject, 'MESSAGE' => $message, 'S_PRIORITY_OPTIONS' => $s_priority_options));
    }
예제 #4
0
" /> 
			</div>
		</td>
	</tr>
	</tfoot>
	<tbody>

<?php 
    foreach ($categories as $id => $row) {
        if (!empty($row['cat_name'])) {
            $parent_cat_name = '';
            if ($row['cat_parent']) {
                $row_cat = queryDB('SELECT name, owner_id, owner_type FROM %slinks_categories WHERE cat_id=%d', array(TABLE_PREFIX, $row['cat_parent']), true);
                $parent_cat_name = AT_print($row_cat['name'], 'links_categories.name');
                if (empty($parent_cat_name)) {
                    $parent_cat_name = get_group_name($row_cat['owner_id']);
                }
            } else {
                $parent_cat_name = '<strong>' . _AT('none') . '</strong>';
            }
            ?>
		<tr onmousedown="document.form['m<?php 
            echo $id;
            ?>
'].checked = true;rowselect(this);" id="r_<?php 
            echo $id;
            ?>
">
			<td width="10"><input type="radio" name="cat_id" value="<?php 
            echo $id;
            ?>
예제 #5
0
    /**
     * Starts the chat.
     *
     * @param Request $request Incoming request.
     * @return string|\Symfony\Component\HttpFoundation\RedirectResponse
     *   Rendered page content or a redirect response.
     * @todo Split the action into pieces.
     */
    public function startAction(Request $request)
    {
        // Check if we should force the user to use SSL
        $ssl_redirect = $this->sslRedirect($request);
        if ($ssl_redirect !== false) {
            return $ssl_redirect;
        }

        // Initialize client side application
        $this->getAssetManager()->attachJs('js/compiled/chat_app.js');

        $thread = null;
        // Try to get thread from the session
        if (isset($_SESSION[SESSION_PREFIX . 'threadid'])) {
            $thread = Thread::reopen($_SESSION[SESSION_PREFIX . 'threadid']);
        }

        // Create new thread
        if (!$thread) {
            // Load group info
            $group_id = '';
            $group_name = '';
            $group = null;
            if (Settings::get('enablegroups') == '1') {
                $group_id = $request->query->get('group');
                if (!preg_match("/^\d{1,10}$/", $group_id)) {
                    $group_id = false;
                }

                if ($group_id) {
                    $group = group_by_id($group_id);
                    if (!$group) {
                        $group_id = false;
                    } else {
                        $group_name = get_group_name($group);
                    }
                }
            }

            // Get operator code
            $operator_code = $request->query->get('operator_code');
            if (!preg_match("/^[A-z0-9_]+$/", $operator_code)) {
                $operator_code = false;
            }

            // Get visitor info
            $visitor = visitor_from_request();
            $info = $request->query->get('info');
            $email = $request->query->get('email');

            // Get referrer
            $referrer = $request->query->get('url', $request->headers->get('referer'));
            if ($request->query->get('referrer')) {
                $referrer .= "\n" . $request->query->get('referrer');
            }

            // Check if there are online operators
            if (!has_online_operators($group_id)) {
                // Display leave message page
                $page = array_merge_recursive(
                    setup_logo($group),
                    setup_leavemessage(
                        $visitor['name'],
                        $email,
                        $group_id,
                        $info,
                        $referrer
                    )
                );
                $page['leaveMessageOptions'] = $page['leaveMessage'];

                $this->getAssetManager()->attachJs(
                    $this->startJsApplication($request, $page),
                    AssetManagerInterface::INLINE,
                    1000
                );

                return $this->render('chat', $page);
            }

            // Get invitation info
            if (Settings::get('enabletracking') && !empty($_SESSION[SESSION_PREFIX . 'visitorid'])) {
                $invitation_state = invitation_state($_SESSION[SESSION_PREFIX . 'visitorid']);
                $visitor_is_invited = $invitation_state['invited'];
            } else {
                $visitor_is_invited = false;
            }

            // Get operator info
            $requested_operator = false;
            if ($operator_code) {
                $requested_operator = operator_by_code($operator_code);
            }

            // Check if survey should be displayed
            if (Settings::get('enablepresurvey') == '1' && !$visitor_is_invited && !$requested_operator) {
                // Display prechat survey
                $page = array_merge_recursive(
                    setup_logo($group),
                    setup_survey(
                        $visitor['name'],
                        $email,
                        $group_id,
                        $info,
                        $referrer
                    )
                );
                $page['surveyOptions'] = $page['survey'];

                $this->getAssetManager()->attachJs(
                    $this->startJsApplication($request, $page),
                    AssetManagerInterface::INLINE,
                    1000
                );

                return $this->render('chat', $page);
            }

            // Start chat thread
            $thread = chat_start_for_user(
                $group_id,
                $requested_operator,
                $visitor['id'],
                $visitor['name'],
                $referrer,
                $info
            );
        }
        $path_args = array(
            'thread_id' => intval($thread->id),
            'token' => urlencode($thread->lastToken),
        );

        $chat_style_name = $request->query->get('style');
        if (preg_match("/^\w+$/", $chat_style_name)) {
            $path_args['style'] = $chat_style_name;
        }

        return $this->redirect($this->generateUrl('chat_user', $path_args));
    }
예제 #6
0
 function reverse_ids()
 {
     if (!is_null($this->pilot_id)) {
         $this->pilot = get_pilot_name($this->pilot_id);
     }
     if (!is_null($this->alliance_id)) {
         $this->alliance = get_alliance_name($this->alliance_id);
     }
     if (!is_null($this->corp_id)) {
         $this->corp = get_corp_name($this->corp_id);
         $this->corp_ticker = get_corp_ticker($this->corp_id, 1);
     }
     if (!is_null($this->ship_id)) {
         $this->ship = get_item_name($this->ship_id);
     }
     if (!is_null($this->group_id)) {
         $this->group = get_group_name($this->group_id);
     }
     if (!is_null($this->weapon_id)) {
         $this->weapon = get_item_name($this->weapon_id);
     }
 }
예제 #7
0
파일: acp_email.php 프로젝트: hgchen/phpbb
    function main($id, $mode)
    {
        global $config, $db, $user, $auth, $template, $cache, $phpbb_log, $request;
        global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $phpbb_dispatcher;
        $user->add_lang('acp/email');
        $this->tpl_name = 'acp_email';
        $this->page_title = 'ACP_MASS_EMAIL';
        $form_key = 'acp_email';
        add_form_key($form_key);
        // Set some vars
        $submit = isset($_POST['submit']) ? true : false;
        $error = array();
        $usernames = $request->variable('usernames', '', true);
        $usernames = !empty($usernames) ? explode("\n", $usernames) : array();
        $group_id = $request->variable('g', 0);
        $subject = $request->variable('subject', '', true);
        $message = $request->variable('message', '', true);
        // Do the job ...
        if ($submit) {
            // Error checking needs to go here ... if no subject and/or no message then skip
            // over the send and return to the form
            $use_queue = isset($_POST['send_immediately']) ? false : true;
            $priority = $request->variable('mail_priority_flag', MAIL_NORMAL_PRIORITY);
            if (!check_form_key($form_key)) {
                $error[] = $user->lang['FORM_INVALID'];
            }
            if (!$subject) {
                $error[] = $user->lang['NO_EMAIL_SUBJECT'];
            }
            if (!$message) {
                $error[] = $user->lang['NO_EMAIL_MESSAGE'];
            }
            if (!sizeof($error)) {
                if (!empty($usernames)) {
                    // If giving usernames the admin is able to email inactive users too...
                    $sql_ary = array('SELECT' => 'username, user_email, user_jabber, user_notify_type, user_lang', 'FROM' => array(USERS_TABLE => ''), 'WHERE' => $db->sql_in_set('username_clean', array_map('utf8_clean_string', $usernames)) . '
							AND user_allow_massemail = 1', 'ORDER_BY' => 'user_lang, user_notify_type');
                } else {
                    if ($group_id) {
                        $sql_ary = array('SELECT' => 'u.user_email, u.username, u.username_clean, u.user_lang, u.user_jabber, u.user_notify_type', 'FROM' => array(USERS_TABLE => 'u', USER_GROUP_TABLE => 'ug'), 'WHERE' => 'ug.group_id = ' . $group_id . '
								AND ug.user_pending = 0
								AND u.user_id = ug.user_id
								AND u.user_allow_massemail = 1
								AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')', 'ORDER_BY' => 'u.user_lang, u.user_notify_type');
                    } else {
                        $sql_ary = array('SELECT' => 'u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'u.user_allow_massemail = 1
								AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')', 'ORDER_BY' => 'u.user_lang, u.user_notify_type');
                    }
                    // Mail banned or not
                    if (!isset($_REQUEST['mail_banned_flag'])) {
                        $sql_ary['WHERE'] .= ' AND (b.ban_id IS NULL
						        OR b.ban_exclude = 1)';
                        $sql_ary['LEFT_JOIN'] = array(array('FROM' => array(BANLIST_TABLE => 'b'), 'ON' => 'u.user_id = b.ban_userid'));
                    }
                }
                /**
                 * Modify sql query to change the list of users the email is sent to
                 *
                 * @event core.acp_email_modify_sql
                 * @var	array	sql_ary		Array which is used to build the sql query
                 * @since 3.1.2-RC1
                 */
                $vars = array('sql_ary');
                extract($phpbb_dispatcher->trigger_event('core.acp_email_modify_sql', compact($vars)));
                $sql = $db->sql_build_query('SELECT', $sql_ary);
                $result = $db->sql_query($sql);
                $row = $db->sql_fetchrow($result);
                if (!$row) {
                    $db->sql_freeresult($result);
                    trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                $i = $j = 0;
                // Send with BCC
                // Maximum number of bcc recipients
                $max_chunk_size = (int) $config['email_max_chunk_size'];
                $email_list = array();
                $old_lang = $row['user_lang'];
                $old_notify_type = $row['user_notify_type'];
                do {
                    if ($row['user_notify_type'] == NOTIFY_EMAIL && $row['user_email'] || $row['user_notify_type'] == NOTIFY_IM && $row['user_jabber'] || $row['user_notify_type'] == NOTIFY_BOTH && ($row['user_email'] || $row['user_jabber'])) {
                        if ($i == $max_chunk_size || $row['user_lang'] != $old_lang || $row['user_notify_type'] != $old_notify_type) {
                            $i = 0;
                            if (sizeof($email_list)) {
                                $j++;
                            }
                            $old_lang = $row['user_lang'];
                            $old_notify_type = $row['user_notify_type'];
                        }
                        $email_list[$j][$i]['lang'] = $row['user_lang'];
                        $email_list[$j][$i]['method'] = $row['user_notify_type'];
                        $email_list[$j][$i]['email'] = $row['user_email'];
                        $email_list[$j][$i]['name'] = $row['username'];
                        $email_list[$j][$i]['jabber'] = $row['user_jabber'];
                        $i++;
                    }
                } while ($row = $db->sql_fetchrow($result));
                $db->sql_freeresult($result);
                // Send the messages
                include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
                include_once $phpbb_root_path . 'includes/functions_user.' . $phpEx;
                $messenger = new messenger($use_queue);
                $errored = false;
                $email_template = 'admin_send_email';
                $template_data = array('CONTACT_EMAIL' => phpbb_get_board_contact($config, $phpEx), 'MESSAGE' => htmlspecialchars_decode($message));
                $generate_log_entry = true;
                /**
                 * Modify email template data before the emails are sent
                 *
                 * @event core.acp_email_send_before
                 * @var	string	email_template		The template to be used for sending the email
                 * @var	string	subject				The subject of the email
                 * @var	array	template_data		Array with template data assigned to email template
                 * @var	bool	generate_log_entry	If false, no log entry will be created
                 * @var	array	usernames			Usernames which will be displayed in log entry, if it will be created
                 * @var	int		group_id			The group this email will be sent to
                 * @var	bool	use_queue			If true, email queue will be used for sending
                 * @var	int		priority			Priority of sent emails
                 * @since 3.1.3-RC1
                 */
                $vars = array('email_template', 'subject', 'template_data', 'generate_log_entry', 'usernames', 'group_id', 'use_queue', 'priority');
                extract($phpbb_dispatcher->trigger_event('core.acp_email_send_before', compact($vars)));
                for ($i = 0, $size = sizeof($email_list); $i < $size; $i++) {
                    $used_lang = $email_list[$i][0]['lang'];
                    $used_method = $email_list[$i][0]['method'];
                    for ($j = 0, $list_size = sizeof($email_list[$i]); $j < $list_size; $j++) {
                        $email_row = $email_list[$i][$j];
                        $messenger->{sizeof($email_list[$i]) == 1 ? 'to' : 'bcc'}($email_row['email'], $email_row['name']);
                        $messenger->im($email_row['jabber'], $email_row['name']);
                    }
                    $messenger->template($email_template, $used_lang);
                    $messenger->anti_abuse_headers($config, $user);
                    $messenger->subject(htmlspecialchars_decode($subject));
                    $messenger->set_mail_priority($priority);
                    $messenger->assign_vars($template_data);
                    if (!$messenger->send($used_method)) {
                        $errored = true;
                    }
                }
                unset($email_list);
                $messenger->save_queue();
                if ($generate_log_entry) {
                    if (!empty($usernames)) {
                        $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_MASS_EMAIL', false, array(implode(', ', utf8_normalize_nfc($usernames))));
                    } else {
                        if ($group_id) {
                            $group_name = get_group_name($group_id);
                        } else {
                            // Not great but the logging routine doesn't cope well with localising on the fly
                            $group_name = $user->lang['ALL_USERS'];
                        }
                        $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_MASS_EMAIL', false, array($group_name));
                    }
                }
                if (!$errored) {
                    $message = $use_queue ? $user->lang['EMAIL_SENT_QUEUE'] : $user->lang['EMAIL_SENT'];
                    trigger_error($message . adm_back_link($this->u_action));
                } else {
                    $message = sprintf($user->lang['EMAIL_SEND_ERROR'], '<a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=logs&amp;mode=critical') . '">', '</a>');
                    trigger_error($message . adm_back_link($this->u_action), E_USER_WARNING);
                }
            }
        }
        // Exclude bots and guests...
        $sql = 'SELECT group_id
			FROM ' . GROUPS_TABLE . "\n\t\t\tWHERE group_name IN ('BOTS', 'GUESTS')";
        $result = $db->sql_query($sql);
        $exclude = array();
        while ($row = $db->sql_fetchrow($result)) {
            $exclude[] = $row['group_id'];
        }
        $db->sql_freeresult($result);
        $select_list = '<option value="0"' . (!$group_id ? ' selected="selected"' : '') . '>' . $user->lang['ALL_USERS'] . '</option>';
        $select_list .= group_select_options($group_id, $exclude);
        $s_priority_options = '<option value="' . MAIL_LOW_PRIORITY . '">' . $user->lang['MAIL_LOW_PRIORITY'] . '</option>';
        $s_priority_options .= '<option value="' . MAIL_NORMAL_PRIORITY . '" selected="selected">' . $user->lang['MAIL_NORMAL_PRIORITY'] . '</option>';
        $s_priority_options .= '<option value="' . MAIL_HIGH_PRIORITY . '">' . $user->lang['MAIL_HIGH_PRIORITY'] . '</option>';
        $template_data = array('S_WARNING' => sizeof($error) ? true : false, 'WARNING_MSG' => sizeof($error) ? implode('<br />', $error) : '', 'U_ACTION' => $this->u_action, 'S_GROUP_OPTIONS' => $select_list, 'USERNAMES' => implode("\n", $usernames), 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser&amp;form=acp_email&amp;field=usernames'), 'SUBJECT' => $subject, 'MESSAGE' => $message, 'S_PRIORITY_OPTIONS' => $s_priority_options);
        /**
         * Modify custom email template data before we display the form
         *
         * @event core.acp_email_display
         * @var	array	template_data		Array with template data assigned to email template
         * @var	array	exclude				Array with groups which are excluded from group selection
         * @var	array	usernames			Usernames which will be displayed in form
         *
         * @since 3.1.4-RC1
         */
        $vars = array('template_data', 'exclude', 'usernames');
        extract($phpbb_dispatcher->trigger_event('core.acp_email_display', compact($vars)));
        $template->assign_vars($template_data);
    }
예제 #8
0
function setup_redirect_links(UrlGeneratorInterface $url_generator, $threadid, $operator, $token)
{
    $result = array();

    $operator_in_isolation = in_isolation($operator);

    $list_options = $operator_in_isolation
        ? array('isolated_operator_id' => $operator['operatorid'])
        : array();
    $operators = get_operators_list($list_options);
    $operators_count = count($operators);

    $groups_count = 0;
    $groups = array();
    if (Settings::get('enablegroups') == "1") {
        $groupslist = $operator_in_isolation
            ? get_groups_for_operator($operator, true)
            : get_groups(true);
        foreach ($groupslist as $group) {
            if ($group['inumofagents'] == 0) {
                continue;
            }
            $groups[] = $group;
        }
        $groups_count = count($groups);
    }

    $p = pagination_info(max($operators_count, $groups_count), 8);
    $result['pagination'] = $p;

    $operators = array_slice($operators, $p['start'], $p['end'] - $p['start']);
    $groups = array_slice($groups, $p['start'], $p['end'] - $p['start']);

    $agent_list = "";
    $params = array('thread_id' => $threadid, 'token' => $token);
    foreach ($operators as $agent) {
        $params['nextAgent'] = $agent['operatorid'];
        $status = $agent['time'] < Settings::get('online_timeout')
            ? ($agent['istatus'] == 0
                ? getlocal("(online)")
                : getlocal("(away)"))
            : "";
        $agent_list .= "<li><a href=\"" . $url_generator->generate('chat_operator_redirect', $params)
            . "\" title=\"" . get_operator_name($agent) . "\">"
            . get_operator_name($agent)
            . "</a> $status</li>";
    }
    $result['redirectToAgent'] = $agent_list;

    $group_list = "";
    if (Settings::get('enablegroups') == "1") {
        $params = array('thread_id' => $threadid, 'token' => $token);
        foreach ($groups as $group) {
            $params['nextGroup'] = $group['groupid'];
            $status = group_is_online($group)
                ? getlocal("(online)")
                : (group_is_away($group) ? getlocal("(away)") : "");
            $group_list .= "<li><a href=\"" . $url_generator->generate('chat_operator_redirect', $params)
                . "\" title=\"" . get_group_name($group) . "\">"
                . get_group_name($group)
                . "</a> $status</li>";
        }
    }
    $result['redirectToGroup'] = $group_list;

    return $result;
}
 /**
  * Generates a page with thread history (thread log).
  *
  * @param Request $request
  * @return string Rendered page content
  */
 public function threadAction(Request $request)
 {
     $operator = $this->getOperator();
     $page = array();
     // Load thread info
     $thread = Thread::load($request->attributes->get('thread_id'));
     $group = group_by_id($thread->groupId);
     $thread_info = array('userName' => $thread->userName, 'userAddress' => get_user_addr($thread->remote), 'userAgentVersion' => get_user_agent_version($thread->userAgent), 'agentName' => $thread->agentName, 'chatTime' => $thread->modified - $thread->created, 'chatStarted' => $thread->created, 'groupName' => get_group_name($group));
     $page['threadInfo'] = $thread_info;
     // Build messages list
     $last_id = -1;
     $messages = array_map('sanitize_message', $thread->getMessages(false, $last_id));
     $page['title'] = getlocal("Chat log");
     $page = array_merge($page, prepare_menu($operator, false));
     $this->getAssetManager()->attachJs('js/compiled/thread_log_app.js');
     $this->getAssetManager()->attachJs(sprintf('jQuery(document).ready(function(){Mibew.Application.start(%s);});', json_encode(array('messages' => $messages))), \Mibew\Asset\AssetManagerInterface::INLINE, 1000);
     return $this->render('history_thread', $page);
 }
예제 #10
0
파일: passage.php 프로젝트: 41px/bmpn
 private function syncgroups()
 {
     // Si l'utilisateur est login alors voir les groups qu'il a et les ajouter s'il n'existe pas.
     // En profiter pour maj l'user
     //todo: code la maj du realname
     // maj des groups
     if (!function_exists('get_group_id')) {
         include $this->phpbb_root_path . 'includes/functions_convert.' . $this->php_ext;
     }
     if (!function_exists('group_memberships')) {
         include $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext;
     }
     if (!function_exists('get_group_name')) {
         include $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext;
     }
     $passage_groups = explode(' ', get_apache_header($this->config['passage_groups']));
     $phpbb_groups = group_memberships(false, $this->user->data['user_id'], false);
     // Append
     if (!empty($phpbb_groups) and !empty($passage_groups)) {
         foreach ($passage_groups as $p_grg) {
             if (is_array($phpbb_groups)) {
                 if (false == in_array($p_grg, $phpbb_groups)) {
                     group_user_add(get_group_id($p_grg), $this->user->data['user_id']);
                 }
             }
         }
         // Clean
         if (is_array($phpbb_groups)) {
             foreach ($phpbb_groups as $bb_grp) {
                 if (false == in_array(get_group_name($bb_grp['group_id']), $passage_groups)) {
                     group_user_del($bb_grp['group_id'], $this->user->data['user_id']);
                 }
             }
         }
     }
 }
예제 #11
0
 /**
  * Process chat thread redirection.
  *
  * @param Request $request Incoming request.
  * @return string|\Symfony\Component\HttpFoundation\RedirectResponse Rendered
  *   page content or a redirect response.
  * @throws NotFoundException If the thread with specified ID and token is
  * not found.
  * @throws BadRequestException If one or more arguments have a wrong format.
  */
 public function redirectAction(Request $request)
 {
     $thread_id = $request->attributes->get('thread_id');
     $token = $request->attributes->get('token');
     $thread = Thread::load($thread_id, $token);
     if (!$thread) {
         throw new NotFoundException('The thread is not found.');
     }
     $page = array('errors' => array());
     if ($request->query->has('nextGroup')) {
         // The thread was redirected to a group.
         $next_id = $request->query->get('nextGroup');
         if (!preg_match("/^\\d{1,10}\$/", $next_id)) {
             throw new BadRequestException('Wrong value of "nextGroup" argument.');
         }
         $next_group = group_by_id($next_id);
         if ($next_group) {
             $page['message'] = getlocal('The visitor has been placed in a priorty queue of the group {0}.', array(get_group_name($next_group)));
             if (!$this->redirectToGroup($thread, (int) $next_id)) {
                 $page['errors'][] = getlocal('You are not chatting with the visitor.');
             }
         } else {
             $page['errors'][] = 'Unknown group';
         }
     } else {
         // The thread was redirected to an operator.
         $next_id = $request->query->get('nextAgent');
         if (!preg_match("/^\\d{1,10}\$/", $next_id)) {
             throw new BadRequestException('Wrong value of "nextAgent" argument.');
         }
         $next_operator = operator_by_id($next_id);
         if ($next_operator) {
             $page['message'] = getlocal('The visitor has been placed in the priorty queue of the operator {0}.', array(get_operator_name($next_operator)));
             if (!$this->redirectToOperator($thread, $next_id)) {
                 $page['errors'][] = getlocal('You are not chatting with the visitor.');
             }
         } else {
             $page['errors'][] = 'Unknown operator';
         }
     }
     $page = array_merge_recursive($page, setup_logo());
     if (count($page['errors']) > 0) {
         return $this->render('error', $page);
     } else {
         return $this->render('redirected', $page);
     }
 }
예제 #12
0
파일: client.php 프로젝트: kuell/chat
if (!isset($_GET['token']) || !isset($_GET['thread'])) {
    $thread = NULL;
    if (isset($_SESSION['threadid'])) {
        $thread = reopen_thread($_SESSION['threadid']);
    }
    if (!$thread) {
        $groupid = "";
        $groupname = "";
        if ($settings['enablegroups'] == '1') {
            $groupid = verifyparam("group", "/^\\d{1,10}\$/", "");
            if ($groupid) {
                $group = group_by_id($groupid);
                if (!$group) {
                    $groupid = "";
                } else {
                    $groupname = get_group_name($group);
                }
            }
        }
        $visitor = visitor_from_request();
        if (isset($_POST['survey']) && $_POST['survey'] == 'on') {
            $firstmessage = getparam("message");
            $info = getparam("info");
            $email = getparam("email");
            $referrer = urldecode(getparam("referrer"));
            if ($settings["surveyaskcaptcha"] == "1") {
                $captcha = getparam('captcha');
                $original = isset($_SESSION["mibew_captcha"]) ? $_SESSION["mibew_captcha"] : "";
                $survey_captcha_failed = empty($original) || empty($captcha) || $captcha != $original;
                unset($_SESSION['mibew_captcha']);
            }
예제 #13
0
    function manage_row($row, $is_show = '')
    {
        global $ttH;
        $output = '';
        $row["link_edit"] = $ttH->admin->get_link_admin($this->modules, $this->action, "edit", array("id" => $row['group_id']));
        $row["link_trash"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_trash", "id" => $row['group_id']));
        $row["link_restore"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_restore", "id" => $row['group_id']));
        $row["link_del"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_del", "id" => $row['group_id']));
        $row["link_pic"] = $ttH->admin->get_link_admin($this->modules, $this->modules . '_pic', 'manage', array("type" => "group", "type_id" => $row['group_id']));
        if (!empty($row["picture"])) {
            $row["picture"] = '<a class="fancybox-effects-a" title="' . $row["picture"] . '" href="' . DIR_UPLOAD . $row["picture"] . '">
				' . $ttH->func->get_pic_mod($row["picture"], 50, 50, '', 1, 0, array('fix_width' => 1)) . '
			</a>';
        }
        $row['name_action'] = $this->modules . '-group-' . $row["group_id"];
        $row["link_add_menu"] = $ttH->admin->get_link_admin_popup('layout', 'menu', 'add_menu', array("name_action" => $row['name_action']));
        //$row['link'] = (isset($ttH->data["modules"][$this->modules]["arr_friendly_link"][$ttH->conf['lang_cur']])) ? $ttH->data["modules"][$this->modules]["arr_friendly_link"][$ttH->conf['lang_cur']] : '';
        $row['link'] = $row["friendly_link"];
        $row['parent'] = get_group_name($row['parent_id'], 'link');
        $row['date_create'] = date('d/m/Y', $row['date_create']);
        //$row['is_focus'] = $ttH->admin->list_yesno ("is_focus[".$row['group_id']."]", $row['is_focus'], "  onchange=\"do_check (".$row['group_id'].")\"");
        //$row['is_focus_checked'] = ($row['is_focus'] == 1) ? ' checked="checked"' : '';
        $row['html_checkbox'] = '';
        foreach ($this->arr_checkbox as $k => $v) {
            if (isset($v['muti'])) {
                continue;
            }
            $row[$k . '_checked'] = $row[$k] == 1 ? ' checked="checked"' : '';
            $row['html_checkbox'] .= '<div><label for="' . $k . '_' . $row['group_id'] . '"><strong>' . (isset($ttH->lang[$this->modules][$k]) ? $ttH->lang[$this->modules][$k] : (isset($ttH->lang['global'][$k]) ? $ttH->lang['global'][$k] : $k)) . ':</strong></label> <input type="checkbox" value="1" id="' . $k . '_' . $row['group_id'] . '" name="' . $k . '[' . $row['group_id'] . ']" ' . $row[$k . '_checked'] . ' onchange="do_check(\'' . $row['group_id'] . '\')" /></div>';
        }
        $ttH->temp_act->assign('row', $row);
        if ($is_show == "trash") {
            $ttH->temp_act->reset("manage.row_item.row_button_manage");
            $ttH->temp_act->parse("manage.row_item.row_button_manage");
            if ($row['is_show'] == 0) {
                $ttH->temp_act->parse("manage.row_item");
                $output = $ttH->temp_act->text("manage.row_item");
                $ttH->temp_act->reset("manage.row_item");
            } else {
                $row["link_edit"] = 'javascript:void(0);';
                $row["link_trash"] = 'javascript:void(0);';
                $row["link_restore"] = 'javascript:void(0);';
                $row["link_del"] = 'javascript:void(0);';
                $ttH->temp_act->parse("manage.row_item_no_control");
                $output = $ttH->temp_act->text("manage.row_item_no_control");
                $ttH->temp_act->reset("manage.row_item_no_control");
            }
        } else {
            $ttH->temp_act->parse("manage.row_item.row_button_trash");
            $ttH->temp_act->parse("manage.row_item");
            $output = $ttH->temp_act->text("manage.row_item");
            $ttH->temp_act->reset("manage.row_item");
        }
        return $output;
    }
예제 #14
0
/**
* This is used to promote (to leader), demote or set as default a member/s
*/
function group_user_attributes($action, $group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $group_attributes = false)
{
    global $db, $auth, $user, $phpbb_container, $phpbb_log, $phpbb_dispatcher;
    // We need both username and user_id info
    $result = user_get_id_name($user_id_ary, $username_ary);
    if (!sizeof($user_id_ary) || $result !== false) {
        return 'NO_USERS';
    }
    if (!$group_name) {
        $group_name = get_group_name($group_id);
    }
    switch ($action) {
        case 'demote':
        case 'promote':
            $sql = 'SELECT user_id
				FROM ' . USER_GROUP_TABLE . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_pending = 1\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $result = $db->sql_query_limit($sql, 1);
            $not_empty = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if ($not_empty) {
                return 'NO_VALID_USERS';
            }
            $sql = 'UPDATE ' . USER_GROUP_TABLE . '
				SET group_leader = ' . ($action == 'promote' ? 1 : 0) . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_pending = 0\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $db->sql_query($sql);
            $log = $action == 'promote' ? 'LOG_GROUP_PROMOTED' : 'LOG_GROUP_DEMOTED';
            break;
        case 'approve':
            // Make sure we only approve those which are pending ;)
            $sql = 'SELECT u.user_id, u.user_email, u.username, u.username_clean, u.user_notify_type, u.user_jabber, u.user_lang
				FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug
				WHERE ug.group_id = ' . $group_id . '
					AND ug.user_pending = 1
					AND ug.user_id = u.user_id
					AND ' . $db->sql_in_set('ug.user_id', $user_id_ary);
            $result = $db->sql_query($sql);
            $user_id_ary = array();
            while ($row = $db->sql_fetchrow($result)) {
                $user_id_ary[] = $row['user_id'];
            }
            $db->sql_freeresult($result);
            if (!sizeof($user_id_ary)) {
                return false;
            }
            $sql = 'UPDATE ' . USER_GROUP_TABLE . "\n\t\t\t\tSET user_pending = 0\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $db->sql_query($sql);
            /* @var $phpbb_notifications \phpbb\notification\manager */
            $phpbb_notifications = $phpbb_container->get('notification_manager');
            $phpbb_notifications->add_notifications('notification.type.group_request_approved', array('user_ids' => $user_id_ary, 'group_id' => $group_id, 'group_name' => $group_name));
            $phpbb_notifications->delete_notifications('notification.type.group_request', $user_id_ary, $group_id);
            $log = 'LOG_USERS_APPROVED';
            break;
        case 'default':
            // We only set default group for approved members of the group
            $sql = 'SELECT user_id
				FROM ' . USER_GROUP_TABLE . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_pending = 0\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $result = $db->sql_query($sql);
            $user_id_ary = $username_ary = array();
            while ($row = $db->sql_fetchrow($result)) {
                $user_id_ary[] = $row['user_id'];
            }
            $db->sql_freeresult($result);
            $result = user_get_id_name($user_id_ary, $username_ary);
            if (!sizeof($user_id_ary) || $result !== false) {
                return 'NO_USERS';
            }
            $sql = 'SELECT user_id, group_id
				FROM ' . USERS_TABLE . '
				WHERE ' . $db->sql_in_set('user_id', $user_id_ary, false, true);
            $result = $db->sql_query($sql);
            $groups = array();
            while ($row = $db->sql_fetchrow($result)) {
                if (!isset($groups[$row['group_id']])) {
                    $groups[$row['group_id']] = array();
                }
                $groups[$row['group_id']][] = $row['user_id'];
            }
            $db->sql_freeresult($result);
            foreach ($groups as $gid => $uids) {
                remove_default_rank($gid, $uids);
                remove_default_avatar($gid, $uids);
            }
            group_set_user_default($group_id, $user_id_ary, $group_attributes);
            $log = 'LOG_GROUP_DEFAULTS';
            break;
    }
    /**
     * Event to perform additional actions on setting user group attributes
     *
     * @event core.user_set_group_attributes
     * @var	int		group_id			ID of the group
     * @var	string	group_name			Name of the group
     * @var	array	user_id_ary			IDs of the users to set group attributes
     * @var	array	username_ary		Names of the users to set group attributes
     * @var	array	group_attributes	Group attributes which were changed
     * @var	string	action				Action to perform over the group members
     * @since 3.1.10-RC1
     */
    $vars = array('group_id', 'group_name', 'user_id_ary', 'username_ary', 'group_attributes', 'action');
    extract($phpbb_dispatcher->trigger_event('core.user_set_group_attributes', compact($vars)));
    // Clear permissions cache of relevant users
    $auth->acl_clear_prefetch($user_id_ary);
    $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log, false, array($group_name, implode(', ', $username_ary)));
    group_update_listings($group_id);
    return false;
}
예제 #15
0
include 'lib/fortissimo.php';
# show the last 50 somethings
$which = $_GET['show'];
if (!$which) {
    $which = 'kill';
}
if ($which == 'kill') {
    $ft->message('Last 50 Kills');
    $ft->title('Last 50 Kills');
    # also show the finalblows/lossrecv by group
    $groups = $ft->dbh->_select_rows_as_objects('SELECT var1, killrecv, lossrecv FROM tbl:stats ' . 'WHERE type = "group" AND dtype = "week" AND var2 = ?', array(this_week()));
    $gout = array();
    if ($groups) {
        foreach ($groups as $grow) {
            $name = get_group_name($grow->var1);
            if ($name) {
                $gout[$name] = array($grow->killrecv, $grow->lossrecv, $grow->var1);
            }
        }
    }
} elseif ($which == 'loss') {
    $ft->message('Last 50 Losses');
    $ft->title('Last 50 Losses');
} else {
    $which = 'murder';
    $ft->message('Last 50 Murders');
    $ft->title('Last 50 Murders');
}
$ids = $ft->dbh->_select_column('SELECT killid FROM tbl:summary WHERE type = ? ORDER BY killtime DESC LIMIT 50', array($which));
# now prepare the page
예제 #16
0
    function do_manage($is_show = "")
    {
        global $ttH;
        $err = "";
        //update
        if (isset($ttH->input['do_action'])) {
            $up_id = isset($ttH->input["selected_id"]) ? $ttH->input["selected_id"] : array();
            switch ($ttH->input["do_action"]) {
                case "do_edit":
                    $arr_show_order = isset($ttH->post["show_order"]) ? $ttH->post["show_order"] : array();
                    $arr_is_focus = isset($ttH->post["is_focus"]) ? $ttH->post["is_focus"] : array();
                    $mess = $ttH->lang['global']['edit_success'] . " ID: <strong>";
                    $str_mess = "";
                    for ($i = 0; $i < count($up_id); $i++) {
                        $dup = array();
                        $dup['show_order'] = $arr_show_order[$up_id[$i]];
                        $dup['is_focus'] = isset($arr_is_focus[$up_id[$i]]) ? $arr_is_focus[$up_id[$i]] : 0;
                        $ok = $ttH->db->do_update("video", $dup, "item_id=" . $up_id[$i]);
                        if ($ok) {
                            $str_mess .= $str_mess ? ", " : "";
                            $str_mess .= $up_id[$i];
                        } else {
                            $mess .= $ttH->lang["global"]['edit_false'] . " ID: <strong>" . $up_id[$i] . "</strong>";
                        }
                    }
                    $mess .= $str_mess . "</strong>";
                    $err = $ttH->html->html_alert($mess, "success");
                    break;
                case "do_restore":
                    $up_id = isset($ttH->input["id"]) ? array($ttH->input["id"]) : $up_id;
                    $mess = $ttH->lang['global']['restore_success'] . " ID: <strong>";
                    $str_mess = "";
                    for ($i = 0; $i < count($up_id); $i++) {
                        $dup = array();
                        $dup['is_show'] = 1;
                        $ok = $ttH->db->do_update("video", $dup, "item_id=" . $up_id[$i]);
                        if ($ok) {
                            $str_mess .= $str_mess ? ", " : "";
                            $str_mess .= $up_id[$i];
                        } else {
                            $mess .= $ttH->lang["global"]['restore_false'] . " ID: <strong>" . $up_id[$i] . "</strong>";
                        }
                    }
                    $mess .= $str_mess . "</strong>";
                    $err = $ttH->html->html_alert($mess, "success");
                    break;
                case "do_trash":
                    $up_id = isset($ttH->input["id"]) ? array($ttH->input["id"]) : $up_id;
                    $mess = $ttH->lang['global']['trash_success'] . " ID: <strong>";
                    $str_mess = "";
                    for ($i = 0; $i < count($up_id); $i++) {
                        $dup = array();
                        $dup['is_show'] = 0;
                        $ok = $ttH->db->do_update("video", $dup, "item_id=" . $up_id[$i]);
                        if ($ok) {
                            $str_mess .= $str_mess ? ", " : "";
                            $str_mess .= $up_id[$i];
                        } else {
                            $mess .= $ttH->lang["global"]['trash_false'] . " ID: <strong>" . $up_id[$i] . "</strong>";
                        }
                    }
                    $mess .= $str_mess . "</strong>";
                    $err = $ttH->html->html_alert($mess, "success");
                    break;
                case "do_del":
                    if (isset($ttH->input['id'])) {
                        $list_del = $ttH->input['id'];
                    } elseif (isset($ttH->post['selected_id']) && is_array($ttH->post['selected_id'])) {
                        $list_del = @implode(',', $ttH->post['selected_id']);
                    }
                    $err = $this->do_del($list_del);
                    break;
            }
        }
        $p = isset($ttH->input["p"]) ? $ttH->input["p"] : 1;
        $search_date_begin = isset($ttH->input["search_date_begin"]) ? $ttH->input["search_date_begin"] : "";
        $search_date_end = isset($ttH->input["search_date_end"]) ? $ttH->input["search_date_end"] : "";
        $search_group_id = isset($ttH->input["search_group_id"]) ? $ttH->input["search_group_id"] : 0;
        $search_title = isset($ttH->input["search_title"]) ? $ttH->input["search_title"] : "";
        $where = " ";
        $ext = "";
        $is_search = 0;
        if ($is_show == "trash") {
            $where .= " AND is_show=0 ";
        } else {
            $where .= " AND is_show=1 ";
        }
        if ($search_date_begin || $search_date_end) {
            $tmp1 = @explode("/", $search_date_begin);
            $time_begin = @mktime(0, 0, 0, $tmp1[1], $tmp1[0], $tmp1[2]);
            $tmp2 = @explode("/", $search_date_end);
            $time_end = @mktime(23, 59, 59, $tmp2[1], $tmp2[0], $tmp2[2]);
            $where .= " AND (date_create BETWEEN {$time_begin} AND {$time_end} ) ";
            $ext .= "&date_begin=" . $search_date_begin . "&date_end=" . $search_date_end;
            $is_search = 1;
        }
        if (!empty($search_group_id)) {
            $where .= " and group_id='" . $search_group_id . "' ";
            $ext .= "&search_group_id=" . $search_group_id;
            $is_search = 1;
        }
        if (!empty($search_title)) {
            $where .= " and (a.item_id='{$search_title}' or title like '%{$search_title}%') ";
            $ext .= "&search_title=" . $search_title;
            $is_search = 1;
        }
        $num_total = 0;
        $res_num = $ttH->db->query("select a.item_id \r\r\n\t\t\t\t\t\tfrom video a, video_lang al \r\r\n\t\t\t\t\t\twhere a.item_id=al.item_id \r\r\n\t\t\t\t\t\tand lang='" . $ttH->conf["lang_cur"] . "' \r\r\n\t\t\t\t\t\t" . $where . " ");
        $num_total = $ttH->db->num_rows($res_num);
        $n = $ttH->conf["n_list"] ? $ttH->conf["n_list"] : 30;
        $num_pages = ceil($num_total / $n);
        if ($p > $num_pages) {
            $p = $num_pages;
        }
        if ($p < 1) {
            $p = 1;
        }
        $start = ($p - 1) * $n;
        $link_action = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub);
        //Sort
        $arr_title = array("item_id" => array("title" => $ttH->lang["global"]["id"], "link" => $link_action . "&p=" . $p . $ext . "&sort=item_id-desc", "class" => ""), "show_order" => array("title" => $ttH->lang["global"]["show_order"], "link" => $link_action . "&p=" . $p . $ext . "&sort=show_order-desc", "class" => ""), "title" => array("title" => $ttH->lang["global"]["title"], "link" => $link_action . "&p=" . $p . $ext . "&sort=title-desc", "class" => ""), "date_create" => array("title" => $ttH->lang["global"]["date_create"], "link" => $link_action . "&p=" . $p . $ext . "&sort=date_create-desc", "class" => ""));
        $sort = isset($ttH->input["sort"]) ? $ttH->input["sort"] : "";
        if ($sort) {
            $arr_allow_sort = array(1 => "asc", 2 => "desc");
            $tmp = explode("-", $sort);
            if (array_key_exists($tmp[0], $arr_title) && in_array($tmp[1], $arr_allow_sort)) {
                $order_tmp = $tmp[0] == "item_id" ? "a.item_id" : $tmp[0];
                $where .= " order by " . $order_tmp . " " . $tmp[1];
                $arr_title[$tmp[0]]["class"] = $tmp[1];
                $arr_title[$tmp[0]]["link"] = $link_action . "&p=" . $p . $ext . "&sort=" . $tmp[0] . "-" . $arr_allow_sort[3 - array_search($tmp[1], $arr_allow_sort)];
            } else {
                $sort = "";
            }
        }
        if ($sort == "") {
            $where .= " order by date_create DESC";
        }
        //End sort
        //Title row
        foreach ($arr_title as $k => $v) {
            $class = $v["class"] ? " class='" . $v["class"] . "'" : "";
            $data["f_" . $k] = '<a href="' . $v["link"] . '" ' . $class . '>' . $v["title"] . '</a>';
        }
        //End title row
        $sql = "select * from video a, video_lang al \r\r\n\t\t\t\t\t\twhere a.item_id=al.item_id \r\r\n\t\t\t\t\t\tand lang='" . $ttH->conf["lang_cur"] . "' \r\r\n\t\t\t\t\t\t" . $where . " \r\r\n\t\t\t\t\t\tlimit {$start},{$n}";
        //echo $sql;
        $nav = $ttH->admin->admin_paginate($link_action, $num_total, $n, $ext, $p);
        $result = $ttH->db->query($sql);
        $i = 0;
        $html_row = "";
        if ($num = $ttH->db->num_rows($result)) {
            while ($row = $ttH->db->fetch_row($result)) {
                $i++;
                $row["link_edit"] = $ttH->admin->get_link_admin($this->modules, $this->action, "edit", array("id" => $row['item_id']));
                $row["link_trash"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_trash", "id" => $row['item_id']));
                $row["link_restore"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_restore", "id" => $row['item_id']));
                $row["link_del"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_del", "id" => $row['item_id']));
                if (!empty($row["picture"])) {
                    $row["picture"] = '<a class="fancybox-effects-a" title="' . $row["picture"] . '" href="' . DIR_UPLOAD . $row["picture"] . '">
						' . $ttH->func->get_pic_mod($row["picture"], 50, 50, '', 1, 0, array('fix_width' => 1)) . '
					</a>';
                }
                /*$row['link'] = (isset($ttH->data["modules"][$this->modules]["arr_friendly_link"][$ttH->conf['lang_cur']])) ? $ttH->data["modules"][$this->modules]["arr_friendly_link"][$ttH->conf['lang_cur']] : '';
                		$row['link'] .= '/'.$row["friendly_link"].'.html';*/
                $row['link'] = $row["friendly_link"] . '.html';
                $row['group_name'] = get_group_name($row['group_id']);
                $row['is_focus_checked'] = $row['is_focus'] == 1 ? ' checked="checked"' : '';
                $row['date_create'] = date('d/m/Y', $row['date_create']);
                $ttH->temp_act->assign('row', $row);
                if ($is_show == "trash") {
                    $ttH->temp_act->parse("manage.row_item.row_button_manage");
                } else {
                    $ttH->temp_act->parse("manage.row_item.row_button_trash");
                }
                $ttH->temp_act->parse("manage.row_item");
            }
        } else {
            $ttH->temp_act->assign('row', array("mess" => $ttH->lang["global"]["no_have_data"]));
            $ttH->temp_act->parse("manage.row_empty");
        }
        $data['html_row'] = $html_row;
        $data['nav'] = $nav;
        $data['err'] = $err;
        $data['link_action_search'] = $link_action;
        $data['link_action'] = $link_action . "&p=" . $p . $ext;
        $data['search_date_begin'] = $search_date_begin;
        $data['search_date_end'] = $search_date_end;
        $data['search_title'] = $search_title;
        $data["list_group_search"] = list_group("search_group_id", $search_group_id, " class=\"form-control\"", array("title" => $ttH->lang['global']['select_title']));
        $data['form_search_class'] = $is_search == 1 ? ' expand' : '';
        if ($is_show == "trash") {
            $ttH->temp_act->parse("manage.button_manage");
        } else {
            $ttH->temp_act->parse("manage.button_trash");
        }
        $ttH->temp_act->assign('data', $data);
        $ttH->temp_act->parse("manage");
        return $ttH->temp_act->text("manage");
    }
예제 #17
0
/**
* This is used to promote (to leader), demote or set as default a member/s
*/
function group_user_attributes($action, $group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $group_attributes = false)
{
    global $db, $auth, $phpbb_root_path, $phpEx, $config, $phpbb_container;
    // We need both username and user_id info
    $result = user_get_id_name($user_id_ary, $username_ary);
    if (!sizeof($user_id_ary) || $result !== false) {
        return 'NO_USERS';
    }
    if (!$group_name) {
        $group_name = get_group_name($group_id);
    }
    switch ($action) {
        case 'demote':
        case 'promote':
            $sql = 'SELECT user_id
				FROM ' . USER_GROUP_TABLE . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_pending = 1\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $result = $db->sql_query_limit($sql, 1);
            $not_empty = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if ($not_empty) {
                return 'NO_VALID_USERS';
            }
            $sql = 'UPDATE ' . USER_GROUP_TABLE . '
				SET group_leader = ' . ($action == 'promote' ? 1 : 0) . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_pending = 0\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $db->sql_query($sql);
            $log = $action == 'promote' ? 'LOG_GROUP_PROMOTED' : 'LOG_GROUP_DEMOTED';
            break;
        case 'approve':
            // Make sure we only approve those which are pending ;)
            $sql = 'SELECT u.user_id, u.user_email, u.username, u.username_clean, u.user_notify_type, u.user_jabber, u.user_lang
				FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug
				WHERE ug.group_id = ' . $group_id . '
					AND ug.user_pending = 1
					AND ug.user_id = u.user_id
					AND ' . $db->sql_in_set('ug.user_id', $user_id_ary);
            $result = $db->sql_query($sql);
            $user_id_ary = array();
            while ($row = $db->sql_fetchrow($result)) {
                $user_id_ary[] = $row['user_id'];
            }
            $db->sql_freeresult($result);
            if (!sizeof($user_id_ary)) {
                return false;
            }
            $sql = 'UPDATE ' . USER_GROUP_TABLE . "\n\t\t\t\tSET user_pending = 0\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $db->sql_query($sql);
            $phpbb_notifications = $phpbb_container->get('notification_manager');
            $phpbb_notifications->add_notifications('notification.type.group_request_approved', array('user_ids' => $user_id_ary, 'group_id' => $group_id, 'group_name' => $group_name));
            $phpbb_notifications->delete_notifications('notification.type.group_request', $user_id_ary, $group_id);
            $log = 'LOG_USERS_APPROVED';
            break;
        case 'default':
            // We only set default group for approved members of the group
            $sql = 'SELECT user_id
				FROM ' . USER_GROUP_TABLE . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_pending = 0\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $result = $db->sql_query($sql);
            $user_id_ary = $username_ary = array();
            while ($row = $db->sql_fetchrow($result)) {
                $user_id_ary[] = $row['user_id'];
            }
            $db->sql_freeresult($result);
            $result = user_get_id_name($user_id_ary, $username_ary);
            if (!sizeof($user_id_ary) || $result !== false) {
                return 'NO_USERS';
            }
            $sql = 'SELECT user_id, group_id
				FROM ' . USERS_TABLE . '
				WHERE ' . $db->sql_in_set('user_id', $user_id_ary, false, true);
            $result = $db->sql_query($sql);
            $groups = array();
            while ($row = $db->sql_fetchrow($result)) {
                if (!isset($groups[$row['group_id']])) {
                    $groups[$row['group_id']] = array();
                }
                $groups[$row['group_id']][] = $row['user_id'];
            }
            $db->sql_freeresult($result);
            foreach ($groups as $gid => $uids) {
                remove_default_rank($gid, $uids);
                remove_default_avatar($gid, $uids);
            }
            group_set_user_default($group_id, $user_id_ary, $group_attributes);
            $log = 'LOG_GROUP_DEFAULTS';
            break;
    }
    // Clear permissions cache of relevant users
    $auth->acl_clear_prefetch($user_id_ary);
    add_log('admin', $log, $group_name, implode(', ', $username_ary));
    group_update_listings($group_id);
    return false;
}
예제 #18
0
    function main($id, $mode)
    {
        global $config, $db, $user, $auth, $template, $cache;
        global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
        $user->add_lang('acp/email');
        $this->tpl_name = 'acp_email';
        $this->page_title = 'ACP_MASS_EMAIL';
        // Set some vars
        $submit = isset($_POST['submit']) ? true : false;
        $error = array();
        $usernames = request_var('usernames', '');
        $group_id = request_var('g', 0);
        $subject = request_var('subject', '', true);
        $message = request_var('message', '', true);
        // Do the job ...
        if ($submit) {
            // Error checking needs to go here ... if no subject and/or no message then skip
            // over the send and return to the form
            $use_queue = isset($_POST['send_immediatly']) ? false : true;
            $priority = request_var('mail_priority_flag', MAIL_NORMAL_PRIORITY);
            if (!$subject) {
                $error[] = $user->lang['NO_EMAIL_SUBJECT'];
            }
            if (!$message) {
                $error[] = $user->lang['NO_EMAIL_MESSAGE'];
            }
            if (!sizeof($error)) {
                if ($usernames) {
                    $usernames = implode(', ', preg_replace('#^[\\s]*?(.*?)[\\s]*?$#e', "\"'\" . \$db->sql_escape('\\1') . \"'\"", explode("\n", $usernames)));
                    $sql = 'SELECT username, user_email, user_jabber, user_notify_type, user_lang 
						FROM ' . USERS_TABLE . " \n\t\t\t\t\t\tWHERE username IN ({$usernames})\n\t\t\t\t\t\t\tAND user_allow_massemail = 1\n\t\t\t\t\t\tORDER BY user_lang, user_notify_type";
                    // , SUBSTRING(user_email FROM INSTR(user_email, '@'))
                } else {
                    if ($group_id) {
                        $sql = 'SELECT u.user_email, u.username, u.user_lang, u.user_jabber, u.user_notify_type 
							FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug \n\t\t\t\t\t\t\tWHERE ug.group_id = {$group_id} \n\t\t\t\t\t\t\t\tAND ug.user_pending = 0\n\t\t\t\t\t\t\t\tAND u.user_id = ug.user_id \n\t\t\t\t\t\t\t\tAND u.user_allow_massemail = 1\n\t\t\t\t\t\t\tORDER BY u.user_lang, u.user_notify_type";
                    } else {
                        $sql = 'SELECT username, user_email, user_jabber, user_notify_type, user_lang 
							FROM ' . USERS_TABLE . '
							WHERE user_allow_massemail = 1
							ORDER BY user_lang, user_notify_type';
                    }
                }
                $result = $db->sql_query($sql);
                $row = $db->sql_fetchrow($result);
                $db->sql_freeresult($result);
                if (!$row) {
                    trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action));
                }
                $i = $j = 0;
                // Send with BCC, no more than 50 recipients for one mail (to not exceed the limit)
                $max_chunk_size = 50;
                $email_list = array();
                $old_lang = $row['user_lang'];
                $old_notify_type = $row['user_notify_type'];
                do {
                    if ($row['user_notify_type'] == NOTIFY_EMAIL && $row['user_email'] || $row['user_notify_type'] == NOTIFY_IM && $row['user_jabber'] || $row['user_notify_type'] == NOTIFY_BOTH && $row['user_email'] && $row['user_jabber']) {
                        if ($i == $max_chunk_size || $row['user_lang'] != $old_lang || $row['user_notify_type'] != $old_notify_type) {
                            $i = 0;
                            $j++;
                            $old_lang = $row['user_lang'];
                            $old_notify_type = $row['user_notify_type'];
                        }
                        $email_list[$j][$i]['lang'] = $row['user_lang'];
                        $email_list[$j][$i]['method'] = $row['user_notify_type'];
                        $email_list[$j][$i]['email'] = $row['user_email'];
                        $email_list[$j][$i]['name'] = $row['username'];
                        $email_list[$j][$i]['jabber'] = $row['user_jabber'];
                        $i++;
                    }
                } while ($row = $db->sql_fetchrow($result));
                $db->sql_freeresult($result);
                // Send the messages
                include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
                include_once $phpbb_root_path . 'includes/functions_user.' . $phpEx;
                $messenger = new messenger($use_queue);
                $errored = false;
                for ($i = 0, $size = sizeof($email_list); $i < $size; $i++) {
                    $used_lang = $email_list[$i][0]['lang'];
                    $used_method = $email_list[$i][0]['method'];
                    for ($j = 0, $list_size = sizeof($email_list[$i]); $j < $list_size; $j++) {
                        $email_row = $email_list[$i][$j];
                        $messenger->{sizeof($email_list[$i]) == 1 ? 'to' : 'bcc'}($email_row['email'], $email_row['name']);
                        $messenger->im($email_row['jabber'], $email_row['name']);
                    }
                    $messenger->template('admin_send_email', $used_lang);
                    $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
                    $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
                    $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
                    $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
                    $messenger->subject(html_entity_decode($subject));
                    $messenger->replyto($config['board_email']);
                    $messenger->set_mail_priority($priority);
                    $messenger->assign_vars(array('SITENAME' => $config['sitename'], 'CONTACT_EMAIL' => $config['board_contact'], 'MESSAGE' => html_entity_decode($message)));
                    if (!$messenger->send($used_method)) {
                        $errored = true;
                    }
                }
                unset($email_list);
                $messenger->save_queue();
                if ($group_id) {
                    $group_name = get_group_name($group_id);
                } else {
                    // Not great but the logging routine doesn't cope well with localising on the fly
                    $group_name = $user->lang['ALL_USERS'];
                }
                add_log('admin', 'LOG_MASS_EMAIL', $group_name);
                if (!$errored) {
                    $message = $use_queue ? $user->lang['EMAIL_SENT_QUEUE'] : $user->lang['EMAIL_SENT'];
                } else {
                    $message = sprintf($user->lang['EMAIL_SEND_ERROR'], '<a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=logs&amp;mode=critical') . '">', '</a>');
                }
                trigger_error($message . adm_back_link($this->u_action));
            }
        }
        // Exclude bots...
        $sql = 'SELECT group_id
			FROM ' . GROUPS_TABLE . "\n\t\t\tWHERE group_name = 'BOTS'";
        $result = $db->sql_query($sql);
        $bot_group_id = (int) $db->sql_fetchfield('group_id');
        $db->sql_freeresult($result);
        $select_list = '<option value="0"' . (!$group_id ? ' selected="selected"' : '') . '>' . $user->lang['ALL_USERS'] . '</option>';
        $select_list .= group_select_options($group_id, array($bot_group_id));
        $s_priority_options = '<option value="' . MAIL_LOW_PRIORITY . '">' . $user->lang['MAIL_LOW_PRIORITY'] . '</option>';
        $s_priority_options .= '<option value="' . MAIL_NORMAL_PRIORITY . '" selected="selected">' . $user->lang['MAIL_NORMAL_PRIORITY'] . '</option>';
        $s_priority_options .= '<option value="' . MAIL_HIGH_PRIORITY . '">' . $user->lang['MAIL_HIGH_PRIORITY'] . '</option>';
        $template->assign_vars(array('S_WARNING' => sizeof($error) ? true : false, 'WARNING_MSG' => sizeof($error) ? implode('<br />', $error) : '', 'U_ACTION' => $this->u_action, 'S_GROUP_OPTIONS' => $select_list, 'USERNAMES' => $usernames, 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser&amp;form=acp_email&amp;field=usernames'), 'SUBJECT' => $subject, 'MESSAGE' => $message, 'S_PRIORITY_OPTIONS' => $s_priority_options));
    }
예제 #19
0
function get_group_link($groupid)
{
    global $_WEB_URL;
    $url = $_WEB_URL . "/show.php?groupid=" . $groupid;
    return "<a href='{$url}'>" . get_group_name($groupid) . "</a>";
}
예제 #20
0
function get_link_categories($manage = false, $list = false)
{
    global $_base_path;
    $categories = array();
    $course_id = $_SESSION['course_id'];
    /* get all the categories: */
    /* $categories[category_id] = array(cat_name, cat_parent, num_courses, [array(children)]) */
    if ($_SESSION['groups']) {
        $groups = implode(',', $_SESSION['groups']);
    } else {
        // not in any groups
        $groups = 0;
    }
    $sql = '';
    $sqlParams = array();
    //if suggest a link page
    if ($_SERVER['PHP_SELF'] == $_base_path . 'mods/links/add.php') {
        $sql = 'SELECT * FROM %slinks_categories WHERE (owner_id=%d AND owner_type=%d) ORDER BY parent_id, name';
        array_push($sqlParams, TABLE_PREFIX, $course_id, LINK_CAT_COURSE);
    } else {
        if ($manage) {
            $sql = 'SELECT * FROM %slinks_categories WHERE ';
            array_push($sqlParams, TABLE_PREFIX);
            if (authenticate(AT_PRIV_GROUPS, true) && authenticate(AT_PRIV_COURSE, true)) {
                if ($list) {
                    $sql .= '(owner_id=%d AND owner_type=%d) OR (owner_id IN (%s) AND owner_type=%d AND name<>"")';
                    array_push($sqlParams, $course_id, LINK_CAT_COURSE, $groups, LINK_CAT_GROUP);
                } else {
                    $sql .= '(owner_id=%d AND owner_type=%d) OR (owner_id IN (%s) AND owner_type=%d)';
                    array_push($sqlParams, $course_id, LINK_CAT_COURSE, $groups, LINK_CAT_GROUP);
                }
            } else {
                if (authenticate(AT_PRIV_LINKS, true)) {
                    $sql .= '(owner_id=%d AND owner_type=%d)';
                    array_push($sqlParams, $course_id, LINK_CAT_COURSE);
                    if (!empty($groups)) {
                        $sql .= ' OR (owner_id IN (%s) AND owner_type=%d)';
                        array_push($sqlParams, $groups, LINK_CAT_GROUP);
                    }
                } else {
                    if (authenticate(AT_PRIV_GROUPS, true) || !empty($groups)) {
                        if ($list) {
                            $sql .= '(owner_id IN (%s) AND owner_type=%d AND name<>"")';
                            array_push($sqlParams, $groups, LINK_CAT_GROUP);
                        } else {
                            $sql .= '(owner_id IN (%s) AND owner_type=%d)';
                            array_push($sqlParams, $groups, LINK_CAT_GROUP);
                        }
                    }
                }
            }
            $sql .= ' ORDER BY parent_id, name';
        } else {
            if (!empty($groups)) {
                $sql = 'SELECT * FROM %slinks_categories WHERE (owner_id=%d AND owner_type=%d) OR (owner_id IN (%s) AND owner_type=%d) ORDER BY parent_id, name';
                array_push($sqlParams, TABLE_PREFIX, $course_id, LINK_CAT_COURSE, $groups, LINK_CAT_GROUP);
            } else {
                $sql = 'SELECT * FROM %slinks_categories WHERE (owner_id=%d AND owner_type=%d) ORDER BY parent_id, name';
                array_push($sqlParams, TABLE_PREFIX, $course_id, LINK_CAT_COURSE);
            }
        }
    }
    $result = queryDB($sql, $sqlParams);
    foreach ($result as $row) {
        //if group, get name
        if (empty($row['name'])) {
            $row['name'] = get_group_name($row['owner_id']);
            $categories[$row['cat_id']]['group'] = 1;
        }
        $categories[$row['cat_id']]['cat_name'] = $row['name'];
        $categories[$row['cat_id']]['cat_parent'] = $row['parent_id'];
        if ($row['parent_id'] > 0) {
            $categories[$row['parent_id']]['children'][] = $row['cat_id'];
        } else {
            $categories[0][] = $row['cat_id'];
        }
    }
    return $categories;
}
예제 #21
0
        echo $row['link_id'];
        ?>
'].checked = true;">
			<td><a href="<?php 
        echo url_rewrite('mods/_standard/links/index.php?view=' . $row['link_id']);
        ?>
" target="_new" title="<?php 
        echo AT_print($row['LinkName'], 'links.LinkName');
        ?>
"><?php 
        echo AT_print($row['LinkName'], 'links.LinkName');
        ?>
</a></td>
			<td><?php 
        if (empty($row['name'])) {
            $row['name'] = get_group_name($row['owner_id']);
        }
        echo AT_print($row['name'], 'links.name');
        ?>
</td>
			<td><?php 
        echo AT_print($row['Description'], 'links.Description');
        ?>
</td>
		</tr>
	<?php 
    }
} else {
    echo sprintf('<td colspan="3">%s</td>', _AT('none_found'));
}
?>
예제 #22
0
파일: chat.php 프로젝트: aburakovskiy/mibew
/**
 * Prepare groups list to build group select box.
 *
 * If $group_id specified groups list will consist of group with id equals to
 * $group_id and its children.
 *
 * @param int $group_id Id of selected group
 * @return array|boolean Array of groups info arrays or boolean false if there
 *   are no suitable groups.
 *   Group info array contain following keys:
 *    - 'id': int, group id;
 *    - 'name': string, group name;
 *    - 'description': string, group description;
 *    - 'online': boolean, indicates if group online;
 *    - 'selected': boolean, indicates if group selected by default.
 */
function prepare_groups_select($group_id)
{
    $show_groups = $group_id == '' ? true : group_has_children($group_id);
    if (!$show_groups) {
        return false;
    }
    $all_groups = get_groups(false);
    if (empty($all_groups)) {
        return false;
    }
    $groups_list = array();
    $selected_group_id = $group_id;
    foreach ($all_groups as $group) {
        $group_is_empty = (bool) ($group['inumofagents'] == 0);
        $group_related_with_specified = empty($group_id) || $group['parent'] == $group_id || $group['groupid'] == $group_id;
        if ($group_is_empty || !$group_related_with_specified) {
            continue;
        }
        if (group_is_online($group) && !$selected_group_id) {
            $selected_group_id = $group['groupid'];
        }
        $groups_list[] = array('id' => $group['groupid'], 'name' => get_group_name($group), 'description' => get_group_description($group), 'online' => group_is_online($group), 'selected' => (bool) ($group['groupid'] == $selected_group_id));
    }
    // One group must be selected by default
    if (!empty($groups_list)) {
        // Check if there is selected group
        $selected_group_present = false;
        foreach ($groups_list as $group) {
            if ($group['selected']) {
                $selected_group_present = true;
                break;
            }
        }
        // If there is no selected group select the first one
        if (!$selected_group_present) {
            $groups_list[0]['selected'] = true;
        }
    }
    return $groups_list;
}
예제 #23
0
    ?>
</td>
		<td><?php 
    echo $contact['Method'];
    ?>
</td>
		<td><?php 
    echo $contact['Status'];
    ?>
</td>
		<td><?php 
    echo display_campaign_manager_name($contact['campaign_manager_KEY']);
    ?>
</td>
		<td><?php 
    echo get_group_name($contact['groups_KEY']);
    ?>
</td>
		<td><?php 
    echo $contact['Notes'];
    ?>
</td>
	</tr>	
	
<?php 
}
?>
</tbody></table>


예제 #24
0
파일: users.php 프로젝트: omtim/kleeja
        break;
        #new user adding form
    #new user adding form
    case 'new_u':
        #preparing the template
        $errs = isset($errs) ? $errs : false;
        $uname = isset($_POST['lname']) ? htmlspecialchars($_POST['lname']) : '';
        $umail = isset($_POST['lmail']) ? htmlspecialchars($_POST['lmail']) : '';
        $k_groups = array_keys($d_groups);
        $u_groups = array();
        foreach ($k_groups as $id) {
            #guests? no skip
            if ($id == 2) {
                continue;
            }
            $u_groups[] = array('id' => $id, 'name' => get_group_name($id), 'default' => $config['default_group'] == $id ? true : false, 'selected' => isset($_POST['lgroup']) ? $_POST['lgroup'] == $id : $id == $config['default_group']);
        }
        break;
}
//after submit
if (isset($_POST['submit'])) {
    $g_link = ADMIN_PATH . '?cp=' . basename(__FILE__, '.php') . '&amp;page=' . (isset($_GET['page']) ? intval($_GET['page']) : 1) . (isset($_GET['search_id']) ? '&amp;search_id=' . htmlspecialchars($_GET['search_id']) : '') . '&amp;smt=' . $current_smt;
    $text = ($affected ? $lang['USERS_UPDATED'] : $lang['NO_UP_CHANGE_S']) . '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . str_replace('&amp;', '&', $g_link) . '\');", 2000);</script>' . "\n";
    $stylee = "admin_info";
}
//secondary menu
$go_menu = array('general' => array('name' => $lang['R_GROUPS'], 'link' => ADMIN_PATH . '?cp=users&amp;smt=general', 'goto' => 'general', 'current' => $current_smt == 'general'), 'show_su' => array('name' => $lang['SEARCH_USERS'], 'link' => ADMIN_PATH . '?cp=search&amp;smt=users', 'goto' => 'show_su', 'current' => $current_smt == 'show_su'));
#user adding is not allowed in integration
if (!$user_not_normal) {
    $go_menu['new_u'] = array('name' => $lang['NEW_USER'], 'link' => ADMIN_PATH . '?cp=users&amp;smt=new_u', 'goto' => 'new_u', 'current' => $current_smt == 'new_u');
}
예제 #25
0
/**
* This is used to promote (to leader), demote or set as default a member/s
*/
function group_user_attributes($action, $group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $group_attributes = false)
{
    global $db, $auth, $phpbb_root_path, $phpEx, $config;
    // We need both username and user_id info
    $result = user_get_id_name($user_id_ary, $username_ary);
    if (!sizeof($user_id_ary) || $result !== false) {
        return 'NO_USERS';
    }
    if (!$group_name) {
        $group_name = get_group_name($group_id);
    }
    switch ($action) {
        case 'demote':
        case 'promote':
            $sql = 'SELECT user_id FROM ' . USER_GROUP_TABLE . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_pending = 1\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $result = $db->sql_query_limit($sql, 1);
            $not_empty = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if ($not_empty) {
                return 'NO_VALID_USERS';
            }
            $sql = 'UPDATE ' . USER_GROUP_TABLE . '
				SET group_leader = ' . ($action == 'promote' ? 1 : 0) . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_pending = 0\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $db->sql_query($sql);
            $log = $action == 'promote' ? 'LOG_GROUP_PROMOTED' : 'LOG_GROUP_DEMOTED';
            break;
        case 'approve':
            // Make sure we only approve those which are pending ;)
            $sql = 'SELECT u.user_id, u.user_email, u.username, u.username_clean, u.user_notify_type, u.user_jabber, u.user_lang
				FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug
				WHERE ug.group_id = ' . $group_id . '
					AND ug.user_pending = 1
					AND ug.user_id = u.user_id
					AND ' . $db->sql_in_set('ug.user_id', $user_id_ary);
            $result = $db->sql_query($sql);
            $user_id_ary = $email_users = array();
            while ($row = $db->sql_fetchrow($result)) {
                $user_id_ary[] = $row['user_id'];
                $email_users[] = $row;
            }
            $db->sql_freeresult($result);
            if (!sizeof($user_id_ary)) {
                return false;
            }
            $sql = 'UPDATE ' . USER_GROUP_TABLE . "\n\t\t\t\tSET user_pending = 0\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $db->sql_query($sql);
            // Send approved email to users...
            include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
            $messenger = new messenger();
            foreach ($email_users as $row) {
                $messenger->template('group_approved', $row['user_lang']);
                $messenger->to($row['user_email'], $row['username']);
                $messenger->im($row['user_jabber'], $row['username']);
                $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($row['username']), 'GROUP_NAME' => htmlspecialchars_decode($group_name), 'U_GROUP' => generate_board_url() . "/ucp.{$phpEx}?i=groups&mode=membership"));
                $messenger->send($row['user_notify_type']);
            }
            $messenger->save_queue();
            $log = 'LOG_USERS_APPROVED';
            break;
        case 'default':
            $sql = 'SELECT user_id, group_id FROM ' . USERS_TABLE . '
				WHERE ' . $db->sql_in_set('user_id', $user_id_ary, false, true);
            $result = $db->sql_query($sql);
            $groups = array();
            while ($row = $db->sql_fetchrow($result)) {
                if (!isset($groups[$row['group_id']])) {
                    $groups[$row['group_id']] = array();
                }
                $groups[$row['group_id']][] = $row['user_id'];
            }
            $db->sql_freeresult($result);
            foreach ($groups as $gid => $uids) {
                remove_default_rank($gid, $uids);
                remove_default_avatar($gid, $uids);
            }
            group_set_user_default($group_id, $user_id_ary, $group_attributes);
            $log = 'LOG_GROUP_DEFAULTS';
            break;
    }
    // Clear permissions cache of relevant users
    $auth->acl_clear_prefetch($user_id_ary);
    add_log('admin', $log, $group_name, implode(', ', $username_ary));
    group_update_listings($group_id);
    return false;
}
예제 #26
0
파일: redirect.php 프로젝트: kuell/chat
require_once '../libs/expand.php';
require_once '../libs/groups.php';
$operator = check_login();
$threadid = verifyparam("thread", "/^\\d{1,10}\$/");
$token = verifyparam("token", "/^\\d{1,10}\$/");
$thread = thread_by_id($threadid);
if (!$thread || !isset($thread['ltoken']) || $token != $thread['ltoken']) {
    die("wrong thread");
}
$page = array();
$errors = array();
if (isset($_GET['nextGroup'])) {
    $nextid = verifyparam("nextGroup", "/^\\d{1,10}\$/");
    $nextGroup = group_by_id($nextid);
    if ($nextGroup) {
        $page['message'] = getlocal2("chat.redirected.group.content", array(safe_htmlspecialchars(topage(get_group_name($nextGroup)))));
        if ($thread['istate'] == $state_chatting) {
            $link = connect();
            commit_thread($threadid, array("istate" => intval($state_waiting), "nextagent" => 0, "groupid" => intval($nextid), "agentId" => 0, "agentName" => "''"), $link);
            post_message_($thread['threadid'], $kind_events, getstring2_("chat.status.operator.redirect", array(get_operator_name($operator)), $thread['locale'], true), $link);
            mysql_close($link);
        } else {
            $errors[] = getlocal("chat.redirect.cannot");
        }
    } else {
        $errors[] = getlocal("chat.redirect.unknown_group");
    }
} else {
    $nextid = verifyparam("nextAgent", "/^\\d{1,10}\$/");
    $nextOperator = operator_by_id($nextid);
    if ($nextOperator) {
예제 #27
0
    echo base_url($profpic);
    ?>
">
								<?php 
}
?>
								<p>
									<?php 
echo $this->session->userdata('name');
?>
									<small>
									<?php 
if ($this->session->userdata('roles') == "backend") {
    echo "Application Owner / Back-end";
} else {
    echo get_group_name($this->session->userdata('group_id'));
}
?>
									</small>
								</p>
							</li>
							<!-- Menu Footer-->
							<li class="user-footer">
								<div class="pull-left">
									<a class="btn btn-default btn-flat" href="<?php 
echo site_url('home/profile');
?>
">Profile</a>
								</div>
								<div class="pull-right">
									<a class="btn btn-default btn-flat" href="<?php 
예제 #28
0
					<?php 
        }
        ?>
				</div>
				<div class="span2 comment_info">
					<div><?php 
        echo gravatar($comment->user_email, 30);
        ?>
</div>
					<div>
						<strong><?php 
        echo $comment->display_name;
        ?>
</strong><br/>
						<div><?php 
        echo get_group_name($comment->created_by);
        ?>
</div><br/>
						<span class="date">	<?php 
        echo format_date($comment->created_on);
        ?>
 </span>
					</div>
				</div>
			
			<hr>
			<?php 
    }
    ?>
		</div>
	</div>
예제 #29
0
파일: menu.php 프로젝트: snehac21/rtw_btw
echo base_url();
?>
images/profile.jpg" class="img-circle m-b" alt="logo">
            </a>

            <div class="stats-label text-color">
                <span class="font-extra-bold font-uppercase"><?php 
echo $this->session->userdata['first_name'] . ' ' . $this->session->userdata['last_name'];
?>
</span>

                <div class="dropdown">
                    <a class="dropdown-toggle" href="#">
                        <small class="text-muted"><?php 
foreach ($this->session->userdata('user_group_id') as $user_g_id) {
    echo '<p>' . get_group_name($user_g_id) . '</p>';
}
?>
</small>
                    </a>
                </div>
            </div>
        </div>
        <?php 
if ($this->session->userdata) {
    ?>
        <ul class="nav" id="side-menu">
                <li class="active">
                    <a href="<?php 
    echo base_url();
    ?>
예제 #30
0
파일: operator.php 프로젝트: kuell/chat
function setup_redirect_links($threadid, $token)
{
    global $page, $mibewroot, $settings, $mysqlprefix;
    loadsettings();
    $link = connect();
    $operatorscount = db_rows_count("{$mysqlprefix}chatoperator", array(), "", $link);
    $groupscount = 0;
    $groups = array();
    if ($settings['enablegroups'] == "1") {
        foreach (get_groups($link, true) as $group) {
            if ($group['inumofagents'] == 0) {
                continue;
            }
            $groups[] = $group;
        }
        $groupscount = count($groups);
    }
    prepare_pagination(max($operatorscount, $groupscount), 8);
    $p = $page['pagination'];
    $limit = $p['limit'];
    $operators = select_multi_assoc(db_build_select("operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time", "{$mysqlprefix}chatoperator", array(), "order by vclogin " . $limit), $link);
    $groups = array_slice($groups, $p['start'], $p['end'] - $p['start']);
    mysql_close($link);
    $agent_list = "";
    $params = array('thread' => $threadid, 'token' => $token);
    foreach ($operators as $agent) {
        $params['nextAgent'] = $agent['operatorid'];
        $status = $agent['time'] < $settings['online_timeout'] ? $agent['istatus'] == 0 ? getlocal("char.redirect.operator.online_suff") : getlocal("char.redirect.operator.away_suff") : "";
        $agent_list .= "<li><a href=\"" . add_params($mibewroot . "/operator/redirect.php", $params) . "\" title=\"" . safe_htmlspecialchars(topage(get_operator_name($agent))) . "\">" . safe_htmlspecialchars(topage(get_operator_name($agent))) . "</a> {$status}</li>";
    }
    $page['redirectToAgent'] = $agent_list;
    $group_list = "";
    if ($settings['enablegroups'] == "1") {
        $params = array('thread' => $threadid, 'token' => $token);
        foreach ($groups as $group) {
            $params['nextGroup'] = $group['groupid'];
            $status = $group['ilastseen'] !== NULL && $group['ilastseen'] < $settings['online_timeout'] ? getlocal("char.redirect.operator.online_suff") : ($group['ilastseenaway'] !== NULL && $group['ilastseenaway'] < $settings['online_timeout'] ? getlocal("char.redirect.operator.away_suff") : "");
            $group_list .= "<li><a href=\"" . add_params($mibewroot . "/operator/redirect.php", $params) . "\" title=\"" . safe_htmlspecialchars(topage(get_group_name($group))) . "\">" . safe_htmlspecialchars(topage(get_group_name($group))) . "</a> {$status}</li>";
        }
    }
    $page['redirectToGroup'] = $group_list;
}