示例#1
0
 private function db_connect()
 {
     $this->db_link = mysql_connect($this->db_host, $this->db_user, $this->db_password);
     $db_test2 = mysql_select_db($this->db_table, $this->db_link);
     if (!$this->db_link or !$db_test2) {
         mainFuncs::print_html('mysql_error');
         exit;
     }
 }
示例#2
0
} else {
    $page_select = "tweet_settings";
    $header_info['on_load'] = "ajax_tweet_settings_tab('tab1');";
    $header_info['js_scripts'] = '<script type="text/javascript" src="inc/scripts/anytime.c.js"></script>' . "\n" . '<link rel="stylesheet" type="text/css" href="inc/scripts/anytime.c.css" />' . "\n";
    //Get data here
    $q1a = $db->get_user_data($_GET['id']);
    if ($_POST['a'] == 'csv_upload') {
        //Bulk CSV upload
        $header_info['on_load'] = "ajax_tweet_settings_tab('tab4');";
        if ($_FILES['csv_file']['name']) {
            //Not ideal, but saves reminding user to chmod a directory
            $handle = @fopen($_FILES['csv_file']['tmp_name'], 'r');
            $valid_rows = 0;
            while (($data = @fgetcsv($handle, 1000, ",")) !== FALSE) {
                if (count($data) == 2) {
                    $valid_rows++;
                    $db->query("INSERT INTO " . DB_PREFIX . "scheduled_tweets (owner_id, tweet_content, time_to_post)\r\n    \t\t  VALUES ('" . $db->prep($q1a['id']) . "','" . $db->prep($data[1]) . "','" . $db->prep($data[0]) . "')");
                }
            }
            @fclose($handle);
            //Check valid rows
            if ($valid_rows == 0) {
                $pass_msg = 19;
            } else {
                $pass_msg = 20;
            }
        }
    }
}
mainFuncs::print_html($page_select);
include 'inc/include_bottom.php';
示例#3
0
                    $bad_flag = false;
                    foreach ($_REQUEST['follow_ids'] as $this_id) {
                        $connection->post('friendships/create', array('user_id' => $this_id));
                        if ($connection->http_code == 200) {
                            $good_flag = true;
                        } else {
                            $bad_flag = true;
                        }
                    }
                    //Show appropriate error message
                    if ($good_flag and !$bad_flag) {
                        $response_msg = mainFuncs::push_response(26);
                    } elseif ($good_flag and $bad_flag) {
                        $response_msg = mainFuncs::push_response(27);
                    } elseif (!$good_flag and $bad_flag) {
                        $response_msg = mainFuncs::push_response(28);
                    }
                }
                break;
                //End of tab switch
        }
        //End of data update POST
    }
    //Get account details
    if (!$q1a) {
        $q1a = $db->get_user_data($_REQUEST['twitter_id']);
    }
    include '../content/' . TWANDO_LANG . '/ajax.follow_settings_inc.php';
    //End of is logged in
}
include '../include_bottom.php';
示例#4
0
/*
Twando.com Free PHP Twitter Application
http://www.twando.com/
*/
if (!$content_id) {
    exit;
}
global $error_array, $return_url;
?>
<h2>Login</h2>
<?php 
if ($error_array['message'] != "") {
    echo $error_array['message'] . '<br />';
} else {
    echo mainFuncs::push_response(6) . '<br />';
}
if (!empty($_POST['username_login'])) {
    $username = $_POST['username_login'];
} else {
    $username = "";
}
if (!empty($_POST['password_login'])) {
    $password = $_POST['password_login'];
} else {
    $password = "";
}
?>
<form method="post" action="<?php 
echo BASE_LINK_URL;
?>
</form>
<input type="submit" value="Schedule Tweet" class="submit_button_style" onclick="ajax_tweet_settings_update('tab3','scheduletweet_form');" />
<br /><br />
*Tweets are posted based on your servers PHP time, which might not be your local time. The current PHP date and time is <?php 
            echo date(TIMESTAMP_FORMAT);
            ?>
.
<br />
<?php 
            break;
        case 'tab4':
            ?>
 <h2>Bulk CSV Tweet Upload</h2>
<?php 
            if ($_REQUEST['pass_msg']) {
                $response_msg = mainFuncs::push_response($_REQUEST['pass_msg']) . '<br />';
                ?>
 <script type="text/javascript">$("#pass_msg").val('')</script>
<?php 
            }
            ?>
 <?php 
            echo $response_msg;
            ?>
 <form method="post" action="tweet_settings.php?id=<?php 
            echo $q1a['id'];
            ?>
" name="bulkcsvupload" id="bulkcsvupload" enctype="multipart/form-data">
 You can upload a CSV of as many tweets as you like below. The CSV should have 2 columns (no headers are required). Column one should have the post date and time in mySQL format (YYYY-MM-DD HH:MM). Column two
 should contain what you want to tweet (<a href="inc/csv/example.csv" target="_blank">example</a>).
 <br /><br />
示例#6
0
/*
Twando.com Free PHP Twitter Application
http://www.twando.com/
*/
if (!$content_id) {
    exit;
}
global $q1a, $response_msg;
?>
<h2>Follow / Unfollow Settings for <?php 
echo htmlentities($q1a['screen_name']);
?>
</h2>
<?php 
if ($q1a['id'] == "") {
    echo mainFuncs::push_response(7);
} else {
    ?>
<div class="tab_row">
<input type="hidden" name="twitter_id" id="twitter_id" value="<?php 
    echo $q1a['id'];
    ?>
" />
<div class="tab_main" id="tab1">
 <a href="javascript:ajax_follow_settings_tab('tab1');">Auto Follow Settings</a>
</div><div class="tab_main" id="tab2">
 <a href="javascript:ajax_follow_settings_tab('tab2');">Unfollow Exclusions</a>
</div><div class="tab_main" id="tab3">
 <a href="javascript:ajax_follow_settings_tab('tab3');">Follow Exclusions</a>
</div><div class="tab_main" id="tab4">
 <a href="javascript:ajax_follow_settings_tab('tab4');">Auto DM Message</a>
" />
 </div>
<?php 
                    }
                    ?>
<br style="clear: both;" />
<input type="hidden" name="search_type" id="search_type" value="<?php 
                    echo (int) $_REQUEST['search_type'];
                    ?>
" />
<input type="hidden" name="search_term" id="search_term" value="<?php 
                    echo strip_tags($_REQUEST['search_term']);
                    ?>
" />
<input type="hidden" name="search_lang" id="search_lang" value="<?php 
                    echo strip_tags($_REQUEST['search_lang']);
                    ?>
" />
<input type="hidden" name="a" value="stf2update" />
</form>
<input type="submit" value="Follow Selected Users" class="submit_button_style" onclick="ajax_follow_settings_update('tab5','stf2_form');" />
<?php 
                } else {
                    echo mainFuncs::push_response(25);
                }
            }
            break;
            //End of switch
    }
    //End of if $_REQUEST['tab_id']
}
                $bot_enabled = intval($_REQUEST['bot_status']);
                $follow_rate = intval($_REQUEST['follow_rate']);
                $follow_rule = $db->prep($_REQUEST['follow_rule']);
                $tweeting_rate = intval($_REQUEST['tweeting_rate']);
                $tweet_bot_enabled = intval($_REQUEST['tweet_bot_status']);
                $tweet_query = $db->prep($_REQUEST['tweet_query']);
                $tweet_template = $db->prep($_REQUEST['tweet_template']);
                $tweet_generation_rate = intval($_REQUEST['tweet_generation_rate']);
                $current_query = $db->fetch_array($db->query("SELECT tweet_query FROM " . DB_PREFIX . "users_config\r\n                         WHERE user_id='{$db->prep($_REQUEST['twitter_id'])}';"));
                if (!empty($current_query) && strcasecmp($current_query['tweet_query'], $tweet_query) != 0) {
                    $db->query("UPDATE " . DB_PREFIX . "users_config\r\n                       SET tweet_generation_offset=0\r\n                     WHERE user_id='{$db->prep($_REQUEST['twitter_id'])}';");
                }
                try {
                    $db->query("\r\n            INSERT INTO " . DB_PREFIX . "users_config\r\n                (user_id, follow_bot_status, follow_rate, follow_rule, tweet_bot_status,\r\n                tweet_template, tweet_query, tweeting_rate, tweet_generation_rate)\r\n            VALUES ('{$db->prep($_REQUEST['twitter_id'])}', {$bot_enabled}, {$follow_rate}, '{$follow_rule}',\r\n                   {$tweet_bot_enabled}, '{$tweet_template}', '{$tweet_query}', {$tweeting_rate}, {$tweet_generation_rate})\r\n                   ON DUPLICATE KEY UPDATE\r\n                   follow_bot_status={$bot_enabled},\r\n                   follow_rate={$follow_rate},\r\n                   follow_rule='{$follow_rule}',\r\n                   tweet_bot_status={$tweet_bot_enabled},\r\n                   tweet_template='{$tweet_template}',\r\n                   tweet_query='{$tweet_query}',\r\n                   tweeting_rate={$tweeting_rate},\r\n                   tweet_generation_rate={$tweet_generation_rate};\r\n        ");
                    $response_msg = mainFuncs::push_response(35);
                } catch (Exception $ex) {
                    $response_msg = mainFuncs::push_response(34);
                }
                break;
                //End of tab switch
        }
        //End of data update POST
    }
    //Get account details
    if (!$q1a) {
        $q1a = $db->get_user_data($_REQUEST['twitter_id']);
    }
    include '../content/' . TWANDO_LANG . '/ajax.follow_settings_inc.php';
    //End of is logged in
}
include '../include_bottom.php';
示例#9
0
<?php

/*
Twando.com Free PHP Twitter Application
http://www.twando.com/
*/
if (!$content_id) {
    exit;
}
global $db, $ap_creds;
if ((int) $_GET['msg'] > 0) {
    $response_msg = mainFuncs::push_response((int) $_GET['msg']);
}
if (!$ap_creds['consumer_key'] or !$ap_creds['consumer_secret']) {
    ?>
<h2>Register Your Application</h2>
Before you can start using Twando, you must first register your application with Twitter.
<ol>
 <li>First, <a href="install_tables.php">click here to install the MySQL tables</a> if you have not done so already.</li>
 <li>Next, visit <a href="https://dev.twitter.com/apps/new" target="_blank">https://dev.twitter.com/apps/new</a>;  you will need to sign in to your Twitter account to register an app.</li>
 <li>Enter the values as demonstrated in <a href="inc/images/reg_ap.jpg" target="_blank">this picture</a>; your application URL is <b><?php 
    echo BASE_LINK_URL;
    ?>
</b>; your callback URL is <b><?php 
    echo BASE_LINK_URL . 'callback.php';
    ?>
</b>.</li>
 <li>You will then be given a consumer key and consumer secret (<a href="inc/images/reg_ap2.jpg" target="_blank">example</a>). Enter these in the boxes below to complete the setup of your Twitter app.</li>
 <li>You must also make sure your application is set with <b>read/write access</b> on the settings page; <a href="inc/images/reg_ap3.jpg" target="_blank">click here to view</a>.</li>
</ol>
<form method="post" action="<?php 
示例#10
0
<?php

/*
Twando.com Free PHP Twitter Application
http://www.twando.com/
*/
include 'inc/include_top.php';
//Twitter can be slow
set_time_limit(0);
if (mainFuncs::is_logged_in() != true) {
    $return_url = "";
    //Don't want to try and redirect straight to this page
    mainFuncs::print_html('not_logged_in');
} else {
    $ap_creds = $db->get_ap_creds();
    //Connect to Twitter
    $connection = new TwitterOAuth($ap_creds['consumer_key'], $ap_creds['consumer_secret'], $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
    $access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
    $_SESSION['access_token'] = $access_token;
    //Remove request tokens
    unset($_SESSION['oauth_token']);
    unset($_SESSION['oauth_token_secret']);
    //Check response
    if ($connection->http_code == 200) {
        //All OK, store credentials in database for this user
        $access_token = $_SESSION['access_token'];
        $connection = new TwitterOAuth($ap_creds['consumer_key'], $ap_creds['consumer_secret'], $access_token['oauth_token'], $access_token['oauth_token_secret']);
        $content = $connection->get('account/verify_credentials');
        //Update DB
        $tw_user = array('id' => $content->id, 'oauth_token' => $access_token['oauth_token'], 'oauth_token_secret' => $access_token['oauth_token_secret'], 'profile_image_url' => $content->profile_image_url, 'screen_name' => $content->screen_name, 'followers_count' => $content->followers_count, 'friends_count' => $content->friends_count, 'log_data' => 1, 'last_updated' => date("Y-m-d H:i:s"));
        $db->store_authed_user($tw_user);
示例#11
0
            //Get users
            $uncached_users = array();
            $uncached_users = $cron->get_uncached_users(1);
            $user_total = sizeof($uncached_users);
            //Loop and build
            if ($req_total > 0 and $user_total > 0) {
                foreach ($uncached_users as $this_id) {
                    //Get user
                    $content = $connection->get('users/show', array('user_id' => $this_id));
                    //If not a 200 code (i.e. 404) delete row from table
                    if ($connection->http_code != 200) {
                        $db->query("DELETE FROM " . DB_PREFIX . "user_cache WHERE twitter_id='" . $db->prep($this_id) . "'");
                    }
                    $req_total--;
                    if ($req_total <= 0) {
                        break;
                    }
                }
                //Optimise table
                $db->query("OPTIMIZE TABLE " . DB_PREFIX . "user_cache");
            }
            //End of first pass check
        }
        //End of db loop
    }
    //Set cron status
    $cron->set_cron_state('follow', 0);
    echo mainFuncs::push_response(32);
    //End of run cron
}
include 'inc/include_bottom.php';