コード例 #1
0
ファイル: groupcp.php プロジェクト: ALTUN69/icy_phoenix
                     }
                     // Get the group name
                     $group_sql = "SELECT group_name\n\t\t\t\t\t\t\tFROM " . GROUPS_TABLE . "\n\t\t\t\t\t\t\tWHERE group_id = '" . $group_id . "'";
                     $result = $db->sql_query($group_sql);
                     $group_name_row = $db->sql_fetchrow($result);
                     $group_name = $group_name_row['group_name'];
                     include IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT;
                     $emailer = new emailer();
                     foreach ($bcc_list as $bcc_address) {
                         if (!empty($bcc_address)) {
                             $emailer->bcc($bcc_address);
                         }
                     }
                     $emailer->use_template('group_approved');
                     $emailer->set_subject($lang['Group_approved']);
                     $email_sig = create_signature($config['board_email_sig']);
                     $emailer->assign_vars(array('SITENAME' => $config['sitename'], 'GROUP_NAME' => $group_name, 'EMAIL_SIG' => $email_sig, 'U_GROUPCP' => $server_url . '?' . POST_GROUPS_URL . '=' . $group_id));
                     $emailer->send();
                     $emailer->reset();
                 }
             }
         }
     }
     // END approve or deny
 } else {
     message_die(GENERAL_MESSAGE, $lang['No_groups_exist']);
 }
 // Get group details
 $sql = "SELECT *\n\t\tFROM " . GROUPS_TABLE . "\n\t\tWHERE group_id = '" . $group_id . "'\n\t\t\tAND group_single_user = '******'";
 $result = $db->sql_query($sql);
 if (!($group_info = $db->sql_fetchrow($result))) {
コード例 #2
0
 /**
  * Send user notifications on new topic or reply
  */
 function send_notifications($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$post_id, &$notify_user)
 {
     global $config, $lang, $db, $user;
     global $bbcode;
     $current_time = time();
     include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT;
     if ($mode != 'delete') {
         if ($mode == 'reply') {
             // Look for users with notification enabled
             $sql = "SELECT u.user_id, u.user_email, u.user_lang, u.username, f.forum_name\n\t\t\t\t\tFROM " . USERS_TABLE . " u, " . TOPICS_WATCH_TABLE . " tw, " . FORUMS_TABLE . " f\n\t\t\t\t\tWHERE tw.topic_id = " . $topic_id . "\n\t\t\t\t\t\tAND " . $db->sql_in_set('tw.user_id', $this->exclude_users, true, true) . "\n\t\t\t\t\t\tAND tw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . "\n\t\t\t\t\t\tAND f.forum_id = " . $forum_id . "\n\t\t\t\t\t\tAND u.user_id = tw.user_id\n\t\t\t\t\t\tAND u.user_active = 1";
             $result = $db->sql_query($sql);
             while ($row = $db->sql_fetchrow($result)) {
                 if (!in_array($row['user_id'], $this->notify_userid)) {
                     if ($row['user_email'] != '') {
                         $this->notify_userdata[] = array('username' => $row['username'], 'user_email' => $row['user_email'], 'user_lang' => $row['user_lang']);
                     }
                     $this->notify_userid[] = $row['user_id'];
                     $this->notify_forum_name = $row['forum_name'];
                 }
             }
             $db->sql_freeresult($result);
         }
         if ($mode == 'newtopic' || $mode == 'reply') {
             // Reply or New Topic forum notification
             $sql = "SELECT u.user_id, u.user_email, u.user_lang, f.forum_name\n\t\t\t\t\tFROM " . USERS_TABLE . " u, " . FORUMS_WATCH_TABLE . " fw, " . FORUMS_TABLE . " f\n\t\t\t\t\tWHERE fw.forum_id = " . $forum_id . "\n\t\t\t\t\t\tAND " . $db->sql_in_set('fw.user_id', array_merge($this->exclude_users, $this->notify_userid), true, true) . "\n\t\t\t\t\t\tAND fw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . "\n\t\t\t\t\t\tAND f.forum_id = " . $forum_id . "\n\t\t\t\t\t\tAND f.forum_notify = '1'\n\t\t\t\t\t\tAND u.user_id = fw.user_id\n\t\t\t\t\t\tAND u.user_active = 1";
             $result = $db->sql_query($sql);
             while ($row = $db->sql_fetchrow($result)) {
                 if (!in_array($row['user_id'], $this->notify_userid)) {
                     if ($row['user_email'] != '') {
                         $this->notify_userdata[] = array('username' => $row['username'], 'user_email' => $row['user_email'], 'user_lang' => $row['user_lang']);
                     }
                     $this->notify_userid[] = $row['user_id'];
                     $this->notify_forum_name = $row['forum_name'];
                 }
             }
             $db->sql_freeresult($result);
         }
         // Users array built, so start sending notifications
         if (sizeof($this->notify_userdata) > 0) {
             include_once IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT;
             $emailer = new emailer();
             $server_url = create_server_url();
             $topic_title = unprepare_message($topic_title);
             $topic_title = censor_text($topic_title);
             $post_text = unprepare_message($post_data['message']);
             $post_text = censor_text($post_text);
             if (!empty($config['html_email'])) {
                 $bbcode->allow_bbcode = !empty($config['allow_bbcode']) ? $config['allow_bbcode'] : false;
                 $bbcode->allow_html = !empty($config['allow_html']) ? $config['allow_html'] : false;
                 $bbcode->allow_smilies = !empty($config['allow_smilies']) ? $config['allow_smilies'] : false;
                 $post_text = $bbcode->parse($post_text);
             } else {
                 $post_text = $bbcode->plain_message($post_text, '');
             }
             for ($i = 0; $i < sizeof($this->notify_userdata); $i++) {
                 $emailer->use_template('topic_notify', $this->notify_userdata[$i]['user_lang']);
                 $emailer->bcc($this->notify_userdata[$i]['user_email']);
                 // The Topic_reply_notification lang string below will be used
                 // if for some reason the mail template subject cannot be read
                 // ... note it will not necessarily be in the posters own language!
                 $emailer->set_subject($lang['Topic_reply_notification']);
                 // This is a nasty kludge to remove the username var ... till (if?) translators update their templates
                 $emailer->msg = preg_replace('#[ ]?{USERNAME}#', $this->notify_userdata[$i]['username'], $emailer->msg);
                 if ($config['url_rw'] == '1') {
                     $topic_url = $server_url . str_replace('--', '-', make_url_friendly($topic_title) . '-vp' . $post_id . '.html#p' . $post_id);
                 } else {
                     $topic_url = $server_url . CMS_PAGE_VIEWTOPIC . '?' . POST_POST_URL . '=' . $post_id . '#p' . $post_id;
                 }
                 $email_sig = create_signature($config['board_email_sig']);
                 $emailer->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'TOPIC_TITLE' => $topic_title, 'POST_TEXT' => $post_text, 'POSTERNAME' => $post_data['username'], 'FORUM_NAME' => $this->notify_forum_name, 'ROOT' => $server_url, 'U_TOPIC' => $topic_url, 'U_STOP_WATCHING_TOPIC' => $server_url . CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $topic_id . '&unwatch=topic'));
                 $emailer->send();
                 $emailer->reset();
             }
         }
         // Emails sent, so set users were notified
         $sql = "UPDATE " . TOPICS_WATCH_TABLE . "\n\t\t\t\tSET notify_status = " . TOPIC_WATCH_NOTIFIED . "\n\t\t\t\tWHERE topic_id = " . $topic_id . "\n\t\t\t\tAND " . $db->sql_in_set('user_id', $this->notify_userid, false, true);
         $db->sql_query($sql);
         $sql = "UPDATE " . FORUMS_WATCH_TABLE . "\n\t\t\t\tSET notify_status = " . TOPIC_WATCH_NOTIFIED . "\n\t\t\t\tWHERE forum_id = " . $forum_id . "\n\t\t\t\tAND " . $db->sql_in_set('user_id', $this->notify_userid, false, true);
         $db->sql_query($sql);
         // Delete notification for poster if present, or re-activate it if requested
         if (!$notify_user && !empty($row['topic_id'])) {
             $this->delete_topic_watch($user->data['user_id'], $topic_id);
         } elseif ($notify_user && empty($row['topic_id'])) {
             $this->delete_topic_watch($user->data['user_id'], $topic_id);
             $this->insert_topic_watch($user->data['user_id'], $topic_id, $forum_id, TOPIC_WATCH_UN_NOTIFIED);
         }
     }
 }
コード例 #3
0
$signature = create_signature($parameters);
$ch = curl_init();
$headers = array("x-nnws-auth:{$user}:{$signature}", "date:" . date('r', $timestamp));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $uri);
$graphs = json_decode(curl_exec($ch), true);
/**
 * Fetch data for a graph
 */
$first_graph = $graphs[0];
$first_graph_id = $first_graph['id'];
$start_time = (new \DateTime("-1 month"))->getTimestamp();
$end_time = (new \DateTime("-1 month + 1 day"))->getTimestamp();
$parameters = ['date' => $timestamp, 'method' => 'GET', 'username' => $user, 'canonical' => get_canonical_string(['start' => $start_time, 'end' => $end_time]), 'api_key' => $api_key, 'host' => $host];
$signature = create_signature($parameters);
$data_path = str_replace(":id", $first_graph_id, $data_path);
$uri = 'https://' . $host . $data_path . '?start=' . $start_time . '&end=' . $end_time;
$headers = array("x-nnws-auth:{$user}:{$signature}", "date:" . date('r', $timestamp));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $uri);
$data_points = json_decode(curl_exec($ch), true);
curl_close($ch);
/**
 * Build a canonical string given an array of query parameters.
 *
 * @param array $parameters
 * @return string
 */
function get_canonical_string(array $parameters)
コード例 #4
0
function create_push_package()
{
    global $certificate_path, $certificate_password;
    // Create a temporary directory in which to assemble the push package
    $package_dir = 'pushPackage' . time();
    if (!mkdir($package_dir)) {
        unlink($package_dir);
        die;
    }
    copy_raw_push_package_files($package_dir);
    create_manifest($package_dir);
    create_signature($package_dir, $certificate_path, $certificate_password);
    $package_path = package_raw_data($package_dir);
    return $package_path;
}
コード例 #5
0
function album_comment_notify($pic_id)
{
    global $db, $config, $user, $lang, $album_config;
    // One row SQL for caching purpose...
    $sql = "SELECT ban_userid FROM " . BANLIST_TABLE . " WHERE ban_userid <> 0 ORDER BY ban_userid ASC";
    $result = $db->sql_query($sql, 0, 'ban_', USERS_CACHE_FOLDER);
    $user_id_sql = '';
    while ($row = $db->sql_fetchrow($result)) {
        if (isset($row['ban_userid']) && !empty($row['ban_userid'])) {
            $user_id_sql .= ', ' . $row['ban_userid'];
        }
    }
    $sql = "SELECT u.user_id, u.user_email, u.user_lang, p.pic_title\n\t\t\t\tFROM " . ALBUM_COMMENT_WATCH_TABLE . " cw, " . USERS_TABLE . " u\n\t\t\t\tLEFT JOIN " . ALBUM_TABLE . " AS p ON p.pic_id = {$pic_id}\n\t\t\t\tWHERE cw.pic_id = {$pic_id}\n\t\t\t\t\tAND cw.user_id NOT IN (" . $user->data['user_id'] . ", " . ANONYMOUS . $user_id_sql . ")\n\t\t\t\t\tAND cw.notify_status = " . COMMENT_WATCH_UN_NOTIFIED . "\n\t\t\t\t\tAND u.user_id = cw.user_id";
    $result = $db->sql_query($sql);
    $bcc_list_ary = array();
    if ($row = $db->sql_fetchrow($result)) {
        $pic_title = $row['pic_title'];
        // Sixty second limit
        @set_time_limit(60);
        do {
            if ($row['user_email'] != '') {
                $bcc_list_ary[$row['user_lang']][] = $row['user_email'];
            }
            $update_watched_sql .= $update_watched_sql != '' ? ', ' . $row['user_id'] : $row['user_id'];
        } while ($row = $db->sql_fetchrow($result));
        //
        // Let's do some checking to make sure that mass mail functions
        // are working in win32 versions of php.
        //
        if (preg_match('/[c-z]:\\\\.*/i', getenv('PATH')) && !$config['smtp_delivery']) {
            $ini_val = @phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var';
            // We are running on windows, force delivery to use our smtp functions
            // since php's are broken by default
            $config['smtp_delivery'] = 1;
            $config['smtp_host'] = @$ini_val('SMTP');
        }
        if (sizeof($bcc_list_ary)) {
            include IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT;
            $emailer = new emailer();
            $server_url = create_server_url();
            $album_showpage_url = $server_url . 'album_showpage.' . PHP_EXT;
            @reset($bcc_list_ary);
            while (list($user_lang, $bcc_list) = each($bcc_list_ary)) {
                $emailer->use_template('album_comment_notify', $user_lang);
                for ($i = 0; $i < sizeof($bcc_list); $i++) {
                    $emailer->bcc($bcc_list[$i]);
                }
                // The Comment_notification lang string below will be used
                // if for some reason the mail template subject cannot be read
                // ... note it will not necessarily be in the posters own language!
                $emailer->set_subject($lang['Pic_comment_notification']);
                // This is a nasty kludge to remove the username var ... till translators update their templates
                $emailer->msg = preg_replace('#[ ]?{USERNAME}#', '', $emailer->msg);
                $email_sig = create_signature($config['board_email_sig']);
                $emailer->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'PIC_TITLE' => $pic_title, 'U_PIC' => $album_showpage_url . '?pic_id=' . $pic_id, 'U_STOP_WATCHING_COMMENT' => $album_showpage_url . '?pic_id=' . $pic_id . '&unwatch=comment'));
                $emailer->send();
                $emailer->reset();
            }
        }
    }
    $db->sql_freeresult($result);
    if ($update_watched_sql != '') {
        $sql = "UPDATE " . ALBUM_COMMENT_WATCH_TABLE . "\n\t\t\tSET notify_status = " . COMMENT_WATCH_NOTIFIED . "\n\t\t\tWHERE pic_id = {$pic_id}\n\t\t\t\tAND user_id IN ({$update_watched_sql})";
        $db->sql_query($sql);
    }
}
コード例 #6
0
ファイル: class_pm.php プロジェクト: ALTUN69/icy_phoenix
 function notification($sender_id, $recipient_id, $recipient_email, $email_subject, $email_text, $use_bcc = false, $pm_subject = '', $recipient_username = '', $recipient_lang = '', $emty_email_template = false)
 {
     global $db, $config, $user, $lang;
     require IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT;
     $recipient_lang = empty($recipient_lang) ? $config['default_lang'] : $recipient_lang;
     // Let's do some checking to make sure that mass mail functions are working in win32 versions of php.
     if (preg_match('/[c-z]:\\\\.*/i', getenv('PATH')) && !$config['smtp_delivery']) {
         // We are running on windows, force delivery to use our smtp functions since php's are broken by default
         $config['smtp_delivery'] = 1;
         $config['smtp_host'] = @ini_get('SMTP');
     }
     $emailer = new emailer();
     $emailer->headers('X-AntiAbuse: Board servername - ' . trim($config['server_name']));
     $emailer->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
     $emailer->headers('X-AntiAbuse: Username - ' . $user->data['username']);
     $emailer->headers('X-AntiAbuse: User IP - ' . $user->ip);
     if ($use_bcc) {
         $emailer->to($config['board_email']);
         $emailer->bcc($recipient_email);
     } else {
         $emailer->to($recipient_email);
     }
     $emailer->set_subject($email_subject);
     if ($emty_email_template) {
         $emailer->use_template('admin_send_email', $recipient_lang);
         $emailer->assign_vars(array('SITENAME' => $config['sitename'], 'BOARD_EMAIL' => $config['board_email'], 'MESSAGE' => $email_text));
     } else {
         $server_url = create_server_url();
         $privmsg_url = $server_url . CMS_PAGE_PRIVMSG;
         $recipient_username = empty($recipient_username) ? $lang['User'] : $recipient_username;
         $email_sig = create_signature($config['board_email_sig']);
         $emailer->use_template('privmsg_notify', $recipient_lang);
         $emailer->assign_vars(array('USERNAME' => $recipient_username, 'SITENAME' => $config['sitename'], 'EMAIL_SIG' => $email_sig, 'FROM' => $user->data['username'], 'DATE' => create_date($config['default_dateformat'], time(), $config['board_timezone']), 'SUBJECT' => $pm_subject, 'PRIV_MSG_TEXT' => $email_text, 'FROM_USERNAME' => $user->data['username'], 'U_INBOX' => $privmsg_url . '?folder=inbox'));
     }
     $emailer->send();
     $emailer->reset();
     return true;
 }
コード例 #7
0
/**
* Sends a birthday Email
*/
function birthday_email_send()
{
    global $db, $cache, $config, $lang;
    if (!class_exists('emailer')) {
        @(include IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
    }
    $server_url = create_server_url();
    $birthdays_list = get_birthdays_list_email();
    foreach ($birthdays_list as $k => $v) {
        // Birthday - BEGIN
        // Check if the user has or have had birthday, also see if greetings are enabled
        if (!empty($config['birthday_greeting'])) {
            // Birthday Email - BEGIN
            setup_extra_lang(array('lang_cron_vars'), '', $v['user_lang']);
            $year = create_date('Y', time(), $v['user_timezone']);
            $date_today = create_date('Ymd', time(), $v['user_timezone']);
            $user_birthday = realdate('md', $v['user_birthday']);
            $user_birthday2 = ($year . $user_birthday < $date_today ? $year + 1 : $year) . $user_birthday;
            $user_age = create_date('Y', time(), $v['user_timezone']) - realdate('Y', $v['user_birthday']);
            if (create_date('md', time(), $v['user_timezone']) < realdate('md', $v['user_birthday'])) {
                $user_age--;
            }
            $email_subject = sprintf($lang['BIRTHDAY_GREETING_EMAIL_SUBJECT'], $config['sitename']);
            //$email_text = sprintf($lang['BIRTHDAY_GREETING_EMAIL_CONTENT_AGE'], $user_age);
            $email_text = sprintf($lang['BIRTHDAY_GREETING_EMAIL_CONTENT'], $config['sitename']);
            // Send the email!
            $emailer = new emailer();
            $emailer->use_template('birthday_greeting', $v['user_lang']);
            $emailer->to($v['user_email']);
            // If for some reason the mail template subject cannot be read... note it will not necessarily be in the posters own language!
            $emailer->set_subject($email_subject);
            $v['username'] = !empty($v['user_first_name']) ? $v['user_first_name'] : $v['username'];
            // This is a nasty kludge to remove the username var ... till (if?) translators update their templates
            $emailer->msg = preg_replace('#[ ]?{USERNAME}#', $v['username'], $emailer->msg);
            $email_sig = create_signature($config['board_email_sig']);
            $emailer->assign_vars(array('USERNAME' => !empty($config['html_email']) ? htmlspecialchars($v['username']) : $v['username'], 'USER_AGE' => $user_age, 'EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'SITE_URL' => $server_url));
            $emailer->send();
            $emailer->reset();
            // Birthday Email - END
            $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\tSET user_next_birthday_greeting = " . (create_date('Y', time(), $v['user_timezone']) + 1) . "\n\t\t\t\tWHERE user_id = " . $v['user_id'];
            $status = $db->sql_query($sql);
        }
        // Birthday - END
    }
    // We reset the lang again for default lang...
    setup_extra_lang(array('lang_cron_vars'));
}