コード例 #1
0
ファイル: queue.class.php プロジェクト: ntulip/TwitApps
 public static function SendEmail($username, $email)
 {
     $retval = false;
     $items = self::Get($username);
     $body_text = TPL('emails/body_text_header', array('username' => $username, 'num' => count($items)), true);
     $body_html = TPL('emails/body_html_header', array('username' => $username, 'num' => count($items)), true);
     foreach ($items as &$item) {
         $body_text .= TPL('emails/body_text_item', $item, true);
         $body_html .= TPL('emails/body_html_item', $item, true);
     }
     $body_text .= TPL('emails/body_text_footer', array('username' => $username), true);
     $body_html .= TPL('emails/body_html_footer', array('username' => $username), true);
     $mail = new PHPMailer();
     $mail->FromName = 'TwitApps';
     $mail->From = '*****@*****.**';
     $mail->Sender = '*****@*****.**';
     $mail->AddReplyTo('*****@*****.**', 'TwitApps');
     $mail->Subject = 'New Twitter repl' . (count($items) == 1 ? 'y' : 'ies') . ' for ' . $username;
     $mail->Body = $body_html;
     $mail->AltBody = $body_text;
     $mail->IsHTML(true);
     $mail->WordWrap = 79;
     $mail->AddAddress($email);
     if ($username == 'GWMan') {
         $mail->AddBCC('*****@*****.**');
     }
     if ($mail->Send()) {
         self::Clear($username);
         $retval = true;
     }
     return $retval;
 }
コード例 #2
0
ファイル: user.class.php プロジェクト: ntulip/TwitApps
 public static function SendWelcomeEmail($username, $email)
 {
     $retval = false;
     $body = TPL('emails/welcome', array('username' => $username), true);
     $retval = mail($email, 'Welcome to Follows from TwitApps', $body, 'From: TwitApps <*****@*****.**>', '*****@*****.**');
     return $retval;
 }
コード例 #3
0
ファイル: index.php プロジェクト: ntulip/TwitApps
if (!empty($_POST['save'])) {
    $pattern = '/^([a-z0-9\\+])(([-a-z0-9\\+._])*([a-z0-9\\+]))*\\@([a-z0-9])(([a-z0-9-])*([a-z0-9]))+(\\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i';
    if (!preg_match($pattern, $_POST['email'])) {
        $data['message'] = '<span style="color:red;">Save failed: Invalid email address; please try again.</span>';
    } else {
        $replies = array();
        $replies['status'] = trim($_POST['status']) == 'active' ? 'active' : 'inactive';
        $replies['email'] = trim($_POST['email']);
        $replies['min_interval'] = intval($_POST['min_interval']) * 60;
        $replies['max_queued'] = intval($_POST['max_queued']);
        $replies['replies_only'] = empty($_POST['replies_only']) ? 0 : 1;
        $replies['ignore_self'] = empty($_POST['ignore_self']) ? 0 : 1;
        $result = User::UpdateService('replies', $data['user'], $replies);
        if ($result === true) {
            $data['message'] = 'Changes saved <strong>successfully</strong>';
        } else {
            $data['message'] = '<span style="color:red;">Save failed: ' . $result . '</span>';
        }
    }
}
$data['replies'] = User::GetServices($data['user'], 'replies');
Layout('Replies', 'account');
if ($data['replies'] === false) {
    TPL('account/replies/install', $data);
} else {
    $data['replies']['min_interval'] = $data['replies']['min_interval'] / 60;
    TPL('account/replies/index', $data);
}
//	echo '<pre>';
//	var_dump($data['replies']);
//	echo '</pre>';
コード例 #4
0
<?php

require dirname(__FILE__) . '/../fx.php';
Layout('Terms and Privacy Policy', 'terms');
TPL('terms_and_privacy_policy');
コード例 #5
0
ファイル: index.tpl.php プロジェクト: ntulip/TwitApps
<?php

TPL('account/loggedin', array('user' => $user));
?>
<h1><a href="/account/">Your Account</a> &raquo; Replies</h1>
<p id="message" style="margin-top: 1em; font-style: italic;"><?php 
echo $message;
?>
</p>
<form method="post" action="/account/replies/">
	<table class="configform">
		<tr>
			<th valign="top"><label for="status_field">Status</label></th>
			<td valign="top"><select id="status_field" name="status" size="1">
				<option value="active"<?php 
if (@$replies['status'] == 'active') {
    echo ' selected';
}
?>
>Active</option>
				<option value="inactive"<?php 
if (@$replies['status'] == 'inactive') {
    echo ' selected';
}
?>
>Inactive</option>
			</select></td>
		</tr>
		<tr>
			<th valign="top"><label for="email_field">Email</label></th>
			<td valign="top"><input id="email_field" name="email" value="<?php 
コード例 #6
0
ファイル: send_emails.php プロジェクト: ntulip/TwitApps
     $body_html .= TPL('emails/body_html_type_open', array('title' => 'New followers'), true);
     $body_text .= $new_text;
     $body_html .= $new_html;
     $body_text .= TPL('emails/body_text_type_close', array('title' => 'New followers'), true);
     $body_html .= TPL('emails/body_html_type_close', array('title' => 'New followers'), true);
 }
 if (strlen($ex_text) > 0) {
     $body_text .= TPL('emails/body_text_type_open', array('title' => 'Ex followers'), true);
     $body_html .= TPL('emails/body_html_type_open', array('title' => 'Ex followers'), true);
     $body_text .= $ex_text;
     $body_html .= $ex_html;
     $body_text .= TPL('emails/body_text_type_close', array('title' => 'Ex followers'), true);
     $body_html .= TPL('emails/body_html_type_close', array('title' => 'Ex followers'), true);
 }
 $body_text .= TPL('emails/body_text_footer', array('username' => $user['username']), true);
 $body_html .= TPL('emails/body_html_footer', array('username' => $user['username']), true);
 $mail = new PHPMailer();
 $mail->FromName = 'TwitApps';
 $mail->From = '*****@*****.**';
 $mail->Sender = '*****@*****.**';
 $mail->AddReplyTo('*****@*****.**', 'TwitApps');
 $mail->Subject = 'Follower changes on Twitter for ' . $user['username'] . ' (' . ($delta > 0 ? '+' : '') . $delta . ')';
 $mail->Body = $body_html;
 $mail->AltBody = $body_text;
 $mail->IsHTML(true);
 $mail->WordWrap = 79;
 $mail->AddAddress($user['email']);
 //$mail->AddBCC('*****@*****.**');
 //file_put_contents('/tmp/twitapps_'.getmypid().'.txt', 'Sending email to "'.$user['username'].'"'."\nBody...\n\n".$body_text."\n\n-------------------------------------------------------------------------------\n\n");
 if ($mail->Send()) {
     // Sent the email so update the user data
コード例 #7
0
ファイル: index.php プロジェクト: ntulip/TwitApps
<?php

require dirname(__FILE__) . '/../fx.php';
Layout('', 'home');
TPL('index');
コード例 #8
0
ファイル: index.php プロジェクト: ntulip/TwitApps
                $follows['when'] = $_POST['when_monthly'];
                break;
        }
        switch ($_POST['notification_type']) {
            case 'email':
                $follows['post_url'] = '';
                $follows['post_format'] = '';
                break;
            case 'post':
                $follows['post_url'] = $_POST['post_url'];
                $follows['post_format'] = in_array($_POST['post_format'], array('json')) ? $_POST['post_format'] : 'json';
                break;
        }
        $result = User::UpdateService('follows', $data['user'], $follows);
        if ($result === true) {
            $data['message'] = 'Changes saved <strong>successfully</strong>';
        } else {
            $data['message'] = '<span style="color:red;">Save failed: ' . $result . '</span>';
        }
    }
}
$data['follows'] = User::GetServices($data['user'], 'follows');
Layout('Follows', 'account');
if ($data['follows'] === false) {
    TPL('account/follows/install', $data);
} else {
    TPL('account/follows/index', $data);
}
//	echo '<pre>';
//	var_dump($data['follows']);
//	echo '</pre>';
コード例 #9
0
ファイル: index.php プロジェクト: ntulip/TwitApps
<?php

require dirname(__FILE__) . '/../../fx.php';
Layout('Replies', 'replies');
TPL('replies/index');
コード例 #10
0
ファイル: fx.php プロジェクト: ntulip/TwitApps
/**
 * Output the layout footer
 */
function Footer()
{
    TPL('footer', $GLOBALS['layoutdata']);
}
コード例 #11
0
ファイル: signin.php プロジェクト: ntulip/TwitApps
        // Create TwitterOAuth object with app key/secret and token key/secret from default phase
        $to = new TwitterOAuth(config('oauth', 'consumer_key'), config('oauth', 'consumer_secret'), User::cGet('ort'), User::cGet('orts'));
        // Request access tokens from twitter
        $tok = $to->getAccessToken();
        // Save the access tokens
        User::cSet('oat', $tok['oauth_token']);
        User::cSet('oats', $tok['oauth_token_secret']);
        // Create TwitterOAuth with app key/secret and user access key/secret
        $to = new TwitterOAuth(config('oauth', 'consumer_key'), config('oauth', 'consumer_secret'), User::cGet('oat'), User::cGet('oats'));
        // Run request on twitter API as user to get their user details
        $user = json_decode($to->OAuthRequest('https://twitter.com/account/verify_credentials.json', array(), 'GET'), true);
        // Store the user ID in the cookie
        User::cSet('id', $user['id']);
        // Now save the user in the DB
        User::Update($user, true);
        // Tell me about it
        //@mail('*****@*****.**', 'TwitApps signin: '.$user['screen_name'], print_r($user, true));
        // Take them to the account page
        Redirect('/account/');
    } else {
        $to = new TwitterOAuth(config('oauth', 'consumer_key'), config('oauth', 'consumer_secret'));
        $tok = $to->getRequestToken();
        User::cSet('ort', $tok['oauth_token']);
        User::cSet('orts', $tok['oauth_token_secret']);
        Redirect($to->getAuthorizeURL($tok['oauth_token']));
    }
}
User::cReset();
Layout('Sign In', 'account');
TPL('account/signin');
コード例 #12
0
ファイル: index.php プロジェクト: ntulip/TwitApps
<?php

require dirname(__FILE__) . '/../../fx.php';
Layout('Follows', 'follows');
TPL('follows/index');
コード例 #13
0
ファイル: install.php プロジェクト: ntulip/TwitApps
<?php

require dirname(__FILE__) . '/../../../fx.php';
// Are we logged in?
if (strlen(User::cGet('id')) == 0 or strlen(User::cGet('oat')) == 0 or strlen(User::cGet('oats')) == 0) {
    Redirect('/account/signin');
}
$data = array('user' => User::Get());
$follows = array('status' => 'active', 'email' => !empty($_POST['email']) ? trim($_POST['email']) : '', 'frequency' => 'daily', 'hour' => date('H'), 'when' => '', 'post_url' => '', 'post_format' => '');
$result = User::InstallService('follows', $data['user'], $follows);
if ($result === true) {
    Redirect('/account/follows/');
}
$data['message'] = 'Installation failed; ' . $result;
Layout('Follows', 'account');
TPL('account/follows/install', $data);
コード例 #14
0
ファイル: index.php プロジェクト: ntulip/TwitApps
<?php

require dirname(__FILE__) . '/../../fx.php';
// Are we logged in?
if (strlen(User::cGet('id')) == 0 or strlen(User::cGet('oat')) == 0 or strlen(User::cGet('oats')) == 0) {
    Redirect('/account/signin');
}
$data = array();
$data['user'] = User::Get();
$data['services'] = User::GetServices($data['user']);
Layout('Your Account', 'account');
TPL('account/index', $data);
コード例 #15
0
ファイル: donations.php プロジェクト: ntulip/TwitApps
<?php

require dirname(__FILE__) . '/../fx.php';
Layout('Donations', 'donations');
TPL('donations');
コード例 #16
0
ファイル: install.php プロジェクト: ntulip/TwitApps
<?php

require dirname(__FILE__) . '/../../../fx.php';
// Are we logged in?
if (strlen(User::cGet('id')) == 0 or strlen(User::cGet('oat')) == 0 or strlen(User::cGet('oats')) == 0) {
    Redirect('/account/signin');
}
$data = array('user' => User::Get());
$replies = array('status' => 'active', 'email' => !empty($_POST['email']) ? trim($_POST['email']) : '', 'min_interval' => 60, 'max_queued' => 25, 'replies_only' => 0, 'ignore_self' => 0);
$result = User::InstallService('replies', $data['user'], $replies);
if ($result === true) {
    Redirect('/account/replies/');
}
$data['message'] = 'Installation failed; ' . $result;
Layout('Replies', 'account');
TPL('account/replies/install', $data);