Example #1
0
?>

<div id="main">
	<div id="content">
		<div class="row">
			<div class="col-lg-12">
				<section class="panel">
					<header class="panel-heading sm" data-color="theme-inverse">
						<h2><strong>Editar</strong> Grupo</h2>
					</header>
					<div class="panel-body">
						<?php 
if (isset($_GET['id'])) {
    $grupo = new Grupos();
    $selectGrupos = $grupo->buscaPorId($_GET['id']);
    $layers = new Layers();
    $selectLayers = $layers->busca();
    $basemaps = new Basemaps();
    $selectBasemaps = $basemaps->busca();
    ?>
						<?php 
    if (!empty($selectGrupos)) {
        ?>
							<?php 
        if ($_SESSION['tipo_id'] == 1) {
            ?>
								<div id="msg-error" class="alert bg-danger">
									<strong></strong>
								</div>

								<form class="form-horizontal" data-collabel="3" data-alignlabel="left">
Example #2
0
<?php

require_once '../config/autoload.php';
$autentica = new Autentica();
$autentica->verificaSessao();
$rotina = new Rotina();
$geoLayers = (array) $rotina->getLayers();
$layers = new Layers();
$selectLayers = $layers->busca();
$numGeoLayers = count($geoLayers);
$numSelectLayers = count($selectLayers);
if ($numSelectLayers < $numGeoLayers) {
    //echo "Foram adicionadas novas layers.";
    while ($numSelectLayers < $numGeoLayers) {
        $resultado = $layers->insere($geoLayers[$numSelectLayers]->name);
        $numSelectLayers++;
    }
} else {
    //echo "Sem novas layers para adicionar.";
}
}
if (function_exists('register_sidebar_widget')) {
    register_sidebar_widget(__('Search', 'layers'), 'widget_outofthebox_search');
}
class Layers
{
    var $style;
    var $version;
    var $date;
    function get_style()
    {
        $this->style = get_option('layers_style');
    }
}
//Admin panel adapted from the hemingwayEx theme http://www.nalinmakar.com/hemingwayex/
$layers = new Layers();
$layers->version = "1.1.0";
$layers->date = "2008-08-19";
//The date when the current update was released
// Default Options. Used only when layers is not installed or a newer version is available
$default_options = array('width' => 'fluid');
// Taken as an array, as I plan to include more options in the future versions of Layers
if (!get_option('layers_version') || get_option('layers_version') < $layers->version) {
    // Layers isn't installed, so we'll need to add options
    if (!get_option('layers_version')) {
        add_option('layers_version', $layers->version, 'Layers Version installed');
    } else {
        update_option('layers_version', $layers->version);
    }
    if (!get_option('layers_last_updated')) {
        add_option('layers_last_updated', '0000-00-00', 'Last date Layers was checked for an update');
Example #4
0
    /**
     * Checks if database updates are needed
     * @param string $version The version string from the Frontend
     */
    public function check($version)
    {
        $permissions = $this->getPermissions();
        $this->updatePermissions(array('IS_AUTH', 'MANAGE_ADMIN', 'MANAGE_USER', 'CREATE_PAGE', 'DELETE_PAGE', 'EDIT_PAGE', 'MOVE_PAGE', 'DELETE_FILE', 'MANAGE_TEMPLATE', 'MANAGE_SETTINGS', 'UPLOAD_FILE', 'MANAGE_MAILINGS', 'MANAGE_CALENDARS', 'MANAGE_ELEMENTS', 'MANAGE_MAPS'));
        $varr = explode(' ', $version);
        $build = (int) array_pop($varr);
        if (file_exists(BASEPATH . 'bright/site/hooks/UpdateHook.php')) {
            require_once BASEPATH . 'bright/site/hooks/UpdateHook.php';
            $ch = new \UpdateHook();
            if (method_exists($ch, 'update')) {
                $ch->update($build);
            }
        }
        $prevbuild = $build - 1;
        $this->_conn->updateRow("UPDATE `update` SET `build`={$prevbuild} WHERE `build`=99999");
        $prevbuild = (int) $this->_conn->getField('SELECT MAX(`build`) FROM `update`');
        if ($prevbuild >= $build) {
            return;
        }
        $sqla[] = 'CREATE TABLE IF NOT EXISTS `treeaccess` (
				  `treeId` int(11) NOT NULL,
				  `groupId` int(11) NOT NULL,
				  KEY `treeId` (`treeId`,`groupId`)
				) ENGINE=MyISAM DEFAULT CHARSET=utf8;';
        $sqla[] = 'CREATE TABLE IF NOT EXISTS `mailqueue` (
					  `id` int(11) NOT NULL AUTO_INCREMENT,
					  `pageId` int(11) NOT NULL,
					  `groups` varchar(255) CHARACTER SET utf8 NOT NULL,
					  `dateadded` datetime NOT NULL,
					  `issend` tinyint(4) NOT NULL DEFAULT \'0\',
					  PRIMARY KEY (`id`)
					) ENGINE=MyISAM  DEFAULT CHARSET=utf8;';
        $sqla[] = 'CREATE TABLE IF NOT EXISTS `parsers` (
					`parserId` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
					`label` VARCHAR( 255 ) NOT NULL ,
					UNIQUE (`label`)
					) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;';
        $colcheck = "SHOW COLUMNS FROM `user` WHERE `field`='deleted'";
        $field = $this->_conn->getRow($colcheck);
        if (strpos($field->Type, 'tinyint') !== false) {
            $sqla[] = "ALTER TABLE  `user` CHANGE  `deleted`  `deleted` TINYINT( 1 ) NULL DEFAULT  '0'";
            $sqla[] = "UPDATE `user` SET `deleted`= null WHERE `deleted`=0";
            $sqla[] = "ALTER TABLE  `user` CHANGE  `deleted`  `deleted` VARCHAR( 50 ) NULL DEFAULT  NULL";
            $sqla[] = "UPDATE `user` SET `deleted`= NOW() WHERE `deleted`='1'";
            $sqla[] = "ALTER TABLE  `user` CHANGE  `deleted`  `deleted` DATETIME NULL DEFAULT NULL";
            $sqla[] = "ALTER TABLE  `user` ADD UNIQUE (`email` ,`deleted`)";
        }
        $colcheck = "SHOW COLUMNS FROM `userfields` WHERE `field`='lang'";
        $hasField = $this->_conn->getField($colcheck);
        if ($hasField == null) {
            $sqla[] = "ALTER TABLE  `userfields` ADD  `lang` VARCHAR( 3 ) NOT NULL DEFAULT  'tpl' AFTER  `userId`";
            $sqla[] = "ALTER TABLE  `userfields` ADD  `index` TINYINT( 1 ) NOT NULL DEFAULT  '1' AFTER  `value`";
        }
        $colcheck = "SHOW COLUMNS FROM `page` WHERE `field`='alwayspublished'";
        $hasField = $this->_conn->getField($colcheck);
        if ($hasField == null) {
            $sqla[] = "ALTER TABLE  `page` CHANGE  `allwayspublished`  `alwayspublished` TINYINT( 1 ) NOT NULL ;";
            $sqla[] = "UPDATE administrators SET settings = REPLACE(settings, 'allwayspublished', 'alwayspublished') WHERE settings LIKE '%allwayspublished%';";
        }
        $colcheck = "SHOW COLUMNS FROM `content` WHERE `field`='deleted'";
        $hasField = $this->_conn->getField($colcheck);
        if ($hasField == null) {
            $sqla[] = "ALTER TABLE  `content` ADD UNIQUE (`pageId` ,`lang` ,`field` ,`index`);";
            $sqla[] = "ALTER TABLE  `userfields` ADD UNIQUE (`userId` ,`lang` ,`field` ,`index`);";
            $sqla[] = "ALTER TABLE  `content` ADD  `deleted` TINYINT( 1 ) NOT NULL DEFAULT  '0'";
        }
        $sqla[] = "CREATE TABLE IF NOT EXISTS `calendarnew` (\n\t\t\t\t\t  `calendarId` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t  `itemType` int(11) NOT NULL,\n\t\t\t\t\t  `label` varchar(255) NOT NULL,\n\t\t\t\t\t  `recur` varchar(255) DEFAULT NULL,\n\t\t\t\t\t  `until` datetime DEFAULT NULL,\n\t\t\t\t\t  `deleted` datetime DEFAULT NULL,\n\t\t\t\t\t  `creationdate` timestamp NULL DEFAULT NULL,\n\t\t\t\t\t  `modificationdate` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\t\t\t\t\t  `createdby` int(11) DEFAULT NULL,\n\t\t\t\t\t  `modifiedby` int(11) DEFAULT NULL,\n\t\t\t\t\t  PRIMARY KEY (`calendarId`)\n\t\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;";
        $sqla[] = "CREATE TABLE IF NOT EXISTS `calendardates` (\n\t\t\t\t  `dateId` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t  `calendarId` int(11) NOT NULL,\n\t\t\t\t  `starttime` TIMESTAMP NULL DEFAULT NULL,\n\t\t\t\t  `endtime` TIMESTAMP NULL DEFAULT NULL,\n\t\t\t\t  `allday` tinyint(1) NOT NULL DEFAULT '0',\n\t\t\t\t  `deleted` tinyint(1) NOT NULL DEFAULT '0',\n\t\t\t\t  PRIMARY KEY (`dateId`),\n\t\t\t\t  UNIQUE KEY `calendarId` (`calendarId`,`starttime`,`endtime`)\n\t\t\t\t) ENGINE=MyISAM  DEFAULT CHARSET=utf8";
        $sqla[] = "CREATE TABLE IF NOT EXISTS `calendarcontent` (\n\t\t\t\t  `contentId` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t  `calendarId` int(11) NOT NULL,\n\t\t\t\t  `lang` varchar(3) NOT NULL DEFAULT 'ALL',\n\t\t\t\t  `field` varchar(20) NOT NULL,\n\t\t\t\t  `value` longtext NOT NULL,\n\t\t\t\t  `index` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t  `deleted` tinyint(1) NOT NULL DEFAULT '0',\n\t\t\t\t  `searchable` tinyint(1) NOT NULL DEFAULT '0',\n\t\t\t\t  PRIMARY KEY (`contentId`),\n\t\t\t\t  UNIQUE KEY `callangfield` (`calendarId`,`lang`,`field`, `index`),\n\t\t\t\t  KEY `lang` (`lang`,`field`),\n\t\t\t\t  FULLTEXT KEY `value` (`value`)\n\t\t\t\t) ENGINE=MyISAM  DEFAULT CHARSET=utf8;";
        $sqla[] = "CREATE TABLE IF NOT EXISTS `calendareventsnew` (\n\t\t\t\t  `eventId` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t  `calendarId` int(11) NOT NULL,\n\t\t\t\t  `starttime` TIMESTAMP NULL DEFAULT NULL,\n\t\t\t\t  `endtime` TIMESTAMP NULL DEFAULT NULL,\n\t\t\t\t  `deleted` tinyint(1) NOT NULL,\n\t\t\t\t  PRIMARY KEY (`eventId`),\n \t\t\t\t  `allday` TINYINT( 1 ) NOT NULL DEFAULT  '0',\n\t\t\t\t  UNIQUE KEY `calendarId` (`calendarId`,`starttime`,`endtime`),\n\t\t\t\t  KEY `calendarId2` (`calendarId`),\n\t\t\t\t  KEY `starttime` (`starttime`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
        $this->_performQueries($sqla);
        $tblcheck = "show tables like 'calendareventsnew'";
        if ($this->_conn->getField($tblcheck)) {
            $colcheck = "SHOW COLUMNS FROM `calendareventsnew` WHERE `field`='allday'";
            $hasField = $this->_conn->getField($colcheck);
            if ($hasField == null) {
                $sqla[] = "ALTER TABLE  `calendareventsnew` ADD  `allday` TINYINT( 1 ) NOT NULL DEFAULT  '0'";
                $sqla[] = "ALTER TABLE  `calendareventsnew` CHANGE  `starttime`  `starttime` TIMESTAMP NULL DEFAULT NULL ,CHANGE  `endtime`  `endtime` TIMESTAMP NULL DEFAULT NULL";
            }
            $colcheck = "SHOW COLUMNS FROM `calendareventsnew` WHERE `field`='noend'";
            $hasField = $this->_conn->getField($colcheck);
            if ($hasField == null) {
                $sqla[] = "ALTER TABLE  `calendareventsnew` ADD  `noend` TINYINT( 1 ) NOT NULL DEFAULT  '0'";
            }
        }
        $tblcheck = "show tables like 'calendardates'";
        if ($this->_conn->getField($tblcheck)) {
            $colcheck = "SHOW COLUMNS FROM `calendardates` WHERE `field`='noend'";
            $hasField = $this->_conn->getField($colcheck);
            if ($hasField == null) {
                $sqla[] = "ALTER TABLE  `calendardates` ADD  `noend` TINYINT( 1 ) NOT NULL DEFAULT  '0'";
            }
        }
        $colcheck = "SHOW COLUMNS FROM `calendarnew` WHERE `field`='enabled'";
        $hasField = $this->_conn->getField($colcheck);
        if ($hasField == null) {
            $sql = "ALTER TABLE  `calendarnew` ADD  `enabled` TINYINT( 1 ) NOT NULL DEFAULT  '1' AFTER  `until` , ADD INDEX (  `enabled` )";
            $this->_conn->updateRow($sql);
        }
        $colcheck = "SHOW COLUMNS FROM `calendarnew` WHERE `field`='locationId'";
        $hasField = $this->_conn->getField($colcheck);
        if ($hasField == null) {
            $sqla[] = "ALTER TABLE  `calendarnew` ADD  `locationId` INT( 11 ) NULL DEFAULT NULL AFTER  `calendarId`, ADD INDEX (  `locationId` )";
        }
        $colcheck = "SHOW COLUMNS FROM `gm_markers` WHERE `field`='enabled'";
        $hasField = $this->_conn->getField($colcheck);
        if ($hasField == null) {
            $sql = "ALTER TABLE  `gm_markers` ADD  `enabled` TINYINT( 1 ) NOT NULL DEFAULT  '1' AFTER  `deleted` , ADD INDEX (  `enabled` )";
            $this->_conn->updateRow($sql);
            $sql = "ALTER TABLE  `gm_polys` ADD  `enabled` TINYINT( 1 ) NOT NULL DEFAULT  '1' AFTER  `deleted` , ADD INDEX (  `enabled` )";
            $this->_conn->updateRow($sql);
        }
        $colcheck = "SHOW COLUMNS FROM `gm_markers` WHERE `field`='street'";
        $hasField = $this->_conn->getField($colcheck);
        if ($hasField == null) {
            $sql = "ALTER TABLE  `gm_markers` ADD  `street` VARCHAR( 255 ) NULL DEFAULT NULL ,\n\t\t\t\t\t\tADD  `number` VARCHAR( 255 ) NULL DEFAULT NULL ,\n\t\t\t\t\t\tADD  `zip` VARCHAR( 255 ) NULL DEFAULT NULL ,\n\t\t\t\t\t\tADD  `city` VARCHAR( 255 ) NULL DEFAULT NULL ,\n\t\t\t\t\t\tADD  `country` INT( 11 ) NULL DEFAULT NULL";
            $this->_conn->updateRow($sql);
        }
        $colcheck = "SHOW COLUMNS FROM `gm_polys` WHERE `field`='search'";
        $hasField = $this->_conn->getField($colcheck);
        if ($hasField == null) {
            $sql = "ALTER TABLE  `gm_polys` ADD  `search` LONGTEXT NULL , ADD FULLTEXT (`search`)";
            $this->_conn->updateRow($sql);
        }
        $colcheck = "SHOW COLUMNS FROM `gm_markers` WHERE `field`='search'";
        $hasField = $this->_conn->getField($colcheck);
        if ($hasField == null) {
            $sqla[] = "ALTER TABLE  `gm_polys` CHANGE  `pageId`  `pageId` INT( 11 ) NULL DEFAULT NULL ,\nCHANGE  `label`  `label` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
            $sql = "ALTER TABLE  `gm_markers` ADD  `search` LONGTEXT NULL , ADD FULLTEXT (`search`)";
            $this->_conn->updateRow($sql);
            $maps = new Maps();
            $lay = new Layers();
            $layers = $lay->getLayers();
            $markers = $this->_conn->getRows("SELECT markerId, pageId FROM gm_markers");
            foreach ($markers as $marker) {
                if ($marker->pageId) {
                    $sql = "SELECT `value` FROM content WHERE pageId = {$marker->pageId}";
                    $rows = $this->_conn->getFields($sql);
                    $search = implode("\r\n", $rows);
                    $search = Connection::getInstance()->escape_string($search);
                    $sql = "UPDATE gm_markers SET `search`='{$search}' WHERE markerId={$marker->markerId}";
                    $this->_conn->updateRow($sql);
                }
            }
        }
        $colcheck = "SHOW COLUMNS FROM `page` WHERE `field`='creationdate'";
        if ($this->_conn->getField($colcheck) == null) {
            $sqla[] = "ALTER TABLE  `page` ADD  `creationdate` TIMESTAMP NULL DEFAULT NULL ,\n\t\t\t\t\t\tADD  `createdby` INT( 11 ) NULL DEFAULT NULL ,\n\t\t\t\t\t\tADD  `modifiedby` INT( 11 ) NULL DEFAULT NULL";
        }
        $colcheck = "SHOW COLUMNS FROM `backup` WHERE `field`='content'";
        $c = $this->_conn->getRow($colcheck);
        if ($c->Type == 'text') {
            $sqla[] = "ALTER TABLE  `backup` CHANGE  `content`  `content` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL";
        }
        $tblcheck = "SHOW TABLES LIKE 'calendarindex'";
        if (!$this->_conn->getField($tblcheck)) {
            $this->_conn->insertRow("CREATE TABLE IF NOT EXISTS `calendarindex` (\n\t\t\t\t\t\t\t\t\t\t  `calendarId` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t\t\t\t\t  `search` text,\n\t\t\t\t\t\t\t\t\t\t  PRIMARY KEY (`calendarId`),\n\t\t\t\t\t\t\t\t\t\t  FULLTEXT KEY `search` (`search`)\n\t\t\t\t\t\t\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
            $cal = new Calendar();
            $ids = $this->_conn->getFields("SELECT calendarId FROM calendarnew");
            $sqlc = "INSERT INTO calendarindex (calendarId, search) VALUES";
            $sqlca = array();
            foreach ($ids as $id) {
                $ev = $cal->getEvent($id);
                $search = BrightUtils::createSearchString($ev);
                if ((int) $ev->locationId > 0) {
                    $search .= $this->_conn->getField("SELECT search FROM gm_markers WHERE pageId={$ev->locationId}");
                }
                $search = Connection::getInstance()->escape_string($search);
                $sqlca[] = "({$ev->calendarId}, '{$search}')";
            }
            if (count($sqlca) > 0) {
                $sqlc .= implode(",\r\n", $sqlca);
                $sqla[] = $sqlc;
            }
            $sqla[] = "ALTER TABLE  `calendareventsnew` ADD INDEX (  `starttime` )";
        }
        $tblcheck = "SHOW TABLES LIKE 'pageindex'";
        if (!$this->_conn->getField($tblcheck)) {
            $this->_conn->insertRow("CREATE TABLE IF NOT EXISTS `pageindex` (\n\t\t\t\t\t\t\t\t\t\t  `pageId` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t\t\t\t\t  `search` text,\n\t\t\t\t\t\t\t\t\t\t  PRIMARY KEY (`pageId`),\n\t\t\t\t\t\t\t\t\t\t  FULLTEXT KEY `search` (`search`)\n\t\t\t\t\t\t\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
            $el = new Element();
            $page = new Page();
            $ids = $el->getElements(false);
            $sqle = "INSERT INTO pageindex (pageId, search) VALUES";
            $sqlea = array();
            foreach ($ids as $elm) {
                $ev = $page->getPageById($elm->pageId);
                $search = BrightUtils::createSearchString($ev);
                $search = Connection::getInstance()->escape_string($search);
                $sqlea[] = "({$ev->pageId}, '{$search}')";
            }
            if (count($sqlea) > 0) {
                $sqle .= implode(",\r\n", $sqlea);
                $sqla[] = $sqle;
            }
        }
        if ($prevbuild < 7098) {
            // Update user settings, this fixes a bug with AmfPHP 2.x,
            // which does not correctly deserialize flex.messaging.io.objectproxy to php stdClass objects
            $rows = Connection::getInstance()->getRows("SELECT id, settings FROM `administrators`");
            foreach ($rows as $row) {
                $settings = json_decode($row->settings);
                if ($settings) {
                    if (isset($settings->_externalizedData)) {
                        $settings = $settings->_externalizedData;
                    }
                    // Clean up settings object
                    foreach ($settings as $key => $value) {
                        if (strpos($key, 'pageDivider_') === 0) {
                            unset($settings->{$key});
                        }
                    }
                    $settings = Connection::getInstance()->escape_string(json_encode($settings));
                    $sql = "UPDATE administrators SET settings='{$settings}' WHERE id={$row->id}";
                    Connection::getInstance()->updateRow($sql);
                }
            }
        }
        // Update to latest version
        $sqla[] = 'TRUNCATE `update`';
        $sqla[] = 'INSERT INTO `update` (`build`) VALUES (' . $build . ')';
        $this->_performQueries($sqla);
        $sql = "SHOW TABLES LIKE 'calendar'";
        $rows = $this->_conn->getRow($sql);
        if ($rows) {
            $sql = 'SELECT * FROM calendar';
            $rows = $this->_conn->getRows($sql);
            if ($rows) {
                $page = new Page();
                $cal = new Calendar();
                $ids = array();
                foreach ($rows as $row) {
                    $ids[] = $row->pageId;
                    $ev = $page->getPageById($row->pageId);
                    $cdo = new OCalendarDateObject();
                    $cdo->starttime = $ev->publicationdate;
                    $cdo->endtime = $ev->expirationdate;
                    $cdo->allday = date('d-m-Y', $cdo->starttime) != date('d-m-Y', $cdo->endtime) || $row->allday;
                    if (date('H', $cdo->starttime) == 22) {
                        $cdo->starttime += 7200;
                        $cdo->endtime += 7200;
                        $cdo->allday = 1;
                    }
                    if (date('H', $cdo->starttime) == 23) {
                        $cdo->starttime += 3600;
                        $cdo->endtime += 3600;
                        $cdo->allday = 1;
                    }
                    if (date('H', $cdo->endtime) == 22) {
                        $cdo->starttime += 7200;
                        $cdo->endtime += 7200;
                        $cdo->allday = 1;
                    }
                    if (date('H', $cdo->endtime) == 23) {
                        $cdo->starttime += 3600;
                        $cdo->endtime += 3600;
                        $cdo->allday = 1;
                    }
                    $cestring = serialize($ev);
                    $cestring = str_replace('O:5:"OPage"', 'O:14:"OCalendarEvent"', $cestring);
                    $cestring = str_replace('s:13:"_explicitType";s:5:"OPage"', 's:13:"_explicitType";s:14:"OCalendarEvent"', $cestring);
                    $ev = unserialize($cestring);
                    $ev->dates = array($cdo);
                    $cal->setEvent($ev);
                }
                $page->deletePages($ids);
                $sql = 'DELETE FROM calendar';
                $rows = $this->_conn->deleteRow($sql);
                $sql = 'DELETE FROM calendarevents';
                $rows = $this->_conn->deleteRow($sql);
            }
        }
        $this->updatePermissions($permissions);
    }