Esempio n. 1
0
 function Execute(&$template, $request, &$dba, &$session, &$user)
 {
     if (is_a($session['user'], 'Member') && $user['perms'] >= ADMIN) {
         global $_MAPITEMS, $_QUERYPARAMS;
         if (!isset($request['id']) || intval($request['id']) == 0) {
             $template->setInfo('content', $template->getVar('L_INVALIDCATEGORY'), FALSE);
             return TRUE;
         }
         $category = $dba->getRow("SELECT " . $_QUERYPARAMS['info'] . $_QUERYPARAMS['category'] . " FROM " . CATEGORIES . " c LEFT JOIN " . INFO . " i ON c.category_id = i.id WHERE i.id = " . intval($request['id']));
         if (!is_array($category) || empty($category)) {
             $template->setInfo('content', $template->getVar('L_INVALIDCATEGORY'), FALSE);
             return TRUE;
         }
         $parent_id = $dba->getValue("SELECT id FROM " . MAPS . " WHERE varname = 'categories'");
         $dba->beginTransaction();
         /* Insert the main category MAP item */
         $map =& new AdminInsertMap();
         /* Set the default data for this category MAP element */
         $category_array = array_merge(array('name' => $category['name'], 'varname' => 'category' . $category['id'], 'parent_id' => $parent_id), $_MAPITEMS['category'][0]);
         /**
          * Insert the main category MAP information
          */
         Error::reset();
         $map->insertNode($category_array, $category['id']);
         if (Error::grab()) {
             $error =& Error::grab();
             $template->setError('content', $template->getVar($error->message));
             return TRUE;
         }
         $category_map_id = $dba->getInsertId();
         /**
          * Insert the secondary category MAP information
          */
         for ($i = 1; $i < count($_MAPITEMS['category']) - 1; $i++) {
             if (isset($_MAPITEMS['category'][$i]) && is_array($_MAPITEMS['category'][$i])) {
                 $category_array = array_merge(array('parent_id' => $category_map_id), $_MAPITEMS['category'][$i]);
                 $category_array['name'] = $template->getVar('L_' . strtoupper($category_array['varname']));
                 Error::reset();
                 $map->insertNode($category_array, $category['id']);
                 if (Error::grab()) {
                     $error =& Error::grab();
                     $template->setError('content', $template->getVar($error->message));
                     return TRUE;
                 }
             }
         }
         $dba->commitTransaction();
         /**
          * If we've gotten to this point.. redirect
          */
         $template->setInfo('content', sprintf($template->getVar('L_ADDEDCATEGORYPERMS'), $category['name']), FALSE);
         $template->setRedirect('admin.php?act=categories', 3);
         if (!@touch(CACHE_FILE, time() - 86460)) {
             @unlink(CACHE_FILE);
         }
     } else {
         $template->setError('content', $template->getVar('L_YOUNEEDPERMS'));
     }
     return TRUE;
 }
Esempio n. 2
0
 function ValidateLoginKey($info)
 {
     global $_DBA, $_SETTINGS;
     if (!isset($info['k4_autolog'])) {
         return FALSE;
     }
     if ($info['k4_autolog'] == '' || empty($info['k4_autolog'])) {
         return FALSE;
     }
     $info = $info['k4_autolog'];
     if (strlen($info) <= 32 || strlen($info) > $_SETTINGS['maxuserlength'] + 32) {
         return FALSE;
     }
     $name = substr($info, 0, strlen($info) - 32);
     $key = substr($info, strlen($info) - 32, strlen($info));
     Error::reset();
     $name = $_DBA->Quote($name);
     $key = $_DBA->Quote($key);
     $result = $_DBA->GetValue("SELECT id FROM " . USERS . " WHERE name='{$name}' AND priv_key='{$key}'");
     if (Error::grab()) {
         return trigger_error("Unable to select the user ID.", E_USER_ERROR);
     }
     return $result;
 }
Esempio n. 3
0
 function Execute(&$template, $request, &$dba, &$session, &$user)
 {
     $this->dba =& $dba;
     if (is_a($session['user'], 'Member') && $user['perms'] >= ADMIN) {
         $map =& new AdminInsertMap();
         Error::reset();
         $map->insertNode($request);
         if (Error::grab()) {
             $error =& Error::grab();
             return $template->setError('content', $template->getVar($error->message));
         }
         /* Redirect the user */
         $template->setInfo('content', $template->getVar('L_ADDEDMAPSITEM'), FALSE);
         $template->setRedirect('admin.php?act=permissions_gui', 3);
         if (!@touch(CACHE_FILE, time() - 86460)) {
             @unlink(CACHE_FILE);
         }
     } else {
         $template->setError('content', $template->getVar('L_YOUNEEDPERMS'));
     }
     return TRUE;
 }
Esempio n. 4
0
File: News.php Progetto: jarick/bx
 /**
  * Удаление новости
  *
  * @param integer $id ID новости
  * @return boolean <p>Возвращает <b>TRUE</b> в случае успеха.
  * </p>
  * <p>
  * Возвращает <b>FALSE</b> в случае ошибки. Саму ошибку можно получить с помощью
  * функции <b>Error::get</b>
  */
 public static function delete($id)
 {
     Error::reset();
     try {
         $return = self::getManager()->delete($id);
     } catch (Exception $ex) {
         Error::set($ex);
         $return = false;
     }
     return $return;
 }
Esempio n. 5
0
 /**
  * Удаляет старые капчи
  *
  * @param integer $day Через сколько дней считать капчу устаревшей
  * @return boolean <p>Возвращает <b>TRUE</b> в случае успеха.
  * </p>
  * <p>
  * Возвращает <b>FALSE</b> в случае ошибки. Саму ошибку можно получить с помощью
  * функции <b>Error::get</b>
  * </p>
  */
 public static function clearOld($day = 30)
 {
     Error::reset();
     try {
         $return = self::getManager()->clearOld($day);
     } catch (Exception $ex) {
         Error::set($ex);
         $return = false;
     }
     return $return;
 }