/setup.php
PHP | 146 lines | 139 code | 7 blank | 0 comment | 16 complexity | c772cd318a7e35e8e42ad597b01778ec MD5 | raw file
- <?php
- error_reporting(E_ALL ^ E_WARNING);
- $base_url = 'http://'.$_SERVER['HTTP_HOST'];
- if ($directory = trim(dirname($_SERVER['SCRIPT_NAME']), '/\,')){
- $base_url .= '/'.$directory;
- }
- define('BASE_URL', $base_url.'/');
- define('ABSPATH', dirname(__FILE__).'/');
- $configFile = file(ABSPATH . 'config-sample.php');
- $notice = '';
-
- if (!function_exists("curl_init")) {
- $notice = '<strong>???</strong>?????? cURL ????????????';
- } elseif (file_exists(ABSPATH.'config.php')) {
- $notice = '<strong>???</strong> config.php ???????????? config.php ????????????????????? config.php ?<a href="setup.php">??</a>?';
- } elseif (!file_exists(ABSPATH.'config-sample.php')) {
- $notice = '<strong>???</strong>????? config-sample.php ????????????????????';
- } elseif (!is_writable(ABSPATH)) {
- $notice = '<strong>???</strong>??????????????????? config.php ?';
- }
-
- if (isset($_GET['step'])) {
- $step = $_GET['step'];
- } else {
- $step = 0;
- }
-
- function rewritable() {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_URL, BASE_URL.'settings');
- curl_exec($ch);
- $response_info = curl_getinfo($ch);
-
- if ($response_info["http_code"] == "404") return false;
- return true;
- }
-
- function display_header($n) {
- header('Content-Type: text/html; charset=utf-8');
- ?>
- <!doctype html><meta charset=utf-8 /><title>???? - ???!</title><link rel="stylesheet" href="https://t.orzdream.com/images/setup.css" type="text/css" /><h1 id="logo"><img alt="???" src="https://t.orzdream.com/images/setup.jpg" /></h1><?php
- if ($n !== ''){
- echo '<div id="error">'.$n.'</div>';
- }
- }
- switch($step) {
- case 0:
- display_header($notice);
- ?><p><strong>??????????</strong><p /><a href="https://t.orzdream.com/">???</a>???????????? Twitter ??????? <a href="http://dabr.co.uk">Dabr</a> (By <a href="https://twitter.com/davidcarrington">@davidcarrington</a>) ?????????????? <a href="https://twitter.com/iChada">@iChada</a> <a href="https://twitter.com/17th">@17th</a> <a href="https://twitter.com/luosheng">@luosheng</a> <a href="https://twitter.com/lonelyswan">@LonelySwan</a> ???????????????????????? <a href="https://twitter.com/NetPuter">@NetPuter</a> ?<p />???????????????????????</p><ol><li>Twitter OAuth Consumer Key & Secret <a href="https://twitter.com/apps/new" title="????">#</a></li><li>Twitpic API Key <a href="http://dev.twitpic.com/apps/new" title="????">#</a></li><li>Twitter API Proxy <a href="http://code.google.com/p/twip/" title="????">#</a></li></ol><p><strong>??????????????????????????????????????????????????? <code>config-sample.php</code> ??????????????????????? <code>config.php</code> ?</strong></p><p>???????????<a href="http://orzdream.com/2009/10/netputweets-guide/" title="?????????">?????????</a>??????????????? <a href="https://twitter.com/NetPuter">@NetPuter</a> ????????? … …</p><?php
- if ($notice !== ''){
- echo '<p class="step"><a href="setup.php" class="button">??????</a></p>';
- }else{
- echo '<p class="step"><a href="setup.php?step=1" class="button">???????</a></p>';
- }
- break;
- case 1:
- display_header($notice);
- ?><form method="post" action="setup.php?step=2"><p>????????????????</p><table class="form-table"><tr><th scope="row"><label for="t_title">??</label></th><td><input name="t_title" id="t_title" type="text" value="???!" size="35" /></td><td>??<a href="https://t.orzdream.com/settings">?? - ???!</a>?</td></tr><tr><th scope="row"><label for="t_urf">??</label></th><td><input name="t_urf" id="t_urf" type="text" value="<?php echo BASE_URL;?>" size="35" /></td><td>??????? ???? / ??</td></tr><tr><th scope="row"><label for="t_ck">Cookie ??</label></th><td><input name="t_ck" id="t_ck" type="text" size="35" value="NetPutweets" /></td><td>????????????????????????</td></tr><tr><th scope="row"><label for="t_tck">Twitter OAuth Consumer Key <a href="https://twitter.com/apps/new" title="????">#</a></label></th><td><input name="t_tck" id="t_tck" type="text" size="35" value="awGBKfiSSqf1B2iKGsmJQ" /></td><td>??????</td></tr><tr><th scope="row"><label for="t_tcs">Twitter OAuth Consumer Secret <a href="https://twitter.com/apps/new" title="????">#</a></label></th><td><input name="t_tcs" id="t_tcs" type="text" size="35" value="hym4qJF1F6nyjISzRUCFBU4OQSIr5mrk7074vId3K8" /></td><td>??????</td></tr><tr><th scope="row"><label for="t_tak">Twitpic API Key <a href="http://dev.twitpic.com/apps/new" title="????">#</a></label></th><td><input name="t_tak" id="t_tak" type="text" value="95a105b0faadab9daa1a5739d4f80992" size="35" /></td><td>???????</td></tr><tr><th scope="row"><label for="t_ta">Twitter API <a href="http://code.google.com/p/twip/" title="????">#</a></label></th><td><input name="t_ta" id="t_ta" type="text" value="http://api.twitter.com/1/" size="35" /></td><td>????????? ?????</td></tr><tr><th scope="row"><label for="t_tsa">Twitter Search API</label></th><td><input name="t_tsa" id="t_tsa" type="text" value="http://search.twitter.com/" size="35" /></td><td>????????? ?????</td></tr><tr><th scope="row"><label for="t_rsl">?????</label></th><td><select name="t_rsl"><option value="1">??</option><option selected="selected" value="0">??</option></select></td><td>????????? ????? ???????????????? ????</td></tr><tr><th scope="row"><label for="t_ivt">????????</label></th><td><select name="t_ivt"><option value="1">??</option><option selected="selected" value="0">??</option></select></td><td>?????????</td></tr><tr><th scope="row"><label for="t_psw">?????</label></th><td><input name="t_psw" id="t_psw" type="text" value="twitter" size="20" /></td><td>??? <a href="invite.php">invite.php</a> ?</td></tr><tr><th scope="row"><label for="t_ssl">???? SSL ????</label></th><td><select name="t_ssl"><option value="1">??</option><option selected="selected" value="0">??</option></select></td><td>??????? ???????????</td></tr></table><?php
- if ($notice !== ''){
- echo '<p class="step"><a href="setup.php" class="button">????</a></p>';
- }else{
- echo '<p class="step"><input name="submit" type="submit" value="????" class="button" /></p>';
- }
- echo '</form>';
- break;
- case 2:
- if (!isset($_POST['submit'])) {
- header('location: index.php');
- } else {
- $t_title= (empty($t_title)) ? trim($_POST['t_title']) : '???!';
- $t_urf = (empty($t_urf)) ? trim($_POST['t_urf']) : BASE_URL;
- $t_ck = (empty($t_ck)) ? trim($_POST['t_ck']) : 'NetPutweets';
- $t_tck = (empty($t_tck)) ? trim($_POST['t_tck']) : 'awGBKfiSSqf1B2iKGsmJQ';
- $t_tcs = (empty($t_tcs)) ? trim($_POST['t_tcs']) : 'hym4qJF1F6nyjISzRUCFBU4OQSIr5mrk7074vId3K8';
- $t_tak = (empty($t_tak)) ? trim($_POST['t_tak']) : '95a105b0faadab9daa1a5739d4f80992';
- $t_ta = (empty($t_ta)) ? trim($_POST['t_ta']) : 'http://api.twitter.com/1/';
- $t_tsa = (empty($t_tsa)) ? trim($_POST['t_tsa']) : 'http://search.twitter.com/';
- $t_rsl = trim($_POST['t_rsl']);
- $t_ivt = trim($_POST['t_ivt']);
- $t_psw = (empty($t_psw)) ? trim($_POST['t_psw']) : 'twitter';
- $t_ssl = trim($_POST['t_ssl']);
-
- if (rewritable()) {
- $t_url = $t_urf;
- } else {
- $t_url = $t_urf.'index.php?q=';
- }
-
- if ($notice == '') {
- $handle = fopen(ABSPATH . 'config.php', 'w');
- foreach ($configFile as $line_num => $line) {
- switch (substr($line,11,5)) {
- case "RYPTI":
- fwrite($handle, str_replace('putyourinfohere', $t_ck, $line));
- break;
- case "TH_KE":
- fwrite($handle, str_replace('putyourinfohere', $t_tck, $line));
- break;
- case "TH_SE":
- fwrite($handle, str_replace('putyourinfohere', $t_tcs, $line));
- break;
- case "TPIC_":
- fwrite($handle, str_replace('putyourinfohere', $t_tak, $line));
- break;
- case "E_URL":
- fwrite($handle, str_replace('putyourinfohere', $t_url, $line));
- break;
- case "E_URF":
- fwrite($handle, str_replace('putyourinfohere', $t_urf, $line));
- break;
- case "_TITL":
- fwrite($handle, str_replace('putyourinfohere', $t_title, $line));
- break;
- case "_URL'":
- fwrite($handle, str_replace('putyourinfohere', $t_ta, $line));
- break;
- case "_URLS":
- fwrite($handle, str_replace('putyourinfohere', $t_tsa, $line));
- break;
- case "G_URL":
- fwrite($handle, str_replace('0', $t_rsl, $line));
- break;
- case "ITE',":
- fwrite($handle, str_replace('0', $t_ivt, $line));
- break;
- case "ITE_C":
- fwrite($handle, str_replace('putyourinfohere', $t_psw, $line));
- break;
- case "CE_SS":
- fwrite($handle, str_replace('0', $t_ssl, $line));
- break;
- default:
- fwrite($handle, $line);
- }
- }
- fclose($handle);
- chmod(ABSPATH.'config.php', 0666);
- chmod(ABSPATH.'invite.php', 0666);
- display_header($notice);
- ?><p>???????????????????? … …</p><p class="step"><a href="<?php echo BASE_URL.'" class="button">??????</a></p>';
- }
- }
- break;
- }
- ?>