/**
  * 生成XML文档
  *@access    public
  *@param     string  $file_name  如果提供了文件名则生成文件,否则返回字符串.
  *@return [void|string]
  */
 function build($file_name = null)
 {
     $file_name = saestor($file_name);
     $map = $this->header . "\n";
     foreach ($this->items as $item) {
         $item->loc = htmlentities($item->loc, ENT_QUOTES);
         $map .= "\t\t<url>\n\t\t\t<loc>{$item->loc}</loc>\n";
         // lastmod
         if (!empty($item->lastmod)) {
             $map .= "\t\t\t<lastmod>{$item->lastmod}</lastmod>\n";
         }
         // changefreq
         if (!empty($item->changefreq)) {
             $map .= "\t\t\t<changefreq>{$item->changefreq}</changefreq>\n";
         }
         // priority
         if (!empty($item->priority)) {
             $map .= "\t\t\t<priority>{$item->priority}</priority>\n";
         }
         $map .= "\t\t</url>\n\n";
     }
     $map .= $this->footer . "\n";
     if (!is_null($file_name)) {
         return file_put_contents($file_name, $map);
     } else {
         return $map;
     }
 }
Exemple #2
0
 } elseif ($type == 1) {
     if (isset($_FILES['upfile_flash']['error']) && $_FILES['upfile_flash']['error'] == 0 || !isset($_FILES['upfile_flash']['error']) && isset($_FILES['upfile_flash']['tmp_name']) && $_FILES['upfile_flash']['tmp_name'] != 'none') {
         /* 检查文件类型 */
         if ($_FILES['upfile_flash']['type'] != "application/x-shockwave-flash") {
             $link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
             sys_msg($_LANG['upfile_flash_type'], 0, $link);
         }
         /* 生成文件名 */
         $urlstr = date('Ymd');
         for ($i = 0; $i < 6; $i++) {
             $urlstr .= chr(mt_rand(97, 122));
         }
         $source_file = $_FILES['upfile_flash']['tmp_name'];
         $target = ROOT_PATH . DATA_DIR . '/afficheimg/';
         $file_name = $urlstr . '.swf';
         if (!move_upload_file($source_file, saestor($target . $file_name))) {
             $link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
             sys_msg($_LANG['upfile_error'], 0, $link);
         } else {
             $ad_code = "ad_code = '{$file_name}', ";
         }
     } elseif (!empty($_POST['flash_url'])) {
         if (substr(strtolower($_POST['flash_url']), strlen($_POST['flash_url']) - 4) != '.swf') {
             $link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
             sys_msg($_LANG['upfile_flash_type'], 0, $link);
         }
         $ad_code = "ad_code = '" . $_POST['flash_url'] . "', ";
     } else {
         $ad_code = '';
     }
 } elseif ($type == 2) {
Exemple #3
0
function move_image_file($source, $dest)
{
    if (@copy($source, saestor($dest))) {
        @unlink($source);
        return true;
    }
    return false;
}
Exemple #4
0
/**
 * 把一个目录的文件复制到另一个目录(包括子目录)
 * 前提:$from_dir 是目录且存在且可读,$to_dir 是目录且存在且可写
 *
 * @param   string  $from_dir   源目录
 * @param   string  $to_dir     目标目录
 * @param   string  $file_prefix 文件前缀
 * @return  mix     成功返回true,否则返回第一个失败的文件名
 */
function copy_dirs($from_dir, $to_dir, $file_prefix = '')
{
    $result = true;
    if (!is_dir($from_dir)) {
        die("It's not a dir");
    }
    if (!is_dir($to_dir)) {
        if (!mkdir($to_dir, 0700)) {
            die("can't mkdir");
        }
    }
    $handle = opendir($from_dir);
    while (($file = readdir($handle)) !== false) {
        if ($file != '.' && $file != '..') {
            $src = $from_dir . DIRECTORY_SEPARATOR . $file;
            $dtn = $to_dir . DIRECTORY_SEPARATOR . $file_prefix . $file;
            if (is_dir($src)) {
                copy_dirs($src, $dtn);
            } else {
                if (!copy($src, saestor($dtn))) {
                    $result = false;
                    break;
                }
            }
        }
    }
    closedir($handle);
    return $result;
}
Exemple #5
0
/**
 * 处理上传文件,并返回上传图片名(上传失败时返回图片名为空)
 *
 * @access  public
 * @param array     $upload     $_FILES 数组
 * @param array     $type       图片所属类别,即data目录下的文件夹名
 *
 * @return string               上传图片名
 */
function upload_file($upload, $type)
{
    if (!empty($upload['tmp_name'])) {
        $ftype = check_file_type($upload['tmp_name'], $upload['name'], '|png|jpg|jpeg|gif|doc|xls|txt|zip|ppt|pdf|rar|');
        if (!empty($ftype)) {
            $name = date('Ymd');
            for ($i = 0; $i < 6; $i++) {
                $name .= chr(mt_rand(97, 122));
            }
            $name = $_SESSION['user_id'] . '_' . $name . '.' . $ftype;
            //            $target = ROOT_PATH . DATA_DIR . '/' . $type . '/' . $name;
            $target = saestor(DATA_DIR . '/' . $type . '/' . $name);
            // for sae
            if (!move_upload_file($upload['tmp_name'], $target)) {
                $GLOBALS['err']->add($GLOBALS['_LANG']['upload_file_error'], 1);
                return false;
            } else {
                return $name;
            }
        } else {
            $GLOBALS['err']->add($GLOBALS['_LANG']['upload_file_type'], 1);
            return false;
        }
    } else {
        $GLOBALS['err']->add($GLOBALS['_LANG']['upload_file_error']);
        return false;
    }
}
Exemple #6
0
    $shipping_id = !empty($_POST['shipping']) ? intval($_POST['shipping']) : 0;
    //接收上传文件
    if (!empty($_FILES['bg']['name'])) {
        if (!get_file_suffix($_FILES['bg']['name'], $allow_suffix)) {
            echo '<script language="javascript">';
            echo 'parent.alert("' . sprintf($_LANG['js_languages']['upload_falid'], implode(',', $allow_suffix)) . '");';
            echo '</script>';
            exit;
        }
        $name = date('Ymd');
        for ($i = 0; $i < 6; $i++) {
            $name .= chr(mt_rand(97, 122));
        }
        $name .= '.' . end(explode('.', $_FILES['bg']['name']));
        //        $target = ROOT_PATH . '/images/receipt/' . $name;
        $target = saestor('/images/receipt/' . $name);
        // for sae
        if (move_upload_file($_FILES['bg']['tmp_name'], $target)) {
            $src = '/images/receipt/' . $name;
        }
    }
    //保存
    $sql = "UPDATE " . $ecs->table('shipping') . " SET print_bg = '{$src}' WHERE shipping_id = '{$shipping_id}'";
    $res = $db->query($sql);
    if ($res) {
        echo '<script language="javascript">';
        echo 'parent.call_flash("bg_add", "' . get_site_root_url() . $src . '");';
        echo '</script>';
    }
} elseif ($_REQUEST['act'] == 'print_del') {
    /* 检查权限 */
Exemple #7
0
function set_flash_default($tplname, $flashdata)
{
    $data_file = saestor(DATA_DIR . '/flashdata/' . $tplname . '/data.xml');
    $xmldata = '<?xml version="1.0" encoding="' . EC_CHARSET . '"?><bcaster>';
    foreach ($flashdata as $data) {
        $xmldata .= '<item item_url="' . $data['src'] . '" link="' . $data['url'] . '" />';
    }
    $xmldata .= '</bcaster>';
    file_put_contents($data_file, $xmldata);
    return true;
}
Exemple #8
0
/**
 * 将插件library从默认模板中移动到指定模板中
 *
 * @access  public
 * @param   string  $tmp_name   模版名称
 * @param   string  $msg        如果出错,保存错误信息,否则为空
 * @return  Boolen
 */
function move_plugin_library($tmp_name, &$msg)
{
    $sql = 'SELECT code, library FROM ' . $GLOBALS['ecs']->table('plugins') . " WHERE library > ''";
    $rec = $GLOBALS['db']->query($sql);
    $return_value = true;
    $target_dir = ROOT_PATH . 'themes/' . $tmp_name;
    $source_dir = ROOT_PATH . 'themes/' . $GLOBALS['_CFG']['template'];
    while ($row = $GLOBALS['db']->fetchRow($rec)) {
        //先移动,移动失败试则拷贝
        if (!@rename($source_dir . $row['library'], $target_dir . $row['library'])) {
            if (!@copy(ROOT_PATH . 'plugins/' . $row['code'] . '/temp' . $row['library'], saestor($target_dir . $row['library']))) {
                $return_value = false;
                $msg .= "\n moving " . $row['library'] . ' failed';
            }
        }
    }
}
Exemple #9
0
             if ($image->add_watermark($gallery_img, '', $GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']) === false) {
                 sys_msg($image->error_msg(), 1, array(), false);
             }
         }
         // 相册缩略图
         if ($_CFG['thumb_width'] != 0 || $_CFG['thumb_height'] != 0) {
             $gallery_thumb = $image->make_thumb($img, $GLOBALS['_CFG']['thumb_width'], $GLOBALS['_CFG']['thumb_height']);
             if ($gallery_thumb === false) {
                 sys_msg($image->error_msg(), 1, array(), false);
             }
         }
     } else {
         /* 复制一份原图 */
         $pos = strpos(basename($img), '.');
         $gallery_img = dirname($img) . '/' . $image->random_filename() . substr(basename($img), $pos);
         if (!copy($img, saestor($gallery_img))) {
             sys_msg('fail to copy file: ' . realpath($img), 1, array(), false);
         }
         $gallery_thumb = '';
     }
 }
 // 未上传,如果自动选择生成,且上传了商品图片,生成所略图
 if (!empty($original_img)) {
     // 如果设置缩略图大小不为0,生成缩略图
     if ($_CFG['thumb_width'] != 0 || $_CFG['thumb_height'] != 0) {
         $goods_thumb = $image->make_thumb($original_img, $GLOBALS['_CFG']['thumb_width'], $GLOBALS['_CFG']['thumb_height']);
         if ($goods_thumb === false) {
             sys_msg($image->error_msg(), 1, array(), false);
         }
     } else {
         $goods_thumb = $original_img;
Exemple #10
0
/**
 * 图片处理函数
 *
 * @access  public
 * @param   integer $page
 * @param   integer $page_size
 * @param   integer $type
 * @param   boolen  $thumb      是否生成缩略图
 * @param   boolen  $watermark  是否生成水印图
 * @param   boolen  $change     true 生成新图,删除旧图 false 用新图覆盖旧图
 * @param   boolen  $silent     是否执行能忽略错误
 *
 * @return void
 */
function process_image($page = 1, $page_size = 100, $type = 0, $thumb = true, $watermark = true, $change = false, $silent = false)
{
    if ($type == 0) {
        $sql = "SELECT g.goods_id, g.original_img, g.goods_img, g.goods_thumb FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE g.original_img > ''" . $GLOBALS['goods_where'];
        $res = $GLOBALS['db']->SelectLimit($sql, $page_size, ($page - 1) * $page_size);
        while ($row = $GLOBALS['db']->fetchRow($res)) {
            $goods_thumb = '';
            $image = '';
            /* 水印 */
            if ($watermark) {
                /* 获取加水印图片的目录 */
                if (empty($row['goods_img'])) {
                    $dir = dirname($row['original_img']) . '/';
                } else {
                    $dir = dirname($row['goods_img']) . '/';
                }
                //                dump($dir,"dir 249");
                $image = $GLOBALS['image']->make_thumb($row['original_img'], $GLOBALS['_CFG']['image_width'], $GLOBALS['_CFG']['image_height'], $dir);
                //先生成缩略图
                //                dump($image,"image");
                if (!$image) {
                    //出错返回
                    $msg = sprintf($GLOBALS['_LANG']['error_pos'], $row['goods_id']) . "\n" . $GLOBALS['image']->error_msg();
                    if ($silent) {
                        $GLOBALS['err_msg'][] = $msg;
                        continue;
                    } else {
                        make_json_error($msg);
                    }
                }
                //                dump($image, "image 260");
                $image = $GLOBALS['image']->add_watermark($image, '', $GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']);
                if (!$image) {
                    //出错返回
                    $msg = sprintf($GLOBALS['_LANG']['error_pos'], $row['goods_id']) . "\n" . $GLOBALS['image']->error_msg();
                    if ($silent) {
                        $GLOBALS['err_msg'][] = $msg;
                        continue;
                    } else {
                        make_json_error($msg);
                    }
                }
                /* 重新格式化图片名称 */
                $image = reformat_image_name('goods', $row['goods_id'], $image, 'goods');
                if ($change || empty($row['goods_img'])) {
                    /* 要生成新链接的处理过程 */
                    if ($image != $row['goods_img']) {
                        $sql = "UPDATE " . $GLOBALS['ecs']->table('goods') . " SET goods_img = '{$image}' WHERE goods_id = '" . $row['goods_id'] . "'";
                        $GLOBALS['db']->query($sql);
                        /* 防止原图被删除 */
                        if ($row['goods_img'] != $row['original_img']) {
                            @unlink($row['goods_img']);
                        }
                    }
                } else {
                    replace_image($image, $row['goods_img'], $row['goods_id'], $silent);
                }
            }
            /* 缩略图 */
            if ($thumb) {
                if (empty($row['goods_thumb'])) {
                    $dir = dirname($row['original_img']) . '/';
                } else {
                    $dir = dirname($row['goods_thumb']) . '/';
                }
                $goods_thumb = $GLOBALS['image']->make_thumb(ROOT_PATH . $row['original_img'], $GLOBALS['_CFG']['thumb_width'], $GLOBALS['_CFG']['thumb_height'], $dir);
                /* 出错处理 */
                if (!$goods_thumb) {
                    $msg = sprintf($GLOBALS['_LANG']['error_pos'], $row['goods_id']) . "\n" . $GLOBALS['image']->error_msg();
                    if ($silent) {
                        $GLOBALS['err_msg'][] = $msg;
                        continue;
                    } else {
                        make_json_error($msg);
                    }
                }
                /* 重新格式化图片名称 */
                $goods_thumb = reformat_image_name('goods_thumb', $row['goods_id'], $goods_thumb, 'thumb');
                if ($change || empty($row['goods_thumb'])) {
                    if ($row['goods_thumb'] != $goods_thumb) {
                        $sql = "UPDATE " . $GLOBALS['ecs']->table('goods') . " SET goods_thumb = '{$goods_thumb}' WHERE goods_id = '" . $row['goods_id'] . "'";
                        $GLOBALS['db']->query($sql);
                        /* 防止原图被删除 */
                        if ($row['goods_thumb'] != $row['original_img']) {
                            @unlink($row['goods_thumb']);
                        }
                    }
                } else {
                    replace_image($goods_thumb, $row['goods_thumb'], $row['goods_id'], $silent);
                }
            }
        }
    } else {
        /* 遍历商品相册 */
        $sql = "SELECT album.goods_id, album.img_id, album.img_url, album.thumb_url, album.img_original FROM " . $GLOBALS['ecs']->table('goods_gallery') . " AS album " . $GLOBALS['album_where'];
        $res = $GLOBALS['db']->SelectLimit($sql, $page_size, ($page - 1) * $page_size);
        while ($row = $GLOBALS['db']->fetchRow($res)) {
            $thumb_url = '';
            $image = '';
            /* 水印 */
            if ($watermark && file_exists($row['img_original'])) {
                if (empty($row['img_url'])) {
                    $dir = dirname($row['img_original']) . '/';
                } else {
                    $dir = dirname($row['img_url']) . '/';
                }
                $file_name = cls_image::unique_name($dir);
                $file_name .= cls_image::get_filetype(empty($row['img_url']) ? $row['img_original'] : $row['img_url']);
                copy($row['img_original'], saestor($dir . $file_name));
                //                dump($dir . $file_name, "dir file_name 350");
                $image = $GLOBALS['image']->add_watermark($dir . $file_name, '', $GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']);
                if (!$image) {
                    @unlink($dir . $file_name);
                    $msg = sprintf($GLOBALS['_LANG']['error_pos'], $row['goods_id']) . "\n" . $GLOBALS['image']->error_msg();
                    if ($silent) {
                        $GLOBALS['err_msg'][] = $msg;
                        continue;
                    } else {
                        make_json_error($msg);
                    }
                }
                /* 重新格式化图片名称 */
                $image = reformat_image_name('gallery', $row['goods_id'], $image, 'goods');
                if ($change || empty($row['img_url']) || $row['img_original'] == $row['img_url']) {
                    if ($image != $row['img_url']) {
                        $sql = "UPDATE " . $GLOBALS['ecs']->table('goods_gallery') . " SET img_url='{$image}' WHERE img_id='{$row['img_id']}'";
                        $GLOBALS['db']->query($sql);
                        if ($row['img_original'] != $row['img_url']) {
                            @unlink($row['img_url']);
                        }
                    }
                } else {
                    replace_image($image, $row['img_url'], $row['goods_id'], $silent);
                }
            }
            /* 缩略图 */
            if ($thumb) {
                if (empty($row['thumb_url'])) {
                    $dir = dirname($row['img_original']) . '/';
                } else {
                    $dir = dirname($row['thumb_url']) . '/';
                }
                $thumb_url = $GLOBALS['image']->make_thumb($row['img_original'], $GLOBALS['_CFG']['thumb_width'], $GLOBALS['_CFG']['thumb_height'], $dir);
                if (!$thumb_url) {
                    $msg = sprintf($GLOBALS['_LANG']['error_pos'], $row['goods_id']) . "\n" . $GLOBALS['image']->error_msg();
                    if ($silent) {
                        $GLOBALS['err_msg'][] = $msg;
                        continue;
                    } else {
                        make_json_error($msg);
                    }
                }
                /* 重新格式化图片名称 */
                $thumb_url = reformat_image_name('gallery_thumb', $row['goods_id'], $thumb_url, 'thumb');
                if ($change || empty($row['thumb_url'])) {
                    if ($thumb_url != $row['thumb_url']) {
                        $sql = "UPDATE " . $GLOBALS['ecs']->table('goods_gallery') . " SET thumb_url='{$thumb_url}' WHERE img_id='{$row['img_id']}'";
                        $GLOBALS['db']->query($sql);
                        @unlink($row['thumb_url']);
                    }
                } else {
                    replace_image($thumb_url, $row['thumb_url'], $row['goods_id'], $silent);
                }
            }
        }
    }
}
Exemple #11
0
     }
     $file = $_FILES['sqlfile'];
     /* 检查上传是否成功 */
     if (isset($file['error']) && $file['error'] > 0 || !isset($file['error']) && $file['tmp_name'] == 'none') {
         sys_msg($_LANG['fail_upload'], 1);
     }
     /* 检查文件格式 */
     if ($file['type'] == 'application/x-zip-compressed') {
         sys_msg($_LANG['not_support_zip_format'], 1);
     }
     if (!preg_match("/\\.sql\$/i", $file['name'])) {
         sys_msg($_LANG['not_sql_file'], 1);
     }
     /* 将文件移动到临时目录,避免权限问题 */
     @unlink($sql_file);
     if (!move_upload_file($file['tmp_name'], saestor($sql_file))) {
         sys_msg($_LANG['fail_upload_move'], 1);
     }
 }
 /* 获取sql文件头部信息 */
 $sql_info = cls_sql_dump::get_head($sql_file);
 /* 如果备份文件的商场系统与现有商城系统版本不同则拒绝执行 */
 if (empty($sql_info['ecs_ver'])) {
     sys_msg($_LANG['unrecognize_version'], 1);
 } else {
     if ($sql_info['ecs_ver'] != VERSION) {
         sys_msg(sprintf($_LANG['version_error'], VERSION, $sql_info['ecs_ver']));
     }
 }
 /* 检查数据库版本是否正确 */
 if (empty($_GET['mysql_ver_confirm'])) {
Exemple #12
0
                 }
             }
             if (!empty($field_arr['goods_img'])) {
                 //设置商品相册图
                 if ($_CFG['auto_generate_gallery'] && !empty($gallery_img)) {
                     $goods_gallery['img_url'] = reformat_image_name('gallery', $goods_gallery['goods_id'], $gallery_img, 'goods');
                 }
                 //设置商品图
                 $goods_img = reformat_image_name('goods', $goods_gallery['goods_id'], $field_arr['goods_img'], 'goods');
             }
             if (!empty($field_arr['goods_thumb'])) {
                 //设置商品相册缩略图
                 if ($_CFG['auto_generate_gallery']) {
                     $ext = substr($field_arr['goods_thumb'], strrpos($field_arr['goods_thumb'], '.'));
                     $gallery_thumb = dirname($field_arr['goods_thumb']) . '/' . $image->random_filename() . $ext;
                     @copy(ROOT_PATH . $field_arr['goods_thumb'], saestor($gallery_thumb));
                     $goods_gallery['thumb_url'] = reformat_image_name('gallery_thumb', $goods_gallery['goods_id'], $gallery_thumb, 'thumb');
                 }
                 //设置商品缩略图
                 $goods_thumb = reformat_image_name('goods_thumb', $goods_gallery['goods_id'], $field_arr['goods_thumb'], 'thumb');
             }
             //修改商品图
             $db->query("UPDATE " . $ecs->table('goods') . " SET goods_img = '{$goods_img}', goods_thumb = '{$goods_thumb}', original_img = '{$original_img}' WHERE goods_id='" . $goods_gallery['goods_id'] . "'");
             //添加商品相册图
             if ($_CFG['auto_generate_gallery']) {
                 $db->autoExecute($ecs->table('goods_gallery'), $goods_gallery, 'INSERT');
             }
         }
     }
 }
 // 记录日志
Exemple #13
0
     $gallery_img = $img;
     $gallery_thumb = $img;
 }
 // 如果系统支持GD,缩放商品图片,且给商品图片和相册图片加水印
 if ($proc_thumb && $image->gd_version() > 0 && $image->check_img_function($_FILES['goods_img']['type'])) {
     // 如果设置大小不为0,缩放图片
     if ($_CFG['image_width'] != 0 || $_CFG['image_height'] != 0) {
         $goods_img = $image->make_thumb($goods_img, $GLOBALS['_CFG']['image_width'], $GLOBALS['_CFG']['image_height']);
         if ($goods_img === false) {
             sys_msg($image->error_msg(), 1, array(), false);
         }
     }
     /* 添加判断是否自动生成相册图片 */
     if ($_CFG['auto_generate_gallery']) {
         $newname = dirname($img) . '/' . $image->random_filename() . substr(basename($img), $pos);
         if (!copy($img, saestor($newname))) {
             sys_msg('fail to copy file: ' . realpath('../' . $img), 1, array(), false);
         }
         $gallery_img = $newname;
     }
     // 加水印
     if (intval($_CFG['watermark_place']) > 0 && !empty($GLOBALS['_CFG']['watermark'])) {
         if ($image->add_watermark('../' . $goods_img, '', $GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']) === false) {
             sys_msg($image->error_msg(), 1, array(), false);
         }
         /* 添加判断是否自动生成相册图片 */
         if ($_CFG['auto_generate_gallery']) {
             if ($image->add_watermark('../' . $gallery_img, '', $GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']) === false) {
                 sys_msg($image->error_msg(), 1, array(), false);
             }
         }
Exemple #14
0
 /**
  *
  *
  * @access  public
  * @param
  *
  * @return void
  */
 function move_file($upload, $target)
 {
     $target = saestor($target);
     if (isset($upload['error']) && $upload['error'] > 0) {
         return false;
     }
     if (!move_upload_file($upload['tmp_name'], $target)) {
         return false;
     }
     return true;
 }
Exemple #15
0
 $smarty->assign('shop_notice', $_CFG['shop_notice']);
 // 商店公告
 //jimphei's code
 /* 首页主广告设置 */
 $smarty->assign('index_ad', $_CFG['index_ad']);
 if ($_CFG['index_ad'] == 'cus') {
     $sql = 'SELECT ad_type, content, url FROM ' . $ecs->table("ad_custom") . ' WHERE ad_status = 1';
     $ad = $db->getRow($sql, true);
     $smarty->assign('ad', $ad);
 } else {
     // for sae
     $flashdb = array();
     if (file_exists(saestor(DATA_DIR . '/flash_data.xml'))) {
         // 兼容v2.7.0及以前版本
         if (!preg_match_all('/item_url="([^"]+)"\\slink="([^"]+)"\\stext="([^"]*)"\\ssort="([^"]*)"/', file_get_contents(saestor(DATA_DIR . '/flash_data.xml')), $t, PREG_SET_ORDER)) {
             preg_match_all('/item_url="([^"]+)"\\slink="([^"]+)"\\stext="([^"]*)"/', file_get_contents(saestor(DATA_DIR . '/flash_data.xml')), $t, PREG_SET_ORDER);
         }
         if (!empty($t)) {
             foreach ($t as $key => $val) {
                 $val[4] = isset($val[4]) ? $val[4] : 0;
                 $flashdb[] = array('src' => sae_repalce_imgpath($val[1]), 'url' => $val[2], 'text' => $val[3], 'sort' => $val[4]);
             }
         }
     }
     $ads = $flashdb;
     $smarty->assign('ads', $ads);
 }
 /* links */
 $links = index_get_links();
 $smarty->assign('img_links', $links['img']);
 $smarty->assign('txt_links', $links['txt']);
Exemple #16
0
/**
 * 将上传文件转移到指定位置
 *
 * @param string $file_name
 * @param string $target_name
 * @return blog
 */
function move_upload_file($file_name, $target_name = '')
{
    if (function_exists("move_uploaded_file")) {
        if (move_uploaded_file($file_name, saestor($target_name))) {
            @chmod($target_name, 0755);
            return true;
        } else {
            if (copy($file_name, saestor($target_name))) {
                @chmod($target_name, 0755);
                return true;
            }
        }
    } elseif (copy($file_name, saestor($target_name))) {
        @chmod($target_name, 0755);
        return true;
    }
    return false;
}
Exemple #17
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'], saestor($path))) {
        return DATA_DIR . "/article/" . $filename;
    } else {
        return false;
    }
}
Exemple #18
0
                 $ext = array_pop(explode('.', $file['name']));
                 $file_name = $file_var_list[$code]['store_dir'] . 'watermark.' . $ext;
                 if (file_exists($file_var_list[$code]['value'])) {
                     @unlink($file_var_list[$code]['value']);
                 }
             } elseif ($code == 'wap_logo') {
                 $ext = array_pop(explode('.', $file['name']));
                 $file_name = $file_var_list[$code]['store_dir'] . 'wap_logo.' . $ext;
                 if (file_exists($file_var_list[$code]['value'])) {
                     @unlink($file_var_list[$code]['value']);
                 }
             } else {
                 $file_name = $file_var_list[$code]['store_dir'] . $file['name'];
             }
             /* 判断是否上传成功 */
             $file_name = saestor($file_name);
             if (move_upload_file($file['tmp_name'], $file_name)) {
                 $sql = "UPDATE " . $ecs->table('shop_config') . " SET value = '{$file_name}' WHERE code = '{$code}'";
                 $db->query($sql);
             } else {
                 sys_msg(sprintf($_LANG['msg_upload_failed'], $file['name'], $file_var_list[$code]['store_dir']));
             }
         }
     }
 }
 /* 处理发票类型及税率 */
 if (!empty($_POST['invoice_rate'])) {
     foreach ($_POST['invoice_rate'] as $key => $rate) {
         $rate = round(floatval($rate), 2);
         if ($rate < 0) {
             $rate = 0;
Exemple #19
0
function FileUpload($resourceType, $currentFolder, $sCommand)
{
    if (!isset($_FILES)) {
        global $_FILES;
    }
    $sErrorNumber = '0';
    $sFileName = '';
    if (isset($_FILES['NewFile']) && !is_null($_FILES['NewFile']['tmp_name'])) {
        global $Config;
        $oFile = $_FILES['NewFile'];
        // Map the virtual path to the local server path.
        $sServerDir = ServerMapFolder($resourceType, $currentFolder, $sCommand);
        // Get the uploaded file name.
        $sFileName = $oFile['name'];
        $sFileName = SanitizeFileName($sFileName);
        $sOriginalFileName = $sFileName;
        // Get the extension.
        $sExtension = substr($sFileName, strrpos($sFileName, '.') + 1);
        $sExtension = strtolower($sExtension);
        if (isset($Config['SecureImageUploads'])) {
            if (($isImageValid = IsImageValid($oFile['tmp_name'], $sExtension)) === false) {
                $sErrorNumber = '202';
            }
        }
        if (isset($Config['HtmlExtensions'])) {
            if (!IsHtmlExtension($sExtension, $Config['HtmlExtensions']) && ($detectHtml = DetectHtml($oFile['tmp_name'])) === true) {
                $sErrorNumber = '202';
            }
        }
        // Check if it is an allowed extension.
        if (!$sErrorNumber && IsAllowedExt($sExtension, $resourceType)) {
            $iCounter = 0;
            while (true) {
                $sFilePath = $sServerDir . $sFileName;
                $sFilePath = saestor($sFileName);
                if (is_file($sFilePath)) {
                    $iCounter++;
                    $sFileName = RemoveExtension($sOriginalFileName) . '(' . $iCounter . ').' . $sExtension;
                    $sErrorNumber = '201';
                } else {
                    move_uploaded_file($oFile['tmp_name'], $sFilePath);
                    //判断并给符合条件图片加上水印
                    if ($sExtension == 'jpg' || $sExtension == 'jpeg' || $sExtension == 'png' || $sExtension == 'gif' || $sExtension == 'bmp') {
                        require_once ROOT_PATH . '/includes/cls_image.php';
                        $image = new cls_image($GLOBALS['_CFG']['bgcolor']);
                        if (intval($GLOBALS['_CFG']['watermark_place']) > 0 && !empty($GLOBALS['_CFG']['watermark'])) {
                            $image->add_watermark($sFilePath, '', '../../../../../' . $GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']);
                        }
                    }
                    if (is_file($sFilePath)) {
                        if (isset($Config['ChmodOnUpload']) && !$Config['ChmodOnUpload']) {
                            break;
                        }
                        $permissions = 0777;
                        if (isset($Config['ChmodOnUpload']) && $Config['ChmodOnUpload']) {
                            $permissions = $Config['ChmodOnUpload'];
                        }
                        $oldumask = umask(0);
                        chmod($sFilePath, $permissions);
                        umask($oldumask);
                    }
                    break;
                }
            }
            if (file_exists($sFilePath)) {
                //previous checks failed, try once again
                if (isset($isImageValid) && $isImageValid === -1 && IsImageValid($sFilePath, $sExtension) === false) {
                    @unlink($sFilePath);
                    $sErrorNumber = '202';
                } else {
                    if (isset($detectHtml) && $detectHtml === -1 && DetectHtml($sFilePath) === true) {
                        @unlink($sFilePath);
                        $sErrorNumber = '202';
                    }
                }
            }
        } else {
            $sErrorNumber = '202';
        }
    } else {
        $sErrorNumber = '202';
    }
    $sFileUrl = CombinePaths(GetResourceTypePath($resourceType, $sCommand), $currentFolder);
    $sFileUrl = CombinePaths($sFileUrl, $sFileName);
    SendUploadResults($sErrorNumber, $sFileUrl, $sFileName);
    exit;
}
Exemple #20
0
/**
 * 上传图片
 *
 * @param string $str 二进制字符串
 * @param string $dir 目录路径
 * @param string $img_name 图片名称
 * @return 图片名称 或 假值
 */
function upload_image($str, $dir = '', $img_name = '')
{
    $dir = saestor($dir);
    if (empty($str['Data'])) {
        return false;
    }
    $allow_file_type = array('jpg', 'jpeg', 'png', 'gif', 'bmp');
    if (empty($dir)) {
        /* 创建当月目录 */
        $dir = date('Ym');
        $dir = saestor('/images/' . $dir);
    } else {
        /* 创建目录 */
        $dir = saestor($dir);
        if ($img_name) {
            /* 判断$img_name文件后缀与路径 */
            $img_name = basename($img_name);
            $img_name_ext = substr($img_name, strrpos($img_name, '.') + 1);
            if (!in_array($img_name_ext, $allow_file_type)) {
                return false;
            }
            $img_name = $dir . '/' . $img_name;
            // 将图片定位到正确地址
        }
    }
    if (!file_exists($dir)) {
        if (!make_dir($dir)) {
            /* 创建目录失败 */
            return false;
        }
    }
    if (empty($img_name)) {
        $img_name = unique_name($dir);
        $img_name = $dir . '/' . $img_name . '.' . $str['Type'];
    }
    $binary_data = base64_decode($str['Data']);
    if ($fp = @fopen($img_name, 'wb')) {
        @fwrite($fp, $binary_data);
        @fclose($fp);
        return str_replace(ROOT_PATH . '/', '', $img_name);
    } else {
        return false;
    }
}
Exemple #21
0
<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
require dirname(__FILE__) . "/../data/config.php";
echo '<meta http-equiv="Content-Type" content="text / html;charset=UTF-8" />';
$install = @file_get_contents(saestor("saestor_" . $_SERVER['HTTP_APPVERSION'] . "/data/install.lock"));
if ($install == "1") {
    echo "<h1>警告</h1>";
    echo "<h3>版本" . $_SERVER['HTTP_APPVERSION'] . "已完成安装!请删除/install/目录!</h3>";
    echo "<h3>如果重新安装请先删除storage内的 saestor_" . $_SERVER['HTTP_APPVERSION'] . "/data/install.lock 文件</h3>";
} else {
    // 判断是否已经初始化了storage,mc,mysql
    if (is_storage() && is_mc() && is_mysql()) {
        $fp = @fopen(dirname(__FILE__) . "/ecshop4sae.sql", "r") or die("不能打开SQL文件 {$file_name}");
        //打开文件
        if ($fp) {
            $mysql = new SaeMysql();
            echo "正在执行导入操作:";
            while ($SQL = GetNextSQL()) {
                $SQL = str_replace("`ecs_", "`" . TABLE_PREFIX, $SQL);
                //                echo $SQL."<BR/>";
                if (!$mysql->runSql($SQL)) {
                    echo "执行出错:" . $mysql->errmsg() . "";
                    echo "SQL语句为:" . $SQL . "";
                    exit;
                }
            }
            echo "导入完成<br/>";
Exemple #22
0
         break;
 }
 // 标题图上传
 if ($_FILES['title_pic']['name'] && $_FILES['title_pic']['size'] > 0) {
     /* 检查文件合法性 */
     if (!get_file_suffix($_FILES['title_pic']['name'], $allow_suffix)) {
         sys_msg($_LANG['invalid_type']);
     }
     /* 处理 */
     $name = date('Ymd');
     for ($i = 0; $i < 6; $i++) {
         $name .= chr(mt_rand(97, 122));
     }
     $name .= '.' . end(explode('.', $_FILES['title_pic']['name']));
     //        $target = ROOT_PATH . DATA_DIR . '/afficheimg/' . $name;
     $target = saestor(DATA_DIR . '/afficheimg/' . $name);
     // for sae
     if (move_upload_file($_FILES['title_pic']['tmp_name'], $target)) {
         $title_pic = DATA_DIR . '/afficheimg/' . $name;
     }
 } else {
     if (!empty($_REQUEST['title_url'])) {
         /* 来自互联网图片 不可以是服务器地址 */
         if (strstr($_REQUEST['title_url'], 'http') && !strstr($_REQUEST['title_url'], $_SERVER['SERVER_NAME'])) {
             /* 取互联网图片至本地 */
             $title_pic = get_url_image($_REQUEST['title_url']);
         } else {
             sys_msg($_LANG['web_url_no']);
         }
     }
 }