<commit_before><?php
namespace Pixmicat\FileIo;

/**
 * FileIO Satellite 衛星計畫後端
 *
 * 搭配 satellite.php/pl 利用遠端空間管理圖檔
 *
 * @package PMCLibrary
 * @version $Id$
 * @date $Date$
 * @deprecated
 */
class FileIOsatellite extends AbstractIfsFileIO
{
    private $userAgent;
    private $parameter;
    private $thumbLocalPath;

    /**
     * 測試連線並且初始化遠端衛星主機
     */
    public function init()
    {
        if (!($fp = \fsockopen($this->parameter[0]['host'], 80))) {
            return false;
        }

        $argument = 'mode=init&key=' . $this->parameter[2];
        $out = 'POST ' . $this->parameter[0]['path'] . " HTTP/1.1\r\n";
        $out .= 'Host: ' . $this->parameter[0]['host'] . "\r\n";
        $out .= 'User-Agent: ' . $this->userAgent . "\r\n";
        $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
        $out .= 'Content-Length: ' . \strlen($argument) . "\r\n\r\n";
        $out .= $argument;
        \fwrite($fp, $out);
        $result = \fgets($fp, 128); // 取一次足以取到檔頭
        \fclose($fp);

        return (\strpos($result, '202 Accepted') !== false); // 檢查狀態值偵測是否傳輸成功
    }

    /**
     * 傳送抓取要求到遠端衛星主機上面
     */
    private function transloadSatellite($imgname)
    {
        if (!($fp = \fsockopen($this->parameter[0]['host'], 80))) {
            return false;
        $argument = 'mode=transload&key=' . $this->parameter[2] . '&imgurl=http:' . $this->getImageLocalURL($imgname) . '&imgname=' . $imgname;
        $out = 'POST ' . $this->parameter[0]['path'] . " HTTP/1.1\r\n";
        $out .= 'Host: ' . $this->parameter[0]['host'] . "\r\n";
        $out .= 'User-Agent: ' . $this->userAgent . "\r\n";
        $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
        $out .= 'Content-Length: ' . \strlen($argument) . "\r\n\r\n";
        $out .= $argument;
        \fwrite($fp, $out);
        $result = \fgets($fp, 128); // 取一次足以取到檔頭
        \fclose($fp);

        return (\strpos($result, '202 Accepted') !== false); // 檢查狀態值偵測是否傳輸成功
    }

    /**
     * 直接傳送檔案到遠端衛星主機上面
     */
    private function uploadSatellite($imgname, $imgpath)
    {
        \srand((double) \microtime() * 1000000);
        $boundary = '---------------------' . \substr(\md5(\rand(0, 32000)), 0, 10); // 生成分隔線

        $argument = ''; // 資料暫存
        // 一般欄位資料轉換
        $formField = array('mode' => 'upload', 'key' => $this->parameter[2], 'imgname' => $imgname);
        foreach ($formField as $ikey => $ival) {
            $argument .= "--$boundary\r\n";
            $argument .= "Content-Disposition: form-data; name=\"" . $ikey . "\"\r\n\r\n";
            $argument .= $ival . "\r\n";
            $argument .= "--$boundary\r\n";<commit_msg>Fixed a merge error that missing a bracket.<commit_after><?php
namespace Pixmicat\FileIo;

/**
 * FileIO Satellite 衛星計畫後端
 *
 * 搭配 satellite.php/pl 利用遠端空間管理圖檔
 *
 * @package PMCLibrary
 * @version $Id$
 * @date $Date$
 * @deprecated
 */
class FileIOsatellite extends AbstractIfsFileIO
{
    private $userAgent;
    private $parameter;
    private $thumbLocalPath;

    /**
     * 測試連線並且初始化遠端衛星主機
     */
    public function init()
    {
        if (!($fp = \fsockopen($this->parameter[0]['host'], 80))) {
            return false;
        }

        $argument = 'mode=init&key=' . $this->parameter[2];
        $out = 'POST ' . $this->parameter[0]['path'] . " HTTP/1.1\r\n";
        $out .= 'Host: ' . $this->parameter[0]['host'] . "\r\n";
        $out .= 'User-Agent: ' . $this->userAgent . "\r\n";
        $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
        $out .= 'Content-Length: ' . \strlen($argument) . "\r\n\r\n";
        $out .= $argument;
        \fwrite($fp, $out);
        $result = \fgets($fp, 128); // 取一次足以取到檔頭
        \fclose($fp);

        return (\strpos($result, '202 Accepted') !== false); // 檢查狀態值偵測是否傳輸成功
    }

    /**
     * 傳送抓取要求到遠端衛星主機上面
     */
    private function transloadSatellite($imgname)
    {
        if (!($fp = \fsockopen($this->parameter[0]['host'], 80))) {
            return false;
        }
        $argument = 'mode=transload&key=' . $this->parameter[2] . '&imgurl=http:' . $this->getImageLocalURL($imgname) . '&imgname=' . $imgname;
        $out = 'POST ' . $this->parameter[0]['path'] . " HTTP/1.1\r\n";
        $out .= 'Host: ' . $this->parameter[0]['host'] . "\r\n";
        $out .= 'User-Agent: ' . $this->userAgent . "\r\n";
        $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
        $out .= 'Content-Length: ' . \strlen($argument) . "\r\n\r\n";
        $out .= $argument;
        \fwrite($fp, $out);
        $result = \fgets($fp, 128); // 取一次足以取到檔頭
        \fclose($fp);

        return (\strpos($result, '202 Accepted') !== false); // 檢查狀態值偵測是否傳輸成功
    }

    /**
     * 直接傳送檔案到遠端衛星主機上面
     */
    private function uploadSatellite($imgname, $imgpath)
    {
        \srand((double) \microtime() * 1000000);
        $boundary = '---------------------' . \substr(\md5(\rand(0, 32000)), 0, 10); // 生成分隔線

        $argument = ''; // 資料暫存
        // 一般欄位資料轉換
        $formField = array('mode' => 'upload', 'key' => $this->parameter[2], 'imgname' => $imgname);
        foreach ($formField as $ikey => $ival) {
            $argument .= "--$boundary\r\n";
            $argument .= "Content-Disposition: form-data; name=\"" . $ikey . "\"\r\n\r\n";
            $argument .= $ival . "\r\n";
            $argument .= "--$boundary\r\n";
{'fraction_non_alphanumeric': 0.2187964338781575, 'fraction_numerical': 0.017087667161961365, 'mean_word_length': 2.066628701594533, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5692714', 'n_tokens_mistral': 2136, 'n_tokens_neox': 2162, 'n_words': 338}