Exemplo n.º 1
0
 function save()
 {
     global $mainframe, $eventListOrder;
     $conf = $this->getModel('config');
     if ($eventListOrder != $_POST['config']["eventListOrder"]) {
         $conf->updateEventorder($_POST['config']["eventListOrder"]);
     }
     $database =& JFactory::getDBO();
     $sql = "TRUNCATE TABLE `#__dtregister_config` ";
     $database->setQuery($sql);
     $database->query();
     $mconfig = $this->getModel('config');
     foreach ($_POST['config'] as $key => $value) {
         if (is_array($value)) {
             if (in_array($key, $mconfig->config_array_map)) {
                 $multiplevalue = json_encode($value);
                 // prd((array)json_decode($value));
             } else {
                 $multiplevalue = implode(',', $value);
             }
             $key = $database->Quote($key);
             $multiplevalue = $database->Quote($multiplevalue);
             $sql = "Insert Into #__dtregister_config(config_key,config_value,`title`) Values({$key},{$multiplevalue},{$key})";
             $database->setQuery($sql);
             if (!$database->query()) {
                 echo $database->getErrorMsg();
                 die;
             }
         } else {
             $value = JRequest::_cleanVar($value, JREQUEST_ALLOWHTML);
             $key = $database->Quote($key);
             $value = $database->Quote($value);
             $sql = "Insert Into #__dtregister_config(config_key,config_value,`title`) Values({$key},{$value},{$key})";
             $database->setQuery($sql);
             if (!$database->query()) {
                 echo $database->getErrorMsg();
                 die;
             }
         }
     }
     $mainframe->redirect("index.php?option=" . DTR_COM_COMPONENT . "&task=index&controller=config", JText::_('SETTINGS_SAVED'));
 }
function simulateSaveRepeat($requestObject)
{
    include_once JPATH_SITE . "/components/com_jevents/jevents.defines.php";
    if (!JEVHelper::isEventCreator()) {
        throwerror(JText::_('ALERTNOTAUTH'));
    }
    // Convert formdata to array
    $formdata = array();
    foreach (get_object_vars($requestObject->formdata) as $k => $v) {
        $k = str_replace("[]", "", $k);
        $formdata[$k] = $v;
    }
    $array = JRequest::_cleanVar($formdata, JREQUEST_ALLOWHTML);
    if (!array_key_exists("rp_id", $array) || intval($array["rp_id"]) <= 0) {
        throwerror(JText::_("Not a repeat", true));
    }
    $rp_id = intval($array["rp_id"]);
    $dataModel = new JEventsDataModel("JEventsAdminDBModel");
    $queryModel = new JEventsDBModel($dataModel);
    // I should be able to do this in one operation but that can come later
    $event = $queryModel->listEventsById(intval($rp_id), 1, "icaldb");
    if (!JEVHelper::canEditEvent($event)) {
        throwerror(JText::_('ALERTNOTAUTH'));
    }
    $db =& JFactory::getDBO();
    $rpt = new iCalRepetition($db);
    $rpt->load($rp_id);
    $query = "SELECT detail_id FROM #__jevents_vevent WHERE ev_id={$rpt->eventid}";
    $db->setQuery($query);
    $eventdetailid = $db->loadResult();
    $data["UID"] = valueIfExists($array, "uid", md5(uniqid(rand(), true)));
    $data["X-EXTRAINFO"] = valueIfExists($array, "extra_info", "");
    $data["LOCATION"] = valueIfExists($array, "location", "");
    $data["allDayEvent"] = valueIfExists($array, "allDayEvent", "off");
    $data["CONTACT"] = valueIfExists($array, "contact_info", "");
    // allow raw HTML (mask =2)
    $data["DESCRIPTION"] = valueIfExists($array, "jevcontent", "", 'request', 'html', 2);
    $data["publish_down"] = valueIfExists($array, "publish_down", "2006-12-12");
    $data["publish_up"] = valueIfExists($array, "publish_up", "2006-12-12");
    $interval = valueIfExists($array, "rinterval", 1);
    $data["SUMMARY"] = valueIfExists($array, "title", "");
    $data["MULTIDAY"] = intval(valueIfExists($array, "multiday", "1"));
    $data["NOENDTIME"] = intval(valueIfExists($array, "noendtime", 0));
    $ics_id = valueIfExists($array, "ics_id", 0);
    if ($data["allDayEvent"] == "on") {
        $start_time = "00:00";
    } else {
        $start_time = valueIfExists($array, "start_time", "08:00");
    }
    $publishstart = $data["publish_up"] . ' ' . $start_time . ':00';
    $data["DTSTART"] = JevDate::strtotime($publishstart);
    if ($data["allDayEvent"] == "on") {
        $end_time = "23:59";
        $publishend = $data["publish_down"] . ' ' . $end_time . ':59';
    } else {
        $end_time = valueIfExists($array, "end_time", "15:00");
        $publishend = $data["publish_down"] . ' ' . $end_time . ':00';
    }
    $data["DTEND"] = JevDate::strtotime($publishend);
    // iCal for whole day uses 00:00:00 on the next day JEvents uses 23:59:59 on the same day
    list($h, $m, $s) = explode(":", $end_time . ':00');
    if ($h + $m + $s == 0 && $data["allDayEvent"] == "on" && $data["DTEND"] > $data["DTSTART"]) {
        $publishend = JevDate::strftime('%Y-%m-%d 23:59:59', $data["DTEND"] - 86400);
        $data["DTEND"] = JevDate::strtotime($publishend);
    }
    $data["X-COLOR"] = valueIfExists($array, "color", "");
    // Add any custom fields into $data array
    foreach ($array as $key => $value) {
        if (strpos($key, "custom_") === 0) {
            $data[$key] = $value;
        }
    }
    // populate rpt with data
    $start = $data["DTSTART"];
    $end = $data["DTEND"];
    $rpt->startrepeat = JevDate::strftime('%Y-%m-%d %H:%M:%S', $start);
    $rpt->endrepeat = JevDate::strftime('%Y-%m-%d %H:%M:%S', $end);
    $rpt->duplicatecheck = md5($rpt->eventid . $start);
    $rpt->rp_id = $rp_id;
    $rpt->event = $event;
    return $rpt;
}
Exemplo n.º 3
0
 /**
  * Module cache helper
  *
  * Caching modes:
  * To be set in XML:
  *    'static'      One cache file for all pages with the same module parameters
  *    'oldstatic'   1.5 definition of module caching, one cache file for all pages
  *                  with the same module id and user aid,
  *    'itemid'      Changes on itemid change, to be called from inside the module:
  *    'safeuri'     Id created from $cacheparams->modeparams array,
  *    'id'          Module sets own cache id's
  *
  * @param   object  $module        Module object
  * @param   object  $moduleparams  Module parameters
  * @param   object  $cacheparams   Module cache parameters - id or url parameters, depending on the module cache mode
  * @param   array   $params        Parameters for given mode - calculated id or an array of safe url parameters and their
  *                                 variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return  string
  *
  * @since   11.1
  *
  * @link JFilterInput::clean()
  */
 public static function moduleCache($module, $moduleparams, $cacheparams)
 {
     if (!isset($cacheparams->modeparams)) {
         $cacheparams->modeparams = null;
     }
     if (!isset($cacheparams->cachegroup)) {
         $cacheparams->cachegroup = $module->module;
     }
     $user = JFactory::getUser();
     $cache = JFactory::getCache($cacheparams->cachegroup, 'callback');
     $conf = JFactory::getConfig();
     // Turn cache off for internal callers if parameters are set to off and for all logged in users
     if ($moduleparams->get('owncache', null) === 0 || $conf->get('caching') == 0 || $user->get('id')) {
         $cache->setCaching(false);
     }
     // module cache is set in seconds, global cache in minutes, setLifeTime works in minutes
     $cache->setLifeTime($moduleparams->get('cache_time', $conf->get('cachetime') * 60) / 60);
     $wrkaroundoptions = array('nopathway' => 1, 'nohead' => 0, 'nomodules' => 1, 'modulemode' => 1, 'mergehead' => 1);
     $wrkarounds = true;
     $view_levels = md5(serialize($user->getAuthorisedViewLevels()));
     switch ($cacheparams->cachemode) {
         case 'id':
             $ret = $cache->get(array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $cacheparams->modeparams, $wrkarounds, $wrkaroundoptions);
             break;
         case 'safeuri':
             $secureid = null;
             if (is_array($cacheparams->modeparams)) {
                 $uri = JRequest::get();
                 $safeuri = new stdClass();
                 foreach ($cacheparams->modeparams as $key => $value) {
                     // Use int filter for id/catid to clean out spamy slugs
                     if (isset($uri[$key])) {
                         $safeuri->{$key} = JRequest::_cleanVar($uri[$key], 0, $value);
                     }
                 }
             }
             $secureid = md5(serialize(array($safeuri, $cacheparams->method, $moduleparams)));
             $ret = $cache->get(array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $module->id . $view_levels . $secureid, $wrkarounds, $wrkaroundoptions);
             break;
         case 'static':
             $ret = $cache->get(array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $module->module . md5(serialize($cacheparams->methodparams)), $wrkarounds, $wrkaroundoptions);
             break;
         case 'oldstatic':
             // provided for backward compatibility, not really usefull
             $ret = $cache->get(array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $module->id . $view_levels, $wrkarounds, $wrkaroundoptions);
             break;
         case 'itemid':
         default:
             $ret = $cache->get(array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $module->id . $view_levels . JRequest::getVar('Itemid', null, 'default', 'INT'), $wrkarounds, $wrkaroundoptions);
             break;
     }
     return $ret;
 }
Exemplo n.º 4
0
 /**
  * Fetches and returns a request array.
  *
  * The default behaviour is fetching variables depending on the
  * current request method: GET and HEAD will result in returning
  * $_GET, POST and PUT will result in returning $_POST.
  *
  * You can force the source by setting the $hash parameter:
  *
  *   post		$_POST
  *   get		$_GET
  *   files		$_FILES
  *   cookie		$_COOKIE
  *   method		via current $_SERVER['REQUEST_METHOD']
  *   default	$_REQUEST
  *
  * @static
  * @param	string	$hash	to get (POST, GET, FILES, METHOD)
  * @param	int		$mask	Filter mask for the variable
  * @return	mixed	Request hash
  * @since	1.5
  */
 function get($hash = 'default', $mask = 0)
 {
     $hash = strtoupper($hash);
     if ($hash === 'METHOD') {
         $hash = strtoupper($_SERVER['REQUEST_METHOD']);
     }
     switch ($hash) {
         case 'GET':
             $input = $_GET;
             break;
         case 'POST':
             $input = $_POST;
             break;
         case 'FILES':
             $input = $_FILES;
             break;
         case 'COOKIE':
             $input = $_COOKIE;
             break;
         case 'REQUEST':
             $input = $_REQUEST;
             break;
         default:
             $input = $GLOBALS['_RSGINSTANCE'];
             $hash = 'rsgInstance';
             break;
     }
     $result = JRequest::_cleanVar($input, $mask);
     // Handle magic quotes compatability
     if (get_magic_quotes_gpc() && $hash != 'FILES') {
         $result = JRequest::_stripSlashesRecursive($result);
     }
     return $result;
 }
Exemplo n.º 5
0
 /**
  * Fetches and returns a request array.
  *
  * The default behaviour is fetching variables depending on the
  * current request method: GET and HEAD will result in returning
  * $_GET, POST and PUT will result in returning $_POST.
  *
  * You can force the source by setting the $hash parameter:
  *
  *   post		$_POST
  *   get		$_GET
  *   files		$_FILES
  *   cookie		$_COOKIE
  *   env		$_ENV
  *   server		$_SERVER
  *   method		via current $_SERVER['REQUEST_METHOD']
  *   default	$_REQUEST
  *
  * @static
  * @param	string	$hash	to get (POST, GET, FILES, METHOD)
  * @param	int		$mask	Filter mask for the variable
  * @return	mixed	Request hash
  * @since	1.5
  */
 function get($hash = 'default', $mask = 0)
 {
     $hash = strtoupper($hash);
     if ($hash === 'METHOD') {
         $hash = strtoupper($_SERVER['REQUEST_METHOD']);
     }
     switch ($hash) {
         case 'GET':
             $input = $_GET;
             break;
         case 'POST':
             $input = $_POST;
             break;
         case 'FILES':
             $input = $_FILES;
             break;
         case 'COOKIE':
             $input = $_COOKIE;
             break;
         case 'ENV':
             $input =& $_ENV;
             break;
         case 'SERVER':
             $input =& $_SERVER;
             break;
         default:
             $input = $_REQUEST;
             break;
     }
     $result = JRequest::_cleanVar($input, $mask);
     // Handle magic quotes compatability
     if (get_magic_quotes_gpc() && $hash != 'FILES') {
         $result = JRequest::_stripSlashesRecursive($result);
         $result = JRequest::_CleanStrip_tags($result);
         $result = JRequest::_CleanSqlInjection($result);
         $result = JRequest::_CleanHtmlspecialchars($result);
     }
     if ($hash == "GET" || $hash == "POST") {
         $result = JRequest::_stripSlashesRecursive($result);
         $result = JRequest::_CleanStrip_tags($result);
         $result = JRequest::_CleanSqlInjection($result);
         $result = JRequest::_CleanHtmlspecialchars($result);
     }
     return $result;
 }
Exemplo n.º 6
0
 /**
  * Find a value in the template
  *
  * @copyright
  * @author 		RolandD
  * @todo		JRequest::_cleanVar
  * @see 		JFilterInput
  * @access 		public
  * @param 		string	$name		the name of the parameter to find
  * @param 		string	$group		the group in which to find the parameter
  * @param		string	$default	the default value to use when not found
  * @param		string	$filter		the filter to apply
  * @param 		int 	$mask		Filter bit mask. 1=no trim: If this flag is cleared and the
  * 									input is a string, the string will have leading and trailing whitespace
  * 									trimmed. 2=allow_raw: If set, no more filtering is performed, higher bits
  * 									are ignored. 4=allow_html: HTML is allowed, but passed through a safe
  * 									HTML filter first. If set, no more filtering is performed. If no bits
  * 									other than the 1 bit is set, a strict filter is applied.
  * @param		bool	$special	if the field should require special processing
  * @return 		mixed	the value found
  * @since 		3.0
  */
 public function get($name, $group = '', $default = '', $filter = null, $mask = 0, $special = true)
 {
     // Set the initial value
     $value = '';
     // Find the value
     if (empty($group)) {
         if (array_key_exists($name, $this->_settings)) {
             $value = $this->_settings[$name];
         }
     } else {
         if (array_key_exists($group, $this->_settings)) {
             if (array_key_exists($name, $this->_settings[$group])) {
                 $value = $this->_settings[$group][$name];
             }
         }
     }
     // Return the found value
     if (is_array($value) && empty($value)) {
         $value = $default;
     } else {
         if ('' === $value) {
             $value = $default;
         }
     }
     // Special processing
     if ($special) {
         switch ($name) {
             case 'language':
             case 'target_language':
                 $value = strtolower(str_replace('-', '_', $value));
                 break;
             case 'field_delimiter':
                 if (strtolower($value) == 't') {
                     $value = "\t";
                 }
                 break;
         }
     }
     // Clean up and return
     if (is_null($filter) && $mask == 0) {
         return $value;
     } else {
         return JRequest::_cleanVar($value, $mask, $filter);
     }
 }