function many_connections_test($category, $client_name, $num_connections, $rate, $total, $msg_per_call, $avg_size) { if ($num_connections < 1) { print "you can't run the test with {$num_connections} connections\n"; } if ($rate % $num_connections != 0 || $total % $num_connections != 0 || $total / $num_connections % $msg_per_call != 0) { print "Arguments don't divide evenly, so number of messages won't be accurate\n"; } $rate_per_conn = $rate / $num_connections; $send_interval = $msg_per_call / $rate_per_conn; // open all the connections. This bypasses the normal client library because // we want to open a lot of connections simultaneously, which is something // a real client would never need to do. // $server_ips = array('localhost'); $port = 1463; $socks = array(); $trans = array(); $prots = array(); $scribes = array(); $opened = array(); try { for ($i = 0; $i < $num_connections; ++$i) { $socks[$i] = new TSocketPool($server_ips, $port); $socks[$i]->setDebug(1); $socks[$i]->setSendTimeout(250); $socks[$i]->setRecvTimeout(250); $socks[$i]->setNumRetries(1); $socks[$i]->setRetryInterval(30); $socks[$i]->setRandomize(true); $socks[$i]->setMaxConsecutiveFailures(2); $socks[$i]->setAlwaysTryLast(false); $trans[$i] = new TFramedTransport($socks[$i], 1024, 1024); $prots[$i] = new TBinaryProtocol($trans[$i]); $scribes[$i] = new scribeClient($prots[$i]); $trans[$i]->open(); $opened[$i] = true; } } catch (Exception $x) { print "exception opening connection {$i}"; // Bummer too bad so sad return; } // Send the messages, a few from each connection every loop // $random = generate_random($avg_size * 2); $last_send_time = microtime(true); $i = 0; while ($i < $total) { $messages = array(); for ($conn = 0; $conn < $num_connections; ++$conn) { for ($j = 0; $j < $msg_per_call; ++$j) { $entry = new LogEntry(); $entry->category = $category; $entry->message = make_message($client_name, $avg_size, $i, $random); $messages[] = $entry; ++$i; } $result = $scribes[$conn]->Log($messages); if ($result != OK) { print "Warning: Log returned {$result} \n"; } $messages = array(); } $now = microtime(true); $wait = $last_send_time + $send_interval - $now; $last_send_time = $now; if ($wait > 0) { print "going to sleep {$wait} ms\n"; usleep($wait * 1000000); } else { print "backed up {$wait} ms\n"; } } // Close the connections // for ($i = 0; $i < $num_connections; ++$i) { if ($opened[$i]) { try { $trans[$i]->close(); } catch (Exception $x) { print "exception closing connection {$i}"; // Ignore close errors } } } }
<label for="add_request"></label><input type="text" style="display:none" name="add_request" id="add_request" value=<?php echo $row["user_name"]; ?> /></li> <tr><td><label for="add_friend"></label><input type="submit" name="add_friend" id="add_friend" value="Add Friend" /></li></td> </div> </form> <?php } ?> <?php if (isset($_POST["message_text"]) && isset($_POST["post_message"]) && !empty($_POST["message_text"])) { if (make_message($_row["user_name"], $_POST["message_text"])) { } else { echo "<div class=\"error\">Message Sending Failed.</div>"; } } ?> </div> <td><a class="user_link" href="user_timeline.php?user_req=<?php echo $row["user_name"]; ?> ">View Timeline</a></td></tr> <td><input type="button" id="new_message" value="Message" /></td></tr> </table> <form method="post" action="make_message.php"> <input type="text" style="display:none" name="user_request" value=<?php
return 0; } } //-------------------------------------------------------------------------- $MM = new Moon_Class(); $TT = new Twitter_Class(); $SunMoon = $MM->StoreSunMoon(); $Moon = $MM->StoreFullNewMoon(); if (date("H") <= 12) { $Answer = timecheck($SunMoon["sunrise_hm"]); } else { $Answer = timecheck($SunMoon["sunset_hm"]); } if (!$Answer) { exit; } $status = make_message(); //------------------------------------------------------------------------- $twitter = new tmhOauth(array("consumer_key" => $consumer_key, "consumer_secret" => $consumer_secret, "token" => $token, "secret" => $secret, "curl_ssl_verifypeer" => false)); $c = 0; $media = count($image); $result_media_id = $TT->upload_image($twitter, $image); // echo count($result_media_id); while (count($result_media_id) != $media && $c < 10) { $result_media_id = $TT->upload_image($twitter, $image); $c++; } //------------------------------------------------------------------------- $update_params = array('media_ids' => $result_media_id["sun_moon"] . "," . $result_media_id["moon"] . "," . $result_media_id["Tokyo_temp"] . "," . $result_media_id["Wallpaper"], 'status' => $status); $code = $twitter->request('POST', "https://api.twitter.com/1.1/statuses/update.json", $update_params); echo "[" . $code . "]\n" . $status;
<?php include "includes/sessions.php"; include "includes/db_connection.php"; include "functions/query_functions.php"; include "functions/common_functions.php"; ?> <?php if (!isset($_SESSION["username"]) || empty($_SESSION["username"])) { redirect_to('login.php'); } ?> <?php if (isset($_POST["message_text"]) && isset($_POST["post_message"]) && !empty($_POST["message_text"])) { if (make_message($_POST["user_request"], $_POST["message_text"])) { echo "<div class=\"success\">Message Sent Successfully.</div>"; } else { echo "<div class=\"error\">Message Sending Failed.</div>"; } }