Revert Readme to C874275
[EroTweet.git] / timed_post.php
blob063b07e8f2c4958f45816037b74724a7ba60d231
1 <?php //When called, make a request to pull a tweet from an SQL table
3 $sql_ini = fopen("settings/sql.ini", "r");
4 $sql_data = array();
5 while(!feof($sql_ini)){
6 $line = fgets($sql_ini);
7 $key = substr($line, 0, strpos($line, ":"));
8 $value = trim(substr($line, strpos($line, ":")+1));
9 $sql_data[$key] = $value;
12 $connection = new mysqli($sql_data["connection"], $sql_data["user"], $sql_data["pass"], $sql_data["database"]);
13 if(!$connection){
14 echo "Error: Unable to connect to MySQL." . PHP_EOL;
15 echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
16 echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
17 exit;
19 echo "<hr/><pre>";
21 $retrieval_query = "SELECT * FROM TweetQueue ORDER BY PostNo ASC LIMIT 1";
23 $most_recent = $connection->query($retrieval_query);
24 print_r($most_recent);
25 echo "\n";
27 $data_arr = $most_recent->fetch_assoc();
29 print_r($data_arr);
31 $file_arr = explode(",", rawurldecode($data_arr["ImageLocation"]));
33 echo "Comm: " . $data_arr["Comment"] . " - ILoc: ";
34 print_r($file_arr);
36 ob_start();
37 require("tweet.php");
38 ob_end_clean();
39 makeTweet($data_arr["Comment"], $file_arr);
41 $delete_query = "DELETE FROM TweetQueue WHERE PostNo=" . $data_arr["PostNo"];
42 $delete_status = $connection->query($delete_query);
43 print_r($delete_status);
44 if($delete_status !== 1){
45 echo "Delete Err" . $delete_query->error;
49 echo "<hr/></pre>Found, Added and Deleted<br/>";