Пример #1
0
 /**
  * Moderate
  *
  * @return	@e void
  */
 protected function _moderate()
 {
     $parentId = intval($this->request['parentId']);
     $commentIds = is_array($_POST['commentIds']) ? IPSLib::cleanIntArray($_POST['commentIds']) : array();
     $modact = trim($this->request['modact']);
     if (count($commentIds)) {
         try {
             $this->_comments->moderate($modact, $parentId, $commentIds, $this->memberData);
             $this->returnJsonArray(array('msg' => 'ok'));
         } catch (Exception $error) {
             if ($error->getMessage() == 'NO_PERMISSION') {
                 $this->returnJsonError($this->lang->words['ap_np_msg']);
             } else {
                 $this->returnJsonError('Error ' . $error->getMessage() . ' line: ' . $error->getFile() . '.' . $error->getLine());
             }
         }
     }
 }
Пример #2
0
 /**
  * Remove log
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function _remove()
 {
     if ($this->request['type'] == 'all') {
         $this->DB->delete('spam_service_log');
     } else {
         $ids = array();
         foreach ($this->request as $k => $v) {
             if (preg_match("/^id_(\\d+)\$/", $k, $match)) {
                 if ($this->request[$match[0]]) {
                     $ids[] = $match[1];
                 }
             }
         }
         $ids = IPSLib::cleanIntArray($ids);
         //-----------------------------------------
         if (count($ids) < 1) {
             $this->registry->output->showError($this->lang->words['erlog_noneselected'], 11115);
         }
         $this->DB->delete('spam_service_log', "id IN (" . implode(',', $ids) . ")");
     }
     $this->registry->output->silentRedirect($this->settings['base_url'] . "&{$this->form_code}");
 }
Пример #3
0
 /**
  * Process a batch. Genius.
  * $options is an array of keys and values:
  * process - INT - number of items to process in this batch
  * @return int count of topics archived
  */
 public function processBatch($options = array())
 {
     $restoreData = $this->getRestoreData();
     $topics = array();
     $forums = array();
     $pids = array();
     /* Fix up options */
     $options['process'] = is_numeric($options['process']) && $options['process'] > 0 ? $options['process'] : 250;
     if (!$restoreData['restore_min_tid'] && !$restoreData['restore_max_tid'] && !count($restoreData['restore_manual_tids'])) {
         return false;
     }
     /* Any manually flagged? */
     if (count($restoreData['restore_manual_tids'])) {
         /* Select remaining Pids */
         $pids = $this->engine->getPidsInTids(IPSLib::cleanIntArray(array_keys($restoreData['restore_manual_tids'])), $options['process']);
         /* Did we complete topics? */
         foreach ($restoreData['restore_manual_tids'] as $tid => $maxPid) {
             if (in_array($maxPid, array_keys($pids))) {
                 $this->deleteManualId($tid);
             }
         }
         /* All done? */
         if (!count($pids)) {
             $restoreData['restore_manual_tids'] = array();
             $this->setRestoreData($restoreData);
         }
         /* Update process for below */
         $options['process'] -= count($pids);
     }
     /* Now fetch the max/min if archiver is on */
     if ($this->settings['archive_on'] && $options['process'] > 0 && $restoreData['restore_min_tid'] && $restoreData['restore_max_tid']) {
         $date = IPS_UNIX_TIME_NOW - 86400 * intval($this->settings['archive_restore_days']);
         $pids = $this->engine->getPidsBetweenTidsAndDate($restoreData['restore_min_tid'], $restoreData['restore_max_tid'], $date, $options['process']);
         /* All done? */
         if (!count($pids)) {
             $restoreData['restore_min_tid'] = 0;
             $restoreData['restore_max_tid'] = 0;
             $this->setRestoreData($restoreData);
         }
     }
     /* Process */
     $this->restore($pids);
     return count($pids);
 }
 /**
  * Multi-statement execute
  *
  * @access	public
  * @param 	mixed		Id | Array of ids
  * @return	boolean
  */
 public function stmExec($id)
 {
     if (count($this->stm) < 1) {
         return false;
     }
     $final_array = array();
     foreach ($this->stm as $real_array) {
         foreach ($real_array as $k => $v) {
             $final_array[$k] = $v;
         }
     }
     if (is_array($id)) {
         $id = IPSLib::cleanIntArray($id);
         if (count($id) > 0) {
             $this->DB->update('topics', $final_array, "tid IN(" . implode(",", $id) . ")");
         } else {
             return false;
         }
     } else {
         if (intval($id) != "") {
             $this->DB->update('topics', $final_array, "tid=" . intval($id));
         } else {
             return false;
         }
     }
     return true;
 }
Пример #5
0
 /**
  * Deletes a cache
  * 
  * @param	mixed		$relId		Relationship ID or array of IDs
  * @param	integer		$memberId 	Member ID
  * @return	@e void
  */
 public function delete($relId, $memberId = null)
 {
     /* Possible future expansion */
     if ($memberId === null) {
         $where = '';
         if (is_numeric($relId)) {
             $where = "='" . classes_like_registry::getKey($relId) . "'";
         } elseif (is_array($relId)) {
             $relId = IPSLib::cleanIntArray($relId);
             $keys = array();
             foreach ($relId as $id) {
                 $keys[] = "'" . classes_like_registry::getKey($id) . "'";
             }
             if (!count($keys)) {
                 return null;
             }
             $where = " IN (" . implode(",", $keys) . ")";
         }
         $this->DB->delete('core_like_cache', 'like_cache_id ' . $where);
     }
 }
Пример #6
0
 /**
  * Multi-statement execute
  *
  * @param 	mixed		Id | Array of ids
  * @return	boolean
  */
 public function stmExec($id)
 {
     if (count($this->stm) < 1) {
         return false;
     }
     $final_array = array();
     foreach ($this->stm as $real_array) {
         foreach ($real_array as $k => $v) {
             $final_array[$k] = $v;
         }
     }
     if (isset($final_array['approved']) and $final_array['approved'] == -1) {
         $this->_addToSoftDeleteLog($id);
     }
     if (is_array($id)) {
         $id = IPSLib::cleanIntArray($id);
         if (count($id) > 0) {
             /* Ensure we don't moderate topics in archives */
             $this->DB->update('topics', $final_array, $this->registry->class_forums->fetchTopicArchiveQuery(array('not', 'exclude')) . " AND tid IN(" . implode(",", $id) . ")");
         } else {
             return false;
         }
     } else {
         if (intval($id) != "") {
             $this->DB->update('topics', $final_array, $this->registry->class_forums->fetchTopicArchiveQuery(array('not', 'exclude')) . " AND tid=" . intval($id));
         } else {
             return false;
         }
     }
     return true;
 }
 /**
  * Delete members [form+process]
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private function _memberDelete()
 {
     //-----------------------------------------
     // Check input
     //-----------------------------------------
     if (!$this->request['member_id']) {
         $this->registry->output->global_message = $this->lang->words['m_nomember'];
         $this->request['do'] = 'members_list';
         $this->_memberList();
         return;
     }
     //-----------------------------------------
     // Single or more?
     //-----------------------------------------
     if (strstr($this->request['member_id'], ',')) {
         $ids = explode(',', $this->request['member_id']);
     } else {
         $ids = array($this->request['member_id']);
     }
     $ids = IPSLib::cleanIntArray($ids);
     /* Don't delete our selves */
     if (in_array($this->memberData['member_id'], $ids)) {
         $this->registry->output->global_message = $this->lang->words['m_nodeleteslefr'];
         $this->request['do'] = 'members_list';
         $this->_memberList();
         return;
     }
     //-----------------------------------------
     // Get accounts
     //-----------------------------------------
     $this->DB->build(array('select' => 'member_id, name, member_group_id, mgroup_others', 'from' => 'members', 'where' => 'member_id IN (' . implode(",", $ids) . ')'));
     $this->DB->execute();
     $names = array();
     while ($r = $this->DB->fetch()) {
         //-----------------------------------------
         // r u trying to kill teh admin?
         //-----------------------------------------
         if (!$this->registry->getClass('class_permissions')->checkPermission('member_delete_admin')) {
             if ($this->caches['group_cache'][$r['member_group_id']]['g_access_cp']) {
                 continue;
             } else {
                 $other_mgroups = explode(',', IPSText::cleanPermString($r['mgroup_others']));
                 if (count($other_mgroups)) {
                     foreach ($other_mgroups as $other_mgroup) {
                         if ($this->caches['group_cache'][$other_mgroup]['g_access_cp']) {
                             continue;
                         }
                     }
                 }
             }
         }
         $names[] = $r['name'];
     }
     //-----------------------------------------
     // Check
     //-----------------------------------------
     if (!count($names)) {
         $this->registry->output->global_message = $this->lang->words['m_nomember'];
         $this->request['do'] = 'members_list';
         $this->_memberList();
         return;
     }
     //-----------------------------------------
     // Delete
     //-----------------------------------------
     IPSMember::remove($ids, true);
     //-----------------------------------------
     // Clear "cookies"
     //-----------------------------------------
     ipsRegistry::getClass('adminFunctions')->staffSaveCookie('memberFilter', array());
     //-----------------------------------------
     // Redirect
     //-----------------------------------------
     $page_query = "";
     ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_deletedlog'], implode(",", $names)));
     $this->registry->output->global_message = sprintf($this->lang->words['m_deletedlog'], implode(",", $names));
     $this->request['do'] = 'members_list';
     $this->_memberList();
 }
Пример #8
0
 /**
  * Bulk remove attachments
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function _bulkRemoveAttachments()
 {
     foreach ($_POST as $key => $value) {
         if (preg_match("/^attach_(\\d+)\$/", $key, $match)) {
             if ($this->request[$match[0]]) {
                 $ids[] = $match[1];
             }
         }
     }
     $ids = IPSLib::cleanIntArray($ids);
     $attach_tid = array();
     if (count($ids)) {
         //-----------------------------------------
         // Get attach details?
         //-----------------------------------------
         $this->DB->build(array('select' => 'a.*', 'from' => array('attachments' => 'a'), 'where' => "a.attach_rel_id > 0 AND a.attach_id IN(" . implode(",", $ids) . ")", 'add_join' => array(array('select' => 'p.pid, p.topic_id', 'from' => array('posts' => 'p'), 'where' => "p.pid=a.attach_rel_id AND attach_rel_module='post'", 'type' => 'left'))));
         $this->DB->execute();
         while ($killmeh = $this->DB->fetch()) {
             if ($killmeh['attach_location']) {
                 @unlink($this->settings['upload_dir'] . "/" . $killmeh['attach_location']);
             }
             if ($killmeh['attach_thumb_location']) {
                 @unlink($this->settings['upload_dir'] . "/" . $killmeh['attach_thumb_location']);
             }
             $attach_tid[$killmeh['topic_id']] = $killmeh['topic_id'];
         }
         $this->DB->delete('attachments', "attach_id IN(" . implode(",", $ids) . ")");
         $this->registry->adminFunctions->saveAdminLog(sprintf($this->lang->words['deleted_attachments'], implode(",", $ids)));
         //-----------------------------------------
         // Recount topic upload marker
         //-----------------------------------------
         require_once IPSLib::getAppDir('forums') . '/sources/classes/post/classPost.php';
         /*noLibHook*/
         $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . '/sources/classes/post/classPostForms.php', 'classPostForms', 'forums');
         $postlib = new $classToLoad($this->registry);
         foreach ($attach_tid as $tid) {
             if ($tid) {
                 $postlib->recountTopicAttachments($tid);
             }
         }
         $this->registry->output->global_message = $this->lang->words['attachments_removed'];
     } else {
         $this->registry->output->global_message = $this->lang->words['noattach_to_remove'];
     }
     if ($this->request['return'] == 'stats') {
         $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . 'module=attachments&section=stats');
     } else {
         if ($_POST['url']) {
             foreach (explode('&', $_POST['url']) as $u) {
                 list($k, $v) = explode('=', $u);
                 $this->request[$k] = $v;
             }
         }
         $this->_searchResults();
     }
 }
Пример #9
0
 /**
  * Action a report drop down
  *
  * @return	@e void
  */
 protected function _multiManage()
 {
     $merge_id = $this->request['sessionID'] = intval($this->request['merge_id']);
     $mergeOption = trim($this->request['mergeOption']);
     $items = is_array($_POST['changeIds']) ? IPSLib::cleanIntArray(array_keys($_POST['changeIds'])) : array();
     /* Fetch session and check */
     $session = $this->skinFunctions->fetchSession($merge_id);
     if ($session === FALSE) {
         $this->registry->output->showError($this->lang->words['sd_nosession']);
     }
     /* Got items? */
     if (count($items)) {
         /* Process. I love pointless comments */
         switch ($mergeOption) {
             case 'resolve_custom':
                 $this->skinFunctions->resolveConflict($items, 'custom');
                 break;
             case 'resolve_new':
                 $this->skinFunctions->resolveConflict($items, 'new');
                 break;
             case 'commit':
                 $this->skinFunctions->commit($items);
                 break;
             case 'revert':
                 $this->skinFunctions->revert($items);
                 break;
         }
     }
     /* Flush CDN */
     $this->skinFunctions->flushipscdn();
     /* Throw it out */
     $this->registry->output->global_message = $this->lang->words['skindiff_okmsg'];
     return $this->_viewReport();
 }
 /**
  * Unlock selected accounts
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private function _unlock()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $ids = array();
     //-----------------------------------------
     // GET checkboxes
     //-----------------------------------------
     foreach ($this->request as $k => $v) {
         if (preg_match("/^mid_(\\d+)\$/", $k, $match)) {
             if ($v) {
                 $ids[] = $match[1];
             }
         }
     }
     $ids = IPSLib::cleanIntArray($ids);
     //-----------------------------------------
     // Check
     //-----------------------------------------
     if (count($ids) < 1) {
         $this->registry->output->showError($this->lang->words['t_nolockloc'], 11251);
     }
     //-----------------------------------------
     // Unlock
     //-----------------------------------------
     if ($this->request['type'] == 'unlock') {
         foreach ($ids as $_id) {
             try {
                 IPSMember::save($_id, array('core' => array('failed_logins' => '', 'failed_login_count' => 0)));
             } catch (Exception $error) {
                 $this->registry->output->showError($error->getMessage(), 11247);
             }
         }
         ipsRegistry::getClass('adminFunctions')->saveAdminLog(count($ids) . $this->lang->words['t_memunlocked']);
         $this->registry->output->global_message = count($ids) . $this->lang->words['t_memunlocked'];
         $this->_viewQueue('locked');
         return;
     } else {
         if ($this->request['type'] == 'ban') {
             try {
                 IPSMember::save($ids, array('core' => array('failed_logins' => '', 'failed_login_count' => 0, 'member_banned' => 1)));
             } catch (Exception $error) {
                 $this->registry->output->showError($error->getMessage(), 11247);
             }
             ipsRegistry::getClass('adminFunctions')->saveAdminLog(count($ids) . $this->lang->words['t_membanned']);
             $this->registry->output->global_message = count($ids) . $this->lang->words['t_membanned'];
             $this->_viewQueue('locked');
             return;
         } else {
             if ($this->request['type'] == 'delete') {
                 IPSMember::remove($ids);
                 ipsRegistry::getClass('adminFunctions')->saveAdminLog(count($ids) . $this->lang->words['t_memdeleted']);
                 $this->registry->output->global_message = count($ids) . $this->lang->words['t_memdeleted'];
                 $this->_viewQueue('locked');
                 return;
             }
         }
     }
 }
Пример #11
0
 /**
  * Delete a ban filter
  *
  * @return	@e void
  */
 public function banDelete()
 {
     /* INI */
     $ids = array();
     /* Loop through the request fields and find checked ban filters */
     foreach ($this->request as $key => $value) {
         if (preg_match('/^banid_(\\d+)$/', $key, $match)) {
             if ($this->request[$match[0]]) {
                 $ids[] = $match[1];
             }
         }
     }
     /* Clean the array */
     $ids = IPSLib::cleanIntArray($ids);
     /* Delete any checked ban filters */
     if (count($ids)) {
         $this->DB->delete('banfilters', 'ban_id IN(' . implode(",", $ids) . ')');
     }
     /* Rebuild the cache */
     $this->rebuildBanCache();
     /* Bounce */
     $this->registry->output->global_message = $this->lang->words['ban_removed'];
     $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . 'do=ban');
 }
Пример #12
0
 /**
  * Resolve Conflict Automatically
  *
  * @access	public
  * @param	array		Array of item (change_id) ids
  * @param	type		Which wins? YOU DECIDE (custom/new)
  * @return	nufink
  */
 public function resolveConflict($items, $type = 'new')
 {
     /* Basic check */
     if (!count($items)) {
         return false;
     }
     /* Fetch Data */
     $this->DB->build(array('select' => '*', 'from' => 'skin_merge_changes', 'where' => 'change_id IN(' . implode(',', IPSLib::cleanIntArray($items)) . ')'));
     $o = $this->DB->execute();
     /* GO freakiNG LoOPy */
     while ($row = $this->DB->fetch($o)) {
         $text = $row['change_merge_content'];
         /* Re-format  */
         preg_match_all("#<ips:conflict id=\"([0-9]+?)\">((?<!(</ips:conflict>)).+?)</ips:conflict>#s", $text, $matches);
         if (is_array($matches) and count($matches)) {
             foreach ($matches[1] as $index => $m) {
                 /* Yeah, I like readable code and copying and pasting evidently */
                 $_all = $matches[0][$index];
                 $_id = $matches[1][$index];
                 $_content = $matches[2][$index];
                 if ($_id != null and $_content) {
                     /* Save which block? */
                     if ($type == 'new') {
                         $_content = preg_replace("#(?:\n)?<ips:cblock type=\"original\">(?:\n)?(.+?)(?:\n)?</ips:cblock>#s", "", $_content);
                         $_content = preg_replace("#(?:\n)?<ips:cblock type=\"new\">(?:\n)?(.+?)(?:\n)?</ips:cblock>#s", "\n\\1", $_content);
                     } else {
                         $_content = preg_replace("#(?:\n)?<ips:cblock type=\"original\">(?:\n)?(.+?)(?:\n)?</ips:cblock>#s", "\n\\1", $_content);
                         $_content = preg_replace("#(?:\n)?<ips:cblock type=\"new\">(?:\n)?(.+?)(?:\n)?</ips:cblock>#s", "", $_content);
                     }
                     $text = str_replace($_all, $_content, $text);
                 }
             }
             /* Save to db */
             $this->DB->update('skin_merge_changes', array('change_final_content' => $text), 'change_id=' . intval($row['change_id']));
         }
     }
     return true;
 }
 /**
  * Delete a ban filter
  *
  * @access	public
  * @return	void
  */
 public function banDelete()
 {
     /* INI */
     $ids = array();
     /* Loop through the request fields and find checked ban filters */
     foreach ($this->request as $key => $value) {
         if (preg_match("/^id_(\\d+)\$/", $key, $match)) {
             if ($this->request[$match[0]]) {
                 $ids[] = $match[1];
             }
         }
     }
     /* Clean the array */
     $ids = IPSLib::cleanIntArray($ids);
     /* Delete any checked ban filters */
     if (count($ids)) {
         $this->DB->delete('banfilters', 'ban_id IN(' . implode(",", $ids) . ')');
         $this->DB->execute();
     }
     /* Rebuild the cache */
     $this->rebuildBanCache();
     /* Bounce */
     $this->registry->output->global_message = $this->lang->words['ban_removed'];
     $this->banOverview();
 }
Пример #14
0
 /**
  * Perform the search
  * @param array $tags
  * @param array $options
  */
 public function run(array $tags, array $options)
 {
     $where = array();
     $order = !empty($options['sortKey']) ? $options['sortKey'] : 'tg.tag_meta_id';
     $dir = !empty($options['sortOrder']) ? $options['sortOrder'] : 'desc';
     $return = array();
     /* Format query */
     if (isset($options['meta_parent_id']) && (is_numeric($options['meta_parent_id']) || count($options['meta_parent_id']))) {
         $where[] = is_array($options['meta_parent_id']) && count($options['meta_parent_id']) ? 'tg.tag_meta_parent_id IN (' . implode(',', IPSLib::cleanIntArray($options['meta_parent_id'])) . ')' : 'tg.tag_meta_parent_id=' . intval($options['meta_parent_id']);
     }
     if (isset($options['meta_id']) && (is_numeric($options['meta_id']) || count($options['meta_id']))) {
         $where[] = is_array($options['meta_id']) && count($options['meta_id']) ? 'tg.tag_meta_id IN (' . implode(',', IPSLib::cleanIntArray($options['meta_id'])) . ')' : 'tg.tag_meta_id=' . intval($options['meta_id']);
     }
     if (isset($options['meta_app'])) {
         $where[] = is_array($options['meta_app']) && count($options['meta_app']) ? 'tg.tag_meta_app IN (\'' . implode("','", $options['meta_app']) . '\')' : 'tg.tag_meta_app=\'' . $options['meta_app'] . '\'';
     }
     if (isset($options['meta_area'])) {
         $where[] = is_array($options['meta_area']) && count($options['meta_area']) ? 'tg.tag_meta_area IN (\'' . implode("','", $options['meta_area']) . '\')' : 'tg.tag_meta_area=\'' . $options['meta_area'] . '\'';
     }
     if (!empty($options['not_meta_id'])) {
         $where[] = is_array($options['not_meta_id']) && count($options['not_meta_id']) ? 'tg.tag_meta_id NOT IN (' . implode(",", $options['not_meta_id']) . ')' : 'tg.tag_meta_id !=' . intval($options['not_meta_id']);
     }
     if (isset($tags)) {
         if (isset($options['match']) and $options['match'] == 'loose') {
             $_tags = is_array($tags) ? $tags : array($tags);
             $_t = array();
             foreach ($_tags as $text) {
                 $_t[] = ' tg.tag_text LIKE \'%' . $this->DB->addSlashes($text) . '%\'';
             }
             if (count($_t)) {
                 $where[] = implode(" OR ", $_t);
             }
         } else {
             if (is_array($tags)) {
                 $_t = $tags;
                 $tags = array();
                 foreach ($_t as $t) {
                     $tags[] = $this->DB->addSlashes($t);
                 }
             }
             $where[] = is_array($tags) ? 'tg.tag_text IN (\'' . implode("','", $tags) . '\')' : 'tg.tag_text=\'' . $this->DB->addSlashes($tags) . '\'';
         }
     }
     $prefix = ips_DBRegistry::getPrefix();
     /* Did we add in perm check? */
     if (!empty($options['isViewable'])) {
         if ($options['joins']) {
             $select = array();
             $join = '';
             foreach ($options['joins'] as $j) {
                 foreach ($j['from'] as $name => $ref) {
                     $select[] = $j['select'];
                     $join .= ' LEFT JOIN ' . $prefix . $name . ' ' . $ref;
                     if ($j['where']) {
                         $join .= ' ON (' . $j['where'] . ')';
                     }
                 }
             }
         }
         if (count($select)) {
             $_select = ',' . implode(',', $select);
         }
         $options['limit'] = $options['limit'] > 0 && $options['limit'] < 5000 ? $options['limit'] : 250;
         /* we need to make an exception if filtering by date */
         if (class_exists('IPSSearchRegistry') && (IPSSearchRegistry::get('in.search_date_start') || IPSSearchRegistry::get('in.search_date_end'))) {
             $options['limit'] = 10000000000.0;
         }
         $this->DB->allow_sub_select = true;
         $this->DB->query('SELECT tg.* ' . $_select . ' FROM ' . $prefix . 'core_tags tg ' . $join . ' WHERE ' . implode(' AND ', $where) . ' AND tg.tag_aai_lookup IN (' . 'SELECT tag_perm_aai_lookup FROM  ' . $prefix . 'core_tags_perms WHERE ' . $this->DB->buildWherePermission($this->member->perm_id_array, 'tag_perm_text') . ' AND tag_perm_visible=1 ' . ') ORDER BY ' . $order . ' ' . $dir . ' LIMIT 0,' . $options['limit']);
         $this->DB->execute();
     } else {
         if (is_array($options['joins'])) {
             $db = array('select' => 'tg.*', 'from' => array('core_tags' => 'tg'), 'where' => implode(' AND ', $where), 'add_join' => array($options['joins']), 'order' => $order . ' ' . $dir);
         } else {
             $db = array('select' => 'tg.*', 'from' => 'core_tags tg', 'where' => implode(' AND ', $where), 'order' => $order . ' ' . $dir);
         }
         if (!empty($options['limit']) || !empty($options['offset'])) {
             $db['limit'] = array(intval($options['offset']), intval($options['limit']));
         }
         /* Fetch */
         $this->DB->build($db);
         $this->DB->execute();
     }
     /* Fetch data */
     while ($row = $this->DB->fetch()) {
         $return[$row['tag_id']] = $row;
     }
     return $return;
 }
Пример #15
0
 /**
  * Perform the search
  * @param array $tags
  * @param array $options
  */
 public function run(array $tags, array $options)
 {
     $order = !empty($options['sortKey']) ? $options['sortKey'] : 'search_id';
     $dir = !empty($options['sortOrder']) ? $options['sortOrder'] : 'desc';
     $return = array();
     $query = '';
     $searchIds = array();
     /* Format query */
     if (!empty($options['meta_parent_id'])) {
         $this->sphinxClient->SetFilter('tag_meta_parent_id', is_array($options['meta_parent_id']) ? IPSLib::cleanIntArray($options['meta_parent_id']) : $options['meta_parent_id']);
     }
     if (!empty($options['meta_id'])) {
         $this->sphinxClient->SetFilter('tag_meta_id', is_array($options['meta_id']) ? IPSLib::cleanIntArray($options['meta_id']) : $options['meta_id']);
     }
     if (isset($options['meta_app'])) {
         $query .= ' @tag_meta_app ' . (is_array($options['meta_app']) ? implode("|", $options['meta_app']) : $options['meta_app']) . '';
     }
     if (isset($options['meta_area'])) {
         if (is_array($options['meta_area'])) {
             $_areas = array();
             foreach ($options['meta_area'] as $v) {
                 $_areas[] = str_replace('-', '_', $v);
             }
             $options['meta_area'] = $_areas;
         }
         $query .= ' @tag_meta_area ' . (is_array($options['meta_area']) ? implode("|", $options['meta_area']) : str_replace('-', '_', $options['meta_area'])) . '';
     }
     if (!empty($options['not_meta_id'])) {
         $this->sphinxClient->SetFilter('tag_meta_id', is_array($options['not_meta_id']) ? IPSLib::cleanIntArray($options['not_meta_id']) : array($options['not_meta_id']), true);
     }
     if (isset($tags)) {
         if (is_array($tags)) {
             foreach ($tags as $key => $tag) {
                 $tags[$key] = $this->sphinxClient->EscapeString($tag);
             }
         } else {
             $tags = $this->sphinxClient->EscapeString($tags);
         }
         if (isset($options['match']) and $options['match'] == 'loose') {
             $query .= ' @tag_text (' . (is_array($tags) ? implode(" | ", $tags) : $tags) . ')';
         } else {
             $query .= ' @tag_text "^' . (is_array($tags) ? implode('$" | "^', $tags) : $tags) . '$"';
         }
     }
     /* Did we add in perm check? */
     if (!empty($options['isViewable'])) {
         $query .= ' @tag_perm_text ",' . implode('," | ",', $this->member->perm_id_array) . ',"';
         $this->sphinxClient->SetFilter('tag_perm_visible', array(1));
     }
     /* Sort */
     if ($dir == 'asc') {
         $this->sphinxClient->SetSortMode(SPH_SORT_ATTR_ASC, str_replace('tg.', '', $order));
     } else {
         $this->sphinxClient->SetSortMode(SPH_SORT_ATTR_DESC, str_replace('tg.', '', $order));
     }
     /* Limit Results */
     if (!empty($options['limit']) || !empty($options['offset'])) {
         $this->sphinxClient->SetLimits(intval($options['offset']), intval($options['limit']));
     }
     /* run it */
     $result = $this->sphinxClient->Query($query, $this->settings['sphinx_prefix'] . 'core_tags_search_main,' . $this->settings['sphinx_prefix'] . 'core_tags_search_delta');
     $this->logSphinxWarnings();
     /* Check matches and fetch data */
     if (is_array($result['matches']) && count($result['matches'])) {
         foreach ($result['matches'] as $res) {
             $searchIds[] = $res['attrs']['search_id'];
         }
     }
     if (count($searchIds)) {
         /* Fetch */
         if (count($options['joins'])) {
             $this->DB->build(array('select' => 'tg.*', 'from' => array('core_tags' => 'tg'), 'where' => 'tg.tag_id IN(' . implode(",", $searchIds) . ')', 'add_join' => $options['joins'], 'order' => str_replace('search_id', 'tag_id', $order) . ' ' . $dir));
         } else {
             $this->DB->build(array('select' => '*', 'from' => 'core_tags', 'where' => 'tag_id IN(' . implode(",", $searchIds) . ')', 'add_join' => $options['joins'], 'order' => str_replace('search_id', 'tag_id', $order) . ' ' . $dir));
         }
         $this->DB->execute();
         while ($row = $this->DB->fetch()) {
             $return[$row['tag_id']] = $row;
         }
     }
     return $return;
 }
 /**
  * Remove email logs
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private function _remove()
 {
     if ($this->request['type'] == 'all') {
         $this->DB->delete('email_logs');
     } else {
         $ids = array();
         foreach ($this->request as $k => $v) {
             if (preg_match("/^id_(\\d+)\$/", $k, $match)) {
                 if ($this->request[$match[0]]) {
                     $ids[] = $match[1];
                 }
             }
         }
         $ids = IPSLib::cleanIntArray($ids);
         //-----------------------------------------
         if (count($ids) < 1) {
             $this->registry->output->showError($this->lang->words['elog_noneselected'], 11119);
         }
         $this->DB->delete('email_logs', "email_id IN (" . implode(',', $ids) . ")");
     }
     $this->registry->getClass('adminFunctions')->saveAdminLog($this->lang->words['elog_removed']);
     $this->registry->output->silentRedirect($this->settings['base_url'] . "&{$this->form_code}");
 }
Пример #17
0
 /**
  * Toggles visbility a comment
  *
  * @param	string	on/off
  * @param	int		Image ID of parent
  * @param	mixed	Comment ID or array of comment IDs
  * @param	array	Member Data of current member
  * @reutrn	html
  * EXCEPTIONS
  * MISSING_DATA		Ids missing
  * NO_PERMISSION	No permission
  */
 public function visibility($toggle, $parentId, $commentId, $memberData)
 {
     /* Init */
     if (is_numeric($memberData)) {
         $memberData = IPSMember::load($memberData, 'all');
     }
     /* Check */
     if (!$memberData['member_id'] or !$parentId or !$commentId) {
         throw new Exception('MISSING_DATA');
     }
     /* Fetch and check image */
     $parent = $this->fetchParent($parentId);
     $_remap = $this->remapKeys();
     $cids = array();
     /* Parent */
     $parent = $this->remapFromLocal($parent, 'parent');
     /* One or many? */
     if (is_numeric($commentId)) {
         /* Fetch comment */
         $_c = $this->fetch($parent, array('comment_id' => $commentId));
         $comment = array_pop($_c);
         /* Permission test */
         $can = $this->can('visibility', array('comment_id' => $commentId, 'comment_parent_id' => $parentId));
         if ($can !== true) {
             throw new Exception($can);
         }
         $cids = array($commentId);
     } else {
         if (is_array($commentId)) {
             /* Permission test */
             $can = $this->can('visibility', array('comment_parent_id' => $parentId));
             if ($can !== true) {
                 throw new Exception($can);
             }
             /* Finalize comment Ids */
             $this->DB->build(array('select' => '*', 'from' => $this->table(), 'where' => $_remap['comment_id'] . ' IN (' . implode(",", IPSLib::cleanIntArray($commentId)) . ') AND ' . $_remap['comment_parent_id'] . '=' . $parent['parent_id']));
             $this->DB->execute();
             while ($row = $this->DB->fetch()) {
                 $cids[] = $row[$_remap['comment_id']];
             }
         }
     }
     /* If we have anything.. */
     if (count($cids)) {
         /* Update array */
         $array = array('comment_approved' => $toggle == 'on' ? 1 : 0);
         /* Pre save */
         $update = $this->preVisibility($toggle, $cids, $parentId, $array);
         /* Insert and fetch DB */
         $save = $this->remapToLocal($update);
         /* Update */
         $this->DB->update($this->table(), $save, $_remap['comment_id'] . ' IN (' . implode(",", $cids) . ')');
         /* Post delete */
         $this->postVisibility($toggle, $cids, $parentId);
     }
     /* Return count deleted */
     return count($cids);
 }
 /**
  * Retrieve all IP addresses a user (or multiple users) have used
  *
  * @access	public
  * @param 	mixed		[Integer] member ID or [Array] array of member ids
  * @param	string		Defaults to 'All', otherwise specify which tables to check (comma separated)
  * @return	array		Multi-dimensional array of found IP addresses in which sections
  */
 public static function findIPAddresses($id, $tables_to_check = 'all')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $ip_addresses = array();
     $tables = array('admin_logs' => array('member_id', 'ip_address', 'ctime'), 'dnames_change' => array('dname_member_id', 'dname_ip_address', 'dname_date'), 'email_logs' => array('from_member_id', 'from_ip_address', 'email_date'), 'members' => array('member_id', 'ip_address', 'joined'), 'message_posts' => array('msg_author_id', 'msg_ip_address', 'msg_date'), 'moderator_logs' => array('member_id', 'ip_address', 'ctime'), 'posts' => array('author_id', 'ip_address', 'post_date'), 'profile_comments' => array('comment_by_member_id', 'comment_ip_address', 'comment_date'), 'profile_ratings' => array('rating_by_member_id', 'rating_ip_address', 'rating_added'), 'sessions' => array('member_id', 'ip_address', 'running_time'), 'topic_ratings' => array('rating_member_id', 'rating_ip_address', ''), 'validating' => array('member_id', 'ip_address', 'entry_date'), 'voters' => array('member_id', 'ip_address', 'vote_date'), 'error_logs' => array('log_member', 'log_ip_address', 'log_date'));
     //-----------------------------------------
     // Check apps
     // @see http://forums./tracker/issue-16966-members-download-manag/
     //-----------------------------------------
     $apps = new IPSApplicationsIterator();
     foreach ($apps as $app) {
         if (file_exists(IPSLib::getAppDir($apps->fetchAppDir()) . "/extensions/coreExtensions.php")) {
             require_once IPSLib::getAppDir($apps->fetchAppDir()) . "/extensions/coreExtensions.php";
             $app_dir = $apps->fetchAppDir();
             if (class_exists($app_dir . '_findIpAddress')) {
                 $classX = $app_dir . '_findIpAddress';
                 $ipLookup = new $classX(ipsRegistry::instance());
                 if (method_exists($ipLookup, 'getTables')) {
                     $tables = array_merge($tables, $ipLookup->getTables());
                 }
             }
         }
     }
     //-----------------------------------------
     // Sort out thingie
     //-----------------------------------------
     if (is_array($id)) {
         $id = IPSLib::cleanIntArray($id);
         $mids = ' IN (' . implode(",", $id) . ')';
     } else {
         $mids = ' = ' . intval($id);
     }
     //-----------------------------------------
     // Got tables?
     //-----------------------------------------
     $_tables = explode(',', $tables_to_check);
     if (!is_array($_tables) or !count($_tables)) {
         return array();
     }
     //-----------------------------------------
     // Loop through them and grab the IPs
     //-----------------------------------------
     foreach ($tables as $tablename => $fields) {
         if ($tables_to_check == 'all' or in_array($tablename, $_tables)) {
             $extra = '';
             if ($fields[2]) {
                 $extra = ', ' . $fields[2] . ' as date';
             }
             ipsRegistry::DB()->build(array('select' => $fields[1] . $extra, 'from' => $tablename, 'where' => $fields[0] . $mids));
             ipsRegistry::DB()->execute();
             while ($r = ipsRegistry::DB()->fetch()) {
                 if ($r[$fields[1]]) {
                     $r['date'] = $r['date'] > $ip_addresses[$r[$fields[1]]][1] ? $r['date'] : ($ip_addresses[$r[$fields[1]]][1] ? $ip_addresses[$r[$fields[1]]][1] : 0);
                     $ip_addresses[$r[$fields[1]]] = array(intval($ip_addresses[$r[$fields[1]]][0]) + 1, $r['date']);
                 }
             }
         }
     }
     //-----------------------------------------
     // Here are your IPs kind sir.  kthxbai
     //-----------------------------------------
     return $ip_addresses;
 }
 /**
  * Export the settings
  *
  * @access	private
  * @return	void
  */
 private function _finishExportingSettings()
 {
     $ids = array();
     $groups = array();
     //-----------------------------------------
     // get ids...
     //-----------------------------------------
     foreach ($_POST as $key => $value) {
         if (preg_match("/^id_(\\d+)\$/", $key, $match)) {
             if ($this->request[$match[0]]) {
                 $ids[] = $match[1];
             }
         }
     }
     $ids = IPSLib::cleanIntArray($ids);
     //-----------------------------------------
     // Got any?
     //-----------------------------------------
     if (!count($ids)) {
         $this->registry->output->global_message = $this->lang->words['s_sometoexport'];
         $this->_startExportingSettings();
         return;
     }
     //-----------------------------------------
     // Get XML class
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'class_xml.php';
     $xml = new class_xml();
     $xml->xml_set_root('settingexport', array('exported' => time()));
     //-----------------------------------------
     // Get groups
     //-----------------------------------------
     $xml->xml_add_group('settinggroup');
     $this->_settingsGetGroups();
     $entry = array();
     $this->DB->build(array('select' => '*', 'from' => 'core_sys_conf_settings', 'where' => "conf_id IN (" . implode(",", $ids) . ")", 'order' => 'conf_position, conf_title'));
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         $content = array();
         $groups[$r['conf_group']] = $r['conf_group'];
         $r['conf_value'] = '';
         //-----------------------------------------
         // Add in setting key
         //-----------------------------------------
         $r['conf_title_keyword'] = $this->setting_groups[$r['conf_group']]['conf_title_keyword'];
         foreach ($r as $k => $v) {
             $content[] = $xml->xml_build_simple_tag($k, $v);
         }
         $entry[] = $xml->xml_build_entry('setting', $content);
     }
     //-----------------------------------------
     // Add in groups...
     //-----------------------------------------
     if (is_array($groups) and count($groups)) {
         foreach ($groups as $conf_group_id) {
             $content = array();
             $thisconf = array('conf_is_title' => 1, 'conf_title_keyword' => $this->setting_groups[$conf_group_id]['conf_title_keyword'], 'conf_title_title' => $this->setting_groups[$conf_group_id]['conf_title_title'], 'conf_title_desc' => $this->setting_groups[$conf_group_id]['conf_title_desc'], 'conf_title_noshow' => $this->setting_groups[$conf_group_id]['conf_title_noshow'], 'conf_title_module' => $this->setting_groups[$conf_group_id]['conf_title_module']);
             foreach ($thisconf as $k => $v) {
                 $content[] = $xml->xml_build_simple_tag($k, $v);
             }
             $entry[] = $xml->xml_build_entry('setting', $content);
         }
     }
     $xml->xml_add_entry_to_group('settinggroup', $entry);
     $xml->xml_format_document();
     $doc = $xml->xml_document;
     //-----------------------------------------
     // Print to browser
     //-----------------------------------------
     $this->registry->output->showDownload($doc, 'ipb_settings_partial.xml', '', 0);
 }
Пример #20
0
 /**
  * Saves the add forum dialog
  */
 protected function _saveAddForumDialog()
 {
     $type = trim($this->request['type']);
     $rules = $this->archiveWriter->getRulesFromDb();
     $forums = array();
     $int = $type == 'archive' ? 0 : 1;
     $return = '';
     /* Mix in data */
     if (is_array($_POST['forumIds'])) {
         $forums = IPSLib::cleanIntArray($_POST['forumIds']);
     } else {
         $forums = array();
     }
     /* Update DB */
     $this->DB->replace('core_archive_rules', array('archive_key' => md5('forums_forum_' . $int), 'archive_app' => 'forums', 'archive_field' => 'forum', 'archive_value' => '', 'archive_text' => serialize($forums), 'archive_unit' => '', 'archive_skip' => $int), array('archive_key'));
     /* Send back serialized data */
     $return['ids'] = serialize($forums);
     /* Now return the data */
     foreach ($forums as $fid) {
         $return['data'][$fid] = array('data' => $this->registry->class_forums->getForumbyId($fid), 'nav' => $this->html->buildForumNav($this->registry->class_forums->forumsBreadcrumbNav($fid, 'showforum=', true)));
     }
     $this->returnJsonArray($return);
 }
 /**
  * Save the new or edited bulk mail
  *
  * @access	private
  * @return	void
  */
 private function _mailSave()
 {
     //-----------------------------------------
     // Set up
     //-----------------------------------------
     $ids = array();
     $id = intval($this->request['id']);
     $type = $this->request['type'];
     //-----------------------------------------
     // Start
     //-----------------------------------------
     if (!$this->request['mail_subject'] or !$this->request['mail_content']) {
         $this->registry->output->global_message = $this->lang->words['b_entercont'];
         $this->_mailForm($type);
         return;
     }
     //-----------------------------------------
     // Groups...
     //-----------------------------------------
     foreach ($_POST as $key => $value) {
         if (preg_match("/^sg_(\\d+)\$/", $key, $match)) {
             if ($this->request[$match[0]] and $value) {
                 $ids[] = $match[1];
             }
         }
     }
     $ids = IPSLib::cleanIntArray($ids);
     if (!count($ids)) {
         $this->registry->output->global_message = $this->lang->words['b_nogroups'];
         $this->_mailForm($type);
         return;
     }
     $this->request['mail_groups'] = implode(",", $ids);
     //-----------------------------------------
     // Format the query
     //-----------------------------------------
     $query = $this->_buildMembersQuery(array('mail_post_ltmt' => $this->request['mail_post_ltmt'], 'mail_filter_post' => $this->request['mail_filter_post'], 'mail_visit_ltmt' => $this->request['mail_visit_ltmt'], 'mail_filter_visit' => intval($this->request['mail_filter_visit']), 'mail_joined_ltmt' => $this->request['mail_joined_ltmt'], 'mail_filter_joined' => intval($this->request['mail_filter_joined']), 'mail_honor' => 1, 'mail_groups' => $this->request['mail_groups']));
     //-----------------------------------------
     // Count how many matches
     //-----------------------------------------
     $count = $this->DB->buildAndFetch(array('select' => 'count(*) as cnt', 'from' => 'members', 'where' => $query));
     if (!$count['cnt']) {
         $this->registry->output->global_message = $this->lang->words['b_nonefound'];
         $this->_mailForm($type);
         return;
     }
     //-----------------------------------------
     // Save
     //-----------------------------------------
     $save_array = array('mail_subject' => IPSText::stripslashes($_POST['mail_subject']), 'mail_content' => IPSText::stripslashes($_POST['mail_content']), 'mail_groups' => $this->request['mail_groups'], 'mail_honor' => 1, 'mail_start' => time(), 'mail_updated' => time(), 'mail_sentto' => 0, 'mail_opts' => serialize(array('mail_post_ltmt' => $_POST['mail_post_ltmt'], 'mail_filter_post' => $_POST['mail_filter_post'], 'mail_visit_ltmt' => $_POST['mail_visit_ltmt'], 'mail_filter_visit' => $_POST['mail_filter_visit'], 'mail_joined_ltmt' => $_POST['mail_joined_ltmt'], 'mail_filter_joined' => $_POST['mail_filter_joined'], 'mail_html_on' => $_POST['mail_html_on'])));
     if ($type == 'add') {
         //-----------------------------------------
         // Save to DB
         //-----------------------------------------
         $this->DB->insert('bulk_mail', $save_array);
         $this->request['id'] = $this->DB->getInsertId();
         ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['b_maillogadd'], $this->request['mail_subject']));
         $this->_mailSendStart();
         return;
     } else {
         if (!$id) {
             $this->registry->output->global_message = $this->lang->words['b_norecord'];
             $this->_mailForm($type);
             return;
         }
         $this->DB->update('bulk_mail', $save_array, 'mail_id=' . $id);
         ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['b_maillogedit'], $this->request['mail_subject']));
         $this->registry->output->global_message = $this->lang->words['b_edited'];
         $this->_mailStart();
         return;
     }
 }
 /**
  * Basic functions for processing actions on 'Report Index' page (Drop Down)
  *
  * @access	private
  * @return	void
  */
 private function _processReports()
 {
     //-----------------------------------------
     // Check form key
     //-----------------------------------------
     if ($this->request['k'] != $this->member->form_hash) {
         $this->registry->getClass('output')->showError('no_permission', 20112);
     }
     //-----------------------------------------
     // Are we pruning?
     //-----------------------------------------
     if (is_numeric($this->request['pruneDays']) && $this->request['newstatus'] == 'p') {
         if (!$this->memberData['g_access_cp']) {
             $this->registry->output->showError('no_report_prune_perm', 2019, true);
         }
         //-----------------------------------------
         // Let's prune those reports.. if we can
         //-----------------------------------------
         $prune_time = ceil(time() - intval($this->request['pruneDays']) * 86400);
         $total_pruned = $this->_pruneReports($prune_time);
         if ($total_pruned) {
             $this->registry->output->redirectScreen($this->lang->words['report_prune_message_done'], $this->settings['base_url'] . "app=core&module=reports&do=index&st=" . $this->request['st']);
         } else {
             $this->registry->output->redirectScreen($this->lang->words['report_prune_message_none'], $this->settings['base_url'] . "app=core&module=reports&do=index&st=" . $this->request['st']);
         }
     } elseif ($this->request['report_ids'] && is_array($this->request['report_ids'])) {
         $ids = implode(',', IPSLib::cleanIntArray($this->request['report_ids']));
         if (strlen($ids) > 0 && !preg_match("/[^0-9,]/", $ids)) {
             if ($this->request['newstatus'] == 'd') {
                 if (!$this->memberData['g_access_cp']) {
                     $this->registry->output->showError('no_report_prune_perm', 20110, true);
                 }
                 //-----------------------------------------
                 // Time to delete some stuff!
                 //-----------------------------------------
                 $this->_deleteReports($ids, true);
                 $this->registry->getClass('reportLibrary')->updateCacheTime();
                 $this->registry->output->redirectScreen($this->lang->words['redirect_delete_report'], $this->settings['base_url'] . "app=core&module=reports&do=index&st=" . $this->request['st']);
             } else {
                 //----------------------------------------------
                 // Change the status of these reports...
                 //----------------------------------------------
                 $build_update = array('status' => intval($this->request['newstatus']), 'date_updated' => time(), 'updated_by' => $this->memberData['member_id']);
                 $this->DB->update('rc_reports_index', $build_update, "id IN({$ids})");
                 $this->registry->getClass('reportLibrary')->updateCacheTime();
                 $this->registry->output->redirectScreen($this->lang->words['redirect_mark_status'], $this->settings['base_url'] . "app=core&module=reports&do=index&st=" . $this->request['st']);
             }
         }
     }
     //-----------------------------------------
     // If we're still here show an error
     //-----------------------------------------
     if (!$this->memberData['g_access_cp']) {
         $this->registry->output->showError('no_report_none_perm', 10131);
     } else {
         $this->registry->output->silentRedirect($this->settings['base_url'] . "app=core&module=reports&do=index");
     }
 }
 /**
  * Delete messages from a topic
  *
  * @access	public
  * @param	array 		Array of message IDs to remove
  * @param	int			Deleted by member ID
  * @return	boolean		Deleted
  */
 public function deleteMessages($msgIDs = array(), $deletedByMemberID)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $idsToDelete = array();
     $topics = array();
     $unread = array();
     $deletedByMember = IPSMember::load(intval($deletedByMemberID), 'all');
     //-----------------------------------------
     // Check
     //-----------------------------------------
     if (!is_array($msgIDs) or !count($msgIDs)) {
         return FALSE;
     }
     //-----------------------------------------
     // Fetch all posts...
     //-----------------------------------------
     $this->DB->build(array('select' => 'msg.msg_id, msg.msg_topic_id, msg.msg_author_id', 'from' => array('message_posts' => 'msg'), 'where' => 'msg.msg_id IN (' . implode(',', IPSLib::cleanIntArray($msgIDs)) . ') AND msg.msg_is_first_post != 1', 'add_join' => array(array('select' => 'mt.*', 'from' => array('message_topics' => 'mt'), 'where' => 'mt.mt_id=msg.msg_topic_id', 'type' => 'left'))));
     $this->DB->execute();
     while ($msg = $this->DB->fetch()) {
         if ($this->_conversationCanDelete($msg, $msg, $deletedByMember) === TRUE) {
             $idsToDelete[$msg['msg_id']] = $msg['msg_id'];
             $topics[$msg['msg_topic_id']] = $msg['msg_topic_id'];
         }
     }
     //-----------------------------------------
     // Got anything?
     //-----------------------------------------
     if (!count($idsToDelete)) {
         return FALSE;
     }
     //-----------------------------------------
     // Is there an attachment to these messages??
     //-----------------------------------------
     require_once IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php';
     $class_attach = new class_attach($this->registry);
     $class_attach->type = 'msg';
     $class_attach->init();
     $class_attach->bulkRemoveAttachment($idsToDelete);
     //-----------------------------------------
     // Delete the messages
     //-----------------------------------------
     $this->DB->delete('message_posts', 'msg_id IN (' . implode(',', IPSLib::cleanIntArray($msgIDs)) . ')');
     //-----------------------------------------
     // Rebuild member's new message count
     // This MUST go before we rebuild the topic
     // so we get all those who haven't yet read
     // the last replies...
     //-----------------------------------------
     $this->DB->build(array('select' => '*', 'from' => 'message_topic_user_map', 'where' => 'map_user_active=1 AND map_topic_id IN (' . implode(",", array_keys($topics)) . ') AND map_has_unread=1'));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         $unread[$row['map_user_id']] = $row['map_user_id'];
     }
     //-----------------------------------------
     // Update all relevant topics
     //-----------------------------------------
     foreach (array_keys($topics) as $topicID) {
         $this->rebuildTopic($topicID);
     }
     /* Update member counts */
     if (count($unread)) {
         $this->resetMembersNewTopicCount($unread);
     }
     return TRUE;
 }
Пример #24
0
 /**
  * Grabs post ids for multi-mod
  *
  * @param	string		Field to look in
  * @return	@e void		Cleaned array of post ids
  */
 protected function _getIds($field = 'selectedtids', $fieldJS = '')
 {
     /* Check main field */
     $ids = array();
     /* Check ids field */
     if ($this->request[$field]) {
         if (is_array($this->request[$field])) {
             $_ids = $this->request[$field];
         } else {
             $_ids = explode(',', $this->request[$field]);
         }
         if (is_array($_ids) && count($_ids)) {
             foreach ($_ids as $_id) {
                 $ids[] = $_id;
             }
         }
     }
     /* Check js saved ids */
     if ($this->request[$fieldJS]) {
         $jsIds = explode(',', $this->request[$fieldJS]);
         if (is_array($jsIds) && count($jsIds)) {
             foreach ($jsIds as $_id) {
                 $ids[] = $_id;
             }
         }
     }
     if (count($ids) < 1) {
         $this->_showError('mod_no_tid', 103118);
     }
     $ids = IPSLib::cleanIntArray($ids);
     $ids = array_diff($ids, array(0));
     $ids = array_unique($ids);
     return $ids;
 }
Пример #25
0
 /**
  * Fetch entries from the delete log
  *
  * @param	array		Object IDs
  * @param	string		Object Type
  * @param	boolean		Parse Member Data
  */
 public static function fetchEntries($ids, $type, $parseMember = true)
 {
     $return = array();
     if (is_array($ids) and count($ids) and $type) {
         $ids = IPSLib::cleanIntArray($ids);
         ipsRegistry::DB()->build(array('select' => 'l.*', 'from' => array('core_soft_delete_log' => 'l'), 'where' => 'sdl_obj_id IN (' . implode(',', $ids) . ') AND sdl_obj_key=\'' . $type . '\'', 'add_join' => array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'l.sdl_obj_member_id=m.member_id'), array('select' => 'p.*', 'from' => array('profile_portal' => 'p'), 'where' => 'l.sdl_obj_member_id=p.pp_member_id'))));
         $i = ipsRegistry::DB()->execute();
         while ($row = ipsRegistry::DB()->fetch($i)) {
             if ($parseMember) {
                 $row['member'] = IPSMember::buildDisplayData($row);
             }
             $return[$row['sdl_obj_id']] = $row;
         }
         return $return;
     }
     return array();
 }
Пример #26
0
 /**
  * UserCP handle our notifications
  *
  * @return	boolean		Successful
  */
 public function customEvent_removeNotifications()
 {
     //-----------------------------------------
     // Check form hash
     //-----------------------------------------
     $this->request['secure_key'] = $this->request['secure_key'] ? $this->request['secure_key'] : $this->request['md5check'];
     if ($this->request['secure_key'] != $this->member->form_hash) {
         $this->registry->output->showError('usercp_forums_bad_key', 1021523);
     }
     //-----------------------------------------
     // Notifications library
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications');
     $notifyLibrary = new $classToLoad($this->registry);
     $notifyLibrary->setMember($this->memberData);
     //-----------------------------------------
     // Delete the notifications
     //-----------------------------------------
     $_toDelete = IPSLib::cleanIntArray($this->request['notifications']);
     if (!count($_toDelete)) {
         return $this->showInlineNotifications($this->lang->words['no_notify_del']);
     }
     $this->DB->delete('inline_notifications', "notify_id IN(" . implode(',', $_toDelete) . ") AND notify_to_id=" . $this->memberData['member_id']);
     //-----------------------------------------
     // If member has 'unread' count, rebuild count
     //-----------------------------------------
     if ($this->memberData['notification_cnt']) {
         $notifyLibrary->rebuildUnreadCount();
     }
     //-----------------------------------------
     // Redirect
     //-----------------------------------------
     $this->registry->getClass('output')->silentRedirect($this->settings['base_url'] . "app=core&amp;module=usercp&amp;tab=core&amp;area=notificationlog&amp;confirm=1");
 }
 /**
  * Grabs post ids for multi-mod
  *
  * @access	private
  * @param	string		Field to look in
  * @return	void		Cleaned array of post ids
  */
 private function _getIds($field = 'selectedtids')
 {
     $ids = array();
     $ids = is_array($this->request[$field]) ? $this->request[$field] : explode(',', $this->request[$field]);
     if (count($ids) < 1) {
         $this->_showError('mod_no_tid', 103118);
     }
     $ids = IPSLib::cleanIntArray($ids);
     $ids = array_diff($ids, array(0));
     return $ids;
 }