Beispiel #1
0
/**
 * upload file db update
 * tempFiles 테이블에 있는 임시파일들 목록을 files 테이블에 옮기고, 썸네일으로 사용하는 첨부파일 번호를 리턴한다.
 *
 * @param array $post $_POST
 * @param int $art_srl 글을 등록하고 바로 가져온 srl번호
 * @param int $thum_srl 썸네일 srl번호
 * @return int 바뀐 썸네일 srl번호
 */
function fileUpload($post, $art_srl, $thum_srl)
{
    $thumnail_srl = null;
    if ($post['addQueue']) {
        $queue = explode(',', $post['addQueue']);
        foreach ($queue as $k => $v) {
            if (!$v) {
                continue;
            }
            $tmpFile = Spawn::item(array('table' => Spawn::getTableName('file_tmp'), 'where' => 'srl=' . (int) $v));
            if (count($tmpFile)) {
                // insert file
                $result = Spawn::insert(array('table' => Spawn::getTableName('file'), 'data' => array('srl' => null, 'article_srl' => $art_srl, 'name' => $tmpFile['name'], 'loc' => $tmpFile['loc'], 'type' => $tmpFile['type'], 'size' => $tmpFile['size'], 'regdate' => date("YmdHis"))));
                // set thumnail srl
                if ($tmpFile['srl'] == $thum_srl) {
                    $thumnail_srl = Spawn::getLastIdx();
                }
                // remove tmp file
                $result = Spawn::delete(array('table' => Spawn::getTableName('file_tmp'), 'where' => 'srl=' . (int) $v));
            }
        }
    }
    return $thumnail_srl ? $thumnail_srl : $thum_srl;
}
Beispiel #2
0
require_once __GOOSE_PWD__ . 'data/config.php';
// create and connect database
$this->goose->createSpawn();
$this->goose->spawn->connect($dbConfig);
$this->goose->spawn->prefix = $table_prefix;
// set admin
$this->goose->isAdmin = true;
// install modules
$arr = array('user', 'nest', 'app', 'json', 'file', 'article', 'category');
foreach ($arr as $k => $v) {
    $result = $this->installModule($v);
    echo "<p>Create table - " . $result['message'] . "</p>";
}
// add admin user
$result = Spawn::insert(array('table' => Spawn::getTableName('user'), 'data' => array('srl' => null, 'email' => $_POST['email'], 'name' => $_POST['name'], 'pw' => md5($_POST['password']), 'level' => $_POST['adminLevel'], 'regdate' => date("YmdHis"))));
echo "<p>Add admin user - " . ($result == 'success' ? 'Complete' : "ERROR : {$result}") . "</p>";
// add basic navigation on json table
$cnt = Spawn::count(array('table' => Spawn::getTableName('json'), 'where' => "name='Goose Navigation'"));
if (!$cnt) {
    $data = Util::checkUserFile(__GOOSE_PWD__ . 'core/misc/navigationTree.json');
    $data = Util::openFile($data);
    $data = Util::jsonToArray($data, true, true);
    $data = Util::arrayToJson($data, true);
    $result = Spawn::insert(array('table' => __dbPrefix__ . 'json', 'data' => array('srl' => null, 'name' => 'Goose Navigation', 'json' => $data, 'regdate' => date("YmdHis"))));
} else {
    $result = '"Goose Navigation" Data already exists.';
}
echo "<p>Add json data - " . ($result == 'success' ? 'Complete' : "ERROR : {$result}") . "</p>";
echo "<hr/>";
echo "<h1>END INSTALL</h1>";
echo "<nav><a href=\"" . __GOOSE_ROOT__ . "\">Go to intro page</a></nav>";
Beispiel #3
0
// check user
if (!$this->isAdmin) {
    return array('state' => 'error', 'action' => 'back', 'message' => '권한이 없습니다.');
}
// check post
$errorValue = Util::checkExistValue($post, array('title', 'content'));
if ($errorValue) {
    return array('state' => 'error', 'action' => 'back', 'message' => "[{$errorValue}]값이 없습니다.");
}
// adjust value
if (!$isExternalTransaction) {
    $post['title'] = htmlspecialchars(addslashes($post['title']));
    $post['content'] = addslashes($post['content']);
}
// insert data
$result = Spawn::insert(array('table' => Spawn::getTableName($this->name), 'data' => array('srl' => null, 'app_srl' => (int) $post['app_srl'], 'nest_srl' => (int) $post['nest_srl'], 'category_srl' => (int) $post['category_srl'], 'title' => $post['title'], 'content' => $post['content'], 'hit' => 0, 'json' => $post['json'], 'ip' => $_SERVER['REMOTE_ADDR'], 'regdate' => date("YmdHis"), 'modate' => date("YmdHis")), 'debug' => false));
if ($result != 'success') {
    return array('state' => 'error', 'action' => 'back', 'message' => 'Fail execution database');
}
// get last insert srl
$last_srl = Spawn::getLastIdx();
// file upload
if (count($files['upload'])) {
    // load module
    $file = Module::load('file');
    // upload file
    $uploadFiles = $file->actUploadFiles($files['upload'], 'data/upload/original/', 'file', $last_srl);
}
// redirect url
$param = $post['nest_srl'] ? $post['nest_srl'] . '/' : '';
$param .= $post['nest_srl'] && $post['category_srl'] ? $post['category_srl'] . '/' : '';
Beispiel #4
0
<?php

if (!defined('__GOOSE__')) {
    exit;
}
// check user
if (!$this->isAdmin) {
    return array('state' => 'error', 'action' => 'back', 'message' => '권한이 없습니다.');
}
// check post
$errorValue = Util::checkExistValue($post, array('nest_srl', 'name'));
if ($errorValue) {
    return array('state' => 'error', 'action' => 'back', 'message' => "[{$errorValue}]값이 없습니다.");
}
// get max
$max = "select max(turn) as maximum from " . Spawn::getTableName($this->name);
$max = $this->goose->spawn->db->prepare($max);
$max->execute();
$max = (int) $max->fetchColumn();
$max += 1;
// insert data
$result = Spawn::insert(array('table' => Spawn::getTableName($this->name), 'data' => array('srl' => null, 'nest_srl' => $post['nest_srl'], 'turn' => $max, 'name' => $post['name'], 'regdate' => date('YmdHis'))));
if ($result != 'success') {
    return array('state' => 'error', 'action' => 'back', 'message' => 'Fail execution database');
}
// redirect url
$params = $post['nest_srl'] ? $post['nest_srl'] . '/' : '';
return array('state' => 'success', 'action' => 'redirect', 'url' => __GOOSE_ROOT__ . $this->name . '/index/' . $params);
Beispiel #5
0
<?php

if (!defined('__GOOSE__')) {
    exit;
}
// check user
if (!$this->isAdmin) {
    return array('state' => 'error', 'action' => 'back', 'message' => '권한이 없습니다.');
}
// check post
$errorValue = Util::checkExistValue($post, array('name', 'email', 'pw', 'level'));
if ($errorValue) {
    return array('state' => 'error', 'action' => 'back', 'message' => "[{$errorValue}]값이 없습니다.");
}
// 중복 이메일주소 감사
$cnt = Spawn::count(array('table' => Spawn::getTableName($this->name), 'where' => "email='{$post['email']}'"));
if ($cnt > 0) {
    return array('state' => 'error', 'action' => 'back', 'message' => '이메일주소가 이미 존재합니다.');
}
// check password
if ($post['pw'] != $post['pw2']) {
    return array('state' => 'error', 'action' => 'back', 'message' => '비밀번호와 비밀번호 확인값이 틀립니다.');
}
// insert data
$result = Spawn::insert(array('table' => Spawn::getTableName($this->name), 'data' => array('srl' => null, 'email' => $post['email'], 'name' => $post['name'], 'pw' => md5($post['pw']), 'level' => $post['level'], 'regdate' => date('YmdHis'))));
if ($result != 'success') {
    return array('state' => 'error', 'action' => 'back', 'message' => 'Fail execution database');
}
// redirect url
return array('state' => 'success', 'action' => 'redirect', 'url' => __GOOSE_ROOT__ . $this->name . '/index/');
Beispiel #6
0
<?php

if (!defined('__GOOSE__')) {
    exit;
}
// check user
if (!$this->isAdmin) {
    return array('state' => 'error', 'action' => 'back', 'message' => '권한이 없습니다.');
}
// check post
$errorValue = Util::checkExistValue($post, array('name', 'id', 'json'));
if ($errorValue) {
    return array('state' => 'error', 'action' => 'back', 'message' => "[{$errorValue}]값이 없습니다.");
}
// 아이디값 중복 확인
$cnt = Spawn::count(array('table' => Spawn::getTableName('nest'), 'where' => "id='{$post['id']}'"));
if ($cnt > 0) {
    return array('state' => 'error', 'action' => 'back', 'message' => 'id가 이미 존재합니다.');
}
// insert data
$result = Spawn::insert(array('table' => Spawn::getTableName('nest'), 'data' => array('srl' => null, 'app_srl' => (int) $post['app_srl'], 'id' => $post['id'], 'name' => $post['name'], 'json' => $post['json'], 'regdate' => date('YmdHis'))));
if ($result != 'success') {
    return array('state' => 'error', 'action' => 'back', 'message' => 'Fail execution database');
}
// redirect url
$params = $_SESSION['app_srl'] ? $_SESSION['app_srl'] : '';
return array('state' => 'success', 'action' => 'redirect', 'url' => __GOOSE_ROOT__ . 'nest/index/' . $params);
Beispiel #7
0
 /**
  * api - action file_tmp to file
  * file_tmp에 있는 db데이터를 file로 옮긴다.
  *
  * @param array $file_tmp_srls
  * @param int|null $article_srl
  * @return array
  */
 public function actDBFiletmpToFile($file_tmp_srls = array(), $article_srl = null)
 {
     if ($this->name != 'file') {
         return array('state' => 'error', 'message' => '잘못된 객체로 접근했습니다.');
     }
     if (!$this->isAdmin) {
         return array('state' => 'error', 'message' => '권한이 없습니다.');
     }
     foreach ($file_tmp_srls as $k => $v) {
         $data = $this->getItem(array('table' => Spawn::getTableName('file_tmp'), 'where' => 'srl=' . (int) $v));
         $tmpData = $data['state'] == 'success' ? $data['data'] : null;
         $db_result = Spawn::insert(array('table' => Spawn::getTableName('file'), 'data' => array('srl' => null, 'article_srl' => $article_srl, 'name' => $tmpData['name'], 'loc' => $tmpData['loc'], 'type' => $tmpData['type'], 'size' => (int) $tmpData['size'], 'regdate' => $tmpData['regdate'])));
         if ($db_result != 'success') {
             return array('state' => 'error', 'message' => '[file] DB : Insert Error');
         }
         $db_result2 = Spawn::delete(array('table' => Spawn::getTableName('file_tmp'), 'where' => 'srl=' . (int) $v));
         if ($db_result2 != 'success') {
             return array('state' => 'error', 'message' => '[file_tmp] DB : remove Error');
         }
     }
     return array('state' => 'success', 'message' => 'complete');
 }