/** * Easy Installation Handler * Function to save special purpose * @param string $purpose */ public function _savePurpose($purpose = '') { if ($purpose == 'mpd') { // Install MPD Plugin $this->installPlugin('http://shop.max2play.com/media/downloadable/beta/mpd.tar', true, 2, false); // Disable Squeezebox-Server, Audioplayer, Remove Autostart Audioplayer $this->removePlugins(array('Audioplayer', 'Squeezebox Server')); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'squeezelite', 0); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'shairport', 0); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'mpd', 1); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'ympd', 1); //Create Sambashare for /var/lib/mpd include_once APPLICATION_PATH . '/model/Samba.php'; $smb = new Samba(); $test1 = $smb->setName('Max2Play-Music'); $test2 = $smb->setOption('path', '/var/lib/mpd'); $test3 = $smb->setOption('comment', 'Max2Play Music MPD'); $test4 = $smb->setOption('writeable', 'yes'); $test5 = $smb->setOption('create mode', '777'); shell_exec("echo '" . $smb->getShareConf() . "' >> /opt/max2play/samba.conf"); $output = shell_exec('sudo /opt/max2play/setSambaPass.sh "max2play"'); shell_exec("sudo /etc/init.d/samba restart"); $this->view->message[] = _t('You can access your Music-Folder from other computers via network. Password is "max2play".'); $this->view->message[] = _t('Music Player can be installed / started on Music Player (MPD) tab.'); } if ($purpose == 'squeeze') { $this->enablePlugin('Audioplayer', 2); $this->enablePlugin('Squeezebox Server', 4); $this->enablePlugin('Jivelite', 6); $this->loadViewHeader(true); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'squeezelite', 1); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'mpd', 0); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'shairport', 0); $this->view->message[] = _t('Audioplayer Squeezelite is enabled and can be configured on Audioplayer-tab. Install a Squeezebox Server, if you do not already have one running.'); } if ($purpose == 'airplay') { $this->enablePlugin('Audioplayer', 2); $this->removePlugins(array('Squeezebox Server')); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'squeezelite', 0); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'shairport', 1); $this->saveConfigFileParameter('/opt/max2play/autostart.conf', 'mpd', 0); $this->view->message[] = _t('Airplay is now enabled by default.'); } $this->saveConfigFileParameter('/opt/max2play/options.conf', 'purpose', $purpose); }
/** * レスを書き込む * * @return boolean 書き込み成功なら true、失敗なら false */ function postIt($host, $bbs, $key, $post) { global $_conf, $post_result, $post_error2ch, $p2cookies, $popup, $rescount, $ttitle_en; global $bbs_cgi; $method = 'POST'; $bbs_cgi_url = 'http://' . $host . $bbs_cgi; $URL = parse_url($bbs_cgi_url); // URL分解 if (isset($URL['query'])) { // クエリー $URL['query'] = '?' . $URL['query']; } else { $URL['query'] = ''; } // プロキシ if ($_conf['proxy_use']) { $send_host = $_conf['proxy_host']; $send_port = $_conf['proxy_port']; $send_path = $bbs_cgi_url; } else { $send_host = $URL['host']; $send_port = isset($URL['port']) ? $URL['port'] : 80; $send_path = $URL['path'] . $URL['query']; } if (!$send_port) { $send_port = 80; } // デフォルトを80 $request = "{$method} {$send_path} HTTP/1.0\r\n"; $request .= "Host: {$URL['host']}\r\n"; $request .= "User-Agent: Monazilla/1.00 ({$_conf['p2ua']})\r\n"; $request .= "Referer: http://{$URL['host']}/\r\n"; // クッキー $cookies_to_send = ''; if ($p2cookies) { foreach ($p2cookies as $cname => $cvalue) { if ($cname != 'expires') { $cookies_to_send .= " {$cname}={$cvalue};"; } } } // be.2ch.net 認証クッキー if (P2Util::isHostBe2chNet($host) || !empty($_REQUEST['beres'])) { $cookies_to_send .= ' MDMD=' . $_conf['be_2ch_code'] . ';'; // be.2ch.netの認証コード(パスワードではない) $cookies_to_send .= ' DMDM=' . $_conf['be_2ch_mail'] . ';'; // be.2ch.netの登録メールアドレス } if (!$cookies_to_send) { $cookies_to_send = ' ;'; } $request .= 'Cookie:' . $cookies_to_send . "\r\n"; //$request .= 'Cookie: PON='.$SPID.'; NAME='.$FROM.'; MAIL='.$mail."\r\n"; $request .= "Connection: Close\r\n"; // {{{ POSTの時はヘッダを追加して末尾にURLエンコードしたデータを添付 if (strcasecmp($method, 'POST') == 0) { $post_enc = array(); while (list($name, $value) = each($post)) { // したらば or be.2ch.netなら、EUCに変換 if (P2Util::isHostJbbsShitaraba($host) || P2Util::isHostBe2chNet($host)) { $value = mb_convert_encoding($value, 'CP51932', 'CP932'); } $post_enc[] = $name . '=' . rawurlencode($value); } $postdata = implode("&", $post_enc); $request .= "Content-Type: application/x-www-form-urlencoded\r\n"; $request .= "Content-Length: " . strlen($postdata) . "\r\n"; $request .= "\r\n"; $request .= $postdata; } else { $request .= "\r\n"; } // }}} // WEBサーバへ接続 $fp = fsockopen($send_host, $send_port, $errno, $errstr, $_conf['http_conn_timeout']); if (!$fp) { $errstr = p2h($errstr); showPostMsg(false, "サーバ接続エラー: {$errstr} ({$errno})<br>p2 Error: 板サーバへの接続に失敗しました", false); return false; } stream_set_timeout($fp, $_conf['http_read_timeout'], 0); //echo '<h4>$request</h4><p>' . $request . "</p>"; //for debug fputs($fp, $request); $start_here = false; $post_seikou = false; while (!p2_stream_eof($fp, $timed_out)) { if ($start_here) { $wr = ''; while (!p2_stream_eof($fp, $timed_out)) { $wr .= fread($fp, 164000); } $response = $wr; break; } else { $l = fgets($fp, 164000); //echo $l .'<br>'; // for debug // クッキーキタ if (preg_match('/Set-Cookie: (.+?)\\r\\n/', $l, $matches)) { //echo '<p>' . $matches[0] . '</p>'; // $cgroups = explode(';', $matches[1]); if ($cgroups) { foreach ($cgroups as $v) { if (preg_match('/(.+)=(.*)/', $v, $m)) { $k = ltrim($m[1]); if ($k != 'path') { if (!$p2cookies) { $p2cookies = array(); } $p2cookies[$k] = $m[2]; } } } } if ($p2cookies) { $cookies_to_send = ''; foreach ($p2cookies as $cname => $cvalue) { if ($cname != 'expires') { $cookies_to_send .= " {$cname}={$cvalue};"; } } $newcookies = "Cookie:{$cookies_to_send}\r\n"; $request = preg_replace('/Cookie: .*?\\r\\n/', $newcookies, $request); } // 転送は書き込み成功と判断 } elseif (preg_match('/^Location: /', $l, $matches)) { $post_seikou = true; } if ($l == "\r\n") { $start_here = true; } } } fclose($fp); // be.2ch.net or JBBSしたらば 文字コード変換 EUC→SJIS if (P2Util::isHostBe2chNet($host) || P2Util::isHostJbbsShitaraba($host)) { $response = mb_convert_encoding($response, 'CP932', 'CP51932'); //<META http-equiv="Content-Type" content="text/html; charset=EUC-JP"> $response = preg_replace('{<head>(.*?)<META http-equiv="Content-Type" content="text/html; charset=EUC-JP">(.*)</head>}is', '<head><meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">$1$2</head>', $response); } $kakikonda_match = '{<title>.*(?:書きこみました|■ 書き込みました ■|書き込み終了 - SubAll BBS).*</title>}is'; $cookie_kakunin_match = '{<!-- 2ch_X:cookie -->|<title>■ 書き込み確認 ■</title>|>書き込み確認。<}'; if (preg_match('/<.+>/s', $response, $matches)) { $response = $matches[0]; } // カキコミ成功 if ($post_seikou || preg_match($kakikonda_match, $response)) { $reload = empty($_POST['from_read_new']); showPostMsg(true, '書きこみが終わりました。', $reload); // +Wiki sambaタイマー if ($_conf['wiki.samba_timer']) { require_once P2_LIB_DIR . '/wiki/Samba.php'; $samba = new Samba(); $samba->setWriteTime($host, $bbs); $samba->save(); } return true; //$response_ht = p2h($response); //echo "<pre>{$response_ht}</pre>"; // cookie確認(post再チャレンジ) } elseif (preg_match($cookie_kakunin_match, $response)) { showCookieConfirmation($host, $response); return false; // その他はレスポンスをそのまま表示 } else { echo preg_replace('@こちらでリロードしてください。<a href="\\.\\./[a-z]+/index\\.html"> GO! </a><br>@', '', $response); return false; } }
/** * Add a new Sambashare * If this Method is called with $share as a already existing share it is not really adding a new one but deleting another -> see removeSambashare * use testparm to check config * @param Samba $share * @return boolean */ public function addSambashare($share = false) { if (!$share) { $smb = new Samba(); $test1 = $smb->setName($_GET['name']); $test2 = $smb->setOption('path', $_GET['path']); $test3 = $smb->setOption('comment', $_GET['comment']); $test4 = $smb->setOption('writeable', $_GET['writeable']); $test5 = $smb->setOption('create mode', $_GET['create_mode']); } else { $smb = $share; $test1 = true; } if ($test1) { shell_exec("echo '" . $smb->getShareConf() . "' >> " . $this->_sambaconf); $this->getSambaConfig(); if (!$share) { $this->view->message[] = _("Sambashare successfully added"); $this->restartSamba(); } return true; } $this->view->message[] = _("Sambashare NOT added! Please refer to the description below!"); return false; }
$htm['kaiko_set_hidden_js'] = ' onclick="setHiddenValue(this);"'; $htm['table_begin'] = '<table border="0" cellpadding="0" cellspacing="0"><tr><td align="left" colspan="2">'; $htm['table_break1'] = '</td></tr><tr><td align="left">'; $htm['table_break2'] = '</td><td align="right">'; $htm['table_end'] = '</td></tr></table>'; $htm['name_label'] = '<label for="FROM">名前</label>:'; $htm['mail_label'] = '<label for="mail">E-mail</label>:'; $htm['name_extra_at'] = ' tabindex="1"'; $htm['mail_extra_at'] = ' tabindex="2"'; $htm['msg_extra_at'] = ' tabindex="3"'; $htm['submit_extra_at'] = ' tabindex="4"'; } // +Wiki:sambaタイマー if ($_conf['wiki.samba_timer']) { require_once P2_LIB_DIR . '/wiki/Samba.php'; $samba = new Samba(); $htm['samba'] .= $samba->createTimer($samba->getSamba($host, $bbs)); } // 下書き保存 $savedraft = ''; if (!$_conf['ktai'] && $_conf['expack.editor.savedraft'] != 0 || $_conf['iphone'] && $_conf['expack.editor.mobile.savedraft'] != 0) { $savedraft = <<<EOP <input id="post_draft_button" type="button" value="下書き保存" onclick="DraftKakiko.saveDraftForm(this.form)"> <span id="post_draft_msg" class="autosave-info"></span> EOP; } elseif ($_conf['ktai'] && $_conf['expack.editor.mobile.savedraft']) { $savedraft = <<<EOP <input type="submit" name="savedraft" value="下書保存"> EOP; } // 文字コード判定用文字列を先頭に仕込むことでmb_convert_variables()の自動判定を助ける