Exemplo n.º 1
0
 function store()
 {
     $msg = $this->check();
     if ($msg) {
         return get_class($this) . "::store-check failed";
     }
     $q = new DBQuery();
     if ($this->user_id) {
         // save the old password
         $perm_func = "updateLogin";
         $q->addTable('users');
         $q->addQuery('user_password');
         $q->addWhere("user_id = {$this->user_id}");
         $pwd = $q->loadResult();
         if ($pwd != $this->user_password) {
             $this->user_password = md5($this->user_password);
             addHistory($this->_tbl, $this->user_id, 'password changed', 'Password changed from IP ' . $_SERVER['REMOTE_ADDR']);
         } else {
             $this->user_password = null;
         }
         $ret = db_updateObject('users', $this, 'user_id', false);
     } else {
         $perm_func = "addLogin";
         $this->user_password = md5($this->user_password);
         $ret = db_insertObject('users', $this, 'user_id');
     }
     if (!$ret) {
         return get_class($this) . "::store failed <br />" . db_error();
     } else {
         $acl =& $GLOBALS['AppUI']->acl();
         $acl->{$perm_func}($this->user_id, $this->user_username);
         return NULL;
     }
 }
Exemplo n.º 2
0
 function delete()
 {
     $q = new DBQuery();
     $q->setDelete('forum_visits');
     $q->addWhere('visit_forum = ' . $this->forum_id);
     $q->exec();
     // No error if this fails, it is not important.
     $q->clear();
     $q->setDelete('forums');
     $q->addWhere('forum_id = ' . $this->forum_id);
     if (!$q->exec()) {
         $q->clear();
         return db_error();
     }
     // $sql = "DELETE FROM forum_messages WHERE message_forum = $this->forum_id";
     $q->clear();
     $q->setDelete('forum_messages');
     $q->addWhere('message_forum = ' . $this->forum_id);
     if (!$q->exec()) {
         $result = db_error();
     } else {
         addHistory('forums', $this->forum_id, 'delete', $this->forum_name);
         $result = NULL;
     }
     $q->clear();
     return $result;
 }
 function delete()
 {
     global $dPconfig;
     $this->_message = "deleted";
     addHistory('files', $this->file_id, 'delete', $this->file_name, $this->file_project);
     // remove the file from the file system
     @unlink("{$dPconfig['root_dir']}/files/{$this->file_project}/{$this->file_real_filename}");
     // delete any index entries
     $q = new DBQuery();
     $q->setDelete('files_index');
     $q->addQuery('*');
     $q->addWhere("file_id = {$this->file_id}");
     if (!$q->exec()) {
         $q->clear();
         return db_error();
     }
     // delete the main table reference
     $q->clear();
     $q->setDelete('files');
     $q->addQuery('*');
     $q->addWhere("file_id = {$this->file_id}");
     if (!$q->exec()) {
         $q->clear();
         return db_error();
     }
     $q->clear();
     return NULL;
 }
Exemplo n.º 4
0
function prepareRequestAndAddHistory($PRP)
{
    $defaultPRP = array('doNotExecute' => false, 'exitOnComplete' => false, 'doNotShowUser' => false, 'directExecute' => false, 'signature' => false, 'timeout' => DEFAULT_MAX_CLIENT_REQUEST_TIMEOUT, 'runCondition' => false, 'status' => 'pending', 'isPluginResponse' => 1, 'sendAfterAllLoad' => false, 'callOpt' => array());
    $PRP = array_merge($defaultPRP, $PRP);
    @extract($PRP);
    if (empty($historyAdditionalData)) {
        echo 'noHistoryAdditionalData';
        return false;
    }
    if ($siteData['connectURL'] == 'default' && defined('CONNECT_USING_SITE_URL') && CONNECT_USING_SITE_URL == 1 || $siteData['connectURL'] == 'siteURL') {
        $URL = $siteData['URL'];
    } else {
        //if($siteData['connectURL'] == 'default' || $siteData['connectURL'] == 'adminURL')
        $URL = $siteData['adminURL'];
    }
    $historyData = array('siteID' => $siteData['siteID'], 'actionID' => Reg::get('currentRequest.actionID'), 'userID' => $GLOBALS['userID'], 'type' => $type, 'action' => $action, 'events' => $events, 'URL' => $URL, 'timeout' => $timeout, 'isPluginResponse' => $isPluginResponse);
    if ($doNotShowUser) {
        $historyData['showUser'] = '******';
    }
    if ($parentHistoryID) {
        $historyData['parentHistoryID'] = $parentHistoryID;
    }
    if (!empty($siteData['callOpt'])) {
        $callOpt = @unserialize($siteData['callOpt']);
    }
    if (!empty($siteData['httpAuth'])) {
        $callOpt['httpAuth'] = @unserialize($siteData['httpAuth']);
    }
    if (!empty($runCondition)) {
        $historyData['runCondition'] = $runCondition;
    }
    if (!empty($timeScheduled)) {
        $historyData['timeScheduled'] = $timeScheduled;
    }
    $historyData['callOpt'] = serialize($callOpt);
    $historyID = addHistory($historyData, $historyAdditionalData);
    if ($signature === false) {
        $signature = signData($requestAction . $historyID, $siteData['isOpenSSLActive'], $siteData['privateKey'], $siteData['randomSignature']);
    }
    $requestParams['username'] = $siteData['adminUsername'];
    if (isset($requestParams['secure'])) {
        $requestParams['secure'] = secureData($requestParams['secure'], $siteData['isOpenSSLActive'], $siteData['privateKey'], $siteData['randomSignature']);
    }
    if (!empty($requestParams['args'])) {
        $requestParams['args']['parentHID'] = $historyID;
    }
    $requestData = array('iwp_action' => $requestAction, 'params' => $requestParams, 'id' => $historyID, 'signature' => $signature, 'iwp_admin_version' => APP_VERSION);
    $updateHistoryData = array('status' => $status);
    updateHistory($updateHistoryData, $historyID);
    DB::insert("?:history_raw_details", array('historyID' => $historyID, 'request' => base64_encode(serialize($requestData)), 'panelRequest' => serialize($_REQUEST)));
    if ($directExecute) {
        set_time_limit(0);
        echo 'direct_execute<br />';
        executeRequest($historyID, $type, $action, $siteData['URL'], $requestData, $timeout, true, $callOpt);
    } else {
        echo 'async_call_it_should_be<br />';
        if ($exitOnComplete) {
            set_time_limit(0);
            echo "async_call_it_should_be_working";
            Reg::set('currentRequest.exitOnComplete', true);
        } elseif ($sendAfterAllLoad) {
            Reg::set('currentRequest.sendAfterAllLoad', true);
        }
    }
    return $historyID;
}
Exemplo n.º 5
0
    // --- TBL: val
    foreach ($_REQUEST as $val_name => $value) {
        if (strpos($val_name, 'input_') !== false) {
            $value = urldecode($value);
            $rslt = updVal($db, $file_id, $val_name, $value);
            if (!$rslt) {
                \Sop\Log::error(__FILE__, __LINE__, 'Failed to update val.');
                $msg012 = "The update failed.: val";
                // 更新に失敗しました: val
                \Sop\Api::exitWithError(array("{$msg012} {$value} (: {$val_name})"));
            }
        }
    }
    // --- TBL: history
    $history_id = -1;
    $rslt = addHistory($db, $history_id, $pj_id, $sop_id, $tpl_id, $schema_id, $file_id, $smpl_given_no, $HISTORY_ACTION_FILE_UPD, $date, $user_id, $user_id_2, null);
    if (!$rslt) {
        \Sop\Log::error(__FILE__, __LINE__, 'Failed to add history.');
        $msg013 = "The update failed.: history";
        // 更新に失敗しました: history
        \Sop\Api::exitWithError(array($msg013));
    }
}
// --- フォームの最終更新日時の更新。
$rslt = updValLastUpdateTime($db, $file_id, $target_val_name, $update_time);
if (!$rslt) {
    \Sop\Log::error(__FILE__, __LINE__, 'Failed to update last update time.');
    $msg014 = "Failed to update last update time.: val";
    // フォーム最終更新時刻の更新に失敗しました: val
    \Sop\Api::exitWithError(array($msg014));
    exit;
Exemplo n.º 6
0
         $r->addOrder('user_access_log_id');
         //execute query and fetch results
         $r->exec();
         $boot_query_row = $r->fetchRow();
         if ($boot_query_row) {
             $boot_user_session = $boot_query_row['session_id'];
             $boot_user_log_id = $boot_query_row['user_access_log_id'];
         }
     }
 }
 do {
     if ($boot_user_id == $AppUI->user_id && $boot_user_session == $_COOKIE['PHPSESSID']) {
         $AppUI->resetPlace();
         $AppUI->redirect('logout=-1');
     } else {
         addHistory('login', $boot_user_id, 'logout', $details);
         w2PsessionDestroy($boot_user_session, $boot_user_log_id);
     }
     if ($boot_query_row) {
         $boot_query_row = $r->fetchRow();
         if ($boot_query_row) {
             $boot_user_session = $boot_query_row['session_id'];
             $boot_user_log_id = $boot_query_row['user_access_log_id'];
         } else {
             $r->clear();
         }
     }
 } while ($boot_query_row);
 $msg = $boot_user_name . ' logged out by ' . $AppUI->user_first_name . ' ' . $AppUI->user_last_name;
 $AppUI->setMsg($msg, UI_MSG_OK);
 $AppUI->redirect('m=admin&tab=3');
Exemplo n.º 7
0
 /**
  * @todo Parent store could be partially used
  * @todo Can't delete a task with children
  */
 function delete()
 {
     if (!$this->task_id) {
         return 'invalid task id';
     }
     $q = new DBQuery();
     if (dPgetConfig('check_task_empty_dynamic') && $this->task_parent != $this->task_id) {
         //Check that we are not deleting the only child of a dynamic parent task
         $task_test = new CTask();
         $task_test->load($this->task_parent);
         $siblings = $task_test->getChildren();
         if ($task_test->task_dynamic == 1 && count($siblings) <= 1) {
             return 'BadDyn_NoChild';
         }
     }
     //load task first because we need info on it to update the parent tasks later
     $task = new CTask();
     $task->load($this->task_id);
     //get child tasks so we can delete them too (no orphans)
     $childrenlist = $task->getDeepChildren();
     //delete task (if we're actually allowed to delete this task)
     $err_msg = parent::delete($task->task_id, $task->task_name, $task->task_project);
     if ($err_msg) {
         return $err_msg;
     }
     $this->_action = 'deleted';
     if ($task->task_parent != $task->task_id) {
         //Has parent, run the update sequence, this child will no longer be in the database
         $this->updateDynamics();
     }
     $q->clear();
     //delete children
     if (!empty($childrenlist)) {
         foreach ($childrenlist as $child_id) {
             $ctask = new CTask();
             $ctask->load($child_id);
             //ignore permissions on child tasks by deleteing task directly from the database
             $q->setDelete('tasks');
             $q->addWhere('task_id=' . $ctask->task_id);
             if (!$q->exec()) {
                 return db_error();
             }
             $q->clear();
             addHistory('tasks', $ctask->task_id, 'delete', $ctask->task_name, $ctask->task_project);
             $this->updateDynamics();
             //to update after children are deleted (see above)
         }
         $this->_action = 'deleted with children';
     }
     //delete affiliated task_logs (overrides any task_log permissions)
     $q->setDelete('task_log');
     if (!empty($childrenlist)) {
         $q->addWhere('task_log_task IN (' . implode(', ', $childrenlist) . ', ' . $this->task_id . ')');
     } else {
         $q->addWhere('task_log_task=' . $this->task_id);
     }
     if (!$q->exec()) {
         return db_error();
     }
     $q->clear();
     //delete affiliated task_dependencies
     $q->setDelete('task_dependencies');
     if (!empty($childrenlist)) {
         $q->addWhere('dependencies_task_id IN (' . implode(', ', $childrenlist) . ', ' . $task->task_id . ')');
     } else {
         $q->addWhere('dependencies_task_id=' . $task->task_id);
     }
     if (!$q->exec()) {
         return db_error();
     }
     $q->clear();
     // delete linked user tasks
     $q->setDelete('user_tasks');
     if (!empty($childrenlist)) {
         $q->addWhere('task_id IN (' . implode(', ', $childrenlist) . ', ' . $task->task_id . ')');
     } else {
         $q->addWhere('task_id=' . $task->task_id);
     }
     if (!$q->exec()) {
         return db_error();
     }
     $q->clear();
     return NULL;
 }
Exemplo n.º 8
0
 function store()
 {
     $this->dPTrimAll();
     $msg = $this->check();
     if ($msg) {
         return get_class($this) . '::store-check failed - ' . $msg;
     }
     if ($this->project_id) {
         $ret = db_updateObject('projects', $this, 'project_id', false);
         addHistory('projects', $this->project_id, 'update', $this->project_name, $this->project_id);
     } else {
         $ret = db_insertObject('projects', $this, 'project_id');
         addHistory('projects', $this->project_id, 'add', $this->project_name, $this->project_id);
     }
     //split out related departments and store them seperatly.
     $q = new DBQuery();
     $q->setDelete('project_departments');
     $q->addWhere('project_id=' . $this->project_id);
     $q->exec();
     $q->clear();
     if ($this->project_departments) {
         $departments = explode(',', $this->project_departments);
         foreach ($departments as $department) {
             $q->addTable('project_departments');
             $q->addInsert('project_id', $this->project_id);
             $q->addInsert('department_id', $department);
             $q->exec();
             $q->clear();
         }
     }
     //split out related contacts and store them seperatly.
     $q->setDelete('project_contacts');
     $q->addWhere('project_id=' . $this->project_id);
     $q->exec();
     $q->clear();
     if ($this->project_contacts) {
         $contacts = explode(',', $this->project_contacts);
         foreach ($contacts as $contact) {
             if ($contact) {
                 $q->addTable('project_contacts');
                 $q->addInsert('project_id', $this->project_id);
                 $q->addInsert('contact_id', $contact);
                 $q->exec();
                 $q->clear();
             }
         }
     }
     return !$ret ? get_class($this) . '::store failed <br />' . db_error() : NULL;
 }
Exemplo n.º 9
0
// and HTTP auth methods now supported.
if (isset($_POST['login'])) {
    $username = w2PgetCleanParam($_POST, 'username', '');
    $password = w2PgetCleanParam($_POST, 'password', '');
    $redirect = w2PgetCleanParam($_POST, 'redirect', '');
    $AppUI->setUserLocale();
    @(include_once W2P_BASE_DIR . '/locales/' . $AppUI->user_locale . '/locales.php');
    include_once W2P_BASE_DIR . '/locales/core.php';
    $ok = $AppUI->login($username, $password);
    if (!$ok) {
        $AppUI->setMsg('Login Failed', UI_MSG_ERROR);
    } else {
        //Register login in user_acces_log
        $AppUI->registerLogin();
    }
    addHistory('login', $AppUI->user_id, 'login', $AppUI->user_first_name . ' ' . $AppUI->user_last_name);
    $AppUI->redirect('' . $redirect);
}
// set the default ui style
$uistyle = $AppUI->getPref('UISTYLE') ? $AppUI->getPref('UISTYLE') : w2PgetConfig('host_style');
// clear out main url parameters
$m = '';
$a = '';
$u = '';
// check if we are logged in
if ($AppUI->doLogin()) {
    // load basic locale settings
    $AppUI->setUserLocale();
    @(include_once './locales/' . $AppUI->user_locale . '/locales.php');
    include_once './locales/core.php';
    setlocale(LC_TIME, $AppUI->user_lang);
Exemplo n.º 10
0
 public function store(CAppUI $AppUI)
 {
     $perms = $AppUI->acl();
     $stored = false;
     $errorMsgArray = $this->check();
     if (count($errorMsgArray) > 0) {
         return $errorMsgArray;
     }
     if ($this->link_id && $perms->checkModuleItem('links', 'edit', $this->link_id)) {
         $q = new DBQuery();
         $this->link_date = $q->dbfnNow();
         if ($msg = parent::store()) {
             return $msg;
         }
         addHistory('links', $this->link_id, 'update', $this->link_name, $this->link_id);
         $stored = true;
     }
     if (0 == $this->link_id && $perms->checkModuleItem('links', 'add')) {
         $q = new DBQuery();
         $this->link_date = $q->dbfnNow();
         if ($msg = parent::store()) {
             return $msg;
         }
         addHistory('links', $this->link_id, 'add', $this->link_name, $this->link_id);
         $stored = true;
     }
     return $stored;
 }
Exemplo n.º 11
0
 public function store(CAppUI $AppUI)
 {
     $perms = $AppUI->acl();
     $stored = false;
     $errorMsgArray = $this->check();
     if (count($errorMsgArray) > 0) {
         return $errorMsgArray;
     }
     $this->company_id = (int) $this->company_id;
     /*
      * TODO: I don't like the duplication on each of these two branches, but I
      *   don't have a good idea on how to fix it at the moment...
      */
     if ($this->company_id && $perms->checkModuleItem('companies', 'edit', $this->company_id)) {
         if ($msg = parent::store()) {
             return $msg;
         }
         addHistory('companies', $this->company_id, 'update', $this->company_name, $this->company_id);
         $stored = true;
     }
     if (0 == $this->company_id && $perms->checkModuleItem('companies', 'add')) {
         if ($msg = parent::store()) {
             return $msg;
         }
         addHistory('companies', $this->company_id, 'add', $this->company_name, $this->company_id);
         $stored = true;
     }
     if ($stored) {
         $custom_fields = new CustomFields('companies', 'addedit', $this->company_id, 'edit');
         $custom_fields->bind($_POST);
         $sql = $custom_fields->store($this->company_id);
         // Store Custom Fields
     }
     return $stored;
 }
Exemplo n.º 12
0
// ---------------------------
// データ登録
// ---------------------------
$db->beginTransaction();
$date = date("Y-m-d H:i:s");
// --- TBL: tpl
$rslt = updTplDetail($db, $tpl_id, $tpl_name, $upld_cmnt);
if (!$rslt) {
    \Sop\Log::error(__FILE__, __LINE__, 'Failed to update tpl.');
    $msg002 = "The update failed.: tpl";
    // 更新に失敗しました: tpl
    \Sop\Api::exitWithError(array($msg002));
}
// --- TBL: history
$history_id = -1;
$rslt = addHistory($db, $history_id, $pj_id, $sop_id, $tpl_id, $schema_id, null, null, $HISTORY_ACTION_TPL_DETAIL_EDIT, $date, $user_id, null, $upld_cmnt);
if (!$rslt) {
    \Sop\Log::error(__FILE__, __LINE__, 'Failed to add history.');
    $msg003 = "The registoration failed: history";
    // 登録に失敗しました: history
    \Sop\Api::exitWithError(array($msg003));
}
// ---------------------------
// 終了処理
// ---------------------------
$db->commit();
$db = null;
$msg004 = "The edit complted.";
// 編集が完了しました
echo json_encode(array('success' => true, 'msg' => \Sop\Api::htmlEncodeLines(array($msg004)), 'role_aprv' => (bool) $role_aprv, 'role_upld' => (bool) $role_upld));
exit;
Exemplo n.º 13
0
    \Sop\Log::error(__FILE__, __LINE__, 'Failed to delete clmn.');
    $msg010 = "The delete failed.: clmn";
    // 削除に失敗しました: clmn
    \Sop\Api::exitWithError(array($msg010));
}
// --- TBL: row
$rslt = delPjRow($db, $pj_id);
if (!$rslt) {
    \Sop\Log::error(__FILE__, __LINE__, 'Failed to delete row.');
    $msg011 = "The delete failed.: row";
    // 削除に失敗しました: row
    \Sop\Api::exitWithError(array(_("削除に失敗しました: row")));
}
// --- TBL: history
$history_id = -1;
$rslt = addHistory($db, $history_id, $pj_id, null, null, null, null, null, $HISTORY_ACTION_PJ_DEL, date("Y-m-d H:i:s"), $user_id, null, null);
if (!$rslt) {
    \Sop\Log::error(__FILE__, __LINE__, 'Failed to delete history.');
    $msg012 = "The delete failed.: history";
    // 削除に失敗しました: history
    \Sop\Api::exitWithError(array($msg012));
}
// ---------------------------
// ファイル削除
// ---------------------------
foreach ($file_path_list as $file_path) {
    if (file_exists($file_path)) {
        unlink($file_path);
    }
}
// ---------------------------
Exemplo n.º 14
0
        \Sop\Api::exitWithError(array($msg005));
    }
}
if ($div == 'upd') {
    // --- TBL: sop
    $rslt = updSop($db, $sop_id, $sop_name, $checker_required_flag);
    if (!$rslt) {
        \Sop\Log::error(__FILE__, __LINE__, 'Failed to update sop.');
        $msg006 = "The update failed.: sop";
        // 更新に失敗しました: sop
        \Sop\Api::exitWithError(array($msg006));
        exit;
    }
    // --- TBL: history
    $history_id = -1;
    $rslt = addHistory($db, $history_id, $pj_id, $sop_id, null, null, null, null, $HISTORY_ACTION_SOP_UPD, date("Y-m-d H:i:s"), $user_id, null, null);
    if (!$rslt) {
        \Sop\Log::error(__FILE__, __LINE__, 'Failed to add history.');
        $msg007 = "The update failed.: history";
        // 更新に失敗しました: history
        \Sop\Api::exitWithError(array($msg007));
    }
}
// ---------------------------
// 終了処理
// ---------------------------
$db->commit();
$db = null;
if ($div == 'add') {
    $msg008 = "The registration completed.";
    // 登録が完了しました
Exemplo n.º 15
0
function add2Room($clientID, $user_id, $room)
{
    global $Server;
    $mes = 'Приглашен в комнату пользователем ' . $Server->wsClients[$clientID][13];
    // sendMess($id, $data);
    addHistory($user_id, $mes, '000', $room);
    if (getRoom($room, $user_id)) {
        updateRoom($room, false, $user_id);
    } else {
        updateRoom($room);
    }
    foreach ($Server->wsClients as $id => $data) {
        if ($data[15] != $room) {
            if ($data[12] == $user_id) {
                sendMess($id, array('System', $Server->wsClients[$clientID][13] . ' пригласил Вас в чат <a href="index.php?module=kChat&room=' . $room . '">"' . getRoomName($room, $data[12]) . '"</a>', '000;font-weight:bolder'));
                getRooms($id);
            }
        } else {
            getUsers($id, $room);
        }
    }
}
Exemplo n.º 16
0
 public function import($AppUI)
 {
     $output = '';
     $company_id = (int) w2PgetParam($_POST, 'company_id', 0);
     if ($company_id == 0) {
         if (isset($_POST['new_company'])) {
             $companyName = w2PgetParam($_POST, 'new_company', 'New Company');
             $company = new CCompany();
             $company->company_name = $companyName;
             $company->company_owner = $AppUI->user_id;
             $AppUI->version_major <= 1 && $AppUI->version_minor <= 1 ? $company->store() : $company->store($AppUI);
             $company_id = $company->company_id;
             $output .= $AppUI->_('createcomp') . $companyName . '<br>';
             echo $output;
         } else {
             $error = $AppUI->_('emptycomp');
             return $error;
         }
     }
     $result = $this->_processProject($AppUI, $company_id, $_POST);
     if (is_array($result)) {
         $AppUI->setMsg($result, UI_MSG_ERROR);
         $AppUI->redirect('m=importers');
     }
     $this->project_id = $result;
     $q = new DBQuery();
     // Users Setup
     if (isset($_POST['users']) && is_array($_POST['users']) && $_POST['nouserimport'] != "true") {
         foreach ($_POST['users'] as $ruid => $r) {
             $q->clear();
             if (!empty($r['user_username'])) {
                 $result = $this->_processContact($AppUI, $r['user_username'], $company_id);
                 if (is_array($result)) {
                     $AppUI->setMsg($result, UI_MSG_ERROR);
                     $AppUI->redirect('m=importers');
                 }
                 $contact_id = $result;
                 //TODO:  Replace with the regular create users functionality
                 $q->addInsert('user_username', $r['user_username']);
                 $q->addInsert('user_contact', $contact_id);
                 $q->addTable('users');
                 $q->exec();
                 $insert_id = db_insert_id();
                 $r['user_id'] = $insert_id;
             } else {
                 $r['user_id'] = $r['user_userselect'];
             }
             if (!empty($r['user_id'])) {
                 $resources[$ruid] = $r;
             }
         }
     }
     // Tasks Setup
     foreach ($_POST['tasks'] as $k => $task) {
         $result = $this->_processTask($AppUI, $this->project_id, $task);
         if (is_array($result)) {
             $AppUI->setMsg($result, UI_MSG_ERROR);
             $AppUI->redirect('m=importers');
         }
         $task_id = $result;
         // Task Parenthood
         $outline[$task['OUTLINENUMBER']] = $task_id;
         $q->clear();
         if (!strpos($task['OUTLINENUMBER'], '.')) {
             $q->addUpdate('task_parent', $task_id);
             $q->addWhere('task_id = ' . $task_id);
             $q->addTable('tasks');
         } else {
             $parent_string = substr($task['OUTLINENUMBER'], 0, strrpos($task['OUTLINENUMBER'], '.'));
             $parent_outline = isset($outline[$parent_string]) ? $outline[$parent_string] : $task_id;
             $q->addUpdate('task_parent', $parent_outline);
             $q->addWhere('task_id = ' . $task_id);
             $q->addTable('tasks');
         }
         $q->exec();
         $task['task_id'] = $task_id;
         $tasks[$task['UID']] = $task;
         // Resources (Workers)
         if (count($task['resources']) > 0) {
             $sql = "DELETE FROM user_tasks WHERE task_id = {$task_id}";
             db_exec($sql);
             $resourceArray = array();
             foreach ($task['resources'] as $uk => $user) {
                 $alloc = $task['resources_alloc'][$uk];
                 if ($alloc > 0 && $resources[$user]['user_id'] > 0) {
                     $q->clear();
                     if (!in_array($resources[$user]['user_id'], $resourceArray)) {
                         $q->addInsert('user_id', $resources[$user]['user_id']);
                         $q->addInsert('task_id', $task_id);
                         $q->addInsert('perc_assignment', $alloc);
                         $q->addTable('user_tasks');
                         $q->exec();
                     }
                     $resourceArray[] = $resources[$user]['user_id'];
                 }
             }
         }
     }
     //dependencies have to be handled alone after all tasks have been saved since the
     //predecessor (ms project term) task might come later and the associated task id
     //is not yet available.
     foreach ($tasks as $k => $task) {
         // Task Dependencies
         if (isset($task['dependencies']) && is_array($task['dependencies'])) {
             $sql = "DELETE FROM task_dependencies WHERE dependencies_task_id = {$task_id}";
             db_exec($sql);
             $dependencyArray = array();
             foreach ($task['dependencies'] as $task_uid) {
                 if ($task_uid > 0 && $tasks[$task_uid]['task_id'] > 0) {
                     $q->clear();
                     if (!in_array($tasks[$task_uid]['task_id'], $dependencyArray)) {
                         $q->addInsert('dependencies_task_id', $task['task_id']);
                         $q->addInsert('dependencies_req_task_id', $tasks[$task_uid]['task_id']);
                         $q->addTable('task_dependencies');
                         $q->exec();
                     }
                     $dependencyTestArray[] = $tasks[$task_uid]['task_id'];
                 }
             }
         }
     }
     $this->_deDynamicLeafNodes($this->project_id);
     addHistory('projects', $this->project_id, 'add', $projectName, $this->project_id);
     return $output;
 }
  $_POST["password-login"] =  stripslashes(trim($_POST["password-login"]));
  
  // test if the password is correct
 if (check_login($_POST["email-login"], $_POST["password-login"]))
 {
    $_SESSION['qcs-isconnect'] = true;
    
    // HISTORY
    //////////////////////////////////////////////////////////////////////////
    
    require_once("qcs-admin/include/member.inc.php");
    require_once("qcs-admin/include/history.inc.php");
    
    $idMember = getIdMemberByEmail($_POST["email-login"]);
    
    addHistory($idMember , "connection");
    
    //////////////////////////////////////////////////////////////////////////
    
    // COOKIE
    $_SESSION['email-login'] = $_POST["email-login"];
    setcookie('loginQCS' , $_POST["email-login"] , mktime(0,0,0,12,31,2037) , '/');
    
    $qcsType = getMemberTypeById($idMember);
    setcookie('qcs-type' , $qcsType , mktime(0,0,0,12,31,2037) , '/');
    
   	header('Location:http://'.$_SERVER['HTTP_HOST'].'/member-area-index/');
    exit();
    
  } else {
    
Exemplo n.º 18
0
 /**
  *	Default delete method
  *
  *	Can be overloaded/supplemented by the child class
  *	@return null|string null if successful otherwise returns and error message
  */
 function delete($oid = null)
 {
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = intval($oid);
     }
     if (!$this->canDelete($msg)) {
         return $msg;
     }
     addHistory($this->_tbl, $this->{$k}, 'delete');
     $q = new DBQuery();
     $q->setDelete($this->_tbl);
     $q->addWhere("{$this->_tbl_key} = '" . $this->{$k} . "'");
     $result = null;
     if (!$q->exec()) {
         $result = db_error();
     }
     $q->clear();
     return $result;
 }
Exemplo n.º 19
0
 /**
  *	Default delete method
  *
  *	Can be overloaded/supplemented by the child class
  *	@return null|string null if successful otherwise returns and error message
  */
 public function delete($oid = null)
 {
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = intval($oid);
     }
     if (!$this->canDelete($msg)) {
         return $msg;
     }
     $q = new DBQuery();
     $q->setDelete($this->_tbl);
     $q->addWhere($this->_tbl_key . ' = \'' . $this->{$k} . '\'');
     $result = !$q->exec() ? db_error() : null;
     if (!$result) {
         // only record history if deletion actually occurred
         addHistory($this->_tbl, $this->{$k}, 'delete');
     }
     $q->clear();
     return $result;
 }
Exemplo n.º 20
0
        }
    }
    if ($div == 'upd') {
        // --- TBL: form
        $rslt = updForm($db, $form_id, $pj_id, $sop_id, $tpl_id, $x, $y, $width, $height, $element_type, $default_value);
        if (!$rslt) {
            \Sop\Log::error(__FILE__, __LINE__, 'Failed to update form.');
            $msg004 = "The update failed.";
            // 更新に失敗しました: form
            \Sop\Api::exitWithError(array($msg004));
        }
    }
}
// --- TBL: history
$history_id = -1;
$rslt = addHistory($db, $history_id, $pj_id, $sop_id, $tpl_id, null, null, null, $HISTORY_ACTION_TPL_FORM_UPSERT, date("Y-m-d H:i:s"), $user_id, null, null);
if (!$rslt) {
    \Sop\Log::error(__FILE__, __LINE__, 'Failed to update form.');
    $msg005 = "The registration and/or update failed.: history";
    // 登録・更新に失敗しました: history
    \Sop\Api::exitWithError(array($msg005));
}
// ---------------------------
// 終了処理
// ---------------------------
$db->commit();
$db = null;
if ($div == 'add') {
    $msg006 = "The registration completed.";
    echo json_encode(array('success' => true, 'msg' => \Sop\Api::htmlEncodeLines(array($msg006))));
    // 登録が完了しました
Exemplo n.º 21
0
 public function delete()
 {
     $q = new DBQuery();
     $q->setDelete('forum_visits');
     $q->addWhere('visit_forum = ' . (int) $this->forum_id);
     $q->exec();
     // No error if this fails, it is not important.
     $q->clear();
     $q->setDelete('forums');
     $q->addWhere('forum_id = ' . (int) $this->forum_id);
     if (!$q->exec()) {
         $q->clear();
         return db_error();
     }
     $q->clear();
     $q->setDelete('forum_messages');
     $q->addWhere('message_forum = ' . (int) $this->forum_id);
     if (!$q->exec()) {
         $result = db_error();
     } else {
         addHistory('forums', $this->forum_id, 'delete', $this->forum_name);
         $result = null;
     }
     $q->clear();
     return $result;
 }
Exemplo n.º 22
0
    $params[':grp_id'] = $grp_id;
    $stmt = $db->prepare($sql);
    $stmt->execute($params);
    $cnt = 0;
    foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
        $cnt = (int) $row['cnt'];
    }
    if ($cnt == 0) {
        \Sop\Log::warning(__FILE__, __LINE__, 'Specified check user does not exist.');
        $msg003 = "There is not the inputted user.";
        // 入力したユーザーは存在しません
        \Sop\Api::exitWithError(array($msg003));
    }
    // DB更新 (TBL: history)
    $history_id = -1;
    $rslt = addHistory($db, $history_id, $pj_id, $sop_id, $tpl_id, $schema_id, $file_id, $smpl_given_no, $HISTORY_ACTION_FILE_ADD_APRV, date("Y-m-d H:i:s"), $user_id, $user_id_2, null);
    if (!$rslt) {
        \Sop\Log::error(__FILE__, __LINE__, 'Failed to add history.');
        $msg004 = "The update failed.: history";
        // 更新に失敗しました: history
        \Sop\Api::exitWithError(array($msg004));
    }
}
// ---------------------------
// ファイル情報取得
// ---------------------------
// --- tpl データ存在チェック
$sel_sql = getSQLBaseForTplList();
$sel_sql .= " AND tpl.tpl_id = :tpl_id";
$sql = "SELECT count(*) cnt FROM ({$sel_sql}) as tmp";
$params = array();
Exemplo n.º 23
0
 /**
  * @todo Parent store could be partially used
  * @todo Can't delete a task with children
  */
 public function delete(CAppUI $AppUI = null)
 {
     global $AppUI;
     $q = new DBQuery();
     $this->_action = 'deleted';
     //load it before deleting it because we need info on it to update the parents later on
     $this->load($this->task_id);
     addHistory('tasks', $this->task_id, 'delete', $this->task_name, $this->task_project);
     // delete children
     $childrenlist = $this->getChildren();
     foreach ($childrenlist as $child) {
         $task = new CTask();
         $task->task_id = $child;
         $task->delete($AppUI);
     }
     $taskList = $childrenlist + array($this->task_id);
     $implodedTaskList = implode(',', $taskList);
     // delete linked user tasks
     $q->setDelete('user_tasks');
     $q->addWhere('task_id IN (' . $implodedTaskList . ')');
     if (!$q->exec()) {
         return db_error();
     }
     $q->clear();
     $q->setDelete('tasks');
     $q->addWhere('task_id=' . (int) $this->task_id);
     if (!$q->exec()) {
         return db_error();
     } elseif ($this->task_parent != $this->task_id) {
         // Has parent, run the update sequence, this child will no longer be in the
         // database
         $this->updateDynamics();
     }
     $q->clear();
     // delete affiliated task_logs
     $q->setDelete('task_log');
     $q->addWhere('task_log_task IN (' . $implodedTaskList . ')');
     if (!$q->exec()) {
         return db_error();
     }
     $q->clear();
     // delete affiliated task_dependencies
     $q->setDelete('task_dependencies');
     $q->addWhere('dependencies_task_id IN (' . $implodedTaskList . ') OR
         dependencies_req_task_id IN (' . $implodedTaskList . ')');
     if (!$q->exec()) {
         return db_error();
     } else {
         $this->_action = 'deleted';
     }
     $q->clear();
     CProject::updateTaskCount($this->task_project, $this->getTaskCount($this->task_project));
     return null;
 }
Exemplo n.º 24
0
 /**
  *	Default delete method
  *
  *	Can be overloaded/supplemented by the child class
  *	@return null|string null if successful otherwise returns and error message
  */
 function delete($oid = null, $history_desc = '', $history_proj = 0)
 {
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = intval($oid);
     }
     if (!$this->canDelete($msg)) {
         return $msg;
     }
     $q = new DBQuery();
     $q->setDelete($this->_tbl);
     $q->addWhere($this->_tbl_key . " = '" . $this->{$k} . "'");
     $result = !$q->exec() ? db_error() : null;
     if (!$result) {
         // only record history if deletion actually occurred
         addHistory($this->_tbl, $this->{$k}, 'delete', $history_desc, $history_proj);
     }
     $q->clear();
     return $result;
 }
Exemplo n.º 25
0
 public function delete(CAppUI $AppUI = null)
 {
     global $AppUI;
     global $helpdesk_available;
     if (!$this->canDelete($msg)) {
         return $msg;
     }
     $this->_message = 'deleted';
     addHistory('files', $this->file_id, 'delete', $this->file_name, $this->file_project);
     // remove the file from the file system
     $this->deleteFile();
     // delete any index entries
     $q = new DBQuery();
     $q->setDelete('files_index');
     $q->addQuery('*');
     $q->addWhere('file_id = ' . (int) $this->file_id);
     if (!$q->exec()) {
         $q->clear();
         return db_error();
     }
     // delete the main table reference
     $q->clear();
     $q->setDelete('files');
     $q->addQuery('*');
     $q->addWhere('file_id = ' . (int) $this->file_id);
     if (!$q->exec()) {
         $q->clear();
         return db_error();
     }
     $q->clear();
     if ($helpdesk_available && $this->file_helpdesk_item != 0) {
         $this->addHelpDeskTaskLog();
     }
     return null;
 }
Exemplo n.º 26
0
            echo json_encode('gameid must be set');
        }
    } elseif ($action == 'gameStart') {
        if (isset($_GET['gameid'])) {
            $count = getPlayerCount($_GET['gameid']);
            if ($count > 1) {
                $resultQuery = mysqli_query($link, "SELECT started FROM gamestatus WHERE gameid = " . mysqli_real_escape_string($link, $_GET['gameid']) . ";");
                while ($row = $resultQuery->fetch_object()) {
                    $started = $row->started;
                }
                if (!$started) {
                    $resultQuery = mysqli_query($link, "UPDATE gamestatus SET started = true WHERE gameid = " . mysqli_real_escape_string($link, $_GET['gameid']) . ";");
                    for ($i = 1; $i < 18; $i++) {
                        createCityInstance($_GET['gameid'], $i);
                    }
                    addHistory($_GET['gameid'], 'game started');
                    echo json_encode('Game Started');
                } else {
                    echo json_encode('Game already started');
                }
            } else {
                echo json_encode('Need at least 2 players to start');
            }
        } else {
            echo json_encode('gameid must be set');
        }
    } else {
        echo json_encode("Action " . $action . " not supported.");
    }
    closeLink($link);
} else {
Exemplo n.º 27
0
if (isset($_GET['mid'])) {
    $meid = $_GET['mid'];
    $z = mysql_query("SELECT uid,permission FROM `Media` WHERE mid='{$meid}' and `permission`='private'") or die(mysql_error());
    $row10 = mysql_fetch_assoc($z);
    $permission = $row10['permission'];
    $oid = $row10['uid'];
    $usersid = $_SESSION['id'];
    if (strcmp($permission, 'private') == 0) {
        if ($usersid != $oid) {
            checkPermissions($meid, $oid);
        }
    }
    $id = $_SESSION["id"];
    $mid = $_GET['mid'];
    if ($_SESSION["id"]) {
        addHistory($id, $mid);
    }
    $ip = getRealIpAddr();
    $count = 0;
    $s = mysql_query("SELECT * FROM `IP_Address` WHERE mid='{$mid}'") or die(mysql_error());
    while ($row1 = mysql_fetch_assoc($s)) {
        $ipc = $row1['userIP'];
        $i = strcmp($ip, $ipc);
        if ($i == 0) {
            $count = $count + 1;
            break;
        }
    }
    if ($count == 0) {
        addView($mid);
    }
Exemplo n.º 28
0
 public static function loadSiteProcessor($siteIDs, $params)
 {
     $timeout = DEFAULT_MAX_CLIENT_REQUEST_TIMEOUT;
     //$siteID = reset($siteIDs);
     $siteID = $_REQUEST['siteID'];
     if (empty($siteID)) {
         echo 'Invalid Site ID';
     }
     //$where = $params['where'] ? $params['where'].".php" : '';
     $where = $_REQUEST['where'] ? $_REQUEST['where'] . ".php" : '';
     $loadSiteVars = array();
     if (isset($_REQUEST['var_0'])) {
         for ($i = 0; $i < 5; $i++) {
             if (isset($_REQUEST['var_' . $i]) && strpos($_REQUEST['var_' . $i], '__IWPVAR__') !== false) {
                 $temp = explode('__IWPVAR__', $_REQUEST['var_' . $i]);
                 $loadSiteVars[$temp[0]] = $temp[1];
             }
         }
     }
     //if(!empty($params['vars']) && is_array($params['vars'])){
     //			$loadSiteVars = $params['vars'];
     //		}
     $siteData = DB::getRow("?:sites", "*", "siteID=" . DB::realEscapeString($siteID));
     if (empty($siteData)) {
         echo 'Invalid Site ID';
     }
     $type = 'site';
     $action = 'load';
     $events = 1;
     $historyData = array('siteID' => $siteData['siteID'], 'actionID' => Reg::get('currentRequest.actionID'), 'userID' => $GLOBALS['userID'], 'type' => $type, 'action' => $action, 'events' => $events, 'URL' => $siteData['URL'], 'status' => 'completed', 'timeout' => $timeout);
     $historyAdditionalData[] = array('detailedAction' => 'loadSite', 'uniqueName' => 'loadSite', 'status' => 'success');
     $historyID = addHistory($historyData, $historyAdditionalData);
     $signature = signData($where . $historyID, $siteData['isOpenSSLActive'], $siteData['privateKey'], $siteData['randomSignature']);
     $URLQueryArray = array('auto_login' => 1, 'iwp_goto' => $where, 'signature' => base64_encode($signature), 'message_id' => $historyID, 'username' => $siteData['adminUsername']);
     //signature urlencode will be taken care by httpBuildURLCustom()
     if (!empty($loadSiteVars) && is_array($loadSiteVars)) {
         $URLQueryArray = array_merge($URLQueryArray, $loadSiteVars);
     }
     $adminURLArray = parse_url($siteData['adminURL']);
     if (!empty($adminURLArray['query'])) {
         $parsedQuery = array();
         parse_str($adminURLArray['query'], $parsedQuery);
         if (!empty($parsedQuery) && is_array($parsedQuery)) {
             $URLQueryArray = array_merge($parsedQuery, $URLQueryArray);
         }
     }
     $adminURLArray['query'] = $URLQueryArray;
     $adminURLArray['path'] .= $where ? $where : '';
     $URL = httpBuildURLCustom($adminURLArray);
     $argSeparator = ini_get('arg_separator.output');
     if ($argSeparator == "&amp;" || $argSeparator == "&amp") {
         $URL = str_replace($argSeparator, "&", $URL);
     }
     //$URL .='&signature='.$tempSignature;
     //$URL = $siteData['adminURL'].$where.'?'."auto_login=1&iwp_goto=".$where."&signature=".urlencode(base64_encode($signature))."&message_id=".$historyID."&username="******"Location: " . $URL);
     exit;
 }
Exemplo n.º 29
0
// ---------------------------
// 承認可能状態に変更
// ---------------------------
$db->beginTransaction();
$date = date("Y-m-d H:i:s");
// --- TBL: tpl
$rslt = updTplTransitAprv($db, $tpl_id, $new_aprv_flg);
if (!$rslt) {
    \Sop\Log::error(__FILE__, __LINE__, 'Failed to update tpl.');
    $msg002 = "";
    // 登録に失敗しました: transit_aprv
    \Sop\Api::exitWithError(array($msg002));
}
// --- TBL: history
$history_id = -1;
$rslt = addHistory($db, $history_id, $pj_id, $sop_id, $tpl_id, null, null, null, $HISTORY_ACTION_TPL_TRANSIT, $date, $user_id, null, null);
if (!$rslt) {
    \Sop\Log::error(__FILE__, __LINE__, 'Failed to add history.');
    $msg003 = "The registration failed: history";
    // 登録に失敗しました: history
    \Sop\Api::exitWithError(array($msg003));
}
// ---------------------------
// 終了処理
// ---------------------------
$db->commit();
$db = null;
$msg004 = "The data was changed to the acceptance available.";
// 承認可能にしました
$msg005 = "The data was chaged to the acceptance disable.";
// 承認申請を取り消しました
Exemplo n.º 30
0
 protected function hook_postDelete()
 {
     //NOTE: This only happens if the delete was successful.
     addHistory($this->_tbl, $this->{$this->_tbl_key}, 'delete');
     return $this;
 }