Beispiel #1
0
function SaveHTTPFile($fFileHTTPPath, $fFileSavePath, $fFileSaveName)
{
    //记录程序开始的时间
    $BeginTime = getmicrotime();
    //取得文件名
    $fFileSaveName = $fFileSavePath . "/" . $fFileSaveName;
    make_dir(dirname($fFileSaveName));
    //取得文件的内容
    ob_start();
    readfile($fFileHTTPPath);
    $img = ob_get_contents();
    ob_end_clean();
    //$size = strlen($img);
    //保存到本地
    $fp2 = @fopen($fFileSaveName, "a");
    fwrite($fp2, $img);
    fclose($fp2);
    /*加水印代码*/
    require_once ROOT_PATH . 'includes/cls_image.php';
    $ext = get_extension($fFileSaveName);
    $fFileSaveName = convert_GIF_to_JPG($fFileSaveName);
    if (CopyFiles($fFileSaveName)) {
        $image = new cls_image();
        $image->add_watermark($fFileSaveName, '', '../../../../' . $GLOBALS['waterMark']['watermark'], $GLOBALS['waterMark']['watermark_place'], $GLOBALS['waterMark']['watermark_alpha']);
    }
    if ($ext == 'gif' || $ext == '.gif') {
        back_JPG_to_GIF($fFileSaveName);
    }
    /*加水印代码--end*/
    //记录程序运行结束的时间
    $EndTime = getmicrotime();
    //返回运行时间
    return $EndTime - $BeginTime;
}
Beispiel #2
0
 function mb_template($temp_file = null, $options = null, $caller = null)
 {
     if ($options !== null) {
         foreach ($options as $k => $v) {
             if ($v !== null) {
                 $this->{$k} = $v;
             }
         }
     }
     $this->caller = $caller ? $caller : $this;
     if ($temp_file != null) {
         $this->temp_file = $temp_file;
     }
     if (substr($this->temp_dir, -1, 1) != '/' && substr($this->temp_dir, -1, 1) != '\\') {
         $this->temp_dir .= '/';
     }
     if (substr($this->compile_dir, -1, 1) != '/' && substr($this->compile_dir, -1, 1) != '\\') {
         $this->compile_dir .= '/';
     }
     $pos = strrpos($temp_file, "/");
     if (false !== $pos) {
         $dir_part = substr($temp_file, 0, $pos + 1);
         $this->temp_dir .= $dir_part;
         $this->compile_dir .= $dir_part;
         $this->temp_file = substr($temp_file, $pos + 1, strlen($temp_file));
     }
     if (!file_exists($this->temp_dir . $this->temp_file)) {
         $this->_raise_error('Template File "' . $this->temp_dir . $this->temp_file . '" doesn\'t exists.');
     }
     if (!make_dir($this->compile_dir)) {
         $this->_raise_error('Cont\'t create template compile dir "' . $this->compile_dir . '".');
     }
 }
function insert_page($cat_id, $title, $parent_cat_id)
{
    global $database;
    $title = trim($title);
    if (1 > $cat_id) {
        return;
    }
    $parent = (int) $database->get_one("SELECT page_id FROM " . TABLE_PREFIX . "pages WHERE cat_id = {$parent_cat_id} LIMIT 1");
    $parent_section = '';
    $parent_titles = array_reverse(get_parent_titles($parent));
    foreach ($parent_titles as $parent_title) {
        $parent_section .= page_filename($parent_title) . '/';
    }
    if ($parent_section == '/') {
        $parent_section = '';
    }
    $link = '/' . $parent_section . page_filename($title);
    $filename = WB_PATH . PAGES_DIRECTORY . $link . '.php';
    make_dir(WB_PATH . PAGES_DIRECTORY . '/' . $parent_section);
    $get_same_page = $database->query("SELECT page_id FROM " . TABLE_PREFIX . "pages WHERE link = '{$link}' LIMIT 1");
    if ($get_same_page->numRows() > 0) {
        echo "Page {$link} exists.";
        return;
    }
    $q = "INSERT INTO " . TABLE_PREFIX . "pages (cat_id,  page_title, menu_title, parent, template, target, visibility, searching, menu, language, admin_groups, viewing_groups, modified_when, modified_by)\n        VALUES ({$cat_id},  '{$title}', '{$title}', {$parent}, '', '', 'public', '1', '3', 'CS', '1,2', '1', '" . time() . "', 1)";
    $pages = $database->query($q);
    if ($database->is_error()) {
        echo $database->get_error();
        return;
    }
    $page_id = $pages->handle->insert_id;
    return $page_id;
}
Beispiel #4
0
 public static function init_lang_tpl()
 {
     $dir = PHPDISK_ROOT . 'system/global/';
     make_dir($dir);
     $file = $dir . 'lang_settings.inc.php';
     file_exists($file) ? require_once $file : lang_cache();
     $file = $dir . 'tpl_settings.inc.php';
     file_exists($file) ? require_once $file : tpl_cache();
     if (count($tpl_settings)) {
         foreach ($tpl_settings as $v) {
             if ($v[actived] && $v[tpl_type] == 'user') {
                 $user_tpl_dir = $v[tpl_name];
             }
             if ($v[actived] && $v[tpl_type] == 'admin') {
                 $admin_tpl_dir = $v[tpl_name];
             }
         }
     }
     if (count($lang_settings)) {
         foreach ($lang_settings as $v) {
             if ($v[actived]) {
                 $lang_name = $v[lang_name];
             }
         }
     }
     $user_tpl_dir = $user_tpl_dir ? "templates/{$user_tpl_dir}/" : 'templates/default/';
     $admin_tpl_dir = $admin_tpl_dir ? "templates/{$admin_tpl_dir}/" : 'templates/admin/';
     $lang_name = $lang_name ? $lang_name : 'zh_cn';
     return array('user_tpl_dir' => $user_tpl_dir, 'admin_tpl_dir' => $admin_tpl_dir, 'lang_name' => $lang_name);
 }
Beispiel #5
0
function create_csv_file($opts, $pipe, $cmd = __FUNCTION__)
{
    # set prefix
    $prefix = 'create_csv';
    # merge opts
    $opts = merge_opts($opts, $pipe, 'file');
    # get file opt
    $file = get_opt($prefix, $opts, 'file');
    if (!check_opt_set_type($cmd, $file, 'file', 'string')) {
        return false;
    }
    # get fields opt
    $fields = get_opt($prefix, $opts, 'fields');
    if (!check_opt_set_type($cmd, $fields, 'fields', 'array_of_strings')) {
        return false;
    }
    # get data opt
    $data = get_opt($prefix, $opts, 'data');
    if (!check_opt_set_type($cmd, $data, 'data', 'array')) {
        return false;
    }
    # make parent dir
    if (!make_dir($opts, dirname($file))) {
        return false;
    }
    # create temp file
    $file_handle = @fopen('php://temp/csv-out', 'w');
    if (!$file_handle) {
        return error($cmd, "cannot create temp CSV file");
    }
    # output the fields
    if (!fputcsv($file_handle, $fields)) {
        return error($cmd, "could not output the fields CSV file : {$file}");
    }
    # output the data
    foreach ($data as $line_no => $line) {
        if (!fputcsv($file_handle, $line)) {
            return error($cmd, "could not output line {$line_no} to CSV file : {$file}");
        }
    }
    # grab contents and close temp file
    rewind($file_handle);
    $text = stream_get_contents($file_handle);
    fclose($file_handle);
    # create file and
    if (!file_put_contents($file, $text)) {
        return error($cmd, "cannot store CSV data to file : {$file}");
    }
    # report
    $lines = count($data);
    debug_echo($cmd, "CSV file created ({$lines} lines) : {$file}");
    # return
    if ($pipe === false) {
        return $file;
    }
    return array('file' => $file);
}
Beispiel #6
0
function cover_image($description, $upload_dir)
{
    make_dir($upload_dir);
    if (preg_match('/<img.+src="(.+?)">/i', $description, $image)) {
        $file_name = random(rand(8, 12)) . '.jpg';
        if (file_put_contents($upload_dir . '/' . $file_name, file_get_contents($image[1]))) {
            return substr($upload_dir . '/' . $file_name, 3);
        }
    }
    return '';
}
Beispiel #7
0
 function make_dir($path, $write_file = 1)
 {
     if (!is_dir($path)) {
         $str = dirname($path);
         if ($str) {
             make_dir($str . '/');
             @mkdir($path, 0777);
             if ($write_file) {
                 file_put_contents($path . 'index.htm', 'PHPDisk');
             }
         }
     }
 }
Beispiel #8
0
 /**
  * 图片上传的处理函数
  *
  * @access      public
  * @param       array       upload       包含上传的图片文件信息的数组
  * @param       array       dir          文件要上传在$this->data_dir下的目录名。如果为空图片放在则在$this->images_dir下以当月命名的目录下
  * @param       array       img_name     上传图片名称,为空则随机生成
  * @return      mix         如果成功则返回文件名,否则返回false
  */
 function upload_image($upload, $dir = '', $img_name = '')
 {
     /* 没有指定目录默认为根目录images */
     if (empty($dir)) {
         /* 创建当月目录 */
         $dir = date('Ym');
         $dir = ROOT_PATH . $this->images_dir . '/' . $dir . '/';
     } else {
         /* 创建目录 */
         $dir = ROOT_PATH . $this->data_dir . '/' . $dir . '/';
         if ($img_name) {
             $img_name = $dir . $img_name;
             // 将图片定位到正确地址
         }
     }
     /* 如果目标目录不存在,则创建它 */
     if (!file_exists($dir)) {
         if (!make_dir($dir)) {
             /* 创建目录失败 */
             $this->error_msg = sprintf($GLOBALS['_LANG']['directory_readonly'], $dir);
             $this->error_no = ERR_DIRECTORY_READONLY;
             return false;
         }
     }
     if (empty($img_name)) {
         $img_name = $this->unique_name($dir);
         $img_name = $dir . $img_name . $this->get_filetype($upload['name']);
     }
     if (!$this->check_img_type($upload['type'])) {
         $this->error_msg = $GLOBALS['_LANG']['invalid_upload_image_type'];
         $this->error_no = ERR_INVALID_IMAGE_TYPE;
         return false;
     }
     /* 允许上传的文件类型 */
     $allow_file_types = '|GIF|JPG|JEPG|PNG|BMP|SWF|';
     if (!check_file_type($upload['tmp_name'], $img_name, $allow_file_types)) {
         $this->error_msg = $GLOBALS['_LANG']['invalid_upload_image_type'];
         $this->error_no = ERR_INVALID_IMAGE_TYPE;
         return false;
     }
     if ($this->move_file($upload, $img_name)) {
         return str_replace(ROOT_PATH, '', $img_name);
     } else {
         $this->error_msg = sprintf($GLOBALS['_LANG']['upload_failure'], $upload['name']);
         $this->error_no = ERR_UPLOAD_FAILURE;
         return false;
     }
 }
Beispiel #9
0
function make_dir($node, $path = null, $root = null)
{
    if (is_null($root)) {
        $root = ".." . DIRECTORY_SEPARATOR;
    }
    $root = trim($root, "/") . DIRECTORY_SEPARATOR;
    $keep = false;
    $ignore = false;
    if ($node == "#keep#") {
        $keep = true;
        $node = null;
    } else {
        if ($node == "#ignore#") {
            $ignore = true;
            $node = null;
        }
    }
    if (!is_null($node) && !is_array($node)) {
        $path = $node;
    }
    if (!is_null($path)) {
        $root = $root . $path . DIRECTORY_SEPARATOR;
        if (!file_exists($root)) {
            echo "> dir " . $root . "\n";
            mkdir($root);
        }
    }
    if ($keep) {
        $keep = $root . ".gitkeep";
        if (!file_exists($keep)) {
            echo "> file " . $keep . "\n";
            file_put_contents($keep, "");
        }
    } else {
        if ($ignore) {
            $ignore = $root . ".gitignore";
            if (!file_exists($ignore)) {
                echo "> file " . $ignore . "\n";
                file_put_contents($ignore, "*");
            }
        }
    }
    if (is_array($node)) {
        foreach ($node as $k => $v) {
            make_dir($v, $k, $root);
        }
    }
}
Beispiel #10
0
 function __construct($opts)
 {
     $this->build_config($opts['config'], $opts['template']);
     // fix paths
     foreach (array('db', 'img') as $path) {
         $this->cfg->rrd->paths->{$path} = absolute_path((string) $this->cfg->rrd->paths->{$path}, $opts['paths'][$path]);
         if (!is_dir((string) $this->cfg->rrd->paths->{$path})) {
             // create a path if not exsits
             echo 'creating ' . $this->cfg->rrd->paths->{$path} . PHP_EOL;
             make_dir((string) $this->cfg->rrd->paths->{$path});
         }
     }
     $this->rrdtool = new rrdtool($this->cfg->rrd);
     //			echo $this->cfg->asXML() . PHP_EOL;
     //			print_r($this->cfg);
     //			exit;
 }
Beispiel #11
0
/**
 *
 * @category        modules
 * @package         news
 * @author          WebsiteBaker Project
 * @copyright       WebsiteBaker Org. e.V.
 * @link            http://websitebaker.org/
 * @license         http://www.gnu.org/licenses/gpl.html
 * @platform        WebsiteBaker 2.8.3
 * @requirements    PHP 5.3.6 and higher
 * @version         $Id: save_post.php 1538 2011-12-10 15:06:15Z Luisehahne $
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb_svn/wb280/tags/2.8.3/wb/modules/news/save_post.php $
 * @lastmodified    $Date: 2011-12-10 16:06:15 +0100 (Sa, 10. Dez 2011) $
 *
 */
function createNewsAccessFile($newLink, $oldLink, $page_id, $section_id, $post_id)
{
    global $admin, $MESSAGE;
    $sPagesPath = WB_PATH . PAGES_DIRECTORY;
    $sPostsPath = $sPagesPath . '/posts';
    // create /posts/ - directory if not exists
    if (!file_exists($sPostsPath)) {
        if (is_writable($sPagesPath)) {
            make_dir(WB_PATH . PAGES_DIRECTORY . '/posts/');
        } else {
            $admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']);
        }
    }
    // check if /posts/ - dir is writable
    if (!is_writable($sPostsPath . '/')) {
        $admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']);
    }
    /*
       // delete old accessfile if link has changed
        if (($newLink != $oldLink) && (is_writable($sPostsPath.$oldLink.PAGE_EXTENSION))) {
           if (!unlink($sPostsPath.$oldLink.PAGE_EXTENSION)) {
              $admin->print_error($MESSAGE['PAGES_CANNOT_DELETE_ACCESS_FILE'].' - '.$oldLink);
           }
        }
    */
    // delete old accessfile if link has changed
    if ($newLink != $oldLink && is_writable($sPagesPath . $oldLink . PAGE_EXTENSION)) {
        if (!unlink($sPagesPath . $oldLink . PAGE_EXTENSION)) {
            $admin->print_error($MESSAGE['PAGES_CANNOT_DELETE_ACCESS_FILE'] . ' - ' . $oldLink);
        }
    }
    // all ok, now create new accessfile
    $newFile = $sPagesPath . $newLink . PAGE_EXTENSION;
    // $backSteps = preg_replace('/^'.preg_quote(WB_PATH).'/', '', $sPostsPath);
    $backSteps = preg_replace('@^' . preg_quote(WB_PATH) . '@', '', $sPostsPath);
    $backSteps = str_repeat('../', substr_count($backSteps, '/'));
    $content = '<?php' . "\n" . '// *** This file is generated by WebsiteBaker Ver.' . WB_VERSION . "\n" . '// *** Creation date: ' . date('c') . "\n" . '// *** Do not modify this file manually' . "\n" . '// *** WB will rebuild this file from time to time!!' . "\n" . '// *************************************************' . "\n" . "\t" . '$page_id      = ' . $page_id . ';' . "\n" . "\t" . '$section_id   = ' . $section_id . ';' . "\n" . "\t" . '$post_id      = ' . $post_id . ';' . "\n" . "\t" . '$post_section = ' . $section_id . ';' . "\n" . "\t" . 'require(\'' . $backSteps . 'index.php\');' . "\n" . '// *************************************************' . "\n";
    if (file_put_contents($newFile, $content) !== false) {
        // Chmod the file
        change_mode($newFile);
    } else {
        $admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE'], ADMIN_URL . '/pages/modify.php?page_id=' . $page_id);
        // $admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE'].': '.$newFile);
    }
}
Beispiel #12
0
function wxch_file($upload)
{
    $dir = date('Ymdh');
    $img_path = 'images' . '/' . $dir . '/';
    $dir = ROOT_PATH . 'images' . '/' . $dir . '/';
    if (!file_exists($dir)) {
        if (!make_dir($dir)) {
            $this->error_msg = sprintf($GLOBALS['_LANG']['directory_readonly'], $dir);
            $this->error_no = ERR_DIRECTORY_READONLY;
            return false;
        }
    }
    $file_name = random_filename();
    $path_name = $dir . $file_name;
    file_put_contents($path_name, $upload);
    $img_name = $img_path . $file_name;
    return $img_name;
}
function rename_recursive_dirs($dirsource, $dirdest, $deep = 0)
{
    if (true === is_dir($dirsource)) {
        $dir = dir($dirsource);
        while ($file = $dir->read()) {
            if ($file[0] != ".") {
                if (!is_dir($dirsource . "/" . $file)) {
                    copy($dirsource . "/" . $file, $dirdest . "/" . $file);
                    change_mode($dirdest . "/" . $file);
                } else {
                    make_dir($dirdest . "/" . $file);
                    rename_recursive_dirs($dirsource . "/" . $file, $dirdest . '/' . $file, $deep + 1);
                }
            }
        }
        $dir->close();
    }
    if ($deep == 0) {
        rm_full_dir($dirsource);
    }
    return true;
}
Beispiel #14
0
 public static function init_lang_tpl()
 {
     global $C, $settings, $auth;
     $dir = PHPDISK_ROOT . 'system/global/';
     make_dir($dir);
     $file = $dir . 'lang_settings.inc.php';
     file_exists($file) ? require_once $file : lang_cache();
     $file = $dir . 'tpl_settings.inc.php';
     file_exists($file) ? require_once $file : tpl_cache();
     if (count($tpl_settings)) {
         foreach ($tpl_settings as $v) {
             if ($v[actived] && $v[tpl_type] == 'user') {
                 $user_tpl_dir = $v[tpl_name];
             }
             if ($v[actived] && $v[tpl_type] == 'admin') {
                 $admin_tpl_dir = $v[tpl_name];
             }
         }
     }
     if (count($lang_settings)) {
         foreach ($lang_settings as $v) {
             if ($v[actived]) {
                 $lang_name = $v[lang_name];
             }
         }
     }
     if ($settings[open_switch_tpls]) {
         $ptpl = gpc('ptpl', 'C', '');
         $user_tpl_dir = $C[tpl_name] = $ptpl ? check_template($ptpl) ? $ptpl : $user_tpl_dir : $user_tpl_dir;
         //$C[tpl_name] = $user_tpl_dir;
     }
     $arr = get_template_info($user_tpl_dir);
     $is_fms = $arr['template_core'] == 'fms' && $auth[open_fms] ? 1 : 0;
     $user_tpl_dir = $user_tpl_dir ? "templates/{$user_tpl_dir}/" : 'templates/default/';
     $admin_tpl_dir = $admin_tpl_dir ? "templates/{$admin_tpl_dir}/" : 'templates/admin/';
     $lang_name = $lang_name ? $lang_name : 'zh_cn';
     return array('user_tpl_dir' => $user_tpl_dir, 'admin_tpl_dir' => $admin_tpl_dir, 'lang_name' => $lang_name, 'fms' => $is_fms);
 }
Beispiel #15
0
 function write($log_type, $str)
 {
     $log_arr = array('cache_log', 'db_log');
     if (in_array($log_type, $log_arr)) {
         $log_dir = PHPDISK_ROOT . "system/{$log_type}/";
         $log_file = $log_dir . date('Ymd') . '.php';
         make_dir($log_dir);
         $str = '<?php exit; ?>' . $str . LF;
         $fp = fopen($log_file, 'ab');
         if (!$fp) {
             die("Logger: Can not open file <b>{$log_type}</b> .code:1");
         }
         if (is_writable($log_file)) {
             if (!fwrite($fp, $str)) {
                 die("Logger: Can not write file <b>{$log_type}</b> .code:2");
             }
         } else {
             die("Logger: Can not write file <b>{$log_type}</b> .code:3");
         }
         fclose($fp);
     } else {
         die("Logger: Logger write error!");
     }
 }
Beispiel #16
0
function _create_post($post_id)
{
    global $database, $admin, $MESSAGE;
    $query_posts = $database->query("SELECT * FROM " . TABLE_PREFIX . "mod_news_posts WHERE `post_id` = '{$post_id}'");
    if (!$query_posts || $query_posts->numRows() == 0) {
        return false;
    }
    $res = $query_posts->fetchRow();
    $link = $res['link'];
    $page_id = $res['page_id'];
    $section_id = $res['section_id'];
    $sPagesPath = WB_PATH . PAGES_DIRECTORY;
    $sPostsPath = $sPagesPath . '/posts';
    if (!file_exists($sPostsPath)) {
        if (is_writable($sPagesPath)) {
            make_dir(WB_PATH . PAGES_DIRECTORY . '/posts/');
        } else {
            $admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']);
        }
    }
    if (!is_writable($sPostsPath . '/')) {
        $admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']);
    }
    $newFile = $sPagesPath . $link . PAGE_EXTENSION;
    // $backSteps = preg_replace('/^'.preg_quote(WB_PATH).'/', '', $sPostsPath);
    $backSteps = preg_replace('@^' . preg_quote(WB_PATH) . '@', '', $sPostsPath);
    $backSteps = str_repeat('../', substr_count($backSteps, '/'));
    $content = '<?php' . "\n" . '// *** This file is generated by WebsiteBaker Ver.' . WB_VERSION . "\n" . '// *** Creation date: ' . date('c') . "\n" . '// *** Do not modify this file manually' . "\n" . '// *** WB will rebuild this file from time to time!!' . "\n" . '// *************************************************' . "\n" . "\t" . '$page_id      = ' . $page_id . ';' . "\n" . "\t" . '$section_id   = ' . $section_id . ';' . "\n" . "\t" . '$post_id      = ' . $post_id . ';' . "\n" . "\t" . '$post_section = ' . $section_id . ';' . "\n" . "\t" . 'require(\'' . $backSteps . 'index.php\');' . "\n" . '// *************************************************' . "\n";
    if (file_put_contents($newFile, $content) !== false) {
        // Chmod the file
        change_mode($newFile);
    } else {
        $admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE'], ADMIN_URL . '/pages/modify.php?page_id=' . $page_id);
        // $admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE'].': '.$newFile);
    }
}
Beispiel #17
0
 /**
  * 创建图片的缩略图
  *
  * @access  public
  * @param   string      $img    原始图片的路径
  * @param   int         $thumb_width  缩略图宽度
  * @param   int         $thumb_height 缩略图高度
  * @param   strint      $path         指定生成图片的目录名
  * @return  mix         如果成功返回缩略图的路径,失败则返回false
  */
 function make_thumb($img, $thumb_width = 0, $thumb_height = 0, $path = '', $bgcolor = '')
 {
     $gd = $this->gd_version();
     //获取 GD 版本。0 表示没有 GD 库,1 表示 GD 1.x,2 表示 GD 2.x
     if ($gd == 0) {
         $this->error_msg = $GLOBALS['_LANG']['missing_gd'];
         return false;
     }
     /* 检查缩略图宽度和高度是否合法 */
     if ($thumb_width == 0 && $thumb_height == 0) {
         return str_replace(ROOT_PATH, '', str_replace('\\', '/', realpath($img)));
     }
     /* 检查原始文件是否存在及获得原始文件的信息 */
     $org_info = @getimagesize($img);
     if (!$org_info) {
         $this->error_msg = sprintf($GLOBALS['_LANG']['missing_orgin_image'], $img);
         $this->error_no = ERR_IMAGE_NOT_EXISTS;
         return false;
     }
     if (!$this->check_img_function($org_info[2])) {
         $this->error_msg = sprintf($GLOBALS['_LANG']['nonsupport_type'], $this->type_maping[$org_info[2]]);
         $this->error_no = ERR_NO_GD;
         return false;
     }
     $img_org = $this->img_resource($img, $org_info[2]);
     /* 原始图片以及缩略图的尺寸比例 */
     $scale_org = $org_info[0] / $org_info[1];
     /* 处理只有缩略图宽和高有一个为0的情况,这时背景和缩略图一样大 */
     if ($thumb_width == 0) {
         $thumb_width = $thumb_height * $scale_org;
     }
     if ($thumb_height == 0) {
         $thumb_height = $thumb_width / $scale_org;
     }
     /* 创建缩略图的标志符 */
     if ($gd == 2) {
         $img_thumb = imagecreatetruecolor($thumb_width, $thumb_height);
     } else {
         $img_thumb = imagecreate($thumb_width, $thumb_height);
     }
     /* 背景颜色 */
     if (empty($bgcolor)) {
         $bgcolor = $this->bgcolor;
     }
     $bgcolor = trim($bgcolor, "#");
     sscanf($bgcolor, "%2x%2x%2x", $red, $green, $blue);
     $clr = imagecolorallocate($img_thumb, $red, $green, $blue);
     imagefilledrectangle($img_thumb, 0, 0, $thumb_width, $thumb_height, $clr);
     if ($org_info[0] / $thumb_width > $org_info[1] / $thumb_height) {
         $lessen_width = $thumb_width;
         $lessen_height = $thumb_width / $scale_org;
     } else {
         /* 原始图片比较高,则以高度为准 */
         $lessen_width = $thumb_height * $scale_org;
         $lessen_height = $thumb_height;
     }
     $dst_x = ($thumb_width - $lessen_width) / 2;
     $dst_y = ($thumb_height - $lessen_height) / 2;
     /* 将原始图片进行缩放处理 */
     if ($gd == 2) {
         imagecopyresampled($img_thumb, $img_org, $dst_x, $dst_y, 0, 0, $lessen_width, $lessen_height, $org_info[0], $org_info[1]);
     } else {
         imagecopyresized($img_thumb, $img_org, $dst_x, $dst_y, 0, 0, $lessen_width, $lessen_height, $org_info[0], $org_info[1]);
     }
     /* 创建当月目录 */
     if (empty($path)) {
         $dir = ROOT_PATH . $this->images_dir . '/' . date('Ym') . '/';
     } else {
         $dir = $path;
     }
     /* 如果目标目录不存在,则创建它 */
     if (!is_dir($dir)) {
         if (!make_dir($dir)) {
             /* 创建目录失败 */
             $this->error_msg = sprintf($GLOBALS['_LANG']['directory_readonly'], $dir);
             $this->error_no = ERR_DIRECTORY_READONLY;
             return false;
         }
     }
     /* 如果文件名为空,生成不重名随机文件名 */
     $filename = $this->unique_name($dir);
     /* 生成文件 */
     if (function_exists('imagejpeg')) {
         $filename .= '.jpg';
         imagejpeg($img_thumb, $dir . $filename);
     } elseif (function_exists('imagegif')) {
         $filename .= '.gif';
         imagegif($img_thumb, $dir . $filename);
     } elseif (function_exists('imagepng')) {
         $filename .= '.png';
         imagepng($img_thumb, $dir . $filename);
     } else {
         $this->error_msg = $GLOBALS['_LANG']['creating_failure'];
         $this->error_no = ERR_NO_GD;
         return false;
     }
     imagedestroy($img_thumb);
     imagedestroy($img_org);
     //确认文件是否生成
     if (is_file($dir . $filename)) {
         return str_replace(ROOT_PATH, '', $dir) . $filename;
     } else {
         $this->error_msg = $GLOBALS['_LANG']['writting_failure'];
         $this->error_no = ERR_DIRECTORY_READONLY;
         return false;
     }
 }
Beispiel #18
0
 function mod_news_Upgrade()
 {
     global $database, $msg, $admin, $MESSAGE;
     $callingScript = $_SERVER["SCRIPT_NAME"];
     $tmp = 'upgrade-script.php';
     $globalStarted = substr_compare($callingScript, $tmp, 0 - strlen($tmp), strlen($tmp)) === 0;
     $sPagesPath = WB_PATH . PAGES_DIRECTORY;
     $sPostsPath = $sPagesPath . '/posts';
     // create /posts/ - directory if not exists
     if (!file_exists($sPostsPath)) {
         if (is_writable($sPagesPath)) {
             make_dir(WB_PATH . PAGES_DIRECTORY . '/posts/');
         } else {
             if (!$globalStarted) {
                 $msg[] = $MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE'];
             } else {
                 $msg[] = $MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE'] . '<br />';
                 return;
             }
         }
         if ($globalStarted) {
             echo 'directory "' . PAGES_DIRECTORY . '/posts/" created.<br />';
         }
     }
     // check if new fields must be added
     $doImportDate = true;
     if (!$database->field_exists(TABLE_PREFIX . 'mod_news_posts', 'created_when')) {
         if (!$database->field_add(TABLE_PREFIX . 'mod_news_posts', 'created_when', 'INT NOT NULL DEFAULT \'0\' AFTER `commenting`')) {
             if ($globalStarted) {
                 echo $MESSAGE['RECORD_MODIFIED_FAILED'] . '<br />';
                 return;
             } else {
                 $admin->print_error($MESSAGE['RECORD_MODIFIED_FAILED']);
             }
         }
         if ($globalStarted) {
             echo 'datafield `' . TABLE_PREFIX . 'mod_news_posts`.`created_when` added.<br />';
         }
     } else {
         $doImportDate = false;
     }
     if (!$database->field_exists(TABLE_PREFIX . 'mod_news_posts', 'created_by')) {
         if (!$database->field_add(TABLE_PREFIX . 'mod_news_posts', 'created_by', 'INT NOT NULL DEFAULT \'0\' AFTER `created_when`')) {
             if ($globalStarted) {
                 echo $MESSAGE['RECORD_MODIFIED_FAILED'] . '<br />';
                 return;
             } else {
                 $admin->print_error($MESSAGE['RECORD_MODIFIED_FAILED']);
             }
         }
         if ($globalStarted) {
             echo 'datafield `' . TABLE_PREFIX . 'mod_news_posts`.`created_by` added.<br />';
         }
     }
     // preset new fields `created_by` and `created_when` from existing values
     if ($doImportDate) {
         $sql = 'UPDATE `' . TABLE_PREFIX . 'mod_news_posts` ' . 'SET `created_by`=`posted_by`, `created_when`=`posted_when`';
         $database->query($sql);
     }
     // now iterate through all existing accessfiles,
     // write its creation date into database
     $oDir = new DirectoryIterator($sPostsPath);
     $count = 0;
     foreach ($oDir as $fileinfo) {
         $fileName = $fileinfo->getFilename();
         if (!$fileinfo->isDot() && $fileName != 'index.php' && substr_compare($fileName, PAGE_EXTENSION, 0 - strlen(PAGE_EXTENSION), strlen(PAGE_EXTENSION)) === 0) {
             // save creation date from old accessfile
             if ($doImportDate) {
                 $link = '/posts/' . preg_replace('/' . preg_quote(PAGE_EXTENSION) . '$/i', '', $fileinfo->getFilename());
                 $sql = 'UPDATE `' . TABLE_PREFIX . 'mod_news_posts` SET ' . '`created_when`=' . $fileinfo->getMTime() . ' ' . 'WHERE `link`=\'' . $database->escapeString($link) . '\' ' . 'AND `created_when`= 0';
                 $database->query($sql);
             }
             // delete old access file
             unlink($fileinfo->getPathname());
             $count++;
         }
     }
     unset($oDir);
     if ($globalStarted && $count > 0) {
         $msg[] = 'save date of creation from ' . $count . ' old accessfiles and delete these files.<br />';
     }
     // ************************************************
     // Check the validity of 'create-file-timestamp' and balance against 'posted-timestamp'
     $sql = 'UPDATE `' . TABLE_PREFIX . 'mod_news_posts` ';
     $sql .= 'SET `created_when`=`published_when` ';
     $sql .= 'WHERE `published_when`<`created_when`';
     $database->query($sql);
     $sql = 'UPDATE `' . TABLE_PREFIX . 'mod_news_posts` ';
     $sql .= 'SET `created_when`=`posted_when` ';
     $sql .= 'WHERE `published_when`=0 OR `published_when`>`posted_when`';
     $database->query($sql);
     // ************************************************
     // rebuild all access-files
     $count = 0;
     $backSteps = preg_replace('@^' . preg_quote(WB_PATH) . '@', '', $sPostsPath);
     $backSteps = str_repeat('../', substr_count($backSteps, '/'));
     $sql = 'SELECT `page_id`,`post_id`,`section_id`,`link` ';
     $sql .= 'FROM `' . TABLE_PREFIX . 'mod_news_posts`';
     $sql .= 'WHERE `link` != \'\'';
     if ($resPosts = $database->query($sql)) {
         while ($recPost = $resPosts->fetchRow()) {
             $file = $sPagesPath . $recPost['link'] . PAGE_EXTENSION;
             $content = '<?php' . "\n" . '// *** This file is generated by WebsiteBaker Ver.' . VERSION . "\n" . '// *** Creation date: ' . date('c') . "\n" . '// *** Do not modify this file manually' . "\n" . '// *** WB will rebuild this file from time to time!!' . "\n" . '// *************************************************' . "\n" . "\t" . '$page_id    = ' . $recPost['page_id'] . ';' . "\n" . "\t" . '$section_id = ' . $recPost['section_id'] . ';' . "\n" . "\t" . '$post_id    = ' . $recPost['post_id'] . ';' . "\n" . "\t" . '$post_section = ' . $recPost['section_id'] . ';' . "\n" . "\t" . 'require(\'' . $backSteps . 'index.php\');' . "\n" . '// *************************************************' . "\n";
             if (file_put_contents($file, $content) !== false) {
                 // Chmod the file
                 change_mode($file);
             } else {
                 if ($globalStarted) {
                     $msg[] = $MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE'] . '<br />';
                     return;
                 } else {
                     $msg[] = $MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE'];
                 }
             }
             $count++;
         }
     }
     if ($globalStarted) {
         $msg[] = 'created ' . $count . ' new accessfiles.';
     }
 }
Beispiel #19
0
function upload_article_file($upload)
{
    if (!make_dir("../" . DATA_DIR . "/article")) {
        /* 创建目录失败 */
        return false;
    }
    $filename = cls_image::random_filename() . substr($upload['name'], strpos($upload['name'], '.'));
    $path = ROOT_PATH . DATA_DIR . "/article/" . $filename;
    if (move_upload_file($upload['tmp_name'], $path)) {
        return DATA_DIR . "/article/" . $filename;
    } else {
        return false;
    }
}
Beispiel #20
0
<?php

/**
 *
 * @category        modules
 * @package         news
 * @author          WebsiteBaker Project
 * @copyright       WebsiteBaker Org. e.V.
 * @link            http://websitebaker.org/
 * @license         http://www.gnu.org/licenses/gpl.html
 * @platform        WebsiteBaker 2.8.3
 * @requirements    PHP 5.3.6 and higher
 * @version         $Id: install.php 1587 2012-01-24 23:19:06Z darkviper $
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb_svn/wb280/tags/2.8.3/wb/modules/news/install.php $
 * @lastmodified    $Date: 2012-01-25 00:19:06 +0100 (Mi, 25. Jan 2012) $
 *
 */
if (defined('WB_PATH')) {
    // create tables from sql dump file
    if (is_readable(__DIR__ . '/install-struct.sql')) {
        $database->SqlImport(__DIR__ . '/install-struct.sql', TABLE_PREFIX, __FILE__);
        // Make news post access files dir
        require_once WB_PATH . '/framework/functions.php';
        if (make_dir(WB_PATH . PAGES_DIRECTORY . '/posts')) {
        }
    }
}
/* **** END INSTALL ********************************************************* */
 /**
  * Validate Upload Path
  *
  * Verifies that it is a valid upload path with proper permissions.
  *
  *
  * @return  bool
  */
 public function validate_upload_path()
 {
     if ($this->upload_path == '') {
         $this->set_error('upload_no_filepath');
         return FALSE;
     }
     if (function_exists('realpath') and @realpath($this->upload_path) !== FALSE) {
         $this->upload_path = str_replace("\\", "/", realpath($this->upload_path));
     }
     if (!defined('IN_SAE')) {
         if (!is_dir($this->upload_path)) {
             if (!make_dir($this->upload_path)) {
                 $this->set_error('upload_not_writable');
                 return FALSE;
             }
         }
         if (!is_really_writable($this->upload_path)) {
             $this->set_error('upload_not_writable');
             return FALSE;
         }
     }
     $this->upload_path = preg_replace("/(.+?)\\/*\$/", "\\1/", $this->upload_path);
     return TRUE;
 }
 // Work-out what the link and page filename should be
 if ($parent == '0') {
     $link = '/' . page_filename($title);
     $filename = WB_PATH . PAGES_DIRECTORY . '/' . page_filename($title) . '.php';
 } else {
     $parent_section = '';
     $parent_titles = array_reverse(get_parent_titles($parent));
     foreach ($parent_titles as $parent_title) {
         $parent_section .= page_filename($parent_title) . '/';
     }
     if ($parent_section == '/') {
         $parent_section = '';
     }
     $link = '/' . $parent_section . page_filename($title);
     $filename = WB_PATH . PAGES_DIRECTORY . '/' . $parent_section . page_filename($title) . '.php';
     make_dir(WB_PATH . PAGES_DIRECTORY . '/' . $parent_section);
 }
 // Check if a page with same page filename exists
 $flag = true;
 $get_same_page = $database->query("SELECT page_id FROM " . TABLE_PREFIX . "pages WHERE link = '{$link}'");
 if ($get_same_page->numRows() > 0 or file_exists(WB_PATH . PAGES_DIRECTORY . $link . '.php') or file_exists(WB_PATH . PAGES_DIRECTORY . $link . '/')) {
     $error[] .= "<br /><span class='red'><b>#{$i}: " . "</b> " . $MESSAGE['PAGES']['PAGE_EXISTS'] . " ({$link})<span><br />";
     $flag = false;
 }
 if ($flag) {
     $admin_groups = implode(',', $admin_groups);
     $viewing_groups = implode(',', $viewing_groups);
     $run[$i]['msg'] = "{$i}) Title: {$title} Module: {$module} Parent: {$parent}<br />";
     $language = DEFAULT_LANGUAGE;
     $time = mktime();
     $uid = $admin->get_user_id();
Beispiel #23
0
/**
 * 递归创建目录
 *
 * 与 mkdir 不同之处在于支持一次性多级创建, 比如 /dir/sub/dir/
 *
 * @param  string
 * @param  int
 * @return boolean
 */
function make_dir($dir, $permission = 0777)
{
    $dir = rtrim($dir, '/') . '/';
    if (is_dir($dir)) {
        return TRUE;
    }
    if (!make_dir(dirname($dir), $permission)) {
        return FALSE;
    }
    return @mkdir($dir, $permission);
}
Beispiel #24
0
        setcookie('QS[password]', "", time() - 3600, $QS_cookiepath, $QS_cookiedomain);
        setcookie("QS[utype]", "", time() - 3600, $QS_cookiepath, $QS_cookiedomain);
        header("Location:" . url_rewrite('QS_login'));
    }
} elseif ($_SESSION['username'] && $_SESSION['utype'] && $_COOKIE['QS']['username'] && $_COOKIE['QS']['password']) {
    header("Location:" . get_member_url($_SESSION['utype']));
} elseif ($act == 'login') {
    /**
     * 微信扫描登录start
     */
    if (intval($_CFG['weixin_apiopen']) == 1) {
        $access_token = get_access_token();
        $scene_id = rand(1, 10000000);
        $_SESSION['scene_id'] = $scene_id;
        $dir = QISHI_ROOT_PATH . 'data/weixin/' . $scene_id % 10;
        make_dir($dir);
        $fp = @fopen($dir . '/' . $scene_id . '.txt', 'wb+');
        $post_data = '{"expire_seconds": 1800, "action_name": "QR_SCENE", "action_info": {"scene": {"scene_id": ' . $scene_id . '}}}';
        $url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" . $access_token;
        $result = https_request($url, $post_data);
        $result_arr = json_decode($result, true);
        $ticket = urlencode($result_arr["ticket"]);
        $html = '<img width="120" height="120" src="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=' . $ticket . '">';
        $smarty->assign('qrcode_img', $html);
    }
    /**
     * 微信扫描登录end
     */
    $smarty->assign('title', '会员登录 - ' . $_CFG['site_name']);
    $smarty->assign('error', $_GET['error']);
    $smarty->assign('url', $_GET['url']);
Beispiel #25
0
 //write_file(PHPDISK_ROOT.'system/1.txt',var_export($_POST,true));
 $file_name = trim(gpc('file_name', 'P', ''));
 $file_do_name = trim(gpc('file_do_name', 'P', ''));
 $file_size = (int) gpc('file_size', 'P', 0);
 $file_name = is_utf8() ? convert_str('gbk', 'utf-8', $file_name) : $file_name;
 $file_do_name = is_utf8() ? convert_str('gbk', 'utf-8', $file_do_name) : $file_do_name;
 $file_extension = get_extension($file_do_name);
 $esp = strlen($file_extension) + 1;
 $file_real_name = $file_extension ? substr($file_do_name, 0, strlen($file_do_name) - $esp) : $file_do_name;
 $file_name = $file_extension ? substr($file_name, 0, strlen($file_name) - $esp) : $file_name;
 $rs = $db->fetch_one_array("select * from {$tpf}uploadx_files where userid='{$uid}' and file_real_name='{$file_real_name}' and file_name='{$file_name}' limit 1");
 if ($rs) {
     $tmp_ext = $rs[file_extension] ? '.' . $rs[file_extension] : '';
     $dir1 = PHPDISK_ROOT . 'system/cache/';
     $dir2 = PHPDISK_ROOT . $settings[file_path] . '/' . $rs[file_store_path];
     make_dir($dir2);
     $file = $dir1 . $rs[file_real_name] . $tmp_ext . '.phpdisk';
     $file_real_name = md5(uniqid(mt_rand(), true) . microtime() . $uid);
     $file_dest = $dir2 . $file_real_name . get_real_ext($rs[file_extension]);
     //write_file(PHPDISK_ROOT.'system/s2.txt',$file.'|'.$file_dest.',');
     //if(@filesize($file)==(int)$rs[file_size]){
     if (file_exists($file) && @rename($file, $file_dest)) {
         $file_real_path = PHPDISK_ROOT . '/' . $settings['file_path'] . '/';
         $img_arr = getimagesize($file_dest);
         if ($img_arr[2] && @in_array($file_extension, array('jpg', 'jpeg', 'png', 'gif', 'bmp'))) {
             $is_image = 1;
             make_thumb($file_dest, $file_real_path . $rs[file_store_path] . $file_real_name . '_thumb.' . $file_extension, $settings['thumb_width'], $settings['thumb_height']);
         } else {
             $is_image = 0;
         }
         if ($configs[server_key]) {
Beispiel #26
0
/**
 * 格式化商品图片名称(按目录存储)
 *
 */
function reformat_image_name($type, $goods_id, $source_img, $position = '')
{
    $rand_name = gmtime() . sprintf("%03d", mt_rand(1, 999));
    $img_ext = substr($source_img, strrpos($source_img, '.'));
    $dir = 'images';
    if (defined('IMAGE_DIR')) {
        $dir = IMAGE_DIR;
    }
    $sub_dir = date('Ym', gmtime());
    if (!make_dir(ROOT_PATH . $dir . '/' . $sub_dir)) {
        return false;
    }
    if (!make_dir(ROOT_PATH . $dir . '/' . $sub_dir . '/source_img')) {
        return false;
    }
    if (!make_dir(ROOT_PATH . $dir . '/' . $sub_dir . '/goods_img')) {
        return false;
    }
    if (!make_dir(ROOT_PATH . $dir . '/' . $sub_dir . '/thumb_img')) {
        return false;
    }
    switch ($type) {
        case 'goods':
            $img_name = $goods_id . '_G_' . $rand_name;
            break;
        case 'goods_thumb':
            $img_name = $goods_id . '_thumb_G_' . $rand_name;
            break;
        case 'gallery':
            $img_name = $goods_id . '_P_' . $rand_name;
            break;
        case 'gallery_thumb':
            $img_name = $goods_id . '_thumb_P_' . $rand_name;
            break;
    }
    if ($position == 'source') {
        if (move_image_file(ROOT_PATH . $source_img, ROOT_PATH . $dir . '/' . $sub_dir . '/source_img/' . $img_name . $img_ext)) {
            return $dir . '/' . $sub_dir . '/source_img/' . $img_name . $img_ext;
        }
    } elseif ($position == 'thumb') {
        if (move_image_file(ROOT_PATH . $source_img, ROOT_PATH . $dir . '/' . $sub_dir . '/thumb_img/' . $img_name . $img_ext)) {
            return $dir . '/' . $sub_dir . '/thumb_img/' . $img_name . $img_ext;
        }
    } else {
        if (move_image_file(ROOT_PATH . $source_img, ROOT_PATH . $dir . '/' . $sub_dir . '/goods_img/' . $img_name . $img_ext)) {
            return $dir . '/' . $sub_dir . '/goods_img/' . $img_name . $img_ext;
        }
    }
    return false;
}
Beispiel #27
0
 public function associate_avatar($uid, $headimgurl)
 {
     if ($headimgurl) {
         if (!($user_info = $this->model('account')->get_user_info_by_uid($uid))) {
             return false;
         }
         if ($user_info['avatar_file']) {
             return false;
         }
         if ($avatar_stream = curl_get_contents($headimgurl, 1)) {
             $avatar_location = get_setting('upload_dir') . '/avatar/' . $this->model('account')->get_avatar($uid, '', 1) . $this->model('account')->get_avatar($uid, '', 2);
             $avatar_dir = str_replace(basename($avatar_location), '', $avatar_location);
             if (!is_dir($avatar_dir)) {
                 make_dir($avatar_dir);
             }
             if (@file_put_contents($avatar_location, $avatar_stream)) {
                 foreach (AWS_APP::config()->get('image')->avatar_thumbnail as $key => $val) {
                     $thumb_file[$key] = $avatar_dir . $this->model('account')->get_avatar($uid, $key, 2);
                     AWS_APP::image()->initialize(array('quality' => 90, 'source_image' => $avatar_location, 'new_image' => $thumb_file[$key], 'width' => $val['w'], 'height' => $val['h']))->resize();
                 }
                 $avatar_file = $this->model('account')->get_avatar($uid, null, 1) . basename($thumb_file['min']);
             }
         }
     }
     if ($avatar_file) {
         return $this->model('account')->update('users', array('avatar_file' => $avatar_file), 'uid = ' . intval($uid));
     }
 }
Beispiel #28
0
function make_dir($path)
{
    if (!file_exists($path)) {
        make_dir(dirname($path));
        @mkdir($path, 0777);
        @chmod($path, 0777);
    }
}
Beispiel #29
0
query("SET CHARACTER SET '" . DB_CHARSET . "';");
// TODO DB_COLLATE setzen? wie?
echo "Reading tags and categories... ";
$res = query("SELECT terms.name, rel.object_id " . "FROM " . $table_prefix . "terms AS terms, " . $table_prefix . "term_relationships AS rel, " . $table_prefix . "term_taxonomy AS tax " . "WHERE terms.term_id = tax.term_id " . "AND tax.term_taxonomy_id = rel.term_taxonomy_id");
$tags = array();
while (($r = mysql_fetch_assoc($res)) !== false) {
    $id = $r['object_id'];
    $tag = $r['name'];
    if (!isset($tags[$id])) {
        $tags[$id] = array();
    }
    $tags[$id][] = tag_quotes($tag);
}
echo "Done.\n";
make_dir($dir . '/src');
make_dir($dir . '/meta');
$res = query("SELECT id, post_date, post_content, post_title, post_name, " . "post_modified FROM " . $table_prefix . "posts WHERE post_type='post';");
chdir($dir) or die("Could not change into directory '{$dir}'.\n");
echo "Exporting to '{$dir}' with suffix {$suf} and meta-suffix {$muf}...\n";
while (($r = mysql_fetch_assoc($res)) !== false) {
    echo $r['id'] . ': "' . $r['post_title'] . '"... ';
    $content = $r['post_content'];
    $content = str_replace("\r\n\r\n", "</p>\n<p>", $content);
    $content = str_replace("\r\n", "<br />\n", $content);
    $content = "<p>{$content}</p>\n";
    // The above inserts extra <br /> inside of some tags, fix that
    $content = preg_replace_callback('|<pre>.*</pre>|Uims', 'remove_br', $content);
    $content = preg_replace_callback('|<ul>.*</ul>|Uims', 'remove_br', $content);
    $content = preg_replace_callback('|<ol>.*</ol>|Uims', 'remove_br', $content);
    $text = '<:' . htmlspecialchars($r['post_title']) . '>';
    if (isset($tags[$r['id']])) {
Beispiel #30
0
 public function associate_remote_avatar($uid, $headimgurl)
 {
     if (!$headimgurl) {
         return false;
     }
     if (!($user_info = $this->get_user_info_by_uid($uid))) {
         return false;
     }
     if ($user_info['avatar_file']) {
         return false;
     }
     if (!($avatar_stream = curl_get_contents($headimgurl, 1))) {
         return false;
     }
     $avatar_location = get_setting('upload_dir') . '/avatar/' . $this->get_avatar($uid, '');
     $avatar_dir = dirname($avatar_location) . '/';
     if (!file_exists($avatar_dir)) {
         make_dir($avatar_dir);
     }
     if (!@file_put_contents($avatar_location, $avatar_stream)) {
         return false;
     }
     foreach (AWS_APP::config()->get('image')->avatar_thumbnail as $key => $val) {
         AWS_APP::image()->initialize(array('quality' => 90, 'source_image' => $avatar_location, 'new_image' => $avatar_dir . $this->get_avatar($uid, $key, 2), 'width' => $val['w'], 'height' => $val['h']))->resize();
     }
     $this->update('users', array('avatar_file' => $this->get_avatar($uid)), 'uid = ' . intval($uid));
     if (!$this->model('integral')->fetch_log($new_user_id, 'UPLOAD_AVATAR')) {
         $this->model('integral')->process($new_user_id, 'UPLOAD_AVATAR', round(get_setting('integral_system_config_profile') * 0.2), '上传头像');
     }
     return true;
 }