/**
  * Get avatar images in a directory
  *
  * @access	protected
  * @return	void		[Outputs to screen]
  */
 protected function _getAvatarImages()
 {
     $dir = IPSText::alphanumericalClean(urldecode($this->request['cat']), ' ');
     $images = IPSMember::getFunction()->getHostedAvatarsFromCategory($dir);
     IPSDebug::fireBug('info', array('Directory: ' . $dir));
     if ($images === FALSE) {
         $this->returnJsonError($this->lang->words['m_nodir']);
         exit;
     } else {
         $output = $this->html->inline_avatar_images($images);
         $this->returnJsonArray(array('html' => $output));
     }
 }
Exemplo n.º 2
0
 /**
  * Get search results count
  *
  * @param	string	[$extraQuery]	Extra query where clause
  * @return	int 	Number of search results
  */
 public function getSearchResultsCount($extraQuery = '')
 {
     $extra = $extraQuery ? " AND " . $extraQuery : '';
     IPSDebug::fireBug('info', array('WHERE: ' . $this->getWhereClause() . $extra));
     $count = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count', 'from' => array('members' => 'm'), 'where' => $this->getWhereClause() . $extra, 'add_join' => array(array('from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'), array('from' => array('pfields_content' => 'p'), 'where' => 'p.member_id=m.member_id', 'type' => 'left'), array('from' => array('members_partial' => 'par'), 'where' => 'par.partial_member_id=m.member_id', 'type' => 'left'), array('from' => array('validating' => 'val'), 'where' => 'val.member_id=m.member_id', 'type' => 'left'))));
     return intval($count['count']);
 }
 /**
  * Executes the ajax request, checks secure key
  *
  * @access	public
  * @param	object	ipsRegistry reference
  * @return	void
  **/
 public function execute(ipsRegistry $registry)
 {
     /* Setup Shortcuts First */
     $this->makeRegistryShortcuts($registry);
     /* Check the secure key */
     $this->request['secure_key'] = $this->request['secure_key'] ? $this->request['secure_key'] : $this->request['md5check'];
     //if( $this->request['secure_key'] && $this->request['secure_key'] != $this->member->form_hash )
     if ($this->request['secure_key'] != $this->member->form_hash) {
         IPSDebug::fireBug('error', array("The security key did not match the member's form hash"));
         $this->returnString('nopermission');
     }
     $this->doExecute($registry);
 }
Exemplo n.º 4
0
 /**
  * Returns an array of the allowed upload sizes in bytes.
  * Return 'space_allowed' as -1 to not allow uploads.
  * Return 'space_allowed' as 0 to allow unlimited uploads
  * Return 'max_single_upload' as 0 to not set a limit
  *
  * @param	string		MD5 post key
  * @param	id			Member ID
  * @return	array 		[ 'space_used', 'space_left', 'space_allowed', 'max_single_upload' ]
  */
 public function getSpaceAllowance($post_key = '', $member_id = '')
 {
     $max_php_size = IPSLib::getMaxPostSize();
     $member_id = intval($member_id ? $member_id : $this->memberData['member_id']);
     $forum_id = intval(ipsRegistry::$request['forum_id'] ? ipsRegistry::$request['forum_id'] : ipsRegistry::$request['f']);
     $space_left = 0;
     $space_used = 0;
     $space_allowed = 0;
     $max_single_upload = 0;
     $space_calculated = 0;
     if ($post_key) {
         //-----------------------------------------
         // Check to make sure we're not attempting
         // to upload to another's post...
         //-----------------------------------------
         if (!$this->memberData['g_is_supmod'] and !$this->memberData['is_mod']) {
             $post = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'posts', 'where' => "post_key='{$post_key}'"));
             if ($post['post_key'] and $post['author_id'] != $member_id) {
                 $space_allowed = -1;
                 $space_calculated = 1;
             }
         }
     }
     //-----------------------------------------
     // Generate total space allowed
     //-----------------------------------------
     $total_space_allowed = ($this->memberData['g_attach_per_post'] ? $this->memberData['g_attach_per_post'] : $this->memberData['g_attach_max']) * 1024;
     //-----------------------------------------
     // Allowed to attach?
     //-----------------------------------------
     if (!$member_id or !$forum_id) {
         $space_allowed = -1;
     }
     if (IPSMember::checkPermissions('upload', $forum_id) !== TRUE) {
         $space_allowed = -1;
     } else {
         if (!$space_calculated) {
             //-----------------------------------------
             // Generate space allowed figure
             //-----------------------------------------
             if ($this->memberData['g_attach_per_post']) {
                 //-----------------------------------------
                 // Per post limit...
                 //-----------------------------------------
                 $_space_used = $this->DB->buildAndFetch(array('select' => 'SUM(attach_filesize) as figure', 'from' => 'attachments', 'where' => "attach_post_key='{$post_key}'"));
                 $space_used = $_space_used['figure'] ? $_space_used['figure'] : 0;
             } else {
                 //-----------------------------------------
                 // Global limit...
                 //-----------------------------------------
                 $_space_used = $this->DB->buildAndFetch(array('select' => 'SUM(attach_filesize) as figure', 'from' => 'attachments', 'where' => "attach_member_id={$member_id} AND attach_rel_module IN( 'post', 'msg' )"));
                 $space_used = $_space_used['figure'] ? $_space_used['figure'] : 0;
             }
             if ($this->memberData['g_attach_max'] > 0) {
                 if ($this->memberData['g_attach_per_post']) {
                     $_g_space_used = $this->DB->buildAndFetch(array('select' => 'SUM(attach_filesize) as figure', 'from' => 'attachments', 'where' => "attach_member_id={$member_id} AND attach_rel_module IN( 'post', 'msg' )"));
                     $g_space_used = $_g_space_used['figure'] ? $_g_space_used['figure'] : 0;
                     if ($this->memberData['g_attach_max'] * 1024 - $g_space_used < 0) {
                         $space_used = $g_space_used;
                         $total_space_allowed = $this->memberData['g_attach_max'] * 1024;
                         $space_allowed = $this->memberData['g_attach_max'] * 1024 - $space_used;
                         $space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
                     } else {
                         $space_allowed = $this->memberData['g_attach_per_post'] * 1024 - $space_used;
                         $space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
                     }
                 } else {
                     $space_allowed = $this->memberData['g_attach_max'] * 1024 - $space_used;
                     $space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
                 }
             } else {
                 if ($this->memberData['g_attach_per_post']) {
                     $space_allowed = $this->memberData['g_attach_per_post'] * 1024 - $space_used;
                     $space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
                 } else {
                     # Unlimited
                     $space_allowed = 0;
                 }
             }
             //-----------------------------------------
             // Generate space left figure
             //-----------------------------------------
             $space_left = $space_allowed ? $space_allowed : 0;
             $space_left = $space_left < 0 ? -1 : $space_left;
             //-----------------------------------------
             // Generate max upload size
             //-----------------------------------------
             if (!$max_single_upload) {
                 if ($space_left > 0 and $space_left < $max_php_size) {
                     $max_single_upload = $space_left;
                 } else {
                     if ($max_php_size) {
                         $max_single_upload = $max_php_size;
                     }
                 }
             }
         }
     }
     IPSDebug::fireBug('info', array('Space left: ' . $space_left));
     IPSDebug::fireBug('info', array('Max PHP size: ' . $max_php_size));
     IPSDebug::fireBug('info', array('Max single file size: ' . $max_single_upload));
     $return = array('space_used' => $space_used, 'space_left' => $space_left, 'space_allowed' => $space_allowed, 'max_single_upload' => $max_single_upload, 'total_space_allowed' => $total_space_allowed);
     return $return;
 }
Exemplo n.º 5
0
 /**
  * Change a member's password
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function save_password()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $member_id = intval($this->request['member_id']);
     $password = IPSText::parseCleanValue($_POST['password']);
     $password2 = IPSText::parseCleanValue($_POST['password2']);
     $new_key = intval($this->request['new_key']);
     $new_salt = intval($this->request['new_salt']);
     $salt = str_replace('\\', "\\\\", IPSMember::generatePasswordSalt(5));
     $key = IPSMember::generateAutoLoginKey();
     $md5_once = md5(trim($password));
     //-----------------------------------------
     // AJAX debug
     //-----------------------------------------
     IPSDebug::fireBug('info', array('Password: '******'password_nogood']);
     }
     if ($password != $password2) {
         $this->registry->output->showError($this->lang->words['m_passmatch']);
     }
     //-----------------------------------------
     // Get member
     //-----------------------------------------
     $member = IPSMember::load($member_id);
     //-----------------------------------------
     // Allowed to edit administrators?
     //-----------------------------------------
     if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_edit_admin', 'members', 'members')) {
         $this->registry->output->showError($this->lang->words['m_editadmin']);
     }
     //-----------------------------------------
     // Check Converge: Password
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login');
     $han_login = new $classToLoad($this->registry);
     $han_login->init();
     $han_login->changePass($member['email'], $md5_once, $password, $member);
     /*if ( $han_login->return_code != 'METHOD_NOT_DEFINED' AND $han_login->return_code != 'SUCCESS' )
        	{
     		$this->returnJsonError( $this->lang->words['m_passchange']);
     		exit();
        	}*/
     //-----------------------------------------
     // Local DB
     //-----------------------------------------
     $update = array();
     if ($new_salt) {
         $update['members_pass_salt'] = $salt;
     }
     if ($new_key) {
         $update['member_login_key'] = $key;
     }
     if (count($update)) {
         IPSMember::save($member_id, array('core' => $update));
     }
     IPSMember::updatePassword($member_id, $md5_once);
     IPSLib::runMemberSync('onPassChange', $member_id, $password);
     ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_passlog'], $member_id));
     $this->registry->output->global_message = $this->lang->words['pw_updated_success'];
     $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . 'module=members&do=viewmember&member_id=' . $member_id);
 }
Exemplo n.º 6
0
 /**
  * Check if search term is found in groups language file or in the group_cache.g_title
  *
  * @param	string		Search term
  * @param	array 		Existing search results
  * @return	array 		New search results
  */
 protected function _checkGroups($term, $results)
 {
     if (!$this->registry->getClass('class_permissions')->checkPermission('groups_edit', 'members', 'groups')) {
         $results['groups'] = array();
         return $results;
     }
     $term = strtolower($term);
     $this->registry->class_localization->loadLanguageFile(array('admin_groups'), 'members');
     $this->registry->class_localization->loadLanguageFile(array('admin_forums'), 'forums');
     $this->registry->class_localization->loadLanguageFile(array('admin_gallery'), 'gallery');
     $this->registry->class_localization->loadLanguageFile(array('admin_blog'), 'blog');
     $this->registry->class_localization->loadLanguageFile(array('admin_downloads'), 'downloads');
     foreach ($this->lang->words as $k => $v) {
         if (strpos($k, 'gf_') !== false and strpos($v, $term) !== false) {
             IPSDebug::fireBug('info', array('Group key found: ' . $k . ': ' . $v));
             $results['groupLangs'] = true;
             break;
         }
     }
     /* Now check group names */
     $groups = $this->cache->getCache('group_cache');
     if (is_array($groups) and count($groups)) {
         foreach ($groups as $id => $data) {
             $_term = preg_quote($term, '#');
             if (preg_match("#" . $_term . "#i", $data['g_title'])) {
                 $results['groups'][] = array('name' => IPSMember::makeNameFormatted($data['g_title'], $data['g_id']), 'url' => $this->settings['_base_url'] . "&amp;app=members&amp;module=groups&amp;section=groups&amp;do=edit&amp;id=" . $data['g_id']);
             }
         }
     }
     return $results;
 }
Exemplo n.º 7
0
 /**
  * Show the results
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function show()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('members') . '/sources/adminSearch.php', 'adminMemberSearch', 'members');
     $searchHelper = new $classToLoad($this->registry);
     $html = $this->registry->output->loadTemplate('cp_skin_member');
     //-----------------------------------------
     // Get the number of results
     //-----------------------------------------
     $count = $searchHelper->getSearchResultsCount();
     IPSDebug::fireBug('info', array('Total results:' . $count));
     //-----------------------------------------
     // Generate pagination
     //-----------------------------------------
     $st = intval($this->request['st']);
     $perpage = 20;
     $pages = $this->registry->output->generatePagination(array('totalItems' => $count, 'itemsPerPage' => $perpage, 'currentStartValue' => $st, 'baseUrl' => $this->settings['base_url'] . 'module=members&amp;section=members'));
     //-----------------------------------------
     // Run the query
     //-----------------------------------------
     $members = $searchHelper->getSearchResults($st, $perpage);
     IPSDebug::fireBug('info', array('Total results (2):' . count($members)));
     //-----------------------------------------
     // Format results
     //-----------------------------------------
     $_memberOutput = '';
     if (count($members)) {
         foreach ($members as $member) {
             /* Ensure encoding is safe */
             //$member['members_display_name'] = IPSText::encodeForXml( $member['members_display_name'] );
             //$member['name'] 			    = IPSText::encodeForXml( $member['name'] );
             /* The above causes strings returned on utf-8 sites to be entirely corrupted
             			@link http://community.invisionpower.com/tracker/issue-32444-ajax-for-text-in-acp */
             IPSDebug::fireBug('info', array('Showing member:' . $member['members_display_name'] . ' (' . $member['email'] . ' - ' . $member['member_id'] . ')'));
             switch ($searchHelper->getMemberType()) {
                 case 'all':
                 default:
                     $_memberOutput .= $html->memberListRow($member);
                     break;
                 case 'spam':
                     $_memberOutput .= $html->memberListRow_spam($member);
                     break;
                 case 'banned':
                     $_memberOutput .= $html->memberListRow_banned($member);
                     break;
                 case 'locked':
                     $_memberOutput .= $html->memberListRow_locked($member);
                     break;
                 case 'validating':
                     $_memberOutput .= $html->memberListRow_validating($member);
                     break;
                 case 'incomplete':
                     $_memberOutput .= $html->memberListRow_incomplete($member);
                     break;
             }
         }
     } else {
         $_memberOutput = $html->memberListRow_empty();
     }
     //-----------------------------------------
     // Return as JSON
     //-----------------------------------------
     $this->returnJsonArray(array('count' => $count, 'pages' => $pages, 'members' => $_memberOutput));
 }
 /**
  * Saves a ajax topic title edit
  *
  * @access	public
  * @return	void
  **/
 public function saveTopicTitle()
 {
     /* INIT */
     IPSDebug::fireBug('info', array('Initial name: ' . $_POST['name']));
     $name = $this->convertAndMakeSafe($_POST['name'], TRUE);
     IPSDebug::fireBug('info', array('after convert and make safe: ' . $name));
     $title_seo = IPSText::makeSeoTitle($name);
     $tid = intval($this->request['tid']);
     $can_edit = 0;
     IPSDebug::fireBug('info', array('The topic title after converting is: ' . $name));
     /* Check ID */
     if (!$tid) {
         $this->returnJsonError($this->lang->words['ajax_no_topic_id']);
     }
     /* Load Topic */
     $topic = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'topics', 'where' => 'tid=' . $tid));
     if (!$topic['tid']) {
         $this->returnJsonError($this->lang->words['ajax_topic_not_found']);
     }
     /* Check Permissions */
     if ($this->memberData['g_is_supmod']) {
         $can_edit = 1;
     } else {
         if (is_array($this->memberData['forumsModeratorData']) and $this->memberData['forumsModeratorData'][$topic['forum_id']]['edit_topic']) {
             $can_edit = 1;
         }
     }
     if (!$can_edit) {
         $this->returnJsonError($this->lang->words['ajax_no_t_permission']);
     }
     /* Make sure we have a valid name */
     if (trim($name) == '' || !$name) {
         $this->returnJsonError($this->lang->words['ajax_no_t_name']);
         exit;
     }
     if ($this->settings['etfilter_punct']) {
         $name = preg_replace("/\\?{1,}/", "?", $name);
         $name = preg_replace("/(&#33;){1,}/", "&#33;", $name);
     }
     if ($this->settings['etfilter_shout']) {
         if (function_exists('mb_convert_case')) {
             if (in_array(strtolower($this->settings['gb_char_set']), array_map('strtolower', mb_list_encodings()))) {
                 $name = mb_convert_case($name, MB_CASE_TITLE, $this->settings['gb_char_set']);
             } else {
                 $name = ucwords($name);
             }
         } else {
             $name = ucwords($name);
         }
     }
     IPSDebug::fireBug('info', array('The topic title after removing shout is: ' . $name));
     /* Update the topic */
     $this->DB->update('topics', array('title' => $name, 'title_seo' => $title_seo), 'tid=' . $tid);
     $this->DB->insert('moderator_logs', array('forum_id' => intval($topic['forum_id']), 'topic_id' => $tid, 'member_id' => $this->memberData['member_id'], 'member_name' => $this->memberData['members_display_name'], 'ip_address' => $this->request['IP_ADDRESS'], 'http_referer' => htmlspecialchars(getenv('HTTP_REFERER')), 'ctime' => time(), 'topic_title' => $name, 'action' => sprintf($this->lang->words['ajax_topictitle'], $topic['title'], $name), 'query_string' => htmlspecialchars(getenv('QUERY_STRING'))));
     /* Update the last topic title? */
     if ($topic['tid'] == $this->registry->class_forums->forum_by_id[$topic['forum_id']]['last_id']) {
         $this->DB->update('forums', array('last_title' => $name, 'seo_last_title' => $title_seo), 'id=' . $topic['forum_id']);
     }
     if ($topic['tid'] == $this->registry->class_forums->forum_by_id[$topic['forum_id']]['newest_id']) {
         $this->DB->update('forums', array('newest_title' => $name), 'id=' . $topic['forum_id']);
     }
     /* All Done */
     $this->returnJsonArray(array('title' => $name, 'url' => $this->registry->output->buildSEOUrl('showtopic=' . $tid, 'public', $title_seo, 'showtopic')));
 }
Exemplo n.º 9
0
 /**
  * Removes a folder
  *
  * @return	string		JSON either error or status
  * @since	IPB 3.0.0.2008-06-25
  */
 protected function _removeFolder()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $folderID = IPSText::alphanumericalClean($this->request['folderID']);
     $memberID = intval($this->request['memberID']);
     $memberData = IPSMember::load($memberID, 'extendedProfile');
     $status = 'ok';
     IPSDebug::fireBug('info', array('Received folder id:' . $folderID));
     IPSDebug::fireBug('info', array('Received member id:' . $memberID));
     //-----------------------------------------
     // First off, get dir data
     //-----------------------------------------
     $folders = $this->messengerFunctions->explodeFolderData($memberData['pconversation_filters']);
     //-----------------------------------------
     // Check
     //-----------------------------------------
     if (!$memberData['member_id'] or !$folderID) {
         IPSDebug::fireBug('error', array('Missing member id or folder id'));
         $this->returnJsonError('noSuchFolder');
     }
     //-----------------------------------------
     // Now ensure we actually have that folder
     //-----------------------------------------
     if (!$folders[$folderID]) {
         IPSDebug::fireBug('error', array('Specified folder does not exist'));
         $this->returnJsonError('noSuchFolder');
     }
     //-----------------------------------------
     // Protected folder?
     //-----------------------------------------
     /* Protected? */
     if ($folders[$folderID]['protected']) {
         $this->returnJsonError('cannotDeleteUndeletable');
     }
     //-----------------------------------------
     // .. and it has no messages
     // Change May 9 2011 - JS alert already warns that
     // all messages in folder will be deleted, so just empty and delete
     // @link http://community.invisionpower.com/tracker/issue-29857-cannot-delete-pm-folder
     //-----------------------------------------
     //if ( $folders[ $folderID ]['count'] > 0 )
     //{
     //	$this->returnJsonError( 'cannotDeleteHasMessages' );
     //}
     $messages = $this->messengerFunctions->getPersonalTopicsList($memberID, $folderID, array('offsetStart' => 0, 'offsetEnd' => 100000));
     /* Just grab IDs */
     $mtids = array_keys($messages);
     try {
         $this->messengerFunctions->deleteTopics($memberData['member_id'], $mtids);
     } catch (Exception $error) {
         if ($error->getMessage() != 'NO_IDS_TO_DELETE') {
             $this->returnJsonError($error->getMessage());
         }
     }
     //-----------------------------------------
     // OK, remove it.
     //-----------------------------------------
     unset($folders[$folderID]);
     ///-----------------------------------------
     // Collapse
     //-----------------------------------------
     $newDirs = $this->messengerFunctions->implodeFolderData($folders);
     //-----------------------------------------
     // Save...
     //-----------------------------------------
     IPSMember::save($memberID, array('extendedProfile' => array('pconversation_filters' => $newDirs)));
     //-----------------------------------------
     // Return...
     //-----------------------------------------
     $this->returnJsonArray(array('status' => $status, 'newDirs' => $newDirs));
 }
Exemplo n.º 10
0
 /**
  * Returns an array of the allowed upload sizes in bytes.
  * Return 'space_allowed' as -1 to not allow uploads.
  * Return 'space_allowed' as 0 to allow unlimited uploads
  * Return 'max_single_upload' as 0 to not set a limit
  *
  * @param	string		MD5 post key
  * @param	id			Member ID
  * @return	array 		[ 'space_used', 'space_left', 'space_allowed', 'max_single_upload' ]
  */
 public function getSpaceAllowance($post_key = '', $member_id = '')
 {
     $max_php_size = IPSLib::getMaxPostSize();
     $member_id = intval($member_id ? $member_id : $this->memberData['member_id']);
     $space_left = 0;
     $space_used = 0;
     $space_allowed = 0;
     $max_single_upload = 0;
     //-----------------------------------------
     // Allowed to attach?
     //-----------------------------------------
     if (!$member_id) {
         $space_allowed = -1;
     } else {
         //-----------------------------------------
         // Generate total space allowed
         //-----------------------------------------
         $total_space_allowed = ($this->memberData['g_attach_per_post'] ? $this->memberData['g_attach_per_post'] : $this->memberData['g_attach_max']) * 1024;
         //-----------------------------------------
         // Generate space used figure
         //-----------------------------------------
         if ($this->memberData['g_attach_per_post']) {
             //-----------------------------------------
             // Per post limit...
             //-----------------------------------------
             $_space_used = $this->DB->buildAndFetch(array('select' => 'SUM(attach_filesize) as figure', 'from' => 'attachments', 'where' => "attach_post_key='" . $post_key . "'"));
             $space_used = $_space_used['figure'] ? $_space_used['figure'] : 0;
         } else {
             //-----------------------------------------
             // Global limit...
             //-----------------------------------------
             $_space_used = $this->DB->buildAndFetch(array('select' => 'SUM(attach_filesize) as figure', 'from' => 'attachments', 'where' => 'attach_member_id=' . $member_id . " AND attach_rel_module IN( 'post', 'msg' )"));
             $space_used = $_space_used['figure'] ? $_space_used['figure'] : 0;
         }
         //-----------------------------------------
         // Generate space allowed figure
         //-----------------------------------------
         if ($this->memberData['g_attach_max'] > 0) {
             if ($this->memberData['g_attach_per_post']) {
                 $_g_space_used = $this->DB->buildAndFetch(array('select' => 'SUM(attach_filesize) as figure', 'from' => 'attachments', 'where' => 'attach_member_id=' . $member_id . " AND attach_rel_module IN( 'post', 'msg' )"));
                 $g_space_used = $_g_space_used['figure'] ? $_g_space_used['figure'] : 0;
                 if ($this->memberData['g_attach_max'] * 1024 - $g_space_used < 0) {
                     $space_used = $g_space_used;
                     $total_space_allowed = $this->memberData['g_attach_max'] * 1024;
                     $space_allowed = $this->memberData['g_attach_max'] * 1024 - $space_used;
                     $space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
                 } else {
                     $space_allowed = $this->memberData['g_attach_per_post'] * 1024 - $space_used;
                     $space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
                 }
             } else {
                 $space_allowed = $this->memberData['g_attach_max'] * 1024 - $space_used;
                 $space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
             }
         } else {
             if ($this->memberData['g_attach_per_post']) {
                 $space_allowed = $this->memberData['g_attach_per_post'] * 1024 - $space_used;
                 $space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
             } else {
                 # Unlimited
                 $space_allowed = 0;
             }
         }
         //-----------------------------------------
         // Generate space left figure
         //-----------------------------------------
         $space_left = $space_allowed ? $space_allowed : 0;
         $space_left = $space_left < 0 ? -1 : $space_left;
         //-----------------------------------------
         // Generate max upload size
         //-----------------------------------------
         if (!$max_single_upload) {
             if ($space_left > 0 and $space_left < $max_php_size) {
                 $max_single_upload = $space_left;
             } else {
                 if ($max_php_size) {
                     $max_single_upload = $max_php_size;
                 }
             }
         }
     }
     IPSDebug::fireBug('info', array('Space left: ' . $space_left));
     IPSDebug::fireBug('info', array('Max PHP size: ' . $max_php_size));
     IPSDebug::fireBug('info', array('Max single file size: ' . $max_single_upload));
     $return = array('space_used' => $space_used, 'space_left' => $space_left, 'space_allowed' => $space_allowed, 'max_single_upload' => $max_single_upload, 'total_space_allowed' => $total_space_allowed);
     return $return;
 }
Exemplo n.º 11
0
 /**
  * Add vote to rating
  *
  * @return	@e void
  */
 public function rateTopic()
 {
     /* INIT */
     $topic_id = intval($this->request['t']);
     $rating_id = intval($this->request['rating']);
     $vote_cast = array();
     IPSDebug::fireBug('info', array('The topic rating request has been received...'));
     /* Query topic */
     $topic_data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'topics', 'where' => "tid={$topic_id}"));
     /* Make sure we have a valid topic id */
     if (!$topic_data['tid']) {
         IPSDebug::fireBug('error', array('The topic was not found in the database'));
         $this->returnJsonArray(array('error_key' => 'topics_no_tid', 'error_code' => 10346));
     }
     if ($topic_data['state'] != 'open') {
         IPSDebug::fireBug('error', array('The topic is not open'));
         $this->returnJsonArray(array('error_key' => 'topic_rate_locked', 'error_code' => 10348));
     }
     /* Query Forum */
     $forum_data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'forums', 'where' => "id={$topic_data['forum_id']}"));
     /* Permission Check */
     $can_rate = $forum_data['forum_allow_rating'] && $this->memberData['member_id'] && $this->memberData['g_topic_rate_setting'] ? 1 : 0;
     if (!$can_rate) {
         IPSDebug::fireBug('error', array('The user cannot rate topics in this forum'));
         $this->returnJsonArray(array('error_key' => 'topic_rate_no_perm', 'error_code' => 10345));
         exit;
     }
     /* Sneaky members rating topic more than 5? */
     if ($rating_id > 5) {
         $rating_id = 5;
     }
     if ($rating_id < 1) {
         $rating_id = 1;
     }
     /* Have we rated before? */
     $rating = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'topic_ratings', 'where' => "rating_tid={$topic_data['tid']} and rating_member_id=" . $this->memberData['member_id']));
     /* Already rated? */
     if ($rating['rating_id']) {
         /* Do we allow re-ratings? */
         if ($this->memberData['g_topic_rate_setting'] == 2) {
             if ($rating_id != $rating['rating_value']) {
                 $new_rating = $rating_id - $rating['rating_value'];
                 $this->DB->update('topic_ratings', array('rating_value' => $rating_id), 'rating_id=' . $rating['rating_id']);
                 $this->DB->update('topics', array('topic_rating_total' => intval($topic_data['topic_rating_total']) + $new_rating), 'tid=' . $topic_data['tid']);
             }
             IPSDebug::fireBug('info', array('The rating was updated'));
             $this->returnJsonArray(array('rated' => 'update', 'message' => $this->lang->words['topic_rating_changed'], 'topic_rating_total' => intval($topic_data['topic_rating_total']) + $new_rating, 'topic_rating_hits' => $topic_data['topic_rating_hits']));
         } else {
             IPSDebug::fireBug('warn', array('The user is not allowed to update their rating'));
             $this->returnJsonArray(array('error_key' => 'topic_rated_already', 'error_code' => 0));
         }
     } else {
         $this->DB->insert('topic_ratings', array('rating_tid' => $topic_data['tid'], 'rating_member_id' => $this->memberData['member_id'], 'rating_value' => $rating_id, 'rating_ip_address' => $this->member->ip_address));
         $this->DB->update('topics', array('topic_rating_hits' => intval($topic_data['topic_rating_hits']) + 1, 'topic_rating_total' => intval($topic_data['topic_rating_total']) + $rating_id), 'tid=' . $topic_data['tid']);
         IPSDebug::fireBug('info', array('The rating was inserted'));
         $this->returnJsonArray(array('rated' => 'new', 'message' => $this->lang->words['topic_rating_done'], 'topic_rating_total' => intval($topic_data['topic_rating_total']) + $rating_id, 'topic_rating_hits' => intval($topic_data['topic_rating_hits']) + 1, '_rate_int' => round((intval($topic_data['topic_rating_total']) + $rating_id) / (intval($topic_data['topic_rating_hits']) + 1))));
     }
 }
 /**
  * Removes a folder
  *
  * @access	private
  * @return	string		JSON either error or status
  * @since	IPB 3.0.0.2008-06-25
  */
 private function _removeFolder()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $folderID = IPSText::alphanumericalClean($this->request['folderID']);
     $memberID = intval($this->request['memberID']);
     $memberData = IPSMember::load($memberID, 'extendedProfile');
     $status = 'ok';
     IPSDebug::fireBug('info', array('Received folder id:' . $folderID));
     IPSDebug::fireBug('info', array('Received member id:' . $memberID));
     //-----------------------------------------
     // First off, get dir data
     //-----------------------------------------
     $folders = $this->messengerFunctions->explodeFolderData($memberData['pconversation_filters']);
     //-----------------------------------------
     // Check
     //-----------------------------------------
     if (!$memberData['member_id'] or !$folderID) {
         IPSDebug::fireBug('error', array('Missing member id or folder id'));
         $this->returnJsonError('noSuchFolder');
     }
     //-----------------------------------------
     // Now ensure we actually have that folder
     //-----------------------------------------
     if (!$folders[$folderID]) {
         IPSDebug::fireBug('error', array('Specified folder does not exist'));
         $this->returnJsonError('noSuchFolder');
     }
     //-----------------------------------------
     // Protected folder?
     //-----------------------------------------
     /* Protected? */
     if ($folders[$folderID]['protected']) {
         $this->returnJsonError('cannotDeleteUndeletable');
     }
     //-----------------------------------------
     // .. and it has no messages
     //-----------------------------------------
     if ($folders[$folderID]['count'] > 0) {
         $this->returnJsonError('cannotDeleteHasMessages');
     }
     //-----------------------------------------
     // OK, remove it.
     //-----------------------------------------
     unset($folders[$folderID]);
     ///-----------------------------------------
     // Collapse
     //-----------------------------------------
     $newDirs = $this->messengerFunctions->implodeFolderData($folders);
     //-----------------------------------------
     // Save...
     //-----------------------------------------
     IPSMember::save($memberID, array('extendedProfile' => array('pconversation_filters' => $newDirs)));
     //-----------------------------------------
     // Return...
     //-----------------------------------------
     $this->returnJsonArray(array('status' => $status, 'newDirs' => $newDirs));
 }
Exemplo n.º 13
0
 /**
  * Saves the template bit
  *
  * @return	@e void
  */
 protected function _saveTemplateBit()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $test = $_POST['_template_name'];
     $setID = intval($this->request['template_set']);
     $templateID = intval($this->request['template_id']);
     $type = $this->request['type'] == 'add' ? 'add' : 'edit';
     $template_content = $_POST['template_content'];
     $template_group = IPSText::alphanumericalClean($_POST['template_group']);
     $ent_template_group = str_replace("skin_", "", IPSText::alphanumericalClean($_POST['_template_group']));
     $template_name = IPSText::alphanumericalClean($_POST['_template_name']);
     $template_data = $_POST['template_data'];
     IPSDebug::fireBug('info', array('Template content: ' . $template_content));
     //-----------------------------------------
     // Checks...
     //-----------------------------------------
     if (!$setID or $type == 'edit' and !$templateID) {
         $this->returnJsonError($this->lang->words['ajax_missing_data']);
     }
     //-----------------------------------------
     // Add checks
     //-----------------------------------------
     if ($type == 'add') {
         if (!$template_name) {
             $this->returnJsonError($this->lang->words['ajax_missing_data']);
         }
     }
     //-----------------------------------------
     // Save it
     //-----------------------------------------
     if ($type == 'edit') {
         try {
             $template_id = $this->skinFunctions->saveTemplateBitFromEdit($templateID, $setID, $template_content, $template_data);
         } catch (Exception $err) {
             $this->returnJsonError($this->lang->words['templates_' . $err->getMessage()] ? $this->lang->words['templates_' . $err->getMessage()] : $err->getMessage());
             //. ' ' . implode( "\n", $this->skinFunctions->fetchMessages() ) );
         }
     } else {
         $template_group = $ent_template_group ? 'skin_' . $ent_template_group : $template_group;
         try {
             $template_id = $this->skinFunctions->saveTemplateBitFromAdd($setID, $template_content, $template_data, $template_group, $template_name);
         } catch (Exception $err) {
             $this->returnJsonError($this->lang->words['templates_' . $err->getMessage()] ? $this->lang->words['templates_' . $err->getMessage()] : $err->getMessage());
             // . ' ' . implode( "\n", $this->skinFunctions->fetchMessages() ) );
         }
     }
     //-----------------------------------------
     // Fetch new data and return
     //-----------------------------------------
     $template = $this->skinFunctions->fetchTemplateBitForEdit($template_id, $setID);
     //-----------------------------------------
     // Get Data
     //-----------------------------------------
     $this->returnJsonArray(array('templateData' => $template, 'errors' => $this->skinFunctions->fetchErrorMessages()));
 }
Exemplo n.º 14
0
 /**
  * Add a new statussesses
  *
  * @return	@e void
  */
 protected function _new()
 {
     IPSDebug::fireBug('info', array('Status content: ' . $_POST['content']));
     IPSDebug::fireBug('info', array('Cleaned status: ' . trim($this->convertAndMakeSafe($_POST['content']))));
     /* INIT */
     $smallSpace = intval($this->request['smallSpace']);
     $su_Twitter = intval($this->request['su_Twitter']);
     $su_Facebook = intval($this->request['su_Facebook']);
     $skin_group = $this->getSkinGroup();
     $forMemberId = intval($this->request['forMemberId']);
     /* Got content? */
     if (!trim($this->convertAndMakeSafe(str_replace(array('&nbsp;', '&#160;'), '', $_POST['content'])))) {
         $this->returnJsonError($this->lang->words['no_status_sent']);
     }
     /* Set Author */
     $this->registry->getClass('memberStatus')->setAuthor($this->memberData);
     /* Set Content */
     $this->registry->getClass('memberStatus')->setContent(trim($this->convertAndMakeSafe($_POST['content'])));
     /* Can we create? */
     if (!$this->registry->getClass('memberStatus')->canCreate()) {
         $this->returnJsonError($this->lang->words['status_off']);
     }
     /* Update or comment? */
     if ($forMemberId && $forMemberId != $this->memberData['member_id']) {
         $owner = IPSMember::load($forMemberId);
         if (!$owner['pp_setting_count_comments']) {
             $this->returnJsonError($this->lang->words['status_off']);
         }
         /* Set owner */
         $this->registry->getClass('memberStatus')->setStatusOwner($owner);
     } else {
         /* Set post outs */
         $this->registry->getClass('memberStatus')->setExternalUpdates(array('twitter' => $su_Twitter, 'facebook' => $su_Facebook));
     }
     /* Update */
     $newStatus = $this->registry->getClass('memberStatus')->create();
     if (!$newStatus) {
         $this->returnJsonError($this->lang->words['status_off']);
     }
     /* Now grab the reply and return it */
     $status = $this->registry->getClass('memberStatus')->fetch($this->memberData['member_id'], array('relatedTo' => $forMemberId, 'sort_dir' => 'desc', 'limit' => 1));
     $last = $status;
     $last = array_pop($last);
     if ($last['status_approved']) {
         $new = $this->registry->getClass('output')->getTemplate($skin_group)->statusUpdates($status, $smallSpace);
         $this->returnJsonArray(array('status' => 'success', 'html' => $new), true);
     } else {
         $this->returnJsonError('prof_comment_mod');
     }
 }
Exemplo n.º 15
0
 /**
  * Switch between bbcode and rte on the fly, man
  *
  * @return	@e void
  */
 protected function _switch()
 {
     $content = $_POST['content'];
     $htmlStatus = intval($_REQUEST['htmlStatus']);
     IPSDebug::fireBug('info', array('Content received: ' . $content));
     if ($content) {
         if ($htmlStatus) {
             $this->editor->setAllowHtml($htmlStatus);
         }
         $content = $this->editor->switchContent($content, intval($_POST['isRte']));
     }
     IPSDebug::fireBug('info', array('Content after conversion: ' . $content));
     /* return if no errors occurred */
     return $this->returnString($content);
 }
Exemplo n.º 16
0
 /**
  * Clear out the mod-queue table appropriately
  *
  * @param	string		[topic|post] Type of item moved
  * @param	mixed		ID of topic or post, or array of ids
  * @param	boolean		Was content approved?
  * @return	@e void
  */
 public function clearModQueueTable($type, $typeId, $approved = false)
 {
     //-----------------------------------------
     // Are we operating on one id, or an array
     //-----------------------------------------
     if (is_array($typeId)) {
         $where = "type_id IN(" . implode(',', IPSLib::cleanIntArray($typeId)) . ")";
     } else {
         $where = "type_id=" . intval($typeId);
     }
     //-----------------------------------------
     // Was content deleted
     //-----------------------------------------
     if (!$approved) {
         $this->DB->delete('mod_queued_items', "type='{$type}' AND {$where}");
     } else {
         //-----------------------------------------
         // Get post class..
         //-----------------------------------------
         require_once IPSLib::getAppDir('forums') . '/sources/classes/post/classPost.php';
         /*noLibHook*/
         $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . '/sources/classes/post/classPostForms.php', 'classPostForms', 'forums');
         $_postClass = new $classToLoad($this->registry);
         //-----------------------------------------
         // Working with posts?
         //-----------------------------------------
         if ($type == 'post') {
             IPSDebug::fireBug('info', array('type is post'));
             $this->DB->build(array('select' => 'm.id', 'from' => array('mod_queued_items' => 'm'), 'where' => "m.type='{$type}' AND m.{$where}", 'add_join' => array(array('select' => 'p.pid, p.post, p.author_id, p.post_date, p.topic_id', 'from' => array('posts' => 'p'), 'where' => 'p.pid=m.type_id', 'type' => 'left'), array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => 't.tid=p.topic_id', 'type' => 'left'))));
             $outer = $this->DB->execute();
             while ($r = $this->DB->fetch($outer)) {
                 $member = IPSMember::load($r['author_id'], 'extendedProfile,groups');
                 $_postClass->setPublished(true);
                 $_postClass->setAuthor($member);
                 $_postClass->setForumData($this->registry->class_forums->allForums[$r['forum_id']]);
                 $_postClass->incrementUsersPostCount();
                 $_postClass->sendOutTrackedTopicEmails($r, $r['post']);
                 $this->DB->delete('mod_queued_items', 'id=' . $r['id']);
             }
         } else {
             IPSDebug::fireBug('info', array('type is topic'));
             $this->DB->build(array('select' => 'm.id', 'from' => array('mod_queued_items' => 'm'), 'where' => "m.type='{$type}' AND m.{$where}", 'add_join' => array(array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => 't.tid=m.type_id', 'type' => 'left'), array('select' => 'p.pid, p.post, p.post_date', 'from' => array('posts' => 'p'), 'where' => 'p.pid=t.topic_firstpost', 'type' => 'left'))));
             $outer = $this->DB->execute();
             while ($r = $this->DB->fetch($outer)) {
                 $member = IPSMember::load($r['starter_id'], 'extendedProfile,groups');
                 $_postClass->setPublished(true);
                 $_postClass->setAuthor($member);
                 $_postClass->setForumData($this->registry->class_forums->allForums[$r['forum_id']]);
                 $_postClass->incrementUsersPostCount();
                 $_postClass->sendOutTrackedForumEmails($this->registry->class_forums->getForumById($r['forum_id']), $r, $r['post']);
                 $this->DB->delete('mod_queued_items', 'id=' . $r['id']);
             }
         }
     }
 }
 /**
  * Clear out the mod-queue table appropriately
  *
  * @access	public
  * @param	string		[topic|post] Type of item moved
  * @param	mixed		ID of topic or post, or array of ids
  * @param	boolean		Was content approved?
  * @return	void
  */
 public function clearModQueueTable($type, $typeId, $approved = false)
 {
     //-----------------------------------------
     // Get post class..
     //-----------------------------------------
     require_once IPSLib::getAppDir('forums') . '/sources/classes/post/classPost.php';
     require_once IPSLib::getAppDir('forums') . '/sources/classes/post/classPostForms.php';
     $_postClass = new classPostForms($this->registry);
     //-----------------------------------------
     // Are we operating on one id, or an array
     //-----------------------------------------
     if (is_array($typeId)) {
         $where = "type_id IN(" . implode(',', IPSLib::cleanIntArray($typeId)) . ")";
     } else {
         $where = "type_id=" . intval($typeId);
     }
     //-----------------------------------------
     // Was content deleted or moved to trash forum
     //-----------------------------------------
     if (!$approved) {
         $this->DB->delete('mod_queued_items', "type='{$type}' AND {$where}");
     } else {
         //-----------------------------------------
         // Working with posts?
         //-----------------------------------------
         if ($type == 'post') {
             IPSDebug::fireBug('info', array('type is post'));
             $this->DB->build(array('select' => 'm.id', 'from' => array('mod_queued_items' => 'm'), 'where' => "m.type='{$type}' AND m.{$where}", 'add_join' => array(array('select' => 'p.pid, p.post, p.author_id, p.post_date', 'from' => array('posts' => 'p'), 'where' => 'p.pid=m.type_id', 'type' => 'left'), array('select' => 't.title, t.forum_id', 'from' => array('topics' => 't'), 'where' => 't.tid=p.topic_id', 'type' => 'left'))));
             $outer = $this->DB->execute();
             while ($r = $this->DB->fetch($outer)) {
                 $member = IPSMember::load($r['author_id'], 'extendedProfile,groups');
                 $_postClass->setPublished(true);
                 $_postClass->setAuthor($member);
                 $_postClass->setForumData($this->registry->class_forums->allForums[$r['forum_id']]);
                 $_postClass->incrementUsersPostCount();
                 $_postClass->sendOutTrackedTopicEmails($r['topic_id'], $r['post'], $member['members_display_name'], time() - $this->settings['session_expiration'], $member['member_id']);
                 $this->DB->delete('mod_queued_items', 'id=' . $r['id']);
             }
         } else {
             IPSDebug::fireBug('info', array('type is topic'));
             $this->DB->build(array('select' => 'm.id', 'from' => array('mod_queued_items' => 'm'), 'where' => "m.type='{$type}' AND m.{$where}", 'add_join' => array(array('select' => 't.tid, t.title, t.starter_id, t.forum_id', 'from' => array('topics' => 't'), 'where' => 't.tid=m.type_id', 'type' => 'left'), array('select' => 'p.pid, p.post, p.post_date', 'from' => array('posts' => 'p'), 'where' => 'p.pid=t.topic_firstpost', 'type' => 'left'))));
             $outer = $this->DB->execute();
             while ($r = $this->DB->fetch($outer)) {
                 $member = IPSMember::load($r['starter_id'], 'extendedProfile,groups');
                 $_postClass->setPublished(true);
                 $_postClass->setAuthor($member);
                 $_postClass->setForumData($this->registry->class_forums->allForums[$r['forum_id']]);
                 $_postClass->incrementUsersPostCount();
                 $_postClass->sendOutTrackedForumEmails($r['forum_id'], $r['tid'], $r['title'], $this->registry->class_forums->allForums[$r['forum_id']]['name'], $r['post'], $member['member_id'], $member['members_display_name']);
                 $this->DB->delete('mod_queued_items', 'id=' . $r['id']);
             }
         }
     }
     $this->addModerateLog($this->request['f'], $this->request['t'], $this->request['p'], $this->topic['title'], sprintf($this->lang->words['modqueue_table_clear'], $type, is_array($typeId) ? implode(', ', $typeId) : $typeId));
 }