Esempio n. 1
0
function orderModule($uid, $inc, $option, $client = 'admin')
{
    global $database;
    $row = new mosModule($database);
    $row->load((int) $uid);
    if ($client == 'admin') {
        $where = "client_id = 1";
    } else {
        $where = "client_id = 0";
    }
    $row->move($inc, "position = " . $database->Quote($row->position) . " AND ( {$where} )");
    mosCache::cleanCache('com_content');
    $redirect = mosGetParam($_REQUEST, 'redirect', 'index2.php?option=' . $option . '&client=' . $client);
    mosRedirect($redirect);
}
function saveOrder(&$cid)
{
    global $database;
    josSpoofCheck();
    $total = count($cid);
    $order = josGetArrayInts('order');
    $row = new mosContent($database);
    $conditions = array();
    // update ordering values
    for ($i = 0; $i < $total; $i++) {
        $row->load((int) $cid[$i]);
        if ($row->ordering != $order[$i]) {
            $row->ordering = $order[$i];
            if (!$row->store()) {
                echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
                exit;
            }
            // if
            // remember to updateOrder this group
            $condition = "catid=" . (int) $row->catid . " AND state >= 0";
            $found = false;
            foreach ($conditions as $cond) {
                if ($cond[1] == $condition) {
                    $found = true;
                    break;
                }
            }
            // if
            if (!$found) {
                $conditions[] = array($row->id, $condition);
            }
        }
        // if
    }
    // for
    // execute updateOrder for each group
    foreach ($conditions as $cond) {
        $row->load($cond[0]);
        $row->updateOrder($cond[1]);
    }
    // foreach
    // clean any existing cache files
    mosCache::cleanCache('com_content');
    $msg = 'New ordering saved';
    mosRedirect('index2.php?option=com_typedcontent', $msg);
}
Esempio n. 3
0
 /**
  * Clean cache for a group
  *
  * @return boolean True on success, false otherwise
  */
 public function clean()
 {
     mosCache::cleanCache($this->_options['defaultgroup']);
     return true;
 }
Esempio n. 4
0
     editModule($option, $id, $client);
     break;
 case 'save':
 case 'apply':
     mosCache::cleanCache('com_content');
     saveModule($option, $client, $task);
     break;
 case 'remove':
     removeModule($cid, $option, $client);
     break;
 case 'cancel':
     cancelModule($option, $client);
     break;
 case 'publish':
 case 'unpublish':
     mosCache::cleanCache('com_content');
     publishModule($cid, $task == 'publish' ? 1 : 0, $option, $client);
     break;
 case 'orderup':
 case 'orderdown':
     orderModule($cid[0], $task == 'orderup' ? -1 : 1, $option, $client);
     break;
 case 'accesspublic':
 case 'accessregistered':
 case 'accessspecial':
     accessMenu($cid[0], $task, $option, $client);
     break;
 case 'saveorder':
     saveOrder($cid, $client);
     break;
 default:
Esempio n. 5
0
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined('_VALID_MOS') or die('Restricted access');
require_once $mainframe->getPath('admin_html');
switch ($task) {
    case 'clean_cache':
        mosCache::cleanCache('com_content');
        mosRedirect('index2.php', 'As caches de artigos foram limpas');
        break;
    case 'clean_all_cache':
        mosCache::cleanCache();
        mosRedirect('index2.php', 'Todas as caches foram limpas');
        break;
    case 'redirect':
        $goto = strval(strtolower(mosGetParam($_REQUEST, 'link')));
        if ($goto == 'null') {
            $msg = 'Não existe nenhum link associado a este item';
            mosRedirect('index2.php?option=com_admin&task=listcomponents', $msg);
            exit;
        }
        $goto = str_replace("'", '', $goto);
        mosRedirect($goto);
        break;
    case 'listcomponents':
        HTML_admin_misc::ListComponents();
        break;
Esempio n. 6
0
	/**
	 * User login into CMS framework
	 *
	 * @param  string          $username    The username
	 * @param  string|boolean  $password    if boolean FALSE: login without password if possible
	 * @param  booleean        $rememberme  1 for "remember-me" cookie method
	 * @param  int             $userId      used for "remember-me" login function only
	 * @return boolean                      Login success
	 */
	function login( $username, $password, $rememberme = 0, $userId = null ) {
		header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"');              // needed for IE6 to accept this anti-spam cookie in higher security setting.

		if ( checkJversion() >= 1 ) {		// Joomla 1.5 RC and above:
			if ( $password !== false ) {
				$result				=	$this->_baseFramework->login( array( 'username' => $username, 'password' => $password ), array( 'remember' => $rememberme ) );
			} else {
				// login without password:
				jimport( 'joomla.user.authentication' );
				// load user plugins:
				JPluginHelper::importPlugin( 'user' );
				// get JAuthentication object:
				$authenticate		=&	JAuthentication::getInstance();
				$dispatcher			=&	JDispatcher::getInstance();
				$response			=	new JAuthenticationResponse();
				// prepare our SUCCESS login response including user data:
				global $_CB_database;
				$row				=	new moscomprofilerUser( $_CB_database );
				$row->loadByUsername( stripslashes( $username ) );
				$response->status	=	JAUTHENTICATE_STATUS_SUCCESS;
				$response->username	=	$username;
				$response->fullname	=	$row->name;
				// now we attempt user login and check results:
				if ( checkJversion() == 2 ) {
					$login			=	$dispatcher->trigger( 'onUserLogin', array( (array) $response, array( 'action' => 'core.login.site' ) ) );
				} else {
					$login			=	$dispatcher->trigger( 'onLoginUser', array( (array) $response, array() ) );
				}
				$result				=	! in_array( false, $login, true );
			}
			if ( $result ) {
				$user				=&	JFactory::getUser();
				$this->_myId		=	(int) $user->id;
				$this->_myUsername	=	$user->username;
				$this->_myUserType	=	$user->usertype;
				$this->_myCmsGid	=	$user->get('aid', 0);
				$lang				=&	JFactory::getLanguage();

				if ( checkJversion() == 2 ) {
					$this->_myLanguage	=	strtolower( preg_replace( '/^(\w+).*$/i', '\1', $lang->getName() ) );
				} else {
					$this->_myLanguage	=	$lang->getBackwardLang();
				}
			}
		} else {
			// Mambo 4.5.x and Joomla before 1.0.13+ (in fact RC3+) do need hashed password for login() method:
			if ( $password !== false ) {
				$hashedPwdLogin		=	( ( checkJversion() == 0 ) && ! function_exists( 'josHashPassword' ) );	// more reliable version-checking than the often hacked version.php file!
				if ( $hashedPwdLogin ) {				// Joomla 1.0.12 and below:
					$dummyRow		=	new moscomprofilerUser( $_CB_database );
					$this->_baseFramework->login( $username, $dummyRow->hashAndSaltPassword( $password ), $rememberme, $userId );
				} else {
					$this->_baseFramework->login( $username, $password, $rememberme, $userId );
				}

				// Joomla 1.0 redirects bluntly if login fails! so we need to check by ourselves below:
				$result				=	true;
			} else {
				// login without password:		//TBD MAMBO 4.6 support here !
				global $_CB_database, $mainframe, $_VERSION;

				$row				=	new moscomprofilerUser( $_CB_database );
				$row->loadByUsername( stripslashes( $username ) );

				// prepare login session with user data:
				$session			=&	$mainframe->_session;
				$session->guest		=	0;
				$session->username	=	$row->username;
				$session->userid	=	(int) $row->id;
				$session->usertype	=	$row->usertype;
				$session->gid		=	(int) $row->gid;

				// attempt to login user:
				if ( $session->update() ) {
					$result			=	true;
				}

				// check if site is demo or production:
				if ( $_VERSION->SITE ) {
					// site is production; remove duplicate sessions:
					$query			=	'DELETE FROM ' . $_CB_database->NameQuote( '#__session' )
									.	"\n WHERE " . $_CB_database->NameQuote( 'session_id' ) . ' != ' . $_CB_database->Quote( $session->session_id )
									.	"\n AND " . $_CB_database->NameQuote( 'username' ) . ' = ' . $_CB_database->Quote( $row->username )
									.	"\n AND " . $_CB_database->NameQuote( 'userid' ) . ' = ' . (int) $row->id
									.	"\n AND " . $_CB_database->NameQuote( 'gid' ) . ' = ' . (int) $row->gid
									.	"\n AND " . $_CB_database->NameQuote( 'guest' ) . ' = 0';
					$_CB_database->setQuery( $query );
					if ( ! $_CB_database->query() ) {
						trigger_error( 'loginUser 1 SQL error: ' . $_CB_database->stderr( true ), E_USER_WARNING );
					}
				}

				// get current datetime:
				$currentDate		=	date( 'Y-m-d H:i:s', $this->now() );

				// update user last login with current datetime:
				$query				=	'UPDATE ' . $_CB_database->NameQuote( '#__users' )
									.	"\n SET " . $_CB_database->NameQuote( 'lastvisitDate' ) . " = " . $_CB_database->Quote( $currentDate )
									.	"\n WHERE " . $_CB_database->NameQuote( 'id' ) . " = " . (int) $session->userid;
				$_CB_database->setQuery( $query );
				if ( ! $_CB_database->query() ) {
					trigger_error( 'loginUser 2 SQL error: ' . $_CB_database->stderr( true ), E_USER_WARNING );
				}

				// clean old cache:
				mosCache::cleanCache();
			}
			if ( checkJversion() == 0 ) {
				global $mainframe;
				$mymy				=	$mainframe->getUser();
				$this->_myId		=	(int) $mymy->id;
				$this->_myUsername	=	$mymy->username;
				$this->_myUserType	=	$mymy->usertype;
				$this->_myCmsGid	=	$mymy->gid;
				if ( ! $this->_myId ) {
					$result			=	false;
				}
			}
			//TBD MAMBO 4.6 support here !
		}
		return $result;
	}
Esempio n. 7
0
 function clearSession($session = null)
 {
     if ($session === null) {
         $session =& mosSession::getCurrent();
     }
     //mosCache::cleanCache('com_content');
     mosCache::cleanCache();
     $session->guest = 1;
     $session->username = '';
     $session->userid = '';
     $session->usertype = '';
     $session->gid = 0;
     $session->update();
     // this is daggy??
     $lifetime = time() - 1800;
     setcookie("usercookie[username]", " ", $lifetime, "/");
     setcookie("usercookie[password]", " ", $lifetime, "/");
     setcookie("usercookie", " ", $lifetime, "/");
     @session_destroy();
 }
function saveOrder(&$cid, $client)
{
    global $database;
    josSpoofCheck();
    $total = count($cid);
    $order = josGetArrayInts('order');
    $row = new mosModule($database);
    $conditions = array();
    // update ordering values
    for ($i = 0; $i < $total; $i++) {
        $row->load((int) $cid[$i]);
        if ($row->ordering != $order[$i]) {
            $row->ordering = $order[$i];
            if (!$row->store()) {
                echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
                exit;
            }
            // if
            // remember to updateOrder this group
            $condition = "position = " . $database->Quote($row->position) . " AND client_id = " . (int) $row->client_id;
            $found = false;
            foreach ($conditions as $cond) {
                if ($cond[1] == $condition) {
                    $found = true;
                    break;
                }
            }
            // if
            if (!$found) {
                $conditions[] = array($row->id, $condition);
            }
        }
        // if
    }
    // for
    // execute updateOrder for each group
    foreach ($conditions as $cond) {
        $row->load($cond[0]);
        $row->updateOrder($cond[1]);
    }
    // foreach
    mosCache::cleanCache('com_content');
    $msg = 'Nova ordenação salva';
    mosRedirect('index2.php?option=com_modules&client=' . $client, $msg);
}
Esempio n. 9
0
function saveOrder(&$cid)
{
    global $database;
    josSpoofCheck();
    $total = count($cid);
    $order = josGetArrayInts('order');
    for ($i = 0; $i < $total; $i++) {
        $query = "UPDATE #__content_frontpage" . "\n SET ordering = " . (int) $order[$i] . "\n WHERE content_id = " . (int) $cid[$i];
        $database->setQuery($query);
        if (!$database->query()) {
            echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        // update ordering
        $row = new mosFrontPage($database);
        $row->load((int) $cid[$i]);
        $row->updateOrder();
    }
    // clean any existing cache files
    mosCache::cleanCache('com_content');
    $msg = 'New ordering saved';
    mosRedirect('index2.php?option=com_frontpage', $msg);
}
Esempio n. 10
0
function saveOrder(&$cid, $menutype)
{
    global $database;
    josSpoofCheck();
    $total = count($cid);
    $order = josGetArrayInts('order');
    $row = new mosMenu($database);
    $conditions = array();
    // update ordering values
    for ($i = 0; $i < $total; $i++) {
        $row->load((int) $cid[$i]);
        if ($row->ordering != $order[$i]) {
            $row->ordering = $order[$i];
            if (!$row->store()) {
                echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
                exit;
            }
            // remember to updateOrder this group
            $condition = "menutype = " . $database->Quote($menutype) . " AND parent = " . (int) $row->parent . " AND published >= 0";
            $found = false;
            foreach ($conditions as $cond) {
                if ($cond[1] == $condition) {
                    $found = true;
                    break;
                }
            }
            if (!$found) {
                $conditions[] = array($row->id, $condition);
            }
        }
    }
    // execute updateOrder for each group
    foreach ($conditions as $cond) {
        $row->load($cond[0]);
        $row->updateOrder($cond[1]);
    }
    // clean any existing cache files
    mosCache::cleanCache('com_content');
    $msg = 'Nova ordenação salva';
    mosRedirect('index2.php?option=com_menus&menutype=' . $menutype, $msg);
}
Esempio n. 11
0
/**
* Copies a complete menu, all its items and creates a new module, using the name speified
*/
function copyMenu($option, $cid, $type)
{
    global $database;
    josSpoofCheck();
    $menu_name = stripslashes(strval(mosGetParam($_POST, 'menu_name', 'New Menu')));
    $module_name = stripslashes(strval(mosGetParam($_POST, 'module_name', 'New Module')));
    // check for unique menutype for new menu copy
    $query = "SELECT params" . "\n FROM #__modules" . "\n WHERE module = 'mod_mainmenu'";
    $database->setQuery($query);
    $menus = $database->loadResultArray();
    foreach ($menus as $menu) {
        $params = mosParseParams($menu);
        if ($params->menutype == $menu_name) {
            echo "<script> alert('A menu already exists with that name - you must enter a unique Menu Name'); window.history.go(-1); </script>\n";
            exit;
        }
    }
    // copy the menu items
    $mids = josGetArrayInts('mids');
    $total = count($mids);
    $copy = new mosMenu($database);
    $original = new mosMenu($database);
    sort($mids);
    $a_ids = array();
    foreach ($mids as $mid) {
        $original->load($mid);
        $copy = $original;
        $copy->id = NULL;
        $copy->parent = $a_ids[$original->parent];
        $copy->menutype = $menu_name;
        if (!$copy->check()) {
            echo "<script> alert('" . $copy->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$copy->store()) {
            echo "<script> alert('" . $copy->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $a_ids[$original->id] = $copy->id;
    }
    // create the module copy
    $row = new mosModule($database);
    $row->load(0);
    $row->title = $module_name;
    $row->iscore = 0;
    $row->published = 1;
    $row->position = 'left';
    $row->module = 'mod_mainmenu';
    $row->params = 'menutype=' . $menu_name;
    if (!$row->check()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->store()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $row->checkin();
    $row->updateOrder('position=' . $database->Quote($row->position));
    // module assigned to show on All pages by default
    // ToDO: Changed to become a Joomla! db-object
    $query = "INSERT INTO #__modules_menu VALUES ( " . (int) $row->id . ", 0 )";
    $database->setQuery($query);
    if (!$database->query()) {
        echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    // clean any existing cache files
    mosCache::cleanCache('com_content');
    $msg = 'Copy of Menu `' . $type . '` created, consisting of ' . $total . ' items';
    mosRedirect('index2.php?option=' . $option, $msg);
}
Esempio n. 12
0
 /**
  * User logout
  *
  * Reverts the current session record back to 'anonymous' parameters
  */
 function logout()
 {
     mosCache::cleanCache();
     $session =& $this->_session;
     $session->guest = 1;
     $session->username = '';
     $session->userid = '';
     $session->usertype = '';
     $session->gid = 0;
     $session->update();
     // kill remember me cookie
     $lifetime = time() - 86400;
     $remCookieName = mosMainFrame::remCookieName_User();
     setcookie($remCookieName, ' ', $lifetime, '/');
     @session_destroy();
 }
Esempio n. 13
0
function saveOrder(&$cid)
{
    global $database;
    josSpoofCheck();
    $total = count($cid);
    $redirect = mosGetParam($_POST, 'redirect', 0);
    $rettask = strval(mosGetParam($_POST, 'returntask', ''));
    $order = josGetArrayInts('order');
    $row = new mosContent($database);
    $conditions = array();
    // update ordering values
    for ($i = 0; $i < $total; $i++) {
        $row->load((int) $cid[$i]);
        if ($row->ordering != $order[$i]) {
            $row->ordering = $order[$i];
            if (!$row->store()) {
                echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
                exit;
            }
            // if
            // remember to updateOrder this group
            $condition = "catid = " . (int) $row->catid . " AND state >= 0";
            $found = false;
            foreach ($conditions as $cond) {
                if ($cond[1] == $condition) {
                    $found = true;
                    break;
                }
            }
            // if
            if (!$found) {
                $conditions[] = array($row->id, $condition);
            }
        }
        // if
    }
    // for
    // execute updateOrder for each group
    foreach ($conditions as $cond) {
        $row->load($cond[0]);
        $row->updateOrder($cond[1]);
    }
    // foreach
    // clean any existing cache files
    mosCache::cleanCache('com_content');
    $msg = 'Nova ordenação salva';
    switch ($rettask) {
        case 'showarchive':
            mosRedirect('index2.php?option=com_content&task=showarchive&sectionid=' . $redirect, $msg);
            break;
        default:
            mosRedirect('index2.php?option=com_content&sectionid=' . $redirect, $msg);
            break;
    }
    // switch
}
Esempio n. 14
0
 /**
  * Clean cache for a group
  * @static 
  * @access	public
  * @param	string	$group	The cache data group
  */
 function cleanCache($group = false)
 {
     if (JCOMMENTS_JVERSION == '1.5') {
         $cache =& JFactory::getCache($group);
         $cache->clean($group);
     } else {
         mosCache::cleanCache($group);
     }
 }