/**
  * @see Action::execute()
  */
 public function execute()
 {
     AbstractAction::execute();
     // check permission
     WCF::getUser()->checkPermission('admin.user.canBanUser');
     if (count($this->userIDs) > 0) {
         // check permission
         $sql = "SELECT\tDISTINCT groupID\n\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\tWHERE\tuserID IN (" . implode(',', $this->userIDs) . ")";
         $result = WCF::getDB()->sendQuery($sql);
         while ($row = WCF::getDB()->fetchArray($result)) {
             if (!Group::isAccessibleGroup($row['groupID'])) {
                 throw new PermissionDeniedException();
             }
         }
         // update user
         $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\tSET\tbanned = 0\n\t\t\t\tWHERE\tuserID IN (" . implode(',', $this->userIDs) . ")";
         WCF::getDB()->sendQuery($sql);
         // unmark users
         UserEditor::unmarkAll();
         // reset sessions
         Session::resetSessions($this->userIDs);
     }
     $this->executed();
     if (!empty($this->url)) {
         HeaderUtil::redirect($this->url);
     } else {
         // set active menu item
         WCFACP::getMenu()->setActiveMenuItem('wcf.acp.menu.link.user.management');
         // show succes message
         WCF::getTPL()->assign('message', 'wcf.acp.user.unban.success');
         WCF::getTPL()->display('success');
     }
     exit;
 }
 /**
  * @see Cronjob::execute()
  */
 public function execute($data)
 {
     $sql = "SELECT\t*\n\t\t\tFROM\twcf" . WCF_N . "_group\n\t\t\tWHERE\tneededAge <> 0\n\t\t\t\tOR neededPoints <> 0";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $userIDArray = array();
         if ($row['neededAge'] > 0) {
             $sql = "SELECT\tuserID\n\t\t\t\t\tFROM\twcf" . WCF_N . "_user\n\t\t\t\t\tWHERE\tregistrationDate <= " . (TIME_NOW - 86400 * $row['neededAge']) . "\n\t\t\t\t\t\tAND userID NOT IN (\n\t\t\t\t\t\t\tSELECT\tuserID\n\t\t\t\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\t\t\t\tWHERE\tgroupID = " . $row['groupID'] . "\n\t\t\t\t\t\t)";
             $result2 = WCF::getDB()->sendQuery($sql);
             while ($row2 = WCF::getDB()->fetchArray($result2)) {
                 $userIDArray[] = $row2['userID'];
             }
         }
         if ($row['neededPoints'] > 0) {
             $sql = "SELECT\tuserID\n\t\t\t\t\tFROM\twcf" . WCF_N . "_user\n\t\t\t\t\tWHERE\tactivityPoints >= " . $row['neededPoints'] . "\n\t\t\t\t\t\tAND userID NOT IN (\n\t\t\t\t\t\t\tSELECT\tuserID\n\t\t\t\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\t\t\t\tWHERE\tgroupID = " . $row['groupID'] . "\n\t\t\t\t\t\t)";
             $result2 = WCF::getDB()->sendQuery($sql);
             while ($row2 = WCF::getDB()->fetchArray($result2)) {
                 $userIDArray[] = $row2['userID'];
             }
         }
         if (count($userIDArray)) {
             $userIDArray = array_unique($userIDArray);
             // assign to group
             $sql = "INSERT INTO\twcf" . WCF_N . "_user_to_groups\n\t\t\t\t\t\t\t(userID, groupID)\n\t\t\t\t\tSELECT\t\tuserID, " . $row['groupID'] . "\n\t\t\t\t\tFROM\t\twcf" . WCF_N . "_user\n\t\t\t\t\tWHERE\t\tuserID IN (" . implode(',', $userIDArray) . ")";
             WCF::getDB()->sendQuery($sql);
             // reset sesions
             Session::resetSessions($userIDArray);
         }
     }
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     // save
     $updateOptionValueUpdate = '';
     foreach ($this->activeOptions as $option) {
         if ($option['defaultValue'] != $option['optionValue']) {
             $sql = "UPDATE\twcf" . WCF_N . "_user_option\n\t\t\t\t\tSET\tdefaultValue = '" . escapeString($option['optionValue']) . "'\n\t\t\t\t\tWHERE\toptionID = " . $option['optionID'];
             WCF::getDB()->sendQuery($sql);
             if (!empty($updateOptionValueUpdate)) {
                 $updateOptionValueUpdate .= ',';
             }
             $updateOptionValueUpdate .= 'userOption' . $option['optionID'] . "='" . escapeString($option['optionValue']) . "'";
         }
     }
     // apply to existing users
     if ($this->applyChangesToExistingUsers == 1 && !empty($updateOptionValueUpdate)) {
         $sql = "UPDATE\twcf" . WCF_N . "_user_option_value\n\t\t\t\tSET\t" . $updateOptionValueUpdate;
         WCF::getDB()->sendQuery($sql);
         // reset sessions
         Session::resetSessions();
     }
     // reset cache
     WCF::getCache()->clearResource($this->cacheName . PACKAGE_ID);
     // show success message
     WCF::getTPL()->assign('success', true);
 }
Example #4
0
 /**
  * Sets a setting with an identifier and value.
  *
  * @param	int		userID
  * @param	string	setting
  * @param	mixed	value
  * @param	int		expire time
  */
 public static function setSetting($userID, $setting, $value, $expireTime = 0x7fffffff)
 {
     $svalue = serialize($value);
     $sql = "REPLACE INTO ugml_user_setting\n\t\t\t\t(userID, setting, expireTime, value)\n\t\t\t\tVALUES\n\t\t\t\t(" . $userID . ", '" . escapeString($setting) . "', " . $expireTime . ", '" . escapeString($svalue) . "')";
     WCF::getDB()->sendQuery($sql);
     self::$settings[$userID][$setting] = $svalue;
     Session::resetSessions($userID);
 }
 /**
  * @see PMRuleAction::execute()
  */
 public function execute(PMEditor $pm, PMRule $rule, UserProfile $recipient)
 {
     $sql = "UPDATE\twcf" . WCF_N . "_pm_to_user\n\t\t\tSET \tisViewed = " . TIME_NOW . ",\n\t\t\t\tuserWasNotified = 1\n\t\t\tWHERE \tpmID = " . $pm->pmID . "\n\t\t\t\tAND recipientID = " . $recipient->userID;
     WCF::getDB()->sendQuery($sql);
     $pm->updateViewedByAll();
     $pm->updateUnreadMessageCount($recipient->userID);
     Session::resetSessions($recipient->userID);
     return true;
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     AbstractForm::save();
     // save
     $this->application->updateByLeader($this->applicationStatus, $this->reply, WCF::getUser()->userID);
     // reset session
     Session::resetSessions($this->application->userID);
     $this->saved();
     HeaderUtil::redirect('index.php?page=UserGroupLeader' . SID_ARG_2ND_NOT_ENCODED);
     exit;
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     AbstractForm::save();
     // save group
     $this->group->update($this->groupName, $this->activeOptions, $this->additionalFields);
     // update sessions
     require_once WCF_DIR . 'lib/system/session/Session.class.php';
     Session::resetSessions();
     $this->saved();
     // show success message
     WCF::getTPL()->assign('success', true);
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // check permission
     WCF::getUser()->checkPermission('admin.user.canEnableUser');
     if (count($this->userIDs) > 0) {
         // check permission
         $sql = "SELECT\tDISTINCT groupID\n\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\tWHERE\tuserID IN (" . implode(',', $this->userIDs) . ")";
         $result = WCF::getDB()->sendQuery($sql);
         while ($row = WCF::getDB()->fetchArray($result)) {
             if (!Group::isAccessibleGroup($row['groupID'])) {
                 throw new PermissionDeniedException();
             }
         }
         // send notification
         $languages = array(0 => WCF::getLanguage(), WCF::getLanguage()->getLanguageID() => WCF::getLanguage());
         $sql = "SELECT\tuserID, username, email, languageID\n\t\t\t\tFROM\twcf" . WCF_N . "_user\n\t\t\t\tWHERE\tuserID IN (" . implode(',', $this->userIDs) . ")\n\t\t\t\t\tAND activationCode <> 0";
         $result = WCF::getDB()->sendQuery($sql);
         while ($row = WCF::getDB()->fetchArray($result)) {
             if (!isset($languages[$row['languageID']])) {
                 $languages[$row['languageID']] = new Language($row['languageID']);
             }
             $mail = new Mail(array($row['username'] => $row['email']), $languages[$row['languageID']]->get('wcf.acp.user.activation.mail.subject', array('PAGE_TITLE' => $languages[$row['languageID']]->get(PAGE_TITLE))), $languages[$row['languageID']]->get('wcf.acp.user.activation.mail', array('PAGE_TITLE' => $languages[$row['languageID']]->get(PAGE_TITLE), '$username' => $row['username'], 'PAGE_URL' => PAGE_URL, 'MAIL_ADMIN_ADDRESS' => MAIL_ADMIN_ADDRESS)));
             $mail->send();
         }
         // update groups
         $sql = "DELETE FROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\tWHERE\t\tuserID IN (" . implode(',', $this->userIDs) . ")\n\t\t\t\t\t\tAND groupID = " . Group::getGroupIdByType(Group::GUESTS);
         WCF::getDB()->sendQuery($sql);
         $sql = "INSERT IGNORE INTO\twcf" . WCF_N . "_user_to_groups\n\t\t\t\t\t\t\t(userID, groupID)\n\t\t\t\tVALUES\t\t\t(" . implode(', ' . Group::getGroupIdByType(Group::USERS) . '),(', $this->userIDs) . ", '" . Group::getGroupIdByType(Group::USERS) . "')";
         WCF::getDB()->sendQuery($sql);
         // update user
         $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\tSET\tactivationCode = 0\n\t\t\t\tWHERE\tuserID IN (" . implode(',', $this->userIDs) . ")";
         WCF::getDB()->sendQuery($sql);
         // unmark users
         UserEditor::unmarkAll();
         // reset sessions
         Session::resetSessions($this->userIDs);
     }
     $this->executed();
     if (!empty($this->url)) {
         HeaderUtil::redirect($this->url);
     } else {
         // set active menu item
         WCFACP::getMenu()->setActiveMenuItem('wcf.acp.menu.link.user.management');
         // show succes message
         WCF::getTPL()->assign('message', 'wcf.acp.user.enable.success');
         WCF::getTPL()->display('success');
     }
     exit;
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // check permission
     WCF::getUser()->checkPermission('admin.user.infraction.canDeleteSuspension');
     // revoke suspension
     if (!$this->userSuspension->revoked) {
         $object = Suspension::getSuspensionTypeObject($this->userSuspension->suspensionType);
         $object->revoke(new User($this->userSuspension->userID), $this->userSuspension, new Suspension($this->userSuspension->suspensionID));
         Session::resetSessions($this->userSuspension->userID);
     }
     // delete suspension
     $this->userSuspension->delete();
     $this->executed();
     // forward to list page
     HeaderUtil::redirect('index.php?page=UserSuspensionList&deletedUserSuspensionID=' . $this->userSuspensionID . '&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED);
     exit;
 }
Example #10
0
 /**
  * Creates a new message
  * 
  * @param	int		recipent id
  * @param	string	subject
  * @param 	string	text
  * @param	int		sender id
  * @param	string	sender name
  * @param	int		message type
  */
 public static function create($recipentID, $subject, $text, $senderID = null, $senderName = null, $messageType = 1)
 {
     if ($senderID === null) {
         $senderID = WCF::getUser()->userID;
     }
     if ($senderName === null) {
         require_once LW_DIR . 'lib/data/user/LWUser.class.php';
         $sender = new LWUser($senderID);
         $senderName = $sender->getLinkedUsername();
     }
     // insert
     $sql = "INSERT INTO ugml_messages\r\n\t\t\t\t(message_owner, message_sender, message_time,\r\n\t\t\t\t message_type, message_from, message_subject,\r\n\t\t\t\t message_text)\r\n\t\t\t\tVALUES\r\n\t\t\t\t(" . $recipentID . ", " . $senderID . ", " . time() . ",\r\n\t\t\t\t " . $messageType . ", '" . escapeString($senderName) . "', '" . escapeString($subject) . "',\r\n\t\t\t\t '" . escapeString($text) . "')";
     WCF::getDB()->sendQuery($sql);
     // update user
     $sql = "UPDATE ugml_users\r\n\t\t\t\tSET new_message = new_message + 1\r\n\t\t\t\tWHERE id = " . $recipentID;
     WCF::getDB()->sendQuery($sql);
     Session::resetSessions($recipentID);
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     $sql = "SELECT\t\tuser.*,\n\t\t\t\t\tGROUP_CONCAT(groupID SEPARATOR ',') AS groupIDs\n\t\t\tFROM\t\twcf" . WCF_N . "_user user\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_to_groups groups\n\t\t\tON\t\t(groups.userID = user.userID)\n\t\t\tWHERE\t\tuser.userID IN (" . $this->userIDs . ")\n\t\t\tGROUP BY\tuser.userID";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         if (!Group::isAccessibleGroup(explode(',', $row['groupIDs']))) {
             throw new PermissionDeniedException();
         }
         $user = new UserEditor(null, $row);
         $user->addToGroups($this->groupIDs, false, false);
     }
     UserEditor::unmarkAll();
     Session::resetSessions(explode(',', $this->userIDs));
     $this->saved();
     WCF::getTPL()->assign('message', 'wcf.acp.user.assignToGroup.success');
     WCF::getTPL()->display('success');
     exit;
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // save pm
     $sql = "INSERT INTO\twcf" . WCF_N . "_pm\n\t\t\t\t\t(userID, username, subject, message, time)\n\t\t\tVALUES\t\t(" . WCF::getUser()->userID . ", '" . escapeString(WCF::getUser()->username) . "', '" . escapeString($this->subject) . "', '" . escapeString($this->text) . "', " . TIME_NOW . ")";
     WCF::getDB()->sendQuery($sql);
     $pmID = WCF::getDB()->getInsertID("wcf" . WCF_N . "_pm", 'pmID');
     // save recipients
     $sql = "INSERT INTO\twcf" . WCF_N . "_pm_to_user\n\t\t\t\t\t(pmID, recipientID, recipient, isBlindCopy)\n\t\t\tSELECT\t\t" . $pmID . ", user_to_groups.userID, user_table.username, 1\n\t\t\tFROM\t\twcf" . WCF_N . "_user_to_groups user_to_groups\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user user_table\n\t\t\tON\t\t(user_table.userID = user_to_groups.userID)\n\t\t\tWHERE\t\tuser_to_groups.groupID = " . $this->groupID;
     WCF::getDB()->sendQuery($sql);
     // update counters
     $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\tSET\tpmUnreadCount = pmUnreadCount + 1,\n\t\t\t\tpmOutstandingNotifications = pmOutstandingNotifications + 1\n\t\t\tWHERE\tuserID IN (\n\t\t\t\t\tSELECT\tuserID\n\t\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\t\tWHERE\tgroupID = " . $this->groupID . "\n\t\t\t\t)";
     WCF::getDB()->sendQuery($sql);
     // reset sessions
     Session::resetSessions(array(), true, false);
     $this->executed();
     HeaderUtil::redirect('index.php?form=UserGroupAdministrate&groupID=' . $this->groupID . '&pmSuccess=1' . SID_ARG_2ND_NOT_ENCODED);
     exit;
 }
Example #13
0
 /**
  * Deletes this news.
  */
 public function delete()
 {
     $identifier = $this->getIdentifier();
     $hash = sha1($identifier);
     WCF::getDB()->sendQuery("START TRANSACTION");
     // user settings
     // TODO: create a class, that handles this
     $sql = "SELECT GROUP_CONCAT(userID)\n\t\t\t\tFROM ugml_user_setting\n\t\t\t\tWHERE hash = '" . $hash . "'\n\t\t\t\tGROUP BY hash";
     $row = WCF::getDB()->getFirstRow($sql);
     $userIDs = $row['userIDs'];
     Session::resetSessions($userIDs, true, false);
     $sql = "DELETE FROM ugml_user_setting\n\t\t\t\tWHERE hash = '" . $hash . "'";
     WCF::getDB()->sendQuery($sql);
     // news itself
     $sql = "DELETE FROM ugml_news\n\t\t\t\tWHERE newsID = " . $this->newsID;
     WCF::getDB()->sendQuery($sql);
     WCF::getCache()->addResource('news-' . PACKAGE_ID, WCF_DIR . 'cache/cache.news-' . PACKAGE_ID . '.php', LW_DIR . 'lib/system/cache/CacheBuilderNews.class.php');
     WCF::getCache()->clearResource('news-' . PACKAGE_ID);
     WCF::getDB()->sendQuery("COMMIT");
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // check permission
     WCF::getUser()->checkPermission('admin.avatar.canDisableAvatar');
     // enable avatar
     require_once WCF_DIR . 'lib/data/user/UserEditor.class.php';
     $user = new UserEditor($this->userID);
     if (!$user->userID) {
         throw new IllegalLinkException();
     }
     $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\tSET\tdisableAvatar = 0\n\t\t\tWHERE\tuserID = " . $this->userID;
     WCF::getDB()->sendQuery($sql);
     // reset session
     Session::resetSessions($this->userID, true, false);
     $this->executed();
     // forward to list page
     HeaderUtil::redirect('index.php?page=AvatarList&type=1&pageNo=' . $this->pageNo . '&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED);
     exit;
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     AbstractAction::execute();
     // check permission
     WCF::getUser()->checkPermission('admin.user.canEnableUser');
     if (count($this->userIDs) > 0) {
         // check permission
         $sql = "SELECT\tDISTINCT groupID\n\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\tWHERE\tuserID IN (" . implode(',', $this->userIDs) . ")";
         $result = WCF::getDB()->sendQuery($sql);
         while ($row = WCF::getDB()->fetchArray($result)) {
             if (!Group::isAccessibleGroup($row['groupID'])) {
                 throw new PermissionDeniedException();
             }
         }
         // update groups
         $sql = "DELETE FROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\tWHERE\t\tuserID IN (" . implode(',', $this->userIDs) . ")\n\t\t\t\t\t\tAND groupID <> " . Group::getGroupIdByType(Group::EVERYONE);
         WCF::getDB()->sendQuery($sql);
         $sql = "INSERT IGNORE INTO\twcf" . WCF_N . "_user_to_groups\n\t\t\t\t\t\t\t(userID, groupID)\n\t\t\t\tVALUES\t\t\t(" . implode(', ' . Group::getGroupIdByType(Group::GUESTS) . '),(', $this->userIDs) . ", '" . Group::getGroupIdByType(Group::GUESTS) . "')";
         WCF::getDB()->sendQuery($sql);
         // update activation code
         foreach ($this->userIDs as $userID) {
             $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\t\tSET\tactivationCode = " . UserRegistrationUtil::getActivationCode() . "\n\t\t\t\t\tWHERE\tuserID = " . $userID;
             WCF::getDB()->sendQuery($sql);
         }
         // unmark users
         UserEditor::unmarkAll();
         // reset sessions
         Session::resetSessions($this->userIDs);
     }
     $this->executed();
     if (!empty($this->url)) {
         HeaderUtil::redirect($this->url);
     } else {
         // set active menu item
         WCFACP::getMenu()->setActiveMenuItem('wcf.acp.menu.link.user.management');
         // show succes message
         WCF::getTPL()->assign('message', 'wcf.acp.user.disable.success');
         WCF::getTPL()->display('success');
     }
     exit;
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     AbstractAction::execute();
     // check permission
     if (!GroupApplicationEditor::isGroupLeader(WCF::getUser(), $this->groupID)) {
         throw new PermissionDeniedException();
     }
     if (MODULE_MODERATED_USER_GROUP != 1) {
         throw new IllegalLinkException();
     }
     // remove users
     if (count($this->userIDs)) {
         $sql = "DELETE FROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\tWHERE\t\tuserID IN (" . implode(',', $this->userIDs) . ")\n\t\t\t\t\t\tAND groupID = " . $this->groupID;
         WCF::getDB()->sendQuery($sql);
         // reset sessions
         Session::resetSessions($this->userIDs);
     }
     $this->executed();
     HeaderUtil::redirect('index.php?form=UserGroupAdministrate&groupID=' . $this->groupID . SID_ARG_2ND_NOT_ENCODED);
     exit;
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     $inserts = $fields = '';
     foreach ($this->permissionSettings as $name) {
         $fields .= ', ' . $name;
     }
     foreach ($this->boardPermissions as $boardID => $permissions) {
         $noDefaultValue = false;
         foreach ($permissions as $value) {
             if ($value != -1) {
                 $noDefaultValue = true;
             }
         }
         if (!$noDefaultValue) {
             continue;
         }
         if (!empty($inserts)) {
             $inserts .= ',';
         }
         $inserts .= '(' . intval($boardID) . ', ' . $this->groupID;
         foreach ($this->permissionSettings as $name) {
             $inserts .= ', ' . (isset($permissions[$name]) ? $permissions[$name] : -1);
         }
         $inserts .= ')';
     }
     // delete old entries
     $sql = "DELETE FROM\twbb" . WBB_N . "_board_to_group\n\t\t\tWHERE\t\tgroupID = " . $this->groupID;
     WCF::getDB()->sendQuery($sql);
     if (!empty($inserts)) {
         $sql = "INSERT IGNORE INTO\twbb" . WBB_N . "_board_to_group\n\t\t\t\t\t\t\t(boardID, groupID" . $fields . ")\n\t\t\t\tVALUES\t\t\t" . $inserts;
         WCF::getDB()->sendQuery($sql);
     }
     // reset permissions cache
     WCF::getCache()->clear(WBB_DIR . 'cache/', 'cache.boardPermissions-*', true);
     // reset sessions
     Session::resetSessions(array(), true, false);
     $this->saved();
     // show success message
     WCF::getTPL()->assign('success', true);
 }
Example #18
0
 /**
  * Changes the actual planet.
  *
  * @param	int		planet id
  * @param	string	class name
  */
 public function changePlanet($planetID, $planetClassName)
 {
     global $planetrow;
     $sql = "UPDATE ugml" . LW_N . "_users\r\n\t\t\t\tSET current_planet = " . $planetID . ",\r\n\t\t\t\t\tplanetClassName = '" . $planetClassName . "'\r\n\t\t\t\tWHERE id = " . $this->userID;
     WCF::getDB()->sendQuery($sql);
     $this->current_planet = $planetID;
     $this->planetClassName = $planetClassName;
     //WCF::getSession()->setUpdate(true);
     // reinit planet
     //LWCore::initPlanet();
     Session::resetSessions($this->userID, true, false);
     // update old ugamela vars
     $planetrow = array_merge((array) $planetrow, (array) $this->getPlanet(), $this->getPlanet()->data);
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     if ($this->action == 'rename') {
         LWCore::getPlanet()->getEditor()->rename($this->newName);
     } else {
         if ($this->action == 'delete') {
             die('delete');
             if (LWCore::getPlanet()->planetKind == 1 && LWCore::getPlanet()->getMoon() != null) {
                 LWCore::getPlanet()->getMoon()->getEditor()->delete();
             }
             LWCore::getPlanet()->getEditor()->delete();
             $sql = "UPDATE ugml_users\r\n\t\t\t\t\tSET current_planet = id_planet\r\n\t\t\t\t\tWHERE id = " . WCF::getUser()->userID;
             WCF::getDB()->sendQuery($sql);
             Session::resetSessions(WCF::getUser()->userID);
             $this->saved();
             header('Location: index.php?page=Overview&cp=' . WCF::getUser()->id_planet);
             exit;
         }
     }
     $this->saved();
 }
 /**
  * @see Page::show()
  */
 public function show()
 {
     // enable menu item
     WCFACP::getMenu()->setActiveMenuItem('wcf.acp.menu.link.group');
     Session::resetSessions();
     WCF::getUser()->checkPermission('admin.user.canPMToUserGroups');
     // show form
     parent::show();
 }
 /**
  * Finalises uninstallation of this package.
  * 
  * @return 	string 		nextStep
  */
 protected function finishUninstallation()
 {
     // reset all cache resources
     WCF::getCache()->clear(WCF_DIR . 'cache', '*.php', true);
     // unregister package installation plugins
     WCF::getSession()->unregister('queueID' . $this->queueID . 'PIPs');
     // mark this package uninstallation as done
     $sql = "UPDATE\twcf" . WCF_N . "_package_installation_queue\n\t\t\tSET\tdone = 1\n\t\t\tWHERE\tqueueID = " . $this->queueID;
     WCF::getDB()->sendQuery($sql);
     // search for other open queue entries in current level
     $sql = "SELECT\t\tqueueID, action\n\t\t\tFROM\t\twcf" . WCF_N . "_package_installation_queue\n\t\t\tWHERE\t\tparentQueueID = " . $this->parentQueueID . "\n\t\t\t\t\tAND processNo = " . $this->processNo . "\n\t\t\t\t\tAND done = 0\n\t\t\tORDER BY\tqueueID";
     $row = WCF::getDB()->getFirstRow($sql);
     if (isset($row['queueID'])) {
         // other entries found
         WCF::getTPL()->assign(array('action' => $row['action'], 'queueID' => $row['queueID'], 'processNo' => $this->processNo));
         // reload installation frame
         // and uninstall next package
         WCF::getTPL()->display('packageInstallationReloadFrame');
         exit;
     } else {
         // nothing to do
         // finish uninstallation
         // delete all package installation queue entries with the active process number
         $sql = "DELETE FROM\twcf" . WCF_N . "_package_installation_queue\n\t\t\t\tWHERE\t\tprocessNo = " . $this->processNo;
         WCF::getDB()->sendQuery($sql);
         // reset sessions
         Session::resetSessions();
         // var to redirect to package list
         WCF::getTPL()->assign('installationType', 'other');
         // show finish page
         WCF::getTPL()->display('packageInstallationFinish');
         exit;
     }
 }
 /**
  * Checks the warnings of a user and applies suspensions.
  * 
  * @param	integer		$userID
  */
 public static function checkWarnings($userID)
 {
     // get suspensions
     $sql = "SELECT\t\t*\n\t\t\tFROM\t\twcf" . WCF_N . "_user_infraction_suspension\n\t\t\tWHERE\t\tpackageID IN (\n\t\t\t\t\t\tSELECT\tdependency\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package_dependency\n\t\t\t\t\t\tWHERE\tpackageID = " . PACKAGE_ID . "\n\t\t\t\t\t)\n\t\t\t\t\tAND points <= IFNULL((\n\t\t\t\t\t\tSELECT\tSUM(points)\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_user_infraction_warning_to_user\n\t\t\t\t\t\tWHERE\tuserID = " . $userID . "\n\t\t\t\t\t\t\tAND (\n\t\t\t\t\t\t\t\texpires >= " . TIME_NOW . "\n\t\t\t\t\t\t\t\tOR expires = 0\n\t\t\t\t\t\t\t)\n\t\t\t\t\t), 0)\n\t\t\t\t\tAND suspensionID NOT IN (\n\t\t\t\t\t\tSELECT\tsuspensionID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_user_infraction_suspension_to_user\n\t\t\t\t\t\tWHERE\tuserID = " . $userID . "\n\t\t\t\t\t\t\tAND (\n\t\t\t\t\t\t\t\texpires >= " . TIME_NOW . "\n\t\t\t\t\t\t\t\tOR expires = 0\n\t\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\tORDER BY \tpoints DESC";
     $result = WCF::getDB()->sendQuery($sql);
     if (WCF::getDB()->countRows($result) > 0) {
         $user = new UserEditor($userID);
         while ($row = WCF::getDB()->fetchArray($result)) {
             // get suspension
             $suspension = new Suspension(null, $row);
             // create user suspension
             $userSuspension = UserSuspensionEditor::create($userID, $suspension->suspensionID, $suspension->expires != 0 ? TIME_NOW + $suspension->expires : 0);
             // get suspension type
             $suspensionTypeObject = Suspension::getSuspensionTypeObject($suspension->suspensionType);
             // apply suspension
             $suspensionTypeObject->apply($user, $userSuspension, $suspension);
         }
         // reset session
         Session::resetSessions($userID);
     }
 }
 /** 
  * Installs sql tables, columns or indeces. 
  */
 public function install()
 {
     parent::install();
     // extract sql file from archive
     if ($this->sqlStr = $this->readSQL($this->installation)) {
         $standalonePackage = $this->installation->getPackage();
         if ($standalonePackage->getParentPackageID()) {
             // package is a plugin; get parent package
             $standalonePackage = $standalonePackage->getParentPackage();
         }
         if ($standalonePackage->isStandalone() == 1) {
             // package is standalone
             $packageAbbr = $standalonePackage->getAbbreviation();
             $tablePrefix = WCF_N . '_' . $standalonePackage->getInstanceNo() . '_';
             // Replace the variable xyz1_1 with $tablePrefix in the table names.
             $this->sqlStr = str_replace($packageAbbr . '1_1_', $packageAbbr . $tablePrefix, $this->sqlStr);
         }
         // replace wcf1_  with the actual WCF_N value
         $this->sqlStr = str_replace("wcf1_", "wcf" . WCF_N . "_", $this->sqlStr);
         // replace charset configuration
         if (Database::$dbCharsets[CHARSET] != 'utf8') {
             $this->sqlStr = str_replace('DEFAULT CHARSET=utf8', 'DEFAULT CHARSET=' . Database::$dbCharsets[CHARSET], $this->sqlStr);
         }
         // get dontAskAgain value from session
         $handleType = WCF::getSession()->getVar('overrideTablesUserDescission');
         $isSetInSession = false;
         if (empty($handleType)) {
             $handleType = 'askAgain';
         } else {
             $isSetInSession = true;
         }
         // check if user decided to not show him again conflicted tables
         if (isset($_POST['dontAskAgainOverride'])) {
             $handleType = $_POST['dontAskAgainOverride'] ? 'dontAskAgainOverride' : 'askAgain';
         } elseif (isset($_POST['dontAskAgainKeep'])) {
             $handleType = $_POST['dontAskAgainKeep'] ? 'dontAskAgainKeep' : 'askAgain';
         }
         if ($handleType == 'dontAskAgainKeep') {
             $this->keepAll = true;
         }
         // store in session
         if (!$isSetInSession && $handleType != 'askAgain') {
             WCF::getSession()->register('overrideTablesUserDescission', $handleType);
             WCF::getSession()->update();
             Session::resetSessions();
         }
         // check and edit (if a table should not be overwritten) sql string
         $this->checkSQL($this->installation->getPackageID(), $this->installation->getAction());
         // display overrides template
         if ($handleType == 'askAgain' && !isset($_POST['overrideTables']) && count($this->overrideTables) > 0) {
             // rearrange array. store each table just one time
             foreach ($this->overrideTables as $table) {
                 $tmp[$table['tableName']][] = $table['overrideType'];
             }
             $this->overrideTables = array();
             // make an indexed array for the javascript funktion selectAll
             foreach ($tmp as $tableName => $table) {
                 $this->overrideTables[] = array('tableName' => $tableName, 'overrideTypes' => $table);
             }
             WCF::getTPL()->assign('tables', $this->overrideTables);
             WCF::getTPL()->display('packageInstallationCheckOverrideTables');
             exit;
         }
         // execute queries
         QueryParser::sendQueries($this->sqlStr, $this->installation->getPackageID());
     }
 }
 /**
  * Updates the amount of activity points of a user.
  * 
  * @param	integer		$points
  * @param	integer		$userID
  * @param	integer		$packageID
  */
 public static function updateActivityPoints($points, $userID = null, $packageID = PACKAGE_ID)
 {
     // get user object
     if ($userID === null) {
         $user = WCF::getUser();
     } else {
         $user = new User($userID);
         if (!$user->userID) {
             return false;
         }
     }
     if ($points != 0) {
         // update activity points for the package
         $sql = "UPDATE\twcf" . WCF_N . "_user_activity_point\n\t\t\t\tSET\tactivityPoints = IF(" . $points . " > 0 OR activityPoints > ABS(" . $points . "), activityPoints + " . $points . ", 0)\n\t\t\t\tWHERE\tuserID = " . $user->userID . "\n\t\t\t\t\tAND packageID = " . $packageID;
         WCF::getDB()->sendQuery($sql);
         if (WCF::getDB()->getAffectedRows() == 0) {
             $sql = "INSERT IGNORE INTO\twcf" . WCF_N . "_user_activity_point\n\t\t\t\t\t\t\t\t(userID, packageID, activityPoints)\n\t\t\t\t\tVALUES\t\t\t(" . $user->userID . ", " . $packageID . ", " . ($points > 0 ? $points : 0) . ")";
             WCF::getDB()->sendQuery($sql);
         }
     }
     // update user new rank
     $newRankID = 0;
     $neededPoints = intval($user->activityPoints + $points);
     if ($neededPoints < 0) {
         $neededPoints = 0;
     }
     $sql = "SELECT\t\trankID\n\t\t\tFROM\t\twcf" . WCF_N . "_user_rank\n\t\t\tWHERE\t\tgroupID IN (" . ($user->rankID ? "(SELECT groupID FROM wcf" . WCF_N . "_user_rank WHERE rankID = " . $user->rankID . ")" : implode(',', $user->getGroupIDs())) . ") \n\t\t\t\t\tAND neededPoints <= " . $neededPoints . "\n\t\t\t\t\tAND gender IN (0," . intval($user->gender) . ")\n\t\t\tORDER BY\tneededPoints DESC, gender DESC";
     $row = WCF::getDB()->getFirstRow($sql);
     if (isset($row['rankID'])) {
         $newRankID = $row['rankID'];
     }
     // update user rank and global activity points
     $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\tSET\tactivityPoints = IF(" . $points . " > 0 OR activityPoints > ABS(" . $points . "), activityPoints + " . $points . ", 0)\n\t\t\t\t" . ($newRankID ? ", rankID = " . $newRankID : "") . "\n\t\t\tWHERE\tuserID = " . $user->userID;
     WCF::getDB()->sendQuery($sql);
     // update user session
     Session::resetSessions($user->userID, true, false);
     return true;
 }
 /**
  * Resets active sessions of this user.
  */
 public function resetSession()
 {
     Session::resetSessions($this->userID);
 }
 /**
  * Resets the board cache after changes.
  */
 protected function resetCache()
 {
     Board::resetCache();
     // reset sessions
     Session::resetSessions(array(), true, false);
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     // active user can't ban himself
     $this->userIDArray = array_diff($this->userIDArray, array(WCF::getUser()->userID));
     if (count($this->userIDArray) > 0) {
         // check permission
         $sql = "SELECT\tDISTINCT groupID\n\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\tWHERE\tuserID IN (" . implode(',', $this->userIDArray) . ")";
         $result = WCF::getDB()->sendQuery($sql);
         while ($row = WCF::getDB()->fetchArray($result)) {
             if (!Group::isAccessibleGroup($row['groupID'])) {
                 throw new PermissionDeniedException();
             }
         }
         // get adminCanMail user option id
         $adminCanMailID = User::getUserOptionID('adminCanMail');
         // update user
         $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\tSET\tbanned = 1,\n\t\t\t\t\tbanReason = '" . escapeString($this->reason) . "'\n\t\t\t\tWHERE\tuserID IN (" . implode(',', $this->userIDArray) . ")";
         WCF::getDB()->sendQuery($sql);
         // update user options
         if ($adminCanMailID !== null) {
             $sql = "UPDATE\twcf" . WCF_N . "_user_option_value\n\t\t\t\t\tSET\tuserOption" . $adminCanMailID . " = 0\n\t\t\t\t\tWHERE\tuserID IN (" . implode(',', $this->userIDArray) . ")";
             WCF::getDB()->sendQuery($sql);
         }
         // unmark users
         UserEditor::unmarkAll();
         // reset sessions
         Session::resetSessions($this->userIDArray);
     }
     $this->saved();
     // forward
     if (empty($this->url)) {
         $this->url = 'index.php?form=UserSearch&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED;
     }
     HeaderUtil::redirect($this->url);
     exit;
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     // save
     $userIDArray = array();
     foreach ($this->users as $user) {
         $userIDArray[] = $user->userID;
         $user->addToGroup($this->groupID);
     }
     // reset sessions
     if (count($userIDArray)) {
         Session::resetSessions($userIDArray);
     }
     $this->saved();
     // reset value
     $this->usernames = '';
     // show success message
     WCF::getTPL()->assign(array('success' => true, 'users' => $this->users));
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     // build conditions
     $this->conditions = new ConditionBuilder();
     // static fields
     if (!empty($this->username)) {
         $this->conditions->add("user.username LIKE '%" . addcslashes(escapeString($this->username), '_%') . "%'");
     }
     if (!empty($this->email)) {
         $this->conditions->add("user.email LIKE '%" . addcslashes(escapeString($this->email), '_%') . "%'");
     }
     if (count($this->groupIDArray) > 0) {
         $this->conditions->add("user.userID " . ($this->invertGroupIDs == 1 ? 'NOT ' : '') . "IN (SELECT userID FROM wcf" . WCF_N . "_user_to_groups WHERE groupID IN (" . implode(',', $this->groupIDArray) . "))");
     }
     if (count($this->languageIDArray) > 0) {
         $this->conditions->add("user.languageID IN (" . implode(',', $this->languageIDArray) . ")");
     }
     // dynamic fields
     foreach ($this->activeOptions as $name => $option) {
         $value = isset($this->values[$option['optionName']]) ? $this->values[$option['optionName']] : null;
         $condition = $this->getTypeObject($option['optionType'])->getCondition($option, $value, isset($this->matchExactly[$name]));
         if ($condition !== false) {
             $this->conditions->add($condition);
         }
     }
     // call buildConditions event
     EventHandler::fireAction($this, 'buildConditions');
     // execute action
     switch ($this->action) {
         case 'sendMail':
             WCF::getUser()->checkPermission('admin.user.canMailUser');
             // get user ids
             $userIDArray = array();
             $sql = "SELECT\t\tuser.userID\n\t\t\t\t\tFROM\t\twcf" . WCF_N . "_user user\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_option_value option_value USING (userID)\n\t\t\t\t\t" . $this->conditions->get();
             $result = WCF::getDB()->sendQuery($sql);
             while ($row = WCF::getDB()->fetchArray($result)) {
                 $userIDArray[] = $row['userID'];
                 $this->affectedUsers++;
             }
             // save config in session
             $userMailData = WCF::getSession()->getVar('userMailData');
             if ($userMailData === null) {
                 $userMailData = array();
             }
             $mailID = count($userMailData);
             $userMailData[$mailID] = array('action' => '', 'userIDs' => implode(',', $userIDArray), 'groupIDs' => '', 'subject' => $this->subject, 'text' => $this->text, 'from' => $this->from, 'enableHTML' => $this->enableHTML);
             WCF::getSession()->register('userMailData', $userMailData);
             $this->saved();
             // show worker template
             WCF::getTPL()->assign(array('pageTitle' => WCF::getLanguage()->get('wcf.acp.user.sendMail'), 'url' => 'index.php?action=UserMail&mailID=' . $mailID . '&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED));
             WCF::getTPL()->display('worker');
             exit;
             break;
         case 'exportMailAddress':
             WCF::getUser()->checkPermission('admin.user.canMailUser');
             // send content type
             header('Content-Type: text/' . $this->fileType . '; charset=' . CHARSET);
             header('Content-Disposition: attachment; filename="export.' . $this->fileType . '"');
             if ($this->fileType == 'xml') {
                 echo "<?xml version=\"1.0\" encoding=\"" . CHARSET . "\"?>\n<addresses>\n";
             }
             // get users
             $sql = "SELECT\t\tuser.email\n\t\t\t\t\tFROM\t\twcf" . WCF_N . "_user user\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_option_value option_value USING (userID)\n\t\t\t\t\t" . $this->conditions->get() . "\n\t\t\t\t\tORDER BY\tuser.email";
             $result = WCF::getDB()->sendQuery($sql);
             $i = 0;
             $j = WCF::getDB()->countRows($result) - 1;
             while ($row = WCF::getDB()->fetchArray($result)) {
                 if ($this->fileType == 'xml') {
                     echo "<address><![CDATA[" . StringUtil::escapeCDATA($row['email']) . "]]></address>\n";
                 } else {
                     echo $this->textSeparator . $row['email'] . $this->textSeparator . ($i < $j ? $this->separator : '');
                 }
                 $i++;
                 $this->affectedUsers++;
             }
             if ($this->fileType == 'xml') {
                 echo "</addresses>";
             }
             $this->saved();
             exit;
             break;
         case 'assignToGroup':
             WCF::getUser()->checkPermission('admin.user.canEditUser');
             $userIDArray = array();
             $sql = "SELECT\t\tuser.*,\n\t\t\t\t\t\t\tGROUP_CONCAT(groupID SEPARATOR ',') AS groupIDs\n\t\t\t\t\tFROM\t\twcf" . WCF_N . "_user user\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_option_value option_value USING (userID)\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_to_groups groups\n\t\t\t\t\tON\t\t(groups.userID = user.userID)\n\t\t\t\t\t" . $this->conditions->get() . "\t\t\n\t\t\t\t\tGROUP BY\tuser.userID";
             $result = WCF::getDB()->sendQuery($sql);
             while ($row = WCF::getDB()->fetchArray($result)) {
                 if (!Group::isAccessibleGroup(explode(',', $row['groupIDs']))) {
                     throw new PermissionDeniedException();
                 }
                 $user = new UserEditor(null, $row);
                 $user->addToGroups($this->assignToGroupIDArray, false, false);
                 $userIDArray[] = $row['userID'];
                 $this->affectedUsers++;
             }
             Session::resetSessions($userIDArray);
             break;
         case 'delete':
             WCF::getUser()->checkPermission('admin.user.canDeleteUser');
             $userIDArray = array();
             $sql = "SELECT\t\tuser.*,\n\t\t\t\t\t\t\tGROUP_CONCAT(groupID SEPARATOR ',') AS groupIDs\n\t\t\t\t\tFROM\t\twcf" . WCF_N . "_user user\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_option_value option_value USING (userID)\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_to_groups groups\n\t\t\t\t\tON\t\t(groups.userID = user.userID)\n\t\t\t\t\t" . $this->conditions->get() . "\t\t\n\t\t\t\t\tGROUP BY\tuser.userID";
             $result = WCF::getDB()->sendQuery($sql);
             while ($row = WCF::getDB()->fetchArray($result)) {
                 if (!Group::isAccessibleGroup(explode(',', $row['groupIDs']))) {
                     throw new PermissionDeniedException();
                 }
                 $userIDArray[] = $row['userID'];
                 $this->affectedUsers++;
             }
             UserEditor::deleteUsers($userIDArray);
             break;
     }
     $this->saved();
     WCF::getTPL()->assign('affectedUsers', $this->affectedUsers);
 }
Example #30
0
$sql = "UPDATE\twcf" . WCF_N . "_group\n\tSET\tgroupName = '" . WCF::getLanguage()->get('wcf.acp.group.guests') . "'\n\tWHERE\tgroupName = 'Guests'";
WCF::getDB()->sendQuery($sql);
$sql = "UPDATE\twcf" . WCF_N . "_group\n\tSET\tgroupName = '" . WCF::getLanguage()->get('wcf.acp.group.users') . "'\n\tWHERE\tgroupName = 'Users'";
WCF::getDB()->sendQuery($sql);
$sql = "UPDATE\twcf" . WCF_N . "_group\n\tSET\tgroupName = '" . WCF::getLanguage()->get('wcf.acp.group.administrators') . "'\n\tWHERE\tgroupName = 'Administrators'";
WCF::getDB()->sendQuery($sql);
$sql = "UPDATE\twcf" . WCF_N . "_group\n\tSET\tgroupName = '" . WCF::getLanguage()->get('wcf.acp.group.moderators') . "'\n\tWHERE\tgroupName = 'Moderators'";
WCF::getDB()->sendQuery($sql);
$sql = "UPDATE\twcf" . WCF_N . "_group\n\tSET\tgroupName = '" . WCF::getLanguage()->get('wcf.acp.group.superModerators') . "'\n\tWHERE\tgroupName = 'Super Moderators'";
WCF::getDB()->sendQuery($sql);
// change the priority of the PIP's to "1"
$sql = "UPDATE\twcf" . WCF_N . "_package_installation_plugin\n\tSET\tpriority = 1";
WCF::getDB()->sendQuery($sql);
// change group options from admin group to true
$sql = "UPDATE\twcf" . WCF_N . "_group_option_value\n\tSET\toptionValue = 1\n\tWHERE\tgroupID = 4\n\t\tAND optionValue = '0'";
WCF::getDB()->sendQuery($sql);
// update accessible groups
$sql = "UPDATE\twcf" . WCF_N . "_group_option_value\n\tSET\toptionValue = '1,2,3,4,5,6'\n\tWHERE\tgroupID = 4\n\t\tAND optionValue = ''";
WCF::getDB()->sendQuery($sql);
// reset sessions
require_once WCF_DIR . 'lib/system/session/Session.class.php';
Session::resetSessions();
// change the packageID from the acp-templates to the wcf-packageID (in database)
$sql = "UPDATE\twcf" . WCF_N . "_acp_template\n\tSET\tpackageID = " . PACKAGE_ID;
WCF::getDB()->sendQuery($sql);
// change the packageID from all installed files to the wcf-packageID (in database)
$sql = "UPDATE\twcf" . WCF_N . "_package_installation_file_log\n\tSET\tpackageID = " . PACKAGE_ID;
WCF::getDB()->sendQuery($sql);
// change the packageID from all installed tables to the wcf-packageID (in database)
$sql = "UPDATE\twcf" . WCF_N . "_package_installation_sql_log\n\tSET\tpackageID = " . PACKAGE_ID;
WCF::getDB()->sendQuery($sql);