• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP push_lang函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中push_lang函数的典型用法代码示例。如果您正苦于以下问题:PHP push_lang函数的具体用法?PHP push_lang怎么用?PHP push_lang使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了push_lang函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: update_fail

function update_fail($update_id, $error_message)
{
    //send the administrators an e-mail
    $admin_mail_list = "'" . implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email'])))) . "'";
    $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)", $admin_mail_list);
    // every admin could had different language
    foreach ($adminlist as $admin) {
        $lang = $admin['language'] ? $admin['language'] : 'en';
        push_lang($lang);
        $preamble = deindent(t("\n\t\t\tThe friendica developers released update %s recently,\n\t\t\tbut when I tried to install it, something went terribly wrong.\n\t\t\tThis needs to be fixed soon and I can't do it alone. Please contact a\n\t\t\tfriendica developer if you can not help me on your own. My database might be invalid."));
        $body = t("The error message is\n[pre]%s[/pre]");
        $preamble = sprintf($preamble, $update_id);
        $body = sprintf($body, $error_message);
        notification(array('type' => "SYSTEM_EMAIL", 'to_email' => $admin['email'], 'preamble' => $preamble, 'body' => $body, 'language' => $lang));
    }
    /*
    $email_tpl = get_intltext_template("update_fail_eml.tpl");
    $email_msg = replace_macros($email_tpl, array(
    	'$sitename' => $a->config['sitename'],
    	'$siteurl' =>  $a->get_baseurl(),
    	'$update' => DB_UPDATE_VERSION,
    	'$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
    ));
    $subject=sprintf(t('Update Error at %s'), $a->get_baseurl());
    require_once('include/email.php');
    $subject = email_header_encode($subject,'UTF-8');
    mail($a->config['admin_email'], $subject, $email_msg,
    	'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
    	.'Content-type: text/plain; charset=UTF-8'."\n"
    	.'Content-transfer-encoding: 8bit');
    */
    //try the logger
    logger("CRITICAL: Database structure update failed: " . $retval);
    break;
}
开发者ID:strk,项目名称:friendica,代码行数:35,代码来源:dbstructure.php


示例2: user_allow

function user_allow($hash)
{
    $a = get_app();
    $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1", dbesc($hash));
    if (!count($register)) {
        return false;
    }
    $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($register[0]['uid']));
    if (!count($user)) {
        killme();
    }
    $r = q("DELETE FROM `register` WHERE `hash` = '%s'", dbesc($register[0]['hash']));
    $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d", intval($register[0]['uid']));
    $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1", intval($user[0]['uid']));
    if (count($r) && $r[0]['net-publish']) {
        $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
        if ($url && strlen(get_config('system', 'directory'))) {
            proc_run('php', "include/directory.php", "{$url}");
        }
    }
    push_lang($register[0]['language']);
    send_register_open_eml($user[0]['email'], $a->config['sitename'], $a->get_baseurl(), $user[0]['username'], $register[0]['password']);
    pop_lang();
    if ($res) {
        info(t('Account approved.') . EOL);
        return true;
    }
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:28,代码来源:regmod.php


示例3: user_allow

function user_allow($hash)
{
    $a = get_app();
    $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1", dbesc($hash));
    if (!count($register)) {
        return false;
    }
    $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($register[0]['uid']));
    if (!count($user)) {
        killme();
    }
    $r = q("DELETE FROM `register` WHERE `hash` = '%s' LIMIT 1", dbesc($register[0]['hash']));
    $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d LIMIT 1", intval($register[0]['uid']));
    $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1", intval($user[0]['uid']));
    if (count($r) && $r[0]['net-publish']) {
        $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
        if ($url && strlen(get_config('system', 'directory_submit_url'))) {
            proc_run('php', "include/directory.php", "{$url}");
        }
    }
    push_lang($register[0]['language']);
    $email_tpl = get_intltext_template("register_open_eml.tpl");
    $email_tpl = replace_macros($email_tpl, array('$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$username' => $user[0]['username'], '$email' => $user[0]['email'], '$password' => $register[0]['password'], '$uid' => $user[0]['uid']));
    $res = mail($user[0]['email'], sprintf(t('Registration details for %s'), $a->config['sitename']), $email_tpl, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
    pop_lang();
    if ($res) {
        info(t('Account approved.') . EOL);
        return true;
    }
}
开发者ID:robhell,项目名称:friendica,代码行数:30,代码来源:regmod.php


示例4: notification

function notification($params)
{
    #logger('notification()', LOGGER_DEBUG);
    $a = get_app();
    // from here on everything is in the recipients language
    push_lang($params['language']);
    $banner = t('Friendica Notification');
    $product = FRIENDICA_PLATFORM;
    $siteurl = $a->get_baseurl(true);
    $thanks = t('Thank You,');
    $sitename = $a->config['sitename'];
    $site_admin = sprintf(t('%s Administrator'), $sitename);
    $nickname = "";
    $sender_name = $sitename;
    $hostname = $a->get_hostname();
    if (strpos($hostname, ':')) {
        $hostname = substr($hostname, 0, strpos($hostname, ':'));
    }
    $sender_email = $a->config['sender_email'];
    if (empty($sender_email)) {
        $sender_email = t('noreply') . '@' . $hostname;
    }
    $user = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($params['uid']));
    if ($user) {
        $nickname = $user[0]["nickname"];
    }
    // with $params['show_in_notification_page'] == false, the notification isn't inserted into
    // the database, and an email is sent if applicable.
    // default, if not specified: true
    $show_in_notification_page = x($params, 'show_in_notification_page') ? $params['show_in_notification_page'] : True;
    $additional_mail_header = "";
    $additional_mail_header .= "Precedence: list\n";
    $additional_mail_header .= "X-Friendica-Host: " . $hostname . "\n";
    $additional_mail_header .= "X-Friendica-Account: <" . $nickname . "@" . $hostname . ">\n";
    $additional_mail_header .= "X-Friendica-Platform: " . FRIENDICA_PLATFORM . "\n";
    $additional_mail_header .= "X-Friendica-Version: " . FRIENDICA_VERSION . "\n";
    $additional_mail_header .= "List-ID: <notification." . $hostname . ">\n";
    $additional_mail_header .= "List-Archive: <" . $a->get_baseurl() . "/notifications/system>\n";
    if (array_key_exists('item', $params)) {
        $title = $params['item']['title'];
        $body = $params['item']['body'];
    } else {
        $title = $body = '';
    }
    // e.g. "your post", "David's photo", etc.
    $possess_desc = t('%s <!item_type!>');
    if ($params['type'] == NOTIFY_MAIL) {
        $subject = sprintf(t('[Friendica:Notify] New mail received at %s'), $sitename);
        $preamble = sprintf(t('%1$s sent you a new private message at %2$s.'), $params['source_name'], $sitename);
        $epreamble = sprintf(t('%1$s sent you %2$s.'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('a private message') . '[/url]');
        $sitelink = t('Please visit %s to view and/or reply to your private messages.');
        $tsitelink = sprintf($sitelink, $siteurl . '/message/' . $params['item']['id']);
        $hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '/message/' . $params['item']['id'] . '">' . $sitename . '</a>');
        $itemlink = $siteurl . '/message/' . $params['item']['id'];
    }
    if ($params['type'] == NOTIFY_COMMENT) {
        //		logger("notification: params = " . print_r($params, true), LOGGER_DEBUG);
        $parent_id = $params['parent'];
        $p = q("SELECT `ignored` FROM `thread` WHERE `iid` = %d AND `uid` = %d LIMIT 1", intval($parent_id), intval($params['uid']));
        if ($p and count($p) and $p[0]["ignored"]) {
            logger("Thread " . $parent_id . " will be ignored", LOGGER_DEBUG);
            return;
        }
        // Check to see if there was already a tag notify or comment notify for this post.
        // If so don't create a second notification
        $p = null;
        $p = q("select id from notify where (type = %d or type = %d or type = %d) and link = '%s' and uid = %d limit 1", intval(NOTIFY_TAGSELF), intval(NOTIFY_COMMENT), intval(NOTIFY_SHARE), dbesc($params['link']), intval($params['uid']));
        if ($p and count($p)) {
            pop_lang();
            return;
        }
        // if it's a post figure out who's post it is.
        $p = null;
        if ($params['otype'] === 'item' && $parent_id) {
            $p = q("select * from item where id = %d and uid = %d limit 1", intval($parent_id), intval($params['uid']));
        }
        $item_post_type = item_post_type($p[0]);
        //$possess_desc = str_replace('<!item_type!>',$possess_desc);
        // "a post"
        $dest_str = sprintf(t('%1$s commented on [url=%2$s]a %3$s[/url]'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', $itemlink, $item_post_type);
        // "George Bull's post"
        if ($p) {
            $dest_str = sprintf(t('%1$s commented on [url=%2$s]%3$s\'s %4$s[/url]'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', $itemlink, $p[0]['author-name'], $item_post_type);
        }
        // "your post"
        if ($p[0]['owner-name'] == $p[0]['author-name'] && $p[0]['wall']) {
            $dest_str = sprintf(t('%1$s commented on [url=%2$s]your %3$s[/url]'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', $itemlink, $item_post_type);
        }
        // Some mail softwares relies on subject field for threading.
        // So, we cannot have different subjects for notifications of the same thread.
        // Before this we have the name of the replier on the subject rendering
        // differents subjects for messages on the same thread.
        $subject = sprintf(t('[Friendica:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $params['source_name']);
        $preamble = sprintf(t('%s commented on an item/conversation you have been following.'), $params['source_name']);
        $epreamble = $dest_str;
        $sitelink = t('Please visit %s to view and/or reply to the conversation.');
        $tsitelink = sprintf($sitelink, $siteurl);
        $hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
        $itemlink = $params['link'];
    }
//.........这里部分代码省略.........
开发者ID:strk,项目名称:friendica,代码行数:101,代码来源:enotify.php


示例5: submit

 /**
  * @brief
  *
  * @param array $params an assoziative array with:
  *  * \e string \b from_xchan sender xchan hash
  *  * \e string \b to_xchan recipient xchan hash
  *  * \e array \b item an assoziative array
  *  * \e int \b type one of the NOTIFY_* constants from boot.php
  *  * \e string \b link
  *  * \e string \b parent_mid
  *  * \e string \b otype
  *  * \e string \b verb
  *  * \e string \b activity
  */
 public static function submit($params)
 {
     logger('notification: entry', LOGGER_DEBUG);
     // throw a small amount of entropy into the system to breakup duplicates arriving at the same precise instant.
     usleep(mt_rand(0, 10000));
     if ($params['from_xchan']) {
         $x = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($params['from_xchan']));
     }
     if ($params['to_xchan']) {
         $y = q("select channel.*, account.* from channel left join account on channel_account_id = account_id\n\t\t\t\twhere channel_hash = '%s' and channel_removed = 0 limit 1", dbesc($params['to_xchan']));
     }
     if ($x & $y) {
         $sender = $x[0];
         $recip = $y[0];
     } else {
         logger('notification: no sender or recipient.');
         logger('sender: ' . $params['from_xchan']);
         logger('recip: ' . $params['to_xchan']);
         return;
     }
     // from here on everything is in the recipients language
     push_lang($recip['account_language']);
     // should probably have a channel language
     $banner = t('$Projectname Notification');
     $product = t('$projectname');
     // PLATFORM_NAME;
     $siteurl = z_root();
     $thanks = t('Thank You,');
     $sitename = get_config('system', 'sitename');
     $site_admin = sprintf(t('%s Administrator'), $sitename);
     $sender_name = $product;
     $hostname = \App::get_hostname();
     if (strpos($hostname, ':')) {
         $hostname = substr($hostname, 0, strpos($hostname, ':'));
     }
     // Do not translate 'noreply' as it must be a legal 7-bit email address
     $reply_email = get_config('system', 'reply_address');
     if (!$reply_email) {
         $reply_email = 'noreply' . '@' . $hostname;
     }
     $sender_email = get_config('system', 'from_email');
     if (!$sender_email) {
         $sender_email = 'Administrator' . '@' . \App::get_hostname();
     }
     $sender_name = get_config('system', 'from_email_name');
     if (!$sender_name) {
         $sender_name = \Zotlabs\Lib\System::get_site_name();
     }
     $additional_mail_header = "";
     if (array_key_exists('item', $params)) {
         require_once 'include/conversation.php';
         // if it's a normal item...
         if (array_key_exists('verb', $params['item'])) {
             // localize_item() alters the original item so make a copy first
             $i = $params['item'];
             logger('calling localize');
             localize_item($i);
             $title = $i['title'];
             $body = $i['body'];
             $private = $i['item_private'] || intval($i['item_obscured']);
         } else {
             $title = $params['item']['title'];
             $body = $params['item']['body'];
         }
     } else {
         $title = $body = '';
     }
     // e.g. "your post", "David's photo", etc.
     $possess_desc = t('%s <!item_type!>');
     if ($params['type'] == NOTIFY_MAIL) {
         logger('notification: mail');
         $subject = sprintf(t('[$Projectname:Notify] New mail received at %s'), $sitename);
         $preamble = sprintf(t('%1$s, %2$s sent you a new private message at %3$s.'), $recip['channel_name'], $sender['xchan_name'], $sitename);
         $epreamble = sprintf(t('%1$s sent you %2$s.'), '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', '[zrl=$itemlink]' . t('a private message') . '[/zrl]');
         $sitelink = t('Please visit %s to view and/or reply to your private messages.');
         $tsitelink = sprintf($sitelink, $siteurl . '/mail/' . $params['item']['id']);
         $hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '/mail/' . $params['item']['id'] . '">' . $sitename . '</a>');
         $itemlink = $siteurl . '/mail/' . $params['item']['id'];
     }
     if ($params['type'] == NOTIFY_COMMENT) {
         //		logger("notification: params = " . print_r($params, true), LOGGER_DEBUG);
         $itemlink = $params['link'];
         // ignore like/unlike activity on posts - they probably require a separate notification preference
         if (array_key_exists('item', $params) && !visible_activity($params['item'])) {
             logger('notification: not a visible activity. Ignoring.');
             pop_lang();
//.........这里部分代码省略.........
开发者ID:phellmes,项目名称:hubzilla,代码行数:101,代码来源:Enotify.php


示例6: account_allow

/**
 * @brief Allows a user registration.
 *
 * @param string $hash
 * @return array|boolean
 */
function account_allow($hash)
{
    $ret = array('success' => false);
    $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1", dbesc($hash));
    if (!$register) {
        return $ret;
    }
    $account = q("SELECT * FROM account WHERE account_id = %d LIMIT 1", intval($register[0]['uid']));
    if (!$account) {
        return $ret;
    }
    $r = q("DELETE FROM register WHERE hash = '%s'", dbesc($register[0]['hash']));
    $r = q("update account set account_flags = (account_flags & ~%d) where (account_flags & %d)>0 and account_id = %d", intval(ACCOUNT_BLOCKED), intval(ACCOUNT_BLOCKED), intval($register[0]['uid']));
    $r = q("update account set account_flags = (account_flags & ~%d) where (account_flags & %d)>0 and account_id = %d", intval(ACCOUNT_PENDING), intval(ACCOUNT_PENDING), intval($register[0]['uid']));
    push_lang($register[0]['language']);
    $email_tpl = get_intltext_template("register_open_eml.tpl");
    $email_tpl = replace_macros($email_tpl, array('$sitename' => get_config('system', 'sitename'), '$siteurl' => z_root(), '$username' => $account[0]['account_email'], '$email' => $account[0]['account_email'], '$password' => '', '$uid' => $account[0]['account_id']));
    $res = mail($account[0]['account_email'], sprintf(t('Registration details for %s'), get_config('system', 'sitename')), $email_tpl, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
    pop_lang();
    if (get_config('system', 'auto_channel_create')) {
        auto_channel_create($register[0]['uid']);
    }
    if ($res) {
        info(t('Account approved.') . EOL);
        return true;
    }
}
开发者ID:bashrc,项目名称:hubzilla,代码行数:33,代码来源:account.php


示例7: register_post


//.........这里部分代码省略.........
      * due to race condition. Remove this one.
      */
     $r = q("SELECT `uid` FROM `user`\n               \tWHERE `nickname` = '%s' ", dbesc($nickname));
     if (count($r) > 1 && $newuid) {
         $err .= t('Nickname is already registered. Please choose another.') . EOL;
         q("DELETE FROM `user` WHERE `uid` = %d LIMIT 1", intval($newuid));
         notice($err);
         return;
     }
     if (x($newuid) !== false) {
         $r = q("INSERT INTO `profile` ( `uid`, `profile-name`, `is-default`, `name`, `photo`, `thumb`, `publish`, `net-publish` )\n\t\t\tVALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, %d ) ", intval($newuid), 'default', 1, dbesc($username), dbesc($a->get_baseurl() . "/photo/profile/{$newuid}.jpg"), dbesc($a->get_baseurl() . "/photo/avatar/{$newuid}.jpg"), intval($publish), intval($netpublish));
         if ($r === false) {
             notice(t('An error occurred creating your default profile. Please try again.') . EOL);
             // Start fresh next time.
             $r = q("DELETE FROM `user` WHERE `uid` = %d", intval($newuid));
             return;
         }
         $r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `nick`, `photo`, `thumb`, `micro`, `blocked`, `pending`, `url`, `nurl`,\n\t\t\t`request`, `notify`, `poll`, `confirm`, `poco`, `name-date`, `uri-date`, `avatar-date` )\n\t\t\tVALUES ( %d, '%s', 1, '%s', '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", intval($newuid), datetime_convert(), dbesc($username), dbesc($nickname), dbesc($a->get_baseurl() . "/photo/profile/{$newuid}.jpg"), dbesc($a->get_baseurl() . "/photo/avatar/{$newuid}.jpg"), dbesc($a->get_baseurl() . "/photo/micro/{$newuid}.jpg"), dbesc($a->get_baseurl() . "/profile/{$nickname}"), dbesc(normalise_link($a->get_baseurl() . "/profile/{$nickname}")), dbesc($a->get_baseurl() . "/dfrn_request/{$nickname}"), dbesc($a->get_baseurl() . "/dfrn_notify/{$nickname}"), dbesc($a->get_baseurl() . "/dfrn_poll/{$nickname}"), dbesc($a->get_baseurl() . "/dfrn_confirm/{$nickname}"), dbesc($a->get_baseurl() . "/poco/{$nickname}"), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()));
     }
     $use_gravatar = get_config('system', 'no_gravatar') ? false : true;
     // if we have an openid photo use it.
     // otherwise unless it is disabled, use gravatar
     if ($use_gravatar || strlen($photo)) {
         require_once 'include/Photo.php';
         if ($use_gravatar && !strlen($photo)) {
             $photo = gravatar_img($email);
         }
         $photo_failure = false;
         $filename = basename($photo);
         $img_str = fetch_url($photo, true);
         $img = new Photo($img_str);
         if ($img->is_valid()) {
             $img->scaleImageSquare(175);
             $hash = photo_new_resource();
             $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 4);
             if ($r === false) {
                 $photo_failure = true;
             }
             $img->scaleImage(80);
             $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 5);
             if ($r === false) {
                 $photo_failure = true;
             }
             $img->scaleImage(48);
             $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 6);
             if ($r === false) {
                 $photo_failure = true;
             }
             if (!$photo_failure) {
                 q("UPDATE `photo` SET `profile` = 1 WHERE `resource-id` = '%s' ", dbesc($hash));
             }
         }
     }
     if ($netpublish && $a->config['register_policy'] != REGISTER_APPROVE) {
         $url = $a->get_baseurl() . "/profile/{$nickname}";
         proc_run('php', "include/directory.php", "{$url}");
     }
     call_hooks('register_account', $newuid);
     if ($a->config['register_policy'] == REGISTER_OPEN) {
         if ($using_invites && $invite_id) {
             q("delete * from register where hash = '%s' limit 1", dbesc($invite_id));
             set_pconfig($newuid, 'system', 'invites_remaining', $num_invites);
         }
         $email_tpl = get_intltext_template("register_open_eml.tpl");
         $email_tpl = replace_macros($email_tpl, array('$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$username' => $username, '$email' => $email, '$password' => $new_password, '$uid' => $newuid));
         $res = mail($email, sprintf(t('Registration details for %s'), $a->config['sitename']), $email_tpl, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
         if ($res) {
             info(t('Registration successful. Please check your email for further instructions.') . EOL);
             goaway(z_root());
         } else {
             notice(t('Failed to send email message. Here is the message that failed.') . $email_tpl . EOL);
         }
     } elseif ($a->config['register_policy'] == REGISTER_APPROVE) {
         if (!strlen($a->config['admin_email'])) {
             notice(t('Your registration can not be processed.') . EOL);
             goaway(z_root());
         }
         $hash = random_string();
         $r = q("INSERT INTO `register` ( `hash`, `created`, `uid`, `password`, `language` ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ", dbesc($hash), dbesc(datetime_convert()), intval($newuid), dbesc($new_password), dbesc($lang));
         $r = q("SELECT `language` FROM `user` WHERE `email` = '%s' LIMIT 1", dbesc($a->config['admin_email']));
         if (count($r)) {
             push_lang($r[0]['language']);
         } else {
             push_lang('en');
         }
         if ($using_invites && $invite_id) {
             q("delete * from register where hash = '%s' limit 1", dbesc($invite_id));
             set_pconfig($newuid, 'system', 'invites_remaining', $num_invites);
         }
         $email_tpl = get_intltext_template("register_verify_eml.tpl");
         $email_tpl = replace_macros($email_tpl, array('$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$username' => $username, '$email' => $email, '$password' => $new_password, '$uid' => $newuid, '$hash' => $hash));
         $res = mail($a->config['admin_email'], sprintf(t('Registration request at %s'), $a->config['sitename']), $email_tpl, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
         pop_lang();
         if ($res) {
             info(t('Your registration is pending approval by the site owner.') . EOL);
             goaway(z_root());
         }
     }
     return;
 }
开发者ID:ryivhnn,项目名称:friendica,代码行数:101,代码来源:register.php


示例8: notification

function notification($params)
{
    logger('notification: entry', LOGGER_DEBUG);
    $a = get_app();
    // from here on everything is in the recipients language
    push_lang($params['language']);
    $banner = t('Friendica Notification');
    $product = FRIENDICA_PLATFORM;
    $siteurl = $a->get_baseurl(true);
    $thanks = t('Thank You,');
    $sitename = get_config('config', 'sitename');
    $site_admin = sprintf(t('%s Administrator'), $sitename);
    $sender_name = $product;
    $hostname = $a->get_hostname();
    if (strpos($hostname, ':')) {
        $hostname = substr($hostname, 0, strpos($hostname, ':'));
    }
    $sender_email = t('noreply') . '@' . $hostname;
    $additional_mail_header = "";
    if (array_key_exists('item', $params)) {
        $title = $params['item']['title'];
        $body = $params['item']['body'];
    } else {
        $title = $body = '';
    }
    // e.g. "your post", "David's photo", etc.
    $possess_desc = t('%s <!item_type!>');
    if ($params['type'] == NOTIFY_MAIL) {
        $subject = sprintf(t('[Friendica:Notify] New mail received at %s'), $sitename);
        $preamble = sprintf(t('%s sent you a new private message at %s.'), $params['source_name'], $sitename);
        $epreamble = sprintf(t('%s sent you %s.'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('a private message') . '[/url]');
        $sitelink = t('Please visit %s to view and/or reply to your private messages.');
        $tsitelink = sprintf($sitelink, $siteurl . '/message/' . $params['item']['id']);
        $hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '/message/' . $params['item']['id'] . '">' . $sitename . '</a>');
        $itemlink = $siteurl . '/message/' . $params['item']['id'];
    }
    if ($params['type'] == NOTIFY_COMMENT) {
        //		logger("notification: params = " . print_r($params, true), LOGGER_DEBUG);
        $parent_id = $params['parent'];
        // if it's a post figure out who's post it is.
        $p = null;
        if ($params['otype'] === 'item' && $parent_id) {
            $p = q("select * from item where id = %d and uid = %d limit 1", intval($parent_id), intval($params['uid']));
        }
        $possess_desc = str_replace('<!item_type!>', item_post_type($p[0]), $possess_desc);
        // "a post"
        $dest_str = sprintf($possess_desc, 'a');
        // "George Bull's post"
        if ($p) {
            $dest_str = sprintf($possess_desc, sprintf(t("%s's"), $p[0]['author-name']));
        }
        // "your post"
        if ($p[0]['owner-name'] == $p[0]['author-name'] && $p[0]['wall']) {
            $dest_str = sprintf($possess_desc, t('your'));
        }
        // Some mail softwares relies on subject field for threading.
        // So, we cannot have different subjects for notifications of the same thread.
        // Before this we have the name of the replier on the subject rendering
        // differents subjects for messages on the same thread.
        $subject = sprintf(t('[Friendica:Notify] Comment to conversation #%d by %s'), $parent_id, $params['source_name']);
        $preamble = sprintf(t('%s commented on an item/conversation you have been following.'), $params['source_name']);
        $epreamble = sprintf(t('%s commented on %s.'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . $dest_str . '[/url]');
        $sitelink = t('Please visit %s to view and/or reply to the conversation.');
        $tsitelink = sprintf($sitelink, $siteurl);
        $hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
        $itemlink = $params['link'];
    }
    if ($params['type'] == NOTIFY_WALL) {
        $subject = sprintf(t('[Friendica:Notify] %s posted to your profile wall'), $params['source_name']);
        $preamble = sprintf(t('%s posted to your profile wall at %s'), $params['source_name'], $sitename);
        $epreamble = sprintf(t('%s posted to %s'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('your profile wall.') . '[/url]');
        $sitelink = t('Please visit %s to view and/or reply to the conversation.');
        $tsitelink = sprintf($sitelink, $siteurl);
        $hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
        $itemlink = $params['link'];
    }
    if ($params['type'] == NOTIFY_TAGSELF) {
        $subject = sprintf(t('[Friendica:Notify] %s tagged you'), $params['source_name']);
        $preamble = sprintf(t('%s tagged you at %s'), $params['source_name'], $sitename);
        $epreamble = sprintf(t('%s %s.'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=' . $params['link'] . ']' . t('tagged you') . '[/url]');
        $sitelink = t('Please visit %s to view and/or reply to the conversation.');
        $tsitelink = sprintf($sitelink, $siteurl);
        $hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
        $itemlink = $params['link'];
    }
    if ($params['type'] == NOTIFY_TAGSHARE) {
        $subject = sprintf(t('[Friendica:Notify] %s tagged your post'), $params['source_name']);
        $preamble = sprintf(t('%s tagged your post at %s'), $params['source_name'], $sitename);
        $epreamble = sprintf(t('%s tagged %s'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('your post') . '[/url]');
        $sitelink = t('Please visit %s to view and/or reply to the conversation.');
        $tsitelink = sprintf($sitelink, $siteurl);
        $hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
        $itemlink = $params['link'];
    }
    if ($params['type'] == NOTIFY_INTRO) {
        $subject = sprintf(t('[Friendica:Notify] Introduction received'));
        $preamble = sprintf(t('You\'ve received an introduction from \'%s\' at %s'), $params['source_name'], $sitename);
        $epreamble = sprintf(t('You\'ve received %s from %s.'), '[url=$itemlink]' . t('an introduction') . '[/url]', '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
        $body = sprintf(t('You may visit their profile at %s'), $params['source_link']);
        $sitelink = t('Please visit %s to approve or reject the introduction.');
//.........这里部分代码省略.........
开发者ID:robhell,项目名称:friendica,代码行数:101,代码来源:enotify.php


示例9: check_config

function check_config(&$a)
{
    $build = get_config('system', 'db_version');
    if (!intval($build)) {
        $build = set_config('system', 'db_version', DB_UPDATE_VERSION);
    }
    $saved = get_config('system', 'urlverify');
    if (!$saved) {
        set_config('system', 'urlverify', bin2hex(z_root()));
    }
    if ($saved && $saved != bin2hex(z_root())) {
        // our URL changed. Do something.
        $oldurl = hex2bin($saved);
        logger('Baseurl changed!');
        $oldhost = substr($oldurl, strpos($oldurl, '//') + 2);
        $host = substr(z_root(), strpos(z_root(), '//') + 2);
        $is_ip_addr = preg_match("/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\$/", $host) ? true : false;
        $was_ip_addr = preg_match("/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\$/", $oldhost) ? true : false;
        // only change the url to an ip address if it was already an ip and not a dns name
        if (!$is_ip_addr || $is_ip_addr && $was_ip_addr) {
            fix_system_urls($oldurl, z_root());
            set_config('system', 'urlverify', bin2hex(z_root()));
        } else {
            logger('Attempt to change baseurl from a DNS name to an IP address was refused.');
        }
    }
    // This will actually set the url to the one stored in .htconfig, and ignore what
    // we're passing - unless we are installing and it has never been set.
    App::set_baseurl(z_root());
    // Make sure each site has a system channel.  This is now created on install
    // so we just need to keep this around a couple of weeks until the hubs that
    // already exist have one
    $syschan_exists = get_sys_channel();
    if (!$syschan_exists) {
        create_sys_channel();
    }
    if ($build != DB_UPDATE_VERSION) {
        $stored = intval($build);
        if (!$stored) {
            logger('Critical: check_config unable to determine database schema version');
            return;
        }
        $current = intval(DB_UPDATE_VERSION);
        if ($stored < $current && file_exists('install/update.php')) {
            load_config('database');
            // We're reporting a different version than what is currently installed.
            // Run any existing update scripts to bring the database up to current.
            require_once 'install/update.php';
            // make sure that boot.php and update.php are the same release, we might be
            // updating right this very second and the correct version of the update.php
            // file may not be here yet. This can happen on a very busy site.
            if (DB_UPDATE_VERSION == UPDATE_VERSION) {
                for ($x = $stored; $x < $current; $x++) {
                    if (function_exists('update_r' . $x)) {
                        // There could be a lot of processes running or about to run.
                        // We want exactly one process to run the update command.
                        // So store the fact that we're taking responsibility
                        // after first checking to see if somebody else already has.
                        // If the update fails or times-out completely you may need to
                        // delete the config entry to try again.
                        if (get_config('database', 'update_r' . $x)) {
                            break;
                        }
                        set_config('database', 'update_r' . $x, '1');
                        // call the specific update
                        $func = 'update_r' . $x;
                        $retval = $func();
                        if ($retval) {
                            // Prevent sending hundreds of thousands of emails by creating
                            // a lockfile.
                            $lockfile = 'store/[data]/mailsent';
                            if (file_exists($lockfile) && filemtime($lockfile) > time() - 86400) {
                                return;
                            }
                            @unlink($lockfile);
                            //send the administrator an e-mail
                            file_put_contents($lockfile, $x);
                            $r = q("select account_language from account where account_email = '%s' limit 1", dbesc(App::$config['system']['admin_email']));
                            push_lang($r ? $r[0]['account_language'] : 'en');
                            $email_tpl = get_intltext_template("update_fail_eml.tpl");
                            $email_msg = replace_macros($email_tpl, array('$sitename' => App::$config['system']['sitename'], '$siteurl' => z_root(), '$update' => $x, '$error' => sprintf(t('Update %s failed. See error logs.'), $x)));
                            $subject = email_header_encode(sprintf(t('Update Error at %s'), z_root()));
                            mail(App::$config['system']['admin_email'], $subject, $email_msg, 'From: Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
                            //try the logger
                            logger('CRITICAL: Update Failed: ' . $x);
                            pop_lang();
                        } else {
                            set_config('database', 'update_r' . $x, 'success');
                        }
                    }
                }
                set_config('system', 'db_version', DB_UPDATE_VERSION);
            }
        }
    }
    /**
     *
     * Synchronise plugins:
     *
     * App::$config['system']['addon'] contains a comma-separated list of names
//.........这里部分代码省略.........
开发者ID:einervonvielen,项目名称:hubzilla,代码行数:101,代码来源:boot.php


示例10: account_allow

/**
 * @brief Allows a user registration.
 *
 * @param string $hash
 * @return array|boolean
 */
function account_allow($hash)
{
    $ret = array('success' => false);
    $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1", dbesc($hash));
    if (!$register) {
        return $ret;
    }
    $account = q("SELECT * FROM account WHERE account_id = %d LIMIT 1", intval($register[0]['uid']));
    if (!$account) {
        return $ret;
    }
    $r = q("DELETE FROM register WHERE hash = '%s'", dbesc($register[0]['hash']));
    $r = q("update account set account_flags = (account_flags & ~%d) where (account_flags & %d)>0 and account_id = %d", intval(ACCOUNT_BLOCKED), intval(ACCOUNT_BLOCKED), intval($register[0]['uid']));
    $r = q("update account set account_flags = (account_flags & ~%d) where (account_flags & %d)>0 and account_id = %d", intval(ACCOUNT_PENDING), intval(ACCOUNT_PENDING), intval($register[0]['uid']));
    push_lang($register[0]['lang']);
    $email_tpl = get_intltext_template("register_open_eml.tpl");
    $email_msg = replace_macros($email_tpl, array('$sitename' => get_config('system', 'sitename'), '$siteurl' => z_root(), '$username' => $account[0]['account_email'], '$email' => $account[0]['account_email'], '$password' => '', '$uid' => $account[0]['account_id']));
    $res = z_mail(['toEmail' => $account[0]['account_email'], 'messageSubject' => sprintf(t('Registration details for %s'), get_config('system', 'sitename')), 'textVersion' => $email_msg]);
    pop_lang();
    if (get_config('system', 'auto_channel_create') || get_config('system', 'server_role') === 'basic') {
        auto_channel_create($register[0]['uid']);
    }
    if ($res) {
        info(t('Account approved.') . EOL);
        return true;
    }
}
开发者ID:phellmes,项目名称:hubzilla,代码行数:33,代码来源:account.php


示例11: local_delivery


//.........这里部分代码省略.........
            $fid = $r[0]['id'];
        } else {
            return 0;
        }
        $hash = random_string();
        $r = q("INSERT INTO `intro` ( `uid`, `fid`, `contact-id`, `note`, `hash`, `datetime`, `blocked` )\n\t\t\tVALUES( %d, %d, %d, '%s', '%s', '%s', %d )", intval($fsugg['uid']), intval($fid), intval($fsugg['cid']), dbesc($fsugg['body']), dbesc($hash), dbesc(datetime_convert()), intval(0));
        // TODO - send email notify (which may require a new notification preference)
        return 0;
    }
    $ismail = false;
    $rawmail = $feed->get_feed_tags(NAMESPACE_DFRN, 'mail');
    if (isset($rawmail[0]['child'][NAMESPACE_DFRN])) {
        logger('local_delivery: private message received');
        $ismail = true;
        $base = $rawmail[0]['child'][NAMESPACE_DFRN];
        $msg = array();
        $msg['uid'] = $importer['importer_uid'];
        $msg['from-name'] = notags(unxmlify($base['sender'][0]['child'][NAMESPACE_DFRN]['name'][0]['data']));
        $msg['from-photo'] = notags(unxmlify($base['sender'][0]['child'][NAMESPACE_DFRN]['avatar'][0]['data']));
        $msg['from-url'] = notags(unxmlify($base['sender'][0]['child'][NAMESPACE_DFRN]['uri'][0]['data']));
        $msg['contact-id'] = $importer['id'];
        $msg['title'] = notags(unxmlify($base['subject'][0]['data']));
        $msg['body'] = escape_tags(unxmlify($base['content'][0]['data']));
        $msg['seen'] = 0;
        $msg['replied'] = 0;
        $msg['uri'] = notags(unxmlify($base['id'][0]['data']));
        $msg['parent-uri'] = notags(unxmlify($base['in-reply-to'][0]['data']));
        $msg['created'] = datetime_convert(notags(unxmlify('UTC', 'UTC', $base['sentdate'][0]['data'])));
        dbesc_array($msg);
        $r = dbq("INSERT INTO `mail` (`" . implode("`, `", array_keys($msg)) . "`) VALUES ('" . implode("', '", array_values($msg)) . "')");
        // send email notification if requested.
        require_once 'bbcode.php';
        if ($importer['notify-flags'] & NOTIFY_MAIL) {
            push_lang($importer['language']);
            // name of the automated email sender
            $msg['notificationfromname'] = t('Administrator');
            // noreply address to send from
            $msg['notificationfromemail'] = t('noreply') . '@' . $a->get_hostname();
            // text version
            // process the message body to display properly in text mode
            // 		1) substitute a \n character for the "\" then "n", so it behaves properly (it doesn't come in as a \n character)
            //		2) remove escape slashes
            //		3) decode any bbcode from the message editor
            //		4) decode any encoded html tags
            //		5) remove html tags
            $msg['textversion'] = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n", $msg['body']))), ENT_QUOTES, 'UTF-8'));
            // html version
            // process the message body to display properly in text mode
            // 		1) substitute a <br /> tag for the "\" then "n", so it behaves properly (it doesn't come in as a \n character)
            //		2) remove escape slashes
            //		3) decode any bbcode from the message editor
            //		4) decode any encoded html tags
            $msg['htmlversion'] = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n\\n", "\\n"), "<br />\n", $msg['body']))));
            // load the template for private message notifications
            $tpl = get_intltext_template('mail_received_html_body_eml.tpl');
            $email_html_body_tpl = replace_macros($tpl, array('$username' => $importer['username'], '$siteName' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$thumb' => $importer['thumb'], '$email' => $importer['email'], '$url' => $importer['url'], '$from' => $msg['from-name'], '$title' => stripslashes($msg['title']), '$htmlversion' => $msg['htmlversion'], '$mimeboundary' => $msg['mimeboundary'], '$hostname' => $a->get_hostname()));
            // load the template for private message notifications
            $tpl = get_intltext_template('mail_received_text_body_eml.tpl');
            $email_text_body_tpl = replace_macros($tpl, array('$username' => $importer['username'], '$siteName' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$thumb' => $importer['thumb'], '$email' => $importer['email'], '$url' => $importer['url'], '$from' => $msg['from-name'], '$title' => stripslashes($msg['title']), '$textversion' => $msg['textversion'], '$mimeboundary' => $msg['mimeboundary'], '$hostname' => $a->get_hostname()));
            // use the EmailNotification library to send the message
            require_once "include/EmailNotification.php";
            EmailNotification::sendTextHtmlEmail($msg['notificationfromname'], $msg['notificationfromemail'], $msg['notificationfromemail'], $importer['email'], t('New mail received at ') . $a->config['sitename'], $email_html_body_tpl, $email_text_body_tpl);
            pop_lang();
        }
        return 0;
        // NOTREACHED
开发者ID:ryivhnn,项目名称:friendica,代码行数:67,代码来源:items.php


示例12: dfrn_confirm_post


//.........这里部分代码省略.........
            $message = t('Unable to set your contact credentials on our system.');
            xml_status(3, $message);
        }
        // It's possible that the other person also requested friendship.
        // If it is a duplex relationship, ditch the issued-id if one exists.
        if ($duplex) {
            $r = q("UPDATE `contact` SET `issued-id` = '' WHERE `id` = %d LIMIT 1", intval($dfrn_record));
        }
        // We're good but now we have to scrape the profile photo and send notifications.
        $r = q("SELECT `photo` FROM `contact` WHERE `id` = %d LIMIT 1", intval($dfrn_record));
        if (count($r)) {
            $photo = $r[0]['photo'];
        } else {
            $photo = $a->get_baseurl() . '/images/person-175.jpg';
        }
        require_once "include/Photo.php";
        $photos = import_profile_photo($photo, $local_uid, $dfrn_record);
        logger('dfrn_confirm: request - photos imported');
        $new_relation = CONTACT_IS_SHARING;
        if ($relation == CONTACT_IS_FOLLOWER || $duplex) {
            $new_relation = CONTACT_IS_FRIEND;
        }
        if ($relation == CONTACT_IS_FOLLOWER && $duplex) {
            $duplex = 0;
        }
        $r = q("UPDATE `contact` SET \n\t\t\t`photo` = '%s', \n\t\t\t`thumb` = '%s', \n\t\t\t`micro` = '%s',\n\t\t\t`rel` = %d, \n\t\t\t`name-date` = '%s', \n\t\t\t`uri-date` = '%s', \n\t\t\t`avatar-date` = '%s', \n\t\t\t`blocked` = 0, \n\t\t\t`pending` = 0,\n\t\t\t`duplex` = %d, \n\t\t\t`forum` = %d,\n\t\t\t`prv` = %d,\n\t\t\t`network` = '%s' WHERE `id` = %d LIMIT 1\n\t\t", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), intval($new_relation), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()), intval($duplex), intval($forum), intval($prv), dbesc(NETWORK_DFRN), intval($dfrn_record));
        if ($r === false) {
            // indicates schema is messed up or total db failure
            $message = t('Unable to update your contact profile details on our system');
            xml_status(3, $message);
        }
        // Otherwise everything seems to have worked and we are almost done. Yay!
        //  

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP push_out_host函数代码示例发布时间:2022-05-15
下一篇:
PHP pushClaroMessage函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap