public function getAcl($domain) { if ($_SESSION['ss_mb_id'] && !$_SESSION['user']['uid']) { $dbm = \CADB\DBM::instance(); if ($_SESSION['ss_mb_id']) { $que = "SELECT * FROM `g5_member` WHERE `mb_id` = '" . $_SESSION['ss_mb_id'] . "'"; $row = $dbm->getFetchArray($que); if ($row['mb_no']) { $_SESSION['user'] = array('uid' => $row['mb_no'], 'glevel' => 11 - $row['mb_level']); $que = "SELECT * FROM {privilege} WHERE user_id = '" . addslashes($_SESSION['ss_mb_id']) . "'"; while ($row = $dbm->getFetchArray($que)) { $_SESSION['acl'][$domain][$row['oid']] = $row['role']; } if (!count($_SESSION['acl'])) { $_SESSION['user']['glevel'] = BITWISE_ATHENTICATED; } \CADB\Log::accessLog('login'); } } } if (!isset($_SESSION['acl'][$domain])) { $_SESSION['acl'][$domain] = array(); } return $_SESSION['acl'][$domain]; }
public static function getFields($table = "all", $active = 1) { $context = \CADB\Model\Context::instance(); if (!is_array($table)) { if ($table != 'all') { $table = array($table); } } $fields = array(); self::$fields = $context->getProperty('fields'); if (!self::$fields) { $dbm = \CADB\DBM::instance(); $que = "SELECT * FROM {fields} " . ($active ? "WHERE active = '" . $active . "' " : "") . "ORDER BY `table` ASC, idx ASC"; while ($row = $dbm->getFetchArray($que)) { self::$fields[$row['fid']] = self::fetchFields($row); } $context->setProperty('fields', self::$fields); } if ($table == 'all') { $fields = self::$fields; } else { foreach (self::$fields as $f => $v) { if (in_array($v['table'], $table)) { $fields[$f] = $v; } } } return $fields; }
public static function updatePrivileges($user_id, $oid, $role) { $dbm = \CADB\DBM::instance(); $que = "UPDATE {privilege} SET role = ? AND user_id = ? AND oid = ?"; $dbm->execute($que, array("dsd", $role, $user_id, $oid)); self::$log = "[" . $user_id . "]에게 조직: " . $oid . "에게 " . $role . "을 수정했습니다.\n"; }
public static function getList($page = 1, $limit = 50) { $dbm = \CADB\DBM::instance(); $que = "SELECT * FROM {log}" . self::makeQuery(); $que .= " LIMIT " . ($page - 1) * $limit . "," . $limit; $log = array(); while ($row = $dbm->getFetchArray($que)) { $log[] = self::fetchLog($row); } return $log; }
public static function search($cids, $q) { $dbm = \CADB\DBM::instance(); if (!is_array($cids)) { $cids = array($cids); } $que = "SELECT * FROM {taxonomy_terms} WHERE cid IN (" . implode(",", $cids) . ") AND name like '%" . $q . "%' AND current = '1' AND active = '1' ORDER BY cid ASC, parent ASC, idx ASC"; while ($row = $dbm->getFetchArray($que)) { $taxonomy_terms[$row['cid']][$row['tid']] = self::fetchTaxonomy($row); } return $taxonomy_terms; }
public static function checkAgreement($articles) { $context = \CADB\Model\Context::instance(); $domain = $context->getProperty('service.domain'); $__Acl = \CADB\Acl::instance(); if ($__Acl->imMaster()) { return true; } $role = $__Acl->getAcl(); $dbm = \CADB\DBM::instance(); $nids = array(); $nids[] = $articles['nid']; for ($i = 4; $i >= 1; $i--) { if ($articles['p' . $i]) { $nids[] = $articles['p' . $i]; } } $que = "SELECT * FROM {agreement_organize} AS r LEFT JOIN {organize} AS o ON ( r.oid = o.oid AND r.vid = o.vid ) WHERE r.nid IN (" . implode(",", $nids) . ") ORDER BY depth ASC"; while ($row = $dbm->getFetchArray($que)) { if ($_SESSION['acl'][$domain][$row['oid']]) { $permit = $__Acl->checkAcl($_SESSION['acl'][$domain][$row['oid']]); if ($permit && $role >= BITWISE_OWNER && !$row['owner']) { $permit = false; } if ($permit == true) { return true; } } else { for ($d = min($row['depth'], 4); $d >= 1; $d--) { if ($row['p' . $d]) { $ret = self::checkOrganize($row['p' . $d]); if ($ret == true) { return true; } } } } } return false; }
public static function getAgreementsByOid($oid, $vid = 0, $current = 1) { $dbm = \CADB\DBM::instance(); if ($vid) { $que = "SELECT a.* FROM {agreement_organize} AS r LEFT JOIN {agreement} AS a ON ( r.nid = a.nid AND r.did = a.did ) WHERE r.oid = " . $oid . " AND r.vid = " . $vid; } else { $que = "SELECT a.* FROM {agreement_organize} AS r LEFT JOIN {agreement} AS a ON ( r.nid = a.nid AND r.did = a.did ) WHERE r.oid = " . $oid . ($current ? " AND a.`current` = '1'" : "") . " ORDER BY r.did"; } $articles = array(); while ($row = $dbm->getFetchArray($que)) { if ($row) { $article[] = self::fetchAgreement($row); } } return $article; }
if (!defined('ROOT')) { $__root_fullpath = rtrim(dirname(__FILE__), "include"); $__root_pathcount = explode("/", substr(dirname($_SERVER['SCRIPT_FILENAME']), strlen($__root_fullpath))); $__root_path = ""; for ($i = 0; $i < @count($__root_pathcount); $i++) { $__root_path .= ($i > 0 ? "/" : "") . ".."; } define('ROOT', $__root_path); } require_once ROOT . '/config/config.php'; define('__CADB_LOADED_CLASS__', true); $browser = new Browser(); $cadb_config = \CADB\Model\Config::instance(); $context = \CADB\Model\Context::instance(); $context->setProperty('service.base_uri', CADB_URI); try { if (!is_null($context->getProperty('database.DB'))) { $cadb_db = $context->getProperty('database.*'); $dbm = \CADB\DBM::instance(); $dbm->bind($cadb_db, 1); register_shutdown_function(array($dbm, 'release')); } $__Acl = \CADB\Acl::instance(); $__Acl->getPrivilege(); $themes = new \CADB\Themes(); $themes->themeHeader(); // $dbm->release(); } catch (Exception $e) { $logger = \CADB\Logger::instance(); $logger->Error($e); }
public static function forkClause($row, $nid) { $dbm = \CADB\DBM::instance(); $que = "INSERT INTO {guide_clause} ("; $que2 = ") VALUES ("; $array1 = 'array("'; $array2 = ""; $c = 0; $old_nid = $row['nid']; foreach ($row as $k => $v) { if ($k == 'id') { continue; } $que .= ($c ? ", " : "") . "`" . $k . "`"; $que2 .= ($c ? ", " : "") . "?"; if (is_numeric($v)) { $array1 .= 'd'; } else { $row[$k] = stripslashes($v); $array1 .= 's'; } if ($k == 'nid') { $row[$k] = $nid; } if ($k == 'parent' && (int) $v > 0) { if (!self::$parentIndex[$row['parent']]) { self::setErrorMsg($row['parent'] . "의 parentIndex가 연산되지 않았습니다."); return -1; } $row[$k] = self::$parentIndex[$row['parent']]; } $array2 .= ($c ? ", " : "") . '$' . 'row[' . $k . ']'; $c++; } $que2 .= ")"; $que = $que . $que2; $array1 .= '",'; $array2 .= ")"; $eval_str = '$' . "q_args = " . $array1 . $array2 . ";"; eval($eval_str); if ($dbm->execute($que, $q_args) < 1) { self::setErrorMsg($que . "가 DB에 반영되지 않았습니다."); return -1; } $insert_cid = $dbm->getLastInsertId(); self::$parentIndex[$row['id']] = $insert_cid; $taxo_rel = self::getClauseTerms($old_nid, $row['id']); if (is_array($taxo_rel)) { foreach ($taxo_rel as $t => $r) { $que = "INSERT INTO {taxonomy_term_relative} (`tid`,`table`,`rid`,`fid`) VALUES (?,?,?,?)"; if ($dbm->execute($que, array("dsdd", $t, 'guide_clause', $nid, $insert_cid)) < 1) { self::setErrorMsg($que . "가 DB에 반영되지 않았습니다."); return -1; } } } return $insert_cid; }
public static function delete($mb_no, $mb_id) { $dbm = \CADB\DBM::instance(); $que = "DELETE FROM `g5_member` WHERE mb_no = ?"; $dbm->execute($que, array("d", $mb_no)); self::$log = $mb_id . "(" . $mb_no . ") 회원을 GNU5 테이블에서 삭제했습니다.\n"; \CADB\Member\DBM::deletePrivilegeByID($mb_id); self::$log .= \CADB\Member\DBM::getLog(); \CADB\Log::memberLog('delete', $mb_no, self::$log); return 0; }
public static function getOrganizeByVid($vid) { $dbm = \CADB\DBM::instance(); $que = "SELECT * FROM {organize} WHERE `vid` = " . $vid; $row = $dbm->getFetchArray($que); $organize = self::fetchOrganize($row); return $organize; }
public static function resort($table, $index) { $dbm = \CADB\DBM::instance(); foreach ($index as $fid => $idx) { $que = "UPDATE {fields} SET `idx` = ? WHERE `table` = ? AND `fid` = ?"; $dbm->execute($que, array("dsd", $idx + 1, $table, $fid)); } self::$log .= "테이블: " . $table . "의 필드순서를 재조정했습니다.\n"; \CADB\Log::fieldLog('modify', 0, self::$log); }
public static function taxonomytermLog($action = "modify", $cid, $tid = 0, $vid = 0, $memo = "") { $dbm = \CADB\DBM::instance(); $member = self::getMember(); if (!$member) { return; } $action = "taxonomy_term:" . $action; $que = "INSERT INTO {log} (`action`,`oid`,`fid`,`vid`,`editor`,`name`,`modified`,`ipaddress`,`memo`) VALUES (?,?,?,?,?,?,?,?,?)"; $dbm->execute($que, array("sddddsdss", $action, $cid, $fid ? $fid : 0, $vid ? $vid : 0, $_SESSION['user']['uid'], $member['name'], time(), $_SERVER['REMOTE_ADDR'], $memo)); }
public static function deleteTerm($terms) { $dbm = \CADB\DBM::instance(); $que = "DELETE FROM {taxonomy_terms} WHERE `cid` = ? AND `tid` = ?"; $dbm->execute($que, array("dd", $terms['cid'], $terms['tid'])); $que = "UPDATE {taxonomy_terms} SET idx = idx - 1 WHERE `cid` = ? AND `parent` = ? AND idx >= ? ORDER BY idx ASC"; $dbm->execute($que, array("ddd", $terms['cid'], $terms['parent'], $terms['idx'])); if ($terms['parent']) { $que = "UPDATE {taxonomy_terms} SET nsubs = nsubs - 1 WHERE `cid` = ? AND `tid` = ?"; $dbm->execute($que, array("dd", $terms['cid'], $terms['parent'])); } self::$log = "분류항목 [" . $terms['name'] . "] 을 삭제했습니다.\n"; \CADB\Log::taxonomytermLog('delete', $terms['cid'], $terms['tid'], $terms['vid'], self::$log); }
private static function copy($table, $args, $nid = 0) { $dbm = \CADB\DBM::instance(); $que = "INSERT INTO {" . $table . "} ("; $que2 = ") VALUES ("; $array1 = 'array("'; $array2 = ""; $c = 0; foreach ($args as $k => $v) { if ($k == 'nid' || $k == 'rid' || $k == 'did') { if ($nid) { $que .= ($c ? ", " : "") . "`" . $k . "`"; $que2 .= ($c ? ", " : "") . "?"; if (is_numeric($v)) { $array1 .= 'd'; } else { $array1 .= 's'; } $array2 .= ($c ? ", " : "") . '$' . 'nid'; } } else { $que .= ($c ? ", " : "") . "`" . $k . "`"; $que2 .= ($c ? ", " : "") . "?"; if (is_numeric($v)) { $array1 .= 'd'; } else { $array1 .= 's'; } $array2 .= ($c ? ", " : "") . '$' . 'args[' . $k . ']'; } } }
public static function reBuildTaxonomy($oid, $vid, $taxonomy_map) { $dbm = \CADB\DBM::instance(); if (is_array($taxonomy_map)) { foreach ($taxonomy_map as $cid => $option_taxonomies) { if (is_array($option_taxonomies)) { foreach ($option_taxonomies as $option => $taxonomies) { switch ($option) { case "add": if (is_array($taxonomies)) { foreach ($taxonomies as $tid => $term) { $que = "INSERT INTO {taxonomy_term_relative} (`tid`, `table`, `rid`, `fid`) VALUES (?,?,?,?)"; if ($dbm->execute($que, array("dsdd", $tid, 'organize', $oid, $term['fid'])) < 1) { self::setErrorMsg($que . " 가 DB에 반영되지 않았습니다."); return -1; } self::$log .= "[" . $oid . "] 조직에 " . $term['name'] . " 분류항목을 연결했습니다.\n"; } } break; case "delete": if (is_array($taxonomies)) { foreach ($taxonomies as $tid => $term) { $que = "DELETE FROM {taxonomy_term_relative} WHERE `tid` = ? AND `table` = ? AND `rid` = ?"; if ($dbm->execute($que, array("dsd", $tid, 'organize', $oid)) < 1) { self::setErrorMsg($que . " 가 DB에 반영되지 않았습니다."); return -1; } self::$log .= "[" . $oid . "] 조직에 [" . $tid . "] 분류항목 연결을 해지했습니다.\n"; } } break; default: break; } } } } } return 0; }
public static function getClauses() { $dbm = \CADB\DBM::instance(); $nid = self::$guide['nid']; $que = "SELECT id,parent,idx,subject FROM {guide_clause} ORDER BY parent ASC, idx ASC"; $_clauses = array(); while ($row = $dbm->getFetchArray($que)) { $clauses[] = self::fetchGuideClause($row); } return $clauses; }