Example #1
0
        // load file module
        if (file_exists(__GOOSE_PWD__ . $article_json['thumnail']['url'])) {
            unlink(__GOOSE_PWD__ . $article_json['thumnail']['url']);
        }
        // upload
        $thumnailUrl = uploadThumnail($_POST['thumnail_image']);
        // set json
        $new_article_json['thumnail']['srl'] = $thumnail_srl;
        $new_article_json['thumnail']['url'] = $thumnailUrl;
        $thumnailUploaded = true;
    }
    // 썸네일 이미지는 있고, 썸네일 이미지가 새로 만들어지지 않을때
    if ($article_json['thumnail']['srl'] && !$thumnailUploaded) {
        // get article item data
        $filesCount = Spawn::count(array('table' => Spawn::getTableName('file'), 'where' => 'article_srl=' . (int) $post['article_srl'] . ' and srl=' . (int) $article_json['thumnail']['srl']));
        if (!$filesCount) {
            // delete thumnail file
            if (file_exists(__GOOSE_PWD__ . $article_json['thumnail']['url'])) {
                unlink(__GOOSE_PWD__ . $article_json['thumnail']['url']);
            }
            // set json
            $new_article_json['thumnail'] = array('srl' => '0', 'url' => '', 'coords' => '');
        }
    }
    // convert array to json
    $json_result = Util::arrayToJson($new_article_json, true);
    // update article
    $result = Spawn::update(array('table' => Spawn::getTableName('article'), 'where' => 'srl=' . (int) $article_srl, 'data' => array("json='{$json_result}'")));
}
// return
return $dbUpdateResult;
Example #2
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', 'category_srl', 'name'));
if ($errorValue) {
    return array('state' => 'error', 'action' => 'back', 'message' => "[{$errorValue}]값이 없습니다.");
}
// update data
$result = Spawn::update(array('table' => Spawn::getTableName($this->name), 'where' => 'srl=' . (int) $post['category_srl'], 'data' => array("name='{$post['name']}'")));
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);
Example #3
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', 'json'));
if ($errorValue) {
    return array('state' => 'error', 'action' => 'back', 'message' => "[{$errorValue}]값이 없습니다.");
}
// update article
$result = Spawn::update(array('table' => Spawn::getTableName('article'), 'where' => "nest_srl=" . (int) $post['nest_srl'], 'data' => array("group_srl=" . (int) $post['group_srl'])));
// update nest
$result = Spawn::update(array('table' => Spawn::getTableName($this->name), 'where' => 'srl=' . (int) $post['nest_srl'], 'data' => array("app_srl=" . (int) $post['app_srl'], "name='{$post['name']}'", "json='{$post['json']}'")));
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);
 /**
  * Up like
  *
  * @param array $options : [
  *   article_srl
  *   header_key
  * ]
  * @return array
  */
 public function upLike($options)
 {
     if (!$this->checkAuthHeader($options['header_key'])) {
         return ['state' => 'error', 'message' => 'Path not allowed'];
     }
     if (!$options['article_srl']) {
         return ['state' => 'error', 'message' => 'not found article_srl'];
     }
     $article = Spawn::item(['table' => Spawn::getTableName('article'), 'where' => 'srl=' . $options['article_srl'], 'field' => 'srl,json']);
     if (!isset($article['json'])) {
         return ['state' => 'error', 'message' => 'not found article data'];
     }
     $article['json'] = Util::jsonToArray($article['json'], null, true);
     $like = isset($article['json']['like']) ? (int) $article['json']['like'] : 0;
     $article['json']['like'] = $like + 1;
     $json = Util::arrayToJson($article['json'], true);
     $result = Spawn::update(['table' => Spawn::getTableName('article'), 'data' => ['json=\'' . $json . '\''], 'where' => 'srl=' . (int) $options['article_srl']]);
     return $result == 'success' ? ['state' => 'success', 'message' => 'update complete'] : ['state' => 'error', 'message' => 'fail update complete'];
 }
Example #5
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']);
}
// update data
$result = Spawn::update(array('table' => Spawn::getTableName($this->name), 'where' => 'srl=' . (int) $post['article_srl'], 'data' => array("app_srl=" . (int) $post['app_srl'], "nest_srl=" . (int) $post['nest_srl'], "category_srl=" . (int) $post['category_srl'], "title='" . $post['title'] . "'", "content='{$post['content']}'", "json='{$post['json']}'", "modate='" . date("YmdHis") . "'")));
if ($result != 'success') {
    return array('state' => 'error', 'action' => 'back', 'message' => 'Fail execution database');
}
// load module
$file = Module::load('file');
// remove files
if (count($post['removeFiles'])) {
    $result = $file->actRemoveFile($post['removeFiles'], 'file');
}
// file upload
if (count($files['upload'])) {
    $result = $file->actUploadFiles($files['upload'], 'data/upload/original/', 'file', $post['article_srl']);
}
// redirect url
$param = $post['category_srl'] ? $post['category_srl'] . '/' : '';
Example #6
0
<?php

if (!defined('__GOOSE__')) {
    exit;
}
// check user
if (!$this->isAdmin && $post['email'] != $_SESSION['goose_email']) {
    return array('state' => 'error', 'action' => 'back', 'message' => '권한이 없습니다.');
}
// check post
$errorValue = Util::checkExistValue($post, array('name', 'level'));
if ($errorValue) {
    return array('state' => 'error', 'action' => 'back', 'message' => "[{$errorValue}]값이 없습니다.");
}
// check password
if ($post['pw'] && $post['pw'] != $post['pw2']) {
    return array('state' => 'error', 'action' => 'back', 'message' => '비밀번호와 비밀번호 확인값이 틀립니다.');
}
// update data
$result = Spawn::update(array('table' => Spawn::getTableName($this->name), 'where' => 'srl=' . (int) $post['user_srl'], 'data' => array("name='" . $post['name'] . "'", "level=" . (int) $post['level'], $post['pw'] ? "pw='" . md5($post['pw']) . "'" : null)));
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/');
Example #7
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', 'srls'));
if ($errorValue) {
    return array('state' => 'error', 'action' => 'back', 'message' => "[{$errorValue}]값이 없습니다.");
}
// set srls
$srls = explode(',', $post['srls']);
// update db
for ($i = 0; $i < count($srls); $i++) {
    $result = Spawn::update(array('table' => Spawn::getTableName($this->name), 'where' => 'srl=' . (int) $srls[$i], 'data' => array('turn=' . $i)));
}
// redirect url
$params = $post['nest_srl'] ? $post['nest_srl'] . '/' : '';
return array('state' => 'success', 'action' => 'redirect', 'url' => __GOOSE_ROOT__ . $this->name . '/index/' . $params);