길선아빠님의 SPAW 편집기에서 이미지 넣을때.... > 그누3질답

그누3질답

길선아빠님의 SPAW 편집기에서 이미지 넣을때.... 정보

그누보드 길선아빠님의 SPAW 편집기에서 이미지 넣을때....

본문

길선아빠님의 SPAW 편집기를 이용해서 게시판을 하나 생성했습니다.
근데 그림넣기를 하는데 로긴하고, 해당폴더(gnu3/data/member/아이디/)에 그림파일도 들어있고...
그런데 그림넣기를 눌러서 뜨는 이미지라이브러리에는 리스트가 나타나지를 않네요...
그림처럼 맹탕만 뜨네요..
다른 뭔가를 설정해야 할 것이 있나요?
더와 주시어요.....^^;;
oops_img.jpg
  • 복사

댓글 전체

생각해 보니 비회원도 이미지파일을 업로드할 수 있게 해주면.......
그게 축적되면 엄청난 용량이 필요 하겠군요....ㅋㅋ
그래서 그냥 원래대로 쓰기로....

이미지가 안보인 이유는 서버 디렉토리 구조에서 약간의 문제가 있었던 거 같네요..
저의 경우
public_html -----
                |
                |---- gnu3/-----bbs/
                                  |
                                  |----spaw/
이런식이라서 spaw/confog/spaw_control.config.php에 있는 $_root,  $_root_url 에 gnu3/를 붙여 주니 잘 나오네요..ㅋㅋ
역시 초짜는 괴로워....
답변 감사 드리구요...
경로 제대로 잡은거 같은데 리스트가 안나오네요...^^;;;
그래서 회원들은 그림보관함에서 불러오는 걸로 그냥 쓰고....
에디터에는 내컴에서 이미지를 불러오게 맹글어 볼랍니다....
즐~~
<?php
// ================================================
// SPAW PHP WYSIWYG editor control
// ================================================
// Image library dialog
// ================================================
// Developed: Alan Mendelevich, www.solmetra.com
// ================================================
// $Revision: 1.7 $, $Date: 2003/04/21 15:09:56 $
// ================================================

//그누보드 설정///////////////////////
include '../../config.php';//<<------------------------------------------------//그누보드

$tmp = dir("../../lib");//<<---------------------------------------------------//그누보드
while ($entry = $tmp->read()) {
    if ($entry{0} == ".") continue;
    include "../../lib/" . $entry;//<<-----------------------------------------//그누보드
}

$today = date("Y-m-d", time());
$now  = date("Y-m-d H:i:s", time());

if (file_exists("../../dbconfig.php")) {//<<-----------------------------------//그누보드
    ini_set("session.use_trans_sid", 0);
    ini_set("session.cache_expire", $cfg[cache_expire]);
    ini_set("session.gc_maxlifetime", $cfg[gc_maxlifetime]);
    session_save_path("../../data/session");//그누보드
    if ($SESSION_CACHE_LIMITER) {
        @session_cache_limiter($SESSION_CACHE_LIMITER);
    } else {
        @session_cache_limiter('no-cache, must-revalidate');
    }
    session_set_cookie_params(0,"/");
    include "../../dbconfig.php";//<<------------------------------------------//그누보드
    $connect = @mysql_connect($cfg[mysql_host], $cfg[mysql_user], $cfg[mysql_pass]);
    $select_db = @mysql_select_db($cfg[mysql_db], $connect);
    if (!$select_db) {
        echo "DB 접속 오류";
        exit;
    }
}
$default = sql_fetch(" select * from $cfg[table_default] ");
ini_set("session.cookie_domain",$default[de_cookie_domain]);
@session_start();

// include wysiwyg config
include '../config/spaw_control.config.php';
include '../class/lang.class.php';

// 로그인중이라면
if ($HTTP_SESSION_VARS[ss_mb_id]) {
    $member = get_member($HTTP_SESSION_VARS[ss_mb_id]);
}
// 회원자료가 있다면
if ($member[0] != '') {
  $spaw_upload_allowed = true;
  $spaw_imglibs[] =
    array(
      'value'  => 'data/member/'. $member[0] .'/',              //그누보드:  따로 설정할 필요없슴
      'text'    => 'My Image Library',                            //그누보드:  따로 설정할 필요없슴
  );
}

$theme = empty($HTTP_POST_VARS['theme'])?(empty($HTTP_GET_VARS['theme'])?$spaw_default_theme:$HTTP_GET_VARS['theme']):$HTTP_POST_VARS['theme'];
$theme_path = $spaw_dir.'lib/themes/'.$theme.'/';

$l = new SPAW_Lang(empty($HTTP_POST_VARS['lang'])?$HTTP_GET_VARS['lang']:$HTTP_POST_VARS['lang']);
$l->setBlock('image_insert');
?>

<?php
$imglib = $HTTP_POST_VARS['lib'];
if (empty($imglib)) $imglib = $HTTP_GET_VARS['lib'];

$value_found = false;
// callback function for preventing listing of non-library directory
function is_array_value($value, $key, $_imglib)
{
  global $value_found;
  if (is_array($value)) array_walk($value, 'is_array_value', $_imglib);
  if ($value == $_imglib){
    $value_found=true;
  }
}
array_walk($spaw_imglibs, 'is_array_value', $imglib);

if (!$value_found || empty($imglib))
{
  $imglib = $spaw_imglibs[0]['value'];
}

$lib_options = liboptions($spaw_imglibs, '', $imglib);

$img = $HTTP_POST_VARS['imglist'];

$preview = '';

$errors = array();
if ($HTTP_POST_FILES['img_file']['size']>0)
{
  if ($img = uploadImg('img_file'))
  {
    $preview = $_root_url.$spaw_imglibs[0]['value'].$img;
  }
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
  <title><?php echo $l->m('title')?></title>
<meta http-equiv="Pragma" content="no-cache">
  <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $l->getCharset()?>">
  <link rel="stylesheet" type="text/css" href="<?php echo $theme_path.'css/'?>dialog.css">
  <script language="javascript" src="utils.js"></script>
 
  <script language="javascript">
  <!--
    function selectClick()
    {
      if (document.libbrowser.lib.selectedIndex>=0 && document.libbrowser.imglist.selectedIndex>=0)
      {
        window.returnValue = '<?php echo $_root_url?>'+document.libbrowser.lib.options[document.libbrowser.lib.selectedIndex].value + document.libbrowser.imglist.options[document.libbrowser.imglist.selectedIndex].value;
        window.close();
      }
      else
      {
        alert('<?php echo $l->m('error').': '.$l->m('error_no_image')?>');
      }
    }
   
    function Init()
    {
      resizeDialogToContent();
    }
  //-->
  </script>
</head>

<body onLoad="Init()" dir="<?php echo $l->getDir();?>">
  <script language="javascript">
  <!--
    window.name = 'imglibrary';
  //-->
  </script>

<form name="libbrowser" method="post" action="img_library.php" enctype="multipart/form-data" target="imglibrary">
<input type="hidden" name="theme" value="<?php echo $theme?>">
<input type="hidden" name="lang" value="<?php echo $l->lang?>">
<div style="border: 1 solid Black; padding: 5 5 5 5;">
<table border="0" cellpadding="2" cellspacing="0">
<tr>
  <td valign="top" align="left"><b><?php echo $l->m('library')?>:</b></td>
  <td valign="top" align="left">&nbsp;</td>
  <td valign="top" align="left"><b><?php echo $l->m('preview')?>:</b></td>
</tr>
<tr>
  <td valign="top" align="left">
  <select name="lib" size="1" class="input" style="width: 150px;" onChange="libbrowser.submit();">
    <?php echo $lib_options; ?>
  </select>
  </td>
  <td valign="top" align="left" rowspan="3">&nbsp;</td>
  <td valign="top" align="left" rowspan="3">

    <iframe name="imgpreview" src="<?php echo $preview?>" style="width: 200px; height: 100%;" scrolling="Auto" marginheight="0" marginwidth="0" frameborder="0"></iframe>

  </td>
</tr>
<tr>
  <td valign="top" align="left"><b><?php echo $l->m('images')?>:</b></td>
</tr>
<tr>
  <td valign="top" align="left">
  <?php
    $d = @dir($_root.$imglib);
  ?>
  <select name="imglist" size="15" class="input" style="width: 150px;"
    onchange="if (this.selectedIndex &gt;=0) imgpreview.location.href = '<?php echo $_root_url.$imglib?>' + this.options[this.selectedIndex].value;" ondblclick="selectClick();">
  <?php
    if ($d)
    {
      while (false !== ($entry = $d->read())) {
        if (is_file($_root.$imglib.$entry))
        {
          ?>
          <option value="<?php echo $entry?>" <?php echo ($entry == $img)?'selected':''?>><?php echo $entry?></option>
          <?php
        }
      }
      $d->close();
    }
    else
    {
      $errors[] = $l->m('error_no_dir');
    }
  ?>


  </select>
  </td>
</tr>
<tr>
  <td valign="top" align="left" colspan="3">
  <input type="button" value="<?php echo $l->m('select')?>" class="bt" onclick="selectClick();">&nbsp;<input type="button" value="<?php echo $l->m('cancel')?>" class="bt" onclick="window.close();">
  </td>
</tr>
</table>
</div>

<?php  if ($spaw_upload_allowed) {  ?>
<div style="border: 1 solid Black; padding: 5 5 5 5;">
<table border="0" cellpadding="2" cellspacing="0">
<tr>
  <td valign="top" align="left">
    <?php 
    if (!empty($errors))
    {
      echo '<span class="error">';
      foreach ($errors as $err)
      {
        echo $err.'<br>';
      }
      echo '</span>';
    }
    ?>

  <?php
  if ($d) {
  ?>
    <b><?php echo $l->m('upload')?>:</b> <input type="file" name="img_file" class="input"><br>
    <input type="submit" name="btnupload" class="bt" value="<?php echo $l->m('upload_button')?>">
  <?php
  }
  ?>
  </td>
</tr>
</table>
</div>
<?php  } ?>
</form>
</body>
</html>

<?php
function liboptions($arr, $prefix = '', $sel = '')
{
  $buf = '';
  foreach($arr as $lib) {
    $buf .= '<option value="'.$lib['value'].'" '.(($lib['value'] == $sel)?' selected':'').'>'.$prefix.$lib['text'].'</option>'."\n";
  }
  return $buf;
}

function uploadImg($img) {

  global $HTTP_POST_FILES;
  global $spaw_valid_imgs;
  global $imglib;
  global $errors;
  global $l;
  global $spaw_upload_allowed;
  global $_root;
 
  if (!$spaw_upload_allowed) return false;

  if ($HTTP_POST_FILES[$img]['size']>0) {
    $data['type'] = $HTTP_POST_FILES[$img]['type'];
    $data['name'] = $HTTP_POST_FILES[$img]['name'];
    $data['size'] = $HTTP_POST_FILES[$img]['size'];
    $data['tmp_name'] = $HTTP_POST_FILES[$img]['tmp_name'];

    // get file extension
    $ext = strtolower(substr(strrchr($data['name'],'.'), 1));
    if (in_array($ext,$spaw_valid_imgs)) {

      $dir_name = $_root.$imglib;
      $img_name = $data['name'];
      $i = 1;
      while (file_exists($_root.$dir_name.$img_name)) {
        $img_name = ereg_replace('(.*)(\.[a-zA-Z]+)$', '\1_'.$i.'\2', $data['name']);
        $i++;
      }

      if (!move_uploaded_file($data['tmp_name'], $dir_name.$img_name)) {
        $errors[] = $l->m('error_uploading');
        return false;
      }
      return $img_name;
    }
    else
    {
      $errors[] = $l->m('error_wrong_type');
    }
  }
  return false;
}
?>
spaw/dialogs/img_library.php
파일을 그누보드의 환경에 맞추어서 올바로 수정해야 합니다.
전체적인 디렉토리의 구조를 알아야 할 것 같구요.
가능하다면 위의 소스를 보고 싶군요.
© SIRSOFT
현재 페이지 제일 처음으로