Example #1
0
 public function modifyAction()
 {
     //检查权限
     $this->manager->checkMenuPermission($this->sign, Widget_Manager::MENU_PURVIEW_UPDATE);
     $SourceTypeId = intval($this->request->SourceTypeId);
     $SourceType = $this->oSourceType->getRow($SourceTypeId, '*');
     include $this->tpl('Config_Source_Type_modify');
 }
Example #2
0
 public function modifyAction()
 {
     //检查权限
     $this->manager->checkMenuPermission($this->sign, Widget_Manager::MENU_PURVIEW_UPDATE);
     $InstMapId = $this->request->InstMapId;
     $AppId = $this->request->AppId;
     $InstMap = $this->oInstMap->getRow($InstMapId, $AppId);
     $AppList = $this->oApp->getAll('name,AppId');
     include $this->tpl('Config_InstMap_modify');
 }
 public function modifyAction()
 {
     //检查权限
     $this->manager->checkMenuPermission($this->sign, Widget_Manager::MENU_PURVIEW_UPDATE);
     $LotoId = $this->request->LotoId;
     $Loto = $this->oLoto->getRow($LotoId, '*');
     $Loto['StartTime'] = date('Y-m-d H:i:s', $Loto['StartTime']);
     $Loto['EndTime'] = date('Y-m-d H:i:s', $Loto['EndTime']);
     include $this->tpl('Loto_modify');
 }
Example #4
0
 public function modifyAction()
 {
     //检查权限
     $this->manager->checkMenuPermission($this->sign, Widget_Manager::MENU_PURVIEW_UPDATE);
     $MoneyTypeId = $this->request->MoneyTypeId;
     $AppId = $this->request->AppId;
     $MoneyType = $this->oMoneyType->getRow($MoneyTypeId, $AppId, '*');
     $AppList = $this->oApp->getAll('name,AppId');
     include $this->tpl('Config_MoneyType_modify');
 }
Example #5
0
 /**
  * get the structure of an index into an array
  *
  * @param string    $table      name of table that should be used in method
  * @param string    $index_name name of index that should be used in method
  * @return mixed data array on success, a PEAR error on failure
  * @access public
  */
 function getTableIndexDefinition($table, $index_name)
 {
     $index_name = $this->_db->quoteSmart(strtoupper($index_name));
     $table = $this->_db->quoteSmart(strtoupper($table));
     $query = "SELECT * FROM user_indexes where table_name = {$table} AND index_name = {$index_name}";
     $row = $this->_db->getRow($query, null, DB_FETCHMODE_ASSOC);
     if (PEAR::isError($row)) {
         return $row;
     }
     $definition = array();
     if ($row) {
         $row = array_change_key_case($row, CASE_LOWER);
         $key_name = $row['index_name'];
         $key_name = strtolower($key_name);
         $query = "SELECT * FROM user_ind_columns WHERE index_name = {$index_name} AND table_name = {$table}";
         $result = $this->_db->query($query);
         if (PEAR::isError($result)) {
             return $result;
         }
         while ($colrow = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
             $column_name = $colrow['column_name'];
             $column_name = strtolower($column_name);
             $definition['fields'][$column_name] = array();
             if (array_key_exists('descend', $colrow)) {
                 $definition['fields'][$column_name]['sorting'] = $colrow['descend'] == 'ASC' ? 'ascending' : 'descending';
             }
         }
         $result->free();
     }
     return $definition;
 }
 public function insertDetailAction()
 {
     //检查权限
     $this->manager->checkMenuPermission($this->sign, Widget_Manager::MENU_PURVIEW_INSERT);
     $bind = $this->request->from('StartTime', 'EndTime', 'PrizeRate', 'LotoPrizeId', 'LotoPrizeCount');
     $bind['StartTime'] = strtotime($bind['StartTime']);
     $bind['EndTime'] = strtotime($bind['EndTime']);
     $LotoInfo = $this->oPrize->getRow($bind['LotoPrizeId']);
     $bind['LotoId'] = $LotoInfo['LotoId'];
     $res = $this->oPrize->insertDetail($bind);
     if ($bind['LotoPrizeId'] == 0) {
         $response = array('errno' => 3);
     } elseif ($bind['PrizeRate'] < 0) {
         $response = array('errno' => 1);
     } elseif ($bind['StartTime'] < 0) {
         $response = array('errno' => 4);
     } elseif ($bind['EndTime'] == '') {
         $response = array('errno' => 2);
     } elseif ($bind['LotoPrizeCount'] < 0) {
         $response = array('errno' => 5);
     } else {
         $response = $res ? array('errno' => 0) : array('errno' => 9);
     }
     echo json_encode($response);
     return true;
 }
Example #7
0
 public function getAppCoinAction()
 {
     $AppId = intval($this->request->AppId);
     $AppInfo = $this->oApp->getRow($AppId);
     $Comment = json_decode($AppInfo['comment'], true);
     echo "<option value={$AppId}>" . $Comment['coin_name'] . "</option>";
 }
Example #8
0
 /**
  * Get user information from database
  *
  * This function uses the given username to fetch
  * the corresponding login data from the database
  * table. If an account that matches the passed username
  * and password is found, the function returns true.
  * Otherwise it returns false.
  *
  * @param   string Username
  * @param   string Password
  * @param   boolean If true password is secured using a md5 hash
  *                  the frontend and auth are responsible for making sure the container supports
  *                  challenge response password authentication
  * @return  mixed  Error object or boolean
  */
 function fetchData($username, $password, $isChallengeResponse = false)
 {
     $this->log('Auth_Container_MDB::fetchData() called.', AUTH_LOG_DEBUG);
     // Prepare for a database query
     $err = $this->_prepare();
     if ($err !== true) {
         return PEAR::raiseError($err->getMessage(), $err->getCode());
     }
     //Check if db_fields contains a *, if so assume all columns are selected
     if (is_string($this->options['db_fields']) && strstr($this->options['db_fields'], '*')) {
         $sql_from = '*';
     } else {
         $sql_from = $this->options['final_usernamecol'] . ", " . $this->options['final_passwordcol'];
         if (strlen($fields = $this->_quoteDBFields()) > 0) {
             $sql_from .= ', ' . $fields;
         }
     }
     $query = sprintf("SELECT %s FROM %s WHERE %s = %s", $sql_from, $this->options['final_table'], $this->options['final_usernamecol'], $this->db->getTextValue($username));
     // check if there is an optional parameter db_where
     if ($this->options['db_where'] != '') {
         // there is one, so add it to the query
         $query .= " AND " . $this->options['db_where'];
     }
     $this->log('Running SQL against MDB: ' . $query, AUTH_LOG_DEBUG);
     $res = $this->db->getRow($query, null, null, null, MDB_FETCHMODE_ASSOC);
     if (MDB::isError($res) || PEAR::isError($res)) {
         return PEAR::raiseError($res->getMessage(), $res->getCode());
     }
     if (!is_array($res)) {
         $this->activeUser = '';
         return false;
     }
     // Perform trimming here before the hashing
     $password = trim($password, "\r\n");
     $res[$this->options['passwordcol']] = trim($res[$this->options['passwordcol']], "\r\n");
     // If using Challenge Response md5 the pass with the secret
     if ($isChallengeResponse) {
         $res[$this->options['passwordcol']] = md5($res[$this->options['passwordcol']] . $this->_auth_obj->session['loginchallenege']);
         // UGLY cannot avoid without modifying verifyPassword
         if ($this->options['cryptType'] == 'md5') {
             $res[$this->options['passwordcol']] = md5($res[$this->options['passwordcol']]);
         }
     }
     if ($this->verifyPassword($password, $res[$this->options['passwordcol']], $this->options['cryptType'])) {
         // Store additional field values in the session
         foreach ($res as $key => $value) {
             if ($key == $this->options['passwordcol'] || $key == $this->options['usernamecol']) {
                 continue;
             }
             $this->log('Storing additional field: ' . $key, AUTH_LOG_DEBUG);
             // Use reference to the auth object if exists
             // This is because the auth session variable can change so a static
             // call to setAuthData does not make sense
             $this->_auth_obj->setAuthData($key, $value);
         }
         return true;
     }
     $this->activeUser = $res[$this->options['usernamecol']];
     return false;
 }
Example #9
0
File: DB.php Project: rhertzog/lcs
 /**
  * Get user information from database
  *
  * This function uses the given username to fetch
  * the corresponding login data from the database
  * table. If an account that matches the passed username
  * and password is found, the function returns true.
  * Otherwise it returns false.
  *
  * @param   string Username
  * @param   string Password
  * @return  mixed  Error object or boolean
  */
 function fetchData($username, $password)
 {
     // Prepare for a database query
     $err = $this->_prepare();
     if ($err !== true) {
         return PEAR::raiseError($err->getMessage(), $err->getCode());
     }
     // Find if db_fileds contains a *, i so assume all col are selected
     if (strstr($this->options['db_fields'], '*')) {
         $sql_from = "*";
     } else {
         $sql_from = $this->options['usernamecol'] . ", " . $this->options['passwordcol'] . $this->options['db_fields'];
     }
     /**
      Old Style, removed to go around the oci8
      problem
      See bug 206
      http://pear.php.net/bugs/bug.php?id=206
     
     $query = "SELECT ! FROM ! WHERE ! = ?";
     $query_params = array(
                      $sql_from,
                      $this->options['table'],
                      $this->options['usernamecol'],
                      $username
                      );
     */
     $query = "SELECT " . $sql_from . " FROM " . $this->options['table'] . " WHERE " . $this->options['usernamecol'] . " = '" . $this->db->quoteString($username) . "'";
     $res = $this->db->getRow($query, null, DB_FETCHMODE_ASSOC);
     if (DB::isError($res)) {
         return PEAR::raiseError($res->getMessage(), $res->getCode());
     }
     if (!is_array($res)) {
         $this->activeUser = '';
         return false;
     }
     if ($this->verifyPassword(trim($password, "\r\n"), trim($res[$this->options['passwordcol']], "\r\n"), $this->options['cryptType'])) {
         // Store additional field values in the session
         foreach ($res as $key => $value) {
             if ($key == $this->options['passwordcol'] || $key == $this->options['usernamecol']) {
                 continue;
             }
             // Use reference to the auth object if exists
             // This is because the auth session variable can change so a static call to setAuthData does not make sence
             if (is_object($this->_auth_obj)) {
                 $this->_auth_obj->setAuthData($key, $value);
             } else {
                 Auth::setAuthData($key, $value);
             }
         }
         return true;
     }
     $this->activeUser = $res[$this->options['usernamecol']];
     return false;
 }
 public function modifyAction()
 {
     //检查权限
     $this->manager->checkMenuPermission($this->sign, Widget_Manager::MENU_PURVIEW_UPDATE);
     $SkinId = $this->request->SkinId;
     $AppId = $this->request->AppId;
     $Skin = $this->oSkin->getRow($SkinId, $AppId, '*');
     $AppList = $this->oApp->getAll('name,AppId');
     $HeroArr = $this->oHero->getAll($AppId);
     include $this->tpl('Config_Skin_modify');
 }
Example #11
0
 public function modifyAction()
 {
     //检查权限
     $this->manager->checkMenuPermission($this->sign, Widget_Manager::MENU_PURVIEW_UPDATE);
     $ProductId = $this->request->ProductId;
     $AppId = $this->request->AppId;
     $Product = $this->oProduct->getRow($ProductId, $AppId, '*');
     $AppList = $this->AppList;
     $ProductTypeList = $this->oProductType->getAll($Product['AppId']);
     include $this->tpl('Config_Product_modify');
 }
Example #12
0
 public function modifyAction()
 {
     //检查权限
     $this->manager->checkMenuPermission($this->sign, Widget_Manager::MENU_PURVIEW_UPDATE);
     $SourceDetail = trim($this->request->SourceDetail);
     $SourceTypeList = $this->SourceTypeList;
     $SourceDetailData = $this->oSourceDetail->getRow($SourceDetail, '*');
     $SourceInfo = $this->oSource->getRow($SourceDetailData['SourceId']);
     $SourceDetailData['SourceTypeId'] = $SourceInfo['SourceTypeId'];
     $SourceList = $this->oSource->getAll($SourceDetailData['SourceTypeId']);
     include $this->tpl('Config_Source_Detail_modify');
 }
 /**
  * Get user information from database
  *
  * This function uses the given username to fetch
  * the corresponding login data from the database
  * table. If an account that matches the passed username
  * and password is found, the function returns true.
  * Otherwise it returns false.
  *
  * @param   string Username
  * @param   string Password
  * @return  mixed  Error object or boolean
  */
 function fetchData($username, $password)
 {
     $this->log('Auth_Container_DBLite::fetchData() called.', AUTH_LOG_DEBUG);
     // Prepare for a database query
     $err = $this->_prepare();
     if ($err !== true) {
         return PEAR::raiseError($err->getMessage(), $err->getCode());
     }
     // Find if db_fields contains a *, if so assume all col are selected
     if (is_string($this->options['db_fields']) && strstr($this->options['db_fields'], '*')) {
         $sql_from = "*";
     } else {
         $sql_from = $this->options['final_usernamecol'] . ", " . $this->options['final_passwordcol'];
         if (strlen($fields = $this->_quoteDBFields()) > 0) {
             $sql_from .= ', ' . $fields;
         }
     }
     $query = "SELECT " . $sql_from . " FROM " . $this->options['final_table'] . " WHERE " . $this->options['final_usernamecol'] . " = " . $this->db->quoteSmart($username);
     // check if there is an optional parameter db_where
     if ($this->options['db_where'] != '') {
         // there is one, so add it to the query
         $query .= " AND " . $this->options['db_where'];
     }
     $this->log('Running SQL against DB: ' . $query, AUTH_LOG_DEBUG);
     $res = $this->db->getRow($query, null, DB_FETCHMODE_ASSOC);
     if (DB::isError($res)) {
         return PEAR::raiseError($res->getMessage(), $res->getCode());
     }
     if (!is_array($res)) {
         $this->activeUser = '';
         return false;
     }
     if ($this->verifyPassword(trim($password, "\r\n"), trim($res[$this->options['passwordcol']], "\r\n"), $this->options['cryptType'])) {
         // Store additional field values in the session
         foreach ($res as $key => $value) {
             if ($key == $this->options['passwordcol'] || $key == $this->options['usernamecol']) {
                 continue;
             }
             $this->log('Storing additional field: ' . $key, AUTH_LOG_DEBUG);
             // Use reference to the auth object if exists
             // This is because the auth session variable can change so a static call to setAuthData does not make sence
             if (is_object($this->_auth_obj)) {
                 $this->_auth_obj->setAuthData($key, $value);
             } else {
                 Auth::setAuthData($key, $value);
             }
         }
         $this->activeUser = $res[$this->options['usernamecol']];
         return true;
     }
     $this->activeUser = $res[$this->options['usernamecol']];
     return false;
 }
 /**
  * Method biuld the tree
  * @param string $parentId The id that you are currently working  with
  * @param string $menuText The text that will be displayed in the tree 
  * @param string $pageNo The page number
  * @return string 
  */
 function _makeNode($parentId, $menuText)
 {
     $this->objIcon = $this->newObject('geticon', 'htmlelements');
     $this->form = $this->newObject('form', 'htmlelements');
     $this->input = $this->newObject('textinput', 'htmlelements');
     $this->link = $this->newObject('link', 'htmlelements');
     $this->button = $this->newObject('button', 'htmlelements');
     $this->radio = $this->newObject('radio', 'htmlelements');
     $node = $this->objDBContentNodes->getRow('id', $parentId);
     if ($menuText == '') {
         $menuText = '[TEXT NEEDED]';
     }
     //set the icon
     $this->objIcon->setIcon('plus');
     $str = '
                  <table border=0 cellpadding="1" cellspacing="2">
                      <tr>
                          <td width="16" ><a id="x' . $parentId . '" href="javascript:Toggle(\'' . $parentId . '\');">' . $this->objIcon->show() . '</a></td>
                          <td width="300"><a href="' . $this->uri(array('action' => 'content', 'nodeid' => $parentId), 'context') . '" >' . $menuText . '</a></td>';
     //set move up icon
     if (!$this->objDBContentNodes->isFirstSibling($parentId)) {
         $this->objIcon->setIcon('mvup');
         $str .= '        
                          <td><a href="' . $this->uri(array('action' => 'moveup', 'nodeid' => $parentId), $this->module) . '" >' . $this->objIcon->show() . '</a></td>';
     } else {
         $str .= '        
                        <td>&nbsp;&nbsp;&nbsp;</td>';
     }
     //set move down icon
     if (!$this->objDBContentNodes->isLastSibling($parentId)) {
         $this->objIcon->setIcon('mvdown');
         $str .= '    
                          <td><a href="' . $this->uri(array('action' => 'movedown', 'nodeid' => $parentId), $this->module) . '" >' . $this->objIcon->show() . '</a></td>
              ';
     }
     //create a small form for moving straight to a node
     $this->radio->name = 'nodeid';
     $this->radio->addOption($parentId, '');
     $str .= '<td>' . $this->radio->show() . '</td>';
     $str .= ' </tr></table>';
     $str .= ' 
      <div id="' . $parentId . '" style="display: none; margin-left: 2em;">';
     $cnt = 0;
     $tmpstr = '';
     //check for more children recursively
     $myArr = $this->objDBContentNodes->getSortedNodes($parentId);
     foreach ($myArr as $line) {
         $str .= $this->_makeNode($line['id'], $line['title']);
     }
     $str .= ' </div>';
     return $str;
 }
 /**
  * 修改数据
  */
 public function modifyAction()
 {
     /**
      * 记录日志
      */
     $log = "游戏类别修改\n\nServerIp:\n" . $this->request->getServer('SERVER_ADDR') . "\n\nGET:\n" . var_export($_GET, true) . "\n\nPOST:\n" . var_export($_POST, true);
     $this->oLogManager->push('log', $log);
     //检查权限
     $this->manager->checkMenuPermission($this->sign, Widget_Manager::MENU_PURVIEW_UPDATE);
     $gameClassId = $this->request->ClassId;
     $gameclassArr = $this->oClass->getRow($gameClassId);
     include $this->tpl();
 }
Example #16
0
 public function modifyAction()
 {
     include 'Third/ckeditor/ckeditor.php';
     $editor = new CKEditor();
     $editor->BasePath = '/js/ckeditor/';
     $editor->config['height'] = 150;
     $editor->config['width'] = 700;
     //检查权限
     $this->manager->checkMenuPermission($this->sign, Widget_Manager::MENU_PURVIEW_UPDATE);
     $FaqId = $this->request->FaqId;
     $FaqTypeId = $this->request->FaqTypeId;
     $Faq = $this->oFaq->getRow($FaqId, '*');
     $FaqTypeList = $this->oFaqType->getAll('name,FaqTypeId');
     include $this->tpl('Config_Faq_modify');
 }
 /**
  * 更新数据模板
  * @return unknown_type
  */
 public function modifyAction()
 {
     /**
      * 记录日志
      */
     $log = "邮箱后缀修改\n\nServerIp:\n" . $this->request->getServer('SERVER_ADDR') . "\n\nGET:\n" . var_export($_GET, true) . "\n\nPOST:\n" . var_export($_POST, true);
     $this->oLogManager->push('log', $log);
     //检查权限
     $this->manager->checkMenuPermission($this->sign, Widget_Manager::MENU_PURVIEW_UPDATE);
     $FixId = intval($this->request->FixId);
     if (empty($FixId)) {
         $this->response->goBack();
     }
     $MailFixInfo = $this->oMailFix->getRow($FixId);
     include $this->tpl();
 }
 /**
  * 修改页面
  * @return unknown_type
  */
 public function modifyAction()
 {
     /**
      * 记录日志
      */
     $log = "合作商修改\n\nServerIp:\n" . $this->request->getServer('SERVER_ADDR') . "\n\nGET:\n" . var_export($_GET, true) . "\n\nPOST:\n" . var_export($_POST, true);
     $this->oLogManager->push('log', $log);
     //检查权限
     $this->manager->checkMenuPermission($this->sign, Widget_Manager::MENU_PURVIEW_UPDATE);
     $PartnerId = $this->request->PartnerId;
     $partner = $this->oPartner->getRow($PartnerId);
     if (!empty($partner['notes'])) {
         $partner['notes'] = json_decode($partner['notes'], true);
     }
     include $this->tpl();
 }
 /**
  * Checks if a user is admin
  * @param  integer $userid user to be checked if none provided we take the current user
  * @return boolean         true if yes
  */
 function isAdmin($userid = 0)
 {
     if (!$userid) {
         if ($this->group->type >= 3) {
             return TRUE;
         } else {
             return FALSE;
         }
     }
     $u = $this->db->getRow("SELECT `username`,`banned` FROM `" . MLS_PREFIX . "users` WHERE `userid` = ?i", $userid);
     $group = $this->getGroup($userid);
     if ($group->type >= 3) {
         return TRUE;
     }
     return FALSE;
 }
Example #20
0
 /**
  * Restores a page.
  *
  * Specifically, this restores the page, page template, and route
  * information so it reflects the values present at initial install. This is meant
  * to be used only on the vBulletin default pages.
  *
  * @param  string Page GUID
  * @param  bool   Print the Page title or not
  */
 public function restorePage($guid, $printMessage = true)
 {
     $xmlpage = $this->xml['page'][$guid];
     $xmlroute = $this->getXmlRouteByPageGuid($xmlpage['guid']);
     $xmlpagetemplate = $this->getXmlPageTemplateByPageGuid($xmlpage['guid']);
     $dbpage = $this->getMatchingPageFromDbByXmlGuid($xmlpage['guid']);
     $dbroute = $this->getDbRouteByRouteId($dbpage['routeid']);
     $dbpagetemplate = $this->getDbPageTemplateByPageTemplateId($dbpage['pagetemplateid']);
     if ($printMessage) {
         echo $xmlpage['title'];
     }
     // delete existing records
     $this->assertor->delete('page', array('guid' => $xmlpage['guid']));
     $this->assertor->delete('pagetemplate', array('guid' => $xmlpagetemplate['guid']));
     $this->assertor->delete('routenew', array('guid' => $xmlroute['guid']));
     // remove name from current db route so xml route can be restored w/o an index conflict
     if ($dbroute['guid'] != $xmlroute['guid']) {
         $this->assertor->update('routenew', array('name' => vB_dB_Query::VALUE_ISNULL), array('routeid' => $dbroute['routeid']));
     }
     // restore pagetemplate record
     $options = vB_Xml_Import::OPTION_OVERWRITE;
     $xml_importer = new vB_Xml_Import_PageTemplate('vbulletin', $options);
     $xml_importer->importFromFile("{$this->xmldir}/vbulletin-pagetemplates.xml", $xmlpagetemplate['guid']);
     $xml_importer->replacePhrasePlaceholdersInWidgetConfigs();
     // restore page record
     $options = vB_Xml_Import::OPTION_OVERWRITE;
     $xml_importer = new vB_Xml_Import_Page('vbulletin', $options);
     $xml_importer->importFromFile("{$this->xmldir}/vbulletin-pages.xml", $xmlpage['guid']);
     // restore route record
     $options = vB_Xml_Import::OPTION_OVERWRITE;
     $xml_importer = new vB_Xml_Import_Route('vbulletin', $options);
     $xml_importer->importFromFile("{$this->xmldir}/vbulletin-routes.xml", $xmlroute['guid']);
     // update page route
     $xml_importer = new vB_Xml_Import_Page('vbulletin', 0);
     $parsedXML = $xml_importer->parseFile("{$this->xmldir}/vbulletin-pages.xml");
     $xml_importer->updatePageRoutes($parsedXML);
     // get the new route
     $newRoute = $this->assertor->getRow('routenew', array('guid' => $xmlroute['guid']));
     // set previous db route to 301 redirect
     if ($dbroute['guid'] != $xmlroute['guid']) {
         $this->assertor->update('routenew', array('redirect301' => $newRoute['routeid']), array('routeid' => $dbroute['routeid']));
     }
     // update node routeid
     $this->assertor->update('vbForum:node', array('routeid' => $newRoute['routeid']), array('routeid' => $dbroute['routeid']));
     // clear cache
     vB_Cache::resetAllCache();
 }
Example #21
0
 public function cagePositionAction()
 {
     $DepotId = $this->request->DepotId;
     $DepotInfo = $this->oDepot->getRow($DepotId);
     $CageArr = $this->oCage->getAll($DepotId);
     for ($i = 1; $i <= $DepotInfo['X']; $i++) {
         $CageMap['total']['X'][$i] = 1;
         for ($j = 1; $j <= $DepotInfo['Y']; $j++) {
             $CageMap['total']['Y'][$j] = 1;
             $CageMap['detail'][$i][$j] = 0;
         }
     }
     if (is_array($CageArr)) {
         foreach ($CageArr as $Cage => $CageData) {
             $CageMap['detail'][$CageData['X']][$CageData['Y']] = $CageData['CageCode'];
         }
     }
     include $this->tpl('Config_Depot_CagePosition');
 }
Example #22
0
 /**
  * Reads auth_user_id, passwd, is_active flag
  * lastlogin timestamp from the database
  * If only $handle is given, it will read the data
  * from the first user with that handle and return
  * true on success.
  * If $handle and $passwd are given, it will try to
  * find the first user with both handle and password
  * matching and return true on success (this allows
  * multiple users having the same handle but different
  * passwords - yep, some people want this).
  * If no match is found, false is being returned.
  *
  * @access private
  * @param  string   user handle
  * @param  boolean  user password
  * @return boolean  true upon success, false otherwise
  */
 function _readUserData($handle, $passwd = false)
 {
     if (!$this->init_ok) {
         return false;
     }
     $success = false;
     $fields = array();
     foreach ($this->authTableCols as $key => $value) {
         if (sizeof($value) > 0) {
             foreach ($value as $alias => $field_data) {
                 $fields[] = $field_data['name'] . ' AS ' . $alias;
             }
         }
     }
     if ($passwd !== false) {
         // If $passwd is set, try to find the first user with the given
         // handle and password.
         $sql = 'SELECT ' . implode(',', $fields) . '
                    FROM   ' . $this->authTable . '
                    WHERE  ' . $this->authTableCols['required']['handle']['name'] . '=' . $this->dbc->quoteSmart($handle) . '
                     AND   ' . $this->authTableCols['required']['passwd']['name'] . '=' . $this->dbc->quoteSmart($this->encryptPW($passwd));
     } else {
         // If only $handle is set, try to find the first matching user
         $sql = 'SELECT ' . implode(',', $fields) . '
                    FROM   ' . $this->authTable . '
                    WHERE  ' . $this->authTableCols['required']['handle']['name'] . '=' . $this->dbc->quoteSmart($handle);
     }
     // Query database
     $result = $this->dbc->getRow($sql, null, DB_FETCHMODE_ASSOC);
     // If a user was found, read data into class variables and set
     // return value to true
     if (!DB::isError($result) && is_array($result)) {
         $udata = $result;
         $this->handle = $udata['handle'];
         $this->passwd = $this->decryptPW($udata['passwd']);
         $this->isActive = !isset($udata['is_active']) || $udata['is_active'] == 'Y' ? true : false;
         $this->authUserId = $udata['auth_user_id'];
         $this->lastLogin = !empty($udata['lastlogin']) ? strtotime($udata['lastlogin']) : '';
         $success = true;
     }
     return $success;
 }
Example #23
0
 /**
  * Tries to find the user with the given user ID in the permissions
  * container. Will read all permission data and return true on success.
  *
  * @access  public
  * @param   string  $uid  user identifier
  * @return  mixed   true on success or a PEAR_Error object
  */
 function init($uid)
 {
     $success = true;
     $query = '
         SELECT
             LU.perm_user_id AS userid,
             LU.perm_type    AS usertype
         FROM
             ' . $this->prefix . 'perm_users LU
         WHERE
             auth_user_id=' . $this->dbc->quoteSmart($uid);
     $result = $this->dbc->getRow($query, null, DB_FETCHMODE_ASSOC);
     if (DB::isError($result)) {
         return $result;
     }
     $this->permUserId = $result['userid'];
     $this->userType = $result['usertype'];
     $this->readRights();
     return $success;
 }
Example #24
0
 /**
  * get the structure of a constraint into an array
  *
  * @param string    $table      name of table that should be used in method
  * @param string    $index_name name of index that should be used in method
  * @return mixed data array on success, a PEAR error on failure
  * @access public
  */
 function getTableConstraintDefinition($table, $index_name)
 {
     $query = "SELECT relname, indisunique, indisprimary, indkey FROM pg_index, pg_class\n            WHERE pg_class.relname = " . $this->_db->quoteSmart($index_name) . " AND pg_class.oid = pg_index.indexrelid\n              AND (indisunique = 't' OR indisprimary = 't')";
     $row = $this->_db->getRow($query, null, DB_FETCHMODE_ASSOC);
     if (PEAR::isError($row)) {
         return $row;
     }
     $columns = $this->_listTableFields($table);
     $definition = array();
     if ($row['indisprimary'] == 't') {
         $definition['primary'] = true;
     } elseif ($row['indisunique'] == 't') {
         $definition['unique'] = true;
     }
     $index_column_numbers = explode(' ', $row['indkey']);
     foreach ($index_column_numbers as $number) {
         $definition['fields'][$columns[$number - 1]] = array('sorting' => 'ascending');
     }
     return $definition;
 }
Example #25
0
File: MDB.php Project: rhertzog/lcs
 /**
  * Get user information from database
  *
  * This function uses the given username to fetch
  * the corresponding login data from the database
  * table. If an account that matches the passed username
  * and password is found, the function returns true.
  * Otherwise it returns false.
  *
  * @param   string Username
  * @param   string Password
  * @return  mixed  Error object or boolean
  */
 function fetchData($username, $password)
 {
     // Prepare for a database query
     $err = $this->_prepare();
     if ($err !== true) {
         return PEAR::raiseError($err->getMessage(), $err->getCode());
     }
     // Find if db_fileds contains a *, i so assume all col are selected
     if (strstr($this->options['db_fields'], '*')) {
         $sql_from = '*';
     } else {
         $sql_from = $this->options['usernamecol'] . ', ' . $this->options['passwordcol'] . $this->options['db_fields'];
     }
     $query = sprintf("SELECT %s FROM %s WHERE %s = %s", $sql_from, $this->options['table'], $this->options['usernamecol'], $this->db->getTextValue($username));
     $res = $this->db->getRow($query, null, null, null, MDB_FETCHMODE_ASSOC);
     if (MDB::isError($res) || PEAR::isError($res)) {
         return PEAR::raiseError($res->getMessage(), $res->getCode());
     }
     if (!is_array($res)) {
         $this->activeUser = '';
         return false;
     }
     if ($this->verifyPassword(trim($password, "\r\n"), trim($res[$this->options['passwordcol']], "\r\n"), $this->options['cryptType'])) {
         // Store additional field values in the session
         foreach ($res as $key => $value) {
             if ($key == $this->options['passwordcol'] || $key == $this->options['usernamecol']) {
                 continue;
             }
             // Use reference to the auth object if exists
             // This is because the auth session variable can change so a static call to setAuthData does not make sence
             if (is_object($this->_auth_obj)) {
                 $this->_auth_obj->setAuthData($key, $value);
             } else {
                 Auth::setAuthData($key, $value);
             }
         }
         return true;
     }
     $this->activeUser = $res[$this->options['usernamecol']];
     return false;
 }
Example #26
0
 /**
  * 修改页面
  * @return unknown_type
  */
 public function modifyAction()
 {
     /**
      * 记录日志
      */
     $log = "区服修改\n\nServerIp:\n" . $this->request->getServer('SERVER_ADDR') . "\n\nGET:\n" . var_export($_GET, true) . "\n\nPOST:\n" . var_export($_POST, true);
     $this->oLogManager->push('log', $log);
     //检查权限
     $this->manager->checkMenuPermission($this->sign, Widget_Manager::MENU_PURVIEW_UPDATE);
     $ServerId = $this->request->ServerId;
     $server = $this->oServer->getRow($ServerId);
     $appArr = $this->oApp->getAll('AppId,name');
     $partnerArr = $this->oPartner->getAll('PartnerId,name');
     $server['LoginStart'] = date('Y-m-d H:i:s', $server['LoginStart']);
     $server['NextEnd'] = date('Y-m-d H:i:s', $server['NextEnd']);
     $server['NextStart'] = date('Y-m-d H:i:s', $server['NextStart']);
     $server['PayEnd'] = date('Y-m-d H:i:s', $server['PayEnd']);
     $server['PayStart'] = date('Y-m-d H:i:s', $server['PayStart']);
     $server['ServerIp'] = long2ip($server['ServerIp']);
     $server['GMIp'] = long2ip($server['GMIp']);
     include $this->tpl();
 }
Example #27
0
 public function machinePositionAction()
 {
     $CageId = $this->request->CageId;
     $CageInfo = $this->oCage->getRow($CageId);
     $MachineList = $this->oMachine->getMachineByCageId($CageId, "MachineCode,Position,Size,LocalIP,WebIP,Comment");
     $CageMap = array();
     for ($i = 1; $i <= $CageInfo["Size"]; $i++) {
         $CageMap[$i] = 0;
     }
     foreach ($MachineList as $k => $val) {
         $val['LocalIP'] = long2ip($val['LocalIP']);
         $val['WebIP'] = long2ip($val['WebIP']);
         $val['Comment'] = json_decode($val['Comment'], true);
         $CageMap[$val['Position']] = $val;
         for ($i = $val['Position']; $i <= $val['Position'] + $val['Size'] - 1; $i++) {
             if ($i > $val['Position']) {
                 unset($CageMap[$i]);
             }
         }
     }
     $i = 1;
     foreach ($CageMap as $row => $row_info) {
         if ($row_info == 0) {
             $trstr .= "<tr><td>{$i}</td><td>empty</td></tr>";
         } elseif (is_array($row_info)) {
             for ($j = $i; $j <= $row_info['Size'] + $i - 1; $j++) {
                 if ($j == $i) {
                     $trstr .= "<tr ><td>{$j}</td><td rowspan = " . $row_info['Size'] . ">" . $row_info['MachineCode'] . "</td></tr>";
                 } else {
                     $trstr .= "<tr rowspan = " . $row_info['Size'] . "><td>{$j}</td></tr>";
                 }
             }
         }
         $i++;
     }
     //print_r($CageMap);
     include $this->tpl('Config_Cage_MachinePosition');
 }
Example #28
0
 public function modifyAction()
 {
     $ResearchId = $this->request->ResearchId;
     $Research = $this->oResearch->getRow($ResearchId);
     include $this->tpl('Config_Research_modify');
 }
Example #29
0
 /**
  * Get user information from database
  *
  * This function uses the given username to fetch
  * the corresponding login data from the database
  * table. If an account that matches the passed username
  * and password is found, the function returns true.
  * Otherwise it returns false.
  *
  * @param   string Username
  * @param   string Password
  * @param   boolean If true password is secured using a md5 hash
  *                  the frontend and auth are responsible for making sure the container supports
  *                  challenge response password authenthication
  * @return  mixed  Error object or boolean
  */
 function fetchData($username, $password, $isChallengeResponce = false)
 {
     //print "Container_DB::fetchData($username, $password, $isChallengeResponce) <br/>\n";
     // Prepare for a database query
     $err = $this->_prepare();
     if ($err !== true) {
         return PEAR::raiseError($err->getMessage(), $err->getCode());
     }
     // Find if db_fields contains a *, if so assume all columns are selected
     if (strstr($this->options['db_fields'], '*')) {
         $sql_from = "*";
     } else {
         $sql_from = $this->options['usernamecol'] . ", " . $this->options['passwordcol'] . $this->options['db_fields'];
     }
     /**
      Old Style, removed to go around the oci8 
      problem 
      See bug 206
      http://pear.php.net/bugs/bug.php?id=206
      
     $query = "SELECT ! FROM ! WHERE ! = ?";
     $query_params = array(
                      $sql_from,
                      $this->options['table'],
                      $this->options['usernamecol'],
                      $username
                      );
     */
     $query = "SELECT " . $sql_from . " FROM " . $this->options['table'] . " WHERE " . $this->options['usernamecol'] . " = '" . $this->db->quoteString($username) . "'";
     $res = $this->db->getRow($query, null, DB_FETCHMODE_ASSOC);
     #print "SQL: $query <br/>\n";
     #print_r($res);
     if (DB::isError($res)) {
         return PEAR::raiseError($res->getMessage(), $res->getCode());
     }
     if (!is_array($res)) {
         $this->activeUser = '';
         return false;
     }
     // Perform trimming here before the hashihg
     $password = trim($password, "\r\n");
     $res[$this->options['passwordcol']] = trim($res[$this->options['passwordcol']], "\r\n");
     // If using Challenge Responce md5 the pass with the secret
     if ($isChallengeResponce) {
         $res[$this->options['passwordcol']] = md5($res[$this->options['passwordcol']] . $this->_auth_obj->session['loginchallenege']);
         // UGLY cannot avoid without modifying verifyPassword
         if ($this->options['cryptType'] == 'md5') {
             $res[$this->options['passwordcol']] = md5($res[$this->options['passwordcol']]);
         }
         //print " Hashed Password [{$res[$this->options['passwordcol']]}]<br/>\n";
     }
     if ($this->verifyPassword($password, $res[$this->options['passwordcol']], $this->options['cryptType'])) {
         // Store additional field values in the session
         foreach ($res as $key => $value) {
             if ($key == $this->options['passwordcol'] || $key == $this->options['usernamecol']) {
                 continue;
             }
             // Use reference to the auth object if exists
             // This is because the auth session variable can change so a static call to setAuthData does not make sence
             $this->_auth_obj->setAuthData($key, $value);
         }
         return true;
     }
     $this->activeUser = $res[$this->options['usernamecol']];
     return false;
 }
Example #30
0
 /**
  * Look up proposal information based on the proposal ID number
  *
  * @param object $dbh  the current DB object
  * @param int    $id   the ID number of the proposal being looked for
  *
  * @return object  a new proposal object.  false if the $id provided is
  *                 not numeric.  null if the $id doesn't refer to
  *                 an actual proposal.
  *
  * @access public
  */
 function get(&$dbh, $id)
 {
     if (!is_numeric($id)) {
         $res = false;
         return $res;
     }
     $id = (int) $id;
     $sql = "SELECT *, UNIX_TIMESTAMP(draft_date) as draft_date,\n                        UNIX_TIMESTAMP(proposal_date) as proposal_date,\n                        UNIX_TIMESTAMP(vote_date) as vote_date,\n                        UNIX_TIMESTAMP(longened_date) as longened_date\n                 FROM package_proposals WHERE id = " . $id;
     $res = $dbh->getRow($sql, null, DB_FETCHMODE_ASSOC);
     if (DB::isError($res)) {
         return $res;
     }
     if (!$res) {
         return $res;
     }
     $t = new proposal($res);
     return $t;
 }