示例#1
0
文件: Stream.php 项目: jgswift/qio
 /**
  * Alias for setEncoding
  * Additionally calls stream_encoding
  * @param mixed $encoding
  */
 public function setEncoding($encoding)
 {
     parent::setEncoding($encoding);
     if ($this->isOpen()) {
         stream_encoding($this->pointer, (string) $this->encoding);
     }
 }
示例#2
0
function cs_update_rss($mod, $action, $name, $desc, $array, $abcode = 0)
{
    global $cs_main;
    $cs_main['rss'] = 1;
    $abcode = is_array($abcode) ? $abcode : array(0 => 1, 1 => 0, 2 => 0, 3 => 0, 4 => 0);
    $target = 'uploads/rss/';
    $name_sec = htmlspecialchars($name, ENT_NOQUOTES, $cs_main['charset']);
    $desc_sec = htmlspecialchars($desc, ENT_NOQUOTES, $cs_main['charset']);
    if (is_writeable($target)) {
        include_once 'system/output/rss_20.php';
        $content = cs_rss_mode(1);
        $content .= cs_rss_channel(1, $mod, $name_sec, $cs_main['php_self']['website'], $desc_sec);
        if (!empty($array)) {
            foreach ($array as $item) {
                if (!empty($item['id']) and !empty($item['title']) and !empty($item['text'])) {
                    $title = htmlspecialchars($item['title'], ENT_NOQUOTES, $cs_main['charset']);
                    $link = $cs_main['php_self']['website'] . cs_url($mod, $action, 'id=' . $item['id'], 'index');
                    $text = empty($item['readmore']) ? $item['text'] : $item['readmore'];
                    $text = cs_secure($text, $abcode[0], $abcode[1], $abcode[2], $abcode[3], $abcode[4]);
                    $text = '<![CDATA[ ' . $text . ' ]]>';
                    if (!empty($abcode[3])) {
                        # use full uri if needed in html content
                        $url_pre = $cs_main['php_self']['website'] . $cs_main['php_self']['dirname'];
                        $pattern = "=(background|href|src)\\=\"(?!http|\\/)(.*?)\"=i";
                        $text = preg_replace($pattern, "\\1=\"" . $url_pre . "\\2\"", $text);
                    }
                    $date = empty($item['time']) ? 0 : date('D, d M Y H:i:s', $item['time']) . ' +0000';
                    # author is presented as 'email (nick)'
                    $author = (empty($item['nick']) or empty($item['author'])) ? '' : $item['author'] . ' (' . cs_secure($item['nick']) . ')';
                    $category = empty($item['cat']) ? '' : htmlspecialchars($item['cat'], ENT_NOQUOTES, $cs_main['charset']);
                    $content .= cs_rss_item($title, $link, $text, $date, $author, $category);
                }
            }
        }
        $content .= cs_rss_channel(0);
        $content .= cs_rss_mode(0);
        $save_file = fopen($target . $mod . '.xml', 'w');
        # set stream encoding if possible to avoid converting issues
        if (function_exists('stream_encoding')) {
            stream_encoding($save_file, $cs_main['charset']);
        }
        fwrite($save_file, $content);
        fclose($save_file);
        @chmod($target . $mod . '.xml', 0755);
    } else {
        cs_error($target, 'cs_update_rss - Unable to write into directory');
    }
    $cs_main['rss'] = 0;
}
示例#3
0
function cs_cache_save($name, $content, $ttl = 0)
{
    $token = empty($ttl) ? $name : 'ttl_' . $name;
    cs_cache_delete($token);
    global $cs_main;
    if (is_bool($content)) {
        cs_error($name, 'cs_cache_save - It is not allowed to just store a boolean');
    } elseif (is_writeable('uploads/cache/')) {
        $store = serialize($content);
        $cache_file = 'uploads/cache/' . $token . '.tmp';
        $save_cache = fopen($cache_file, 'a');
        # set stream encoding if possible to avoid converting issues
        if (function_exists('stream_encoding')) {
            stream_encoding($save_cache, $cs_main['charset']);
        }
        fwrite($save_cache, $store);
        fclose($save_cache);
        chmod($cache_file, 0755);
    } elseif ($cs_main['mod'] != 'install') {
        cs_error('uploads/cache/' . $token . '.tmp', 'cs_cache_save - Unable to write cache file');
    }
    return $content;
}
示例#4
0
 /**
  * Sets the character set for stream encoding
  *
  * Note: This function only exists in PHP 6. For PHP < 6, this method will return void.
  *
  * @link http://www.php.net/manual/en/function.stream-encoding.php stream_encoding()
  * @param string $charset
  * @return mixed Returns `null` if `stream_encoding()` function does not exist, boolean
  *         result of `stream_encoding()` otherwise.
  */
 public function encoding($charset)
 {
     if (!function_exists('stream_encoding')) {
         return false;
     }
     return is_resource($this->_resource) ? stream_encoding($this->_resource, $charset) : false;
 }
示例#5
0
    $save['max_height'] = (int) $_POST['max_height'];
    $save['max_size'] = (int) $_POST['max_size'];
    $save['max_navlist'] = (int) $_POST['max_navlist'];
    $save['max_navlist2'] = (int) $_POST['max_navlist2'];
    $save['max_navnext'] = (int) $_POST['max_navnext'];
    require_once 'mods/clansphere/func_options.php';
    cs_optionsave('wars', $save);
    $lang = cs_substr($account['users_lang'], 0, 2);
    if (!file_exists('uploads/wars/news_' . $lang . '.txt')) {
        $lang = 'de';
    }
    $text = $_POST['news_text'];
    $fp = fopen('uploads/wars/news_' . $lang . '.txt', 'w');
    # set stream encoding if possible to avoid converting issues
    if (function_exists('stream_encoding')) {
        stream_encoding($fp, $cs_main['charset']);
    }
    fwrite($fp, $text);
    fclose($fp);
    cs_redirect($cs_lang['success'], 'options', 'roots');
} else {
    $data = array();
    $data['head']['message'] = cs_getmsg();
    $data['op'] = cs_sql_option(__FILE__, 'wars');
    $pholders = array();
    $pholders['{SQUADNAME}'] = $cs_lang['op_squadname'];
    $pholders['{SQUADURL}'] = $cs_lang['op_squadurl'];
    $pholders['{OPPONENTNAME}'] = $cs_lang['op_opponentname'];
    $pholders['{OPPONENTURL}'] = $cs_lang['op_opponenturl'];
    $pholders['{SCORE_1}'] = $cs_lang['op_score1'];
    $pholders['{SCORE_2}'] = $cs_lang['op_score2'];
示例#6
0
 $setup_php .= "\$cs_db['type'] = '" . $cs_db['type'] . "';\n";
 $setup_php .= "\$cs_db['subtype'] = '" . $cs_db['subtype'] . "';\n";
 $setup_php .= "\$cs_db['place'] = '" . $cs_db['place'] . "';\n";
 $setup_php .= "\$cs_db['user'] = '******'user'] . "';\n";
 $setup_php .= "\$cs_db['pwd'] = '" . $cs_db['pwd'] . "';\n";
 $setup_php .= "\$cs_db['name'] = '" . $cs_db['name'] . "';\n";
 $setup_php .= "\$cs_db['prefix'] = '" . $cs_db['prefix'] . "';\n\n";
 $setup_php .= "\$cs_logs['save_actions'] = " . $log['save_actions'] . ";\n";
 $setup_php .= "\$cs_logs['save_errors'] = " . $log['save_errors'] . ";\n\n";
 $setup_php .= "\$cs_main['charset'] = '" . $cs_main['charset'] . "';";
 if (isset($_POST['create'])) {
     $flerr = 0;
     $create_setup = fopen('setup.php', 'w') or $flerr++;
     # set stream encoding if possible to avoid converting issues
     if (function_exists('stream_encoding')) {
         stream_encoding($create_setup, $cs_main['charset']);
     }
     fwrite($create_setup, $setup_php) or $flerr++;
     fclose($create_setup) or $flerr++;
     # check again to skip form page and prohibite errors
     $setup_exists = file_exists('setup.php') ? 1 : 0;
     if (empty($setup_exists)) {
         $flerr++;
     }
 }
 if (!empty($flerr)) {
     $error++;
     $errormsg = $cs_lang['file_err'];
     $cs_db['pwd'] = '';
     # Don't show password, if file creation was denied
 }
示例#7
0
function cs_log($target, $content)
{
    global $cs_logs, $cs_main;
    $full_path = $cs_logs['dir'] . '/' . $target;
    if (is_writeable($full_path . '/')) {
        $log = "-------- \n" . date('H:i:s') . "\n" . $content;
        $log_file = $full_path . '/' . date('Y-m-d') . '.log';
        $save_error = fopen($log_file, 'a');
        # set stream encoding if possible to avoid converting issues
        if (function_exists('stream_encoding')) {
            stream_encoding($save_error, $cs_main['charset']);
        }
        fwrite($save_error, $log);
        fclose($save_error);
        chmod($log_file, 0755);
    } else {
        $msg = 'cs_log - Unable to write into directory -> ' . $full_path;
        $cs_logs['errors'] .= $msg . "\n";
    }
}
示例#8
0
    } elseif (!($file = fopen($cs_main['def_path'] . '/' . $dir, 'r'))) {
        cs_redirect($cs_lang['file_not_opened'], 'explorer', 'roots');
    } else {
        $content = fread($file, filesize($cs_main['def_path'] . '/' . $dir));
        fclose($file);
        $ending = strtolower(substr(strrchr($dir, '.'), 1));
        if ($ending == 'php') {
            $data['if']['phpfile'] = true;
            include_once 'mods/explorer/abcode.php';
            $data['abcode']['tools'] = cs_abcode_tools('data_content');
            $data['abcode']['html1'] = cs_abcode_toolshtml('data_content');
            $data['abcode']['sql'] = cs_abcode_sql('data_content');
            $data['abcode']['html2'] = cs_abcode_toolshtml2('data_content');
        } else {
            $data['if']['phpfile'] = false;
        }
        $data['var']['content'] = cs_secure($content);
        $data['var']['source'] = $dir;
        $data['icn']['unknown'] = cs_html_img('symbols/files/filetypes/unknown.gif', 16, 16);
        echo cs_subtemplate(__FILE__, $data, 'explorer', 'edit');
    }
} else {
    $data = fopen($cs_main['def_path'] . '/' . $dir, 'w');
    # set stream encoding if possible to avoid converting issues
    if (function_exists('stream_encoding')) {
        stream_encoding($data, $cs_main['charset']);
    }
    $message = fwrite($data, $_POST['data_content']) ? $cs_lang['changes_done'] : $cs_lang['error_edit'];
    fclose($data);
    cs_redirect($message, 'explorer', 'roots', 'dir=' . $red_lsd);
}