Пример #1
0
 public function content_samples_parse($ws = null)
 {
     global $website;
     if (empty($ws) && !empty($website)) {
         $ws = $website;
     } else {
         $ws = new website();
     }
     $content_samples = array();
     $grid_samples = array('6,6', '4,4,4', '3,3,3,3', '9,3', '3,9', '8,4', '4,8', '7,5', '5,7', '6,3,3', '3,6,3', '3,3,6');
     $text = "Vis prodesset adolescens adipiscing te, usu mazim perfecto recteque at, assum putant erroribus mea in.\n";
     $text .= "Vel facete imperdiet id, cum an libris luptatum perfecto, vel fabellas inciderint ut.";
     if (!empty($this->content_samples)) {
         foreach ($this->content_samples as $cs) {
             switch ($cs->file) {
                 case 'foundation_grid':
                 case 'bootstrap_grid':
                 case 'grid':
                     $stylesheets = $ws->content_stylesheets('array', "content", false, $this);
                     $html_pre = '<html><head>';
                     if (!empty($stylesheets) && is_array($stylesheets)) {
                         foreach ($stylesheets as $ss) {
                             $html_pre .= '<link rel="stylesheet" type="text/css" href="' . $ss . '" />';
                         }
                     }
                     $html_pre .= '</head><body><div id="navigate-theme-content-sample" style=" width: 99%; ">';
                     foreach ($grid_samples as $gs) {
                         $cols = explode(',', $gs);
                         $name = "Grid &nbsp; [ ";
                         $html = $html_pre . '<div class="row">';
                         foreach ($cols as $col) {
                             $name .= $col . str_pad("", $col, "-");
                             $scol = $col * 2;
                             // set the small column to the closest step: 6 or 12
                             if ($scol >= 8) {
                                 $scol = 12;
                             }
                             if ($scol <= 7) {
                                 $scol = 6;
                             }
                             $html .= '<div class="col-md-' . $col . ' medium-' . $col . ' col-xs-' . $scol . ' small-' . $scol . ' columns">' . $text . '</div>';
                         }
                         $name .= " ]";
                         $html .= '</div>';
                         // close row
                         $html .= '<div><p>+</p></div>';
                         // add extra space under the row
                         $html .= '</div>';
                         // close copy enabled content
                         $html .= '</body></html>';
                         $content_samples[] = json_decode(json_encode(array('title' => $name, 'content' => $html)));
                     }
                     break;
                 case 'skeleton_grid':
                     $stylesheets = explode(",", $ws->content_stylesheets());
                     $translate = array(1 => "one", 2 => "two", 3 => "three", 4 => "four", 5 => "fix", 6 => "six", 7 => "seven", 8 => "eight", 9 => "nine", 10 => "ten", 11 => "eleven", 12 => "twelve");
                     $html_pre = '<html><head>';
                     foreach ($stylesheets as $ss) {
                         $html_pre .= '<link rel="stylesheet" type="text/css" href="' . $ss . '" />';
                     }
                     $html_pre .= '</head><body><div id="navigate-theme-content-sample" style=" width: 99%; ">';
                     foreach ($grid_samples as $gs) {
                         $cols = explode(',', $gs);
                         $name = "Grid &nbsp; [ ";
                         $html = $html_pre . '<div class="row">';
                         foreach ($cols as $col) {
                             $name .= $col . str_pad("", $col, "-");
                             $scol = $col * 2;
                             // set the small column to the closest step: 6 or 12
                             if ($scol >= 8) {
                                 $scol = 12;
                             }
                             if ($scol <= 7) {
                                 $scol = 6;
                             }
                             $html .= '<div class="' . $translate[$col] . ' columns">' . $text . '</div>';
                         }
                         $name .= " ]";
                         $html .= '</div>';
                         // close row
                         $html .= '<div><p>+</p></div>';
                         // add extra space under the row
                         $html .= '</div>';
                         // close copy enabled content
                         $html .= '</body></html>';
                         $content_samples[] = json_decode(json_encode(array('title' => $name, 'content' => $html)));
                     }
                     break;
                 default:
                     $content_samples[] = $cs;
             }
         }
         $this->content_samples = $content_samples;
     }
 }
Пример #2
0
function process()
{
    global $DB;
    global $website;
    global $events;
    global $theme;
    set_time_limit(0);
    setlocale(LC_ALL, $_SESSION['navigate_install_locale']);
    $lang = navigate_install_load_language();
    switch ($_REQUEST['process']) {
        case 'verify_zip':
            sleep(1);
            if (!file_exists('package.zip')) {
                die(json_encode($lang['missing_package']));
            } else {
                $zip = new ZipArchive();
                if ($zip->open('package.zip') !== TRUE) {
                    die(json_encode($lang['invalid_package']));
                } else {
                    $zip->close();
                    die(json_encode(true));
                }
            }
            break;
        case 'extract_zip':
            $npath = getcwd() . NAVIGATE_FOLDER;
            $npath = str_replace('\\', '/', $npath);
            if (!file_exists($npath)) {
                mkdir($npath);
            }
            if (file_exists($npath)) {
                $zip = new ZipArchive();
                if ($zip->open('package.zip') === TRUE) {
                    $zip->extractTo($npath);
                    $zip->close();
                    copy($npath . '/crossdomain.xml', dirname($npath) . '/crossdomain.xml');
                    die(json_encode(true));
                } else {
                    die(json_encode($lang['extraction_failed']));
                }
            }
            die(json_encode($lang['folder_not_exists']));
            break;
        case 'chmod':
            sleep(1);
            // chmod the directories recursively
            $npath = getcwd() . NAVIGATE_FOLDER;
            if (!navigate_install_chmodr($npath, 0755)) {
                die(json_encode($lang['chmod_failed']));
            } else {
                die(json_encode(true));
            }
            break;
        case 'verify_database':
            if ($_REQUEST['PDO_DRIVER'] == 'mysql' || $_REQUEST['PDO_DRIVER'] == 'mysql-socket') {
                try {
                    $dsn = "mysql:host=" . $_REQUEST['PDO_HOSTNAME'] . ";port=" . $_REQUEST['PDO_PORT'] . ';charset=utf8';
                    if ($_REQUEST['PDO_DRIVER'] == "mysql-socket") {
                        $dsn = "mysql:unix_socket=" . $_REQUEST['PDO_SOCKET'] . ";charset=utf8";
                    }
                    $db_test = @new PDO($dsn, $_REQUEST['PDO_USERNAME'], $_REQUEST['PDO_PASSWORD']);
                    if (!$db_test) {
                        echo json_encode(array('error' => $lang['database_connect_error']));
                    } else {
                        $create_database_privilege = false;
                        $drop_database_privilege = false;
                        $stm = $db_test->query('SHOW DATABASES;');
                        $rs = $stm->fetchAll(PDO::FETCH_COLUMN, 'Database');
                        $rs = array_diff($rs, array('mysql', 'information_schema'));
                        $stm = $db_test->query('SHOW PRIVILEGES;');
                        $privileges = $stm->fetchAll(PDO::FETCH_ASSOC);
                        for ($p = 0; $p < count($privileges); $p++) {
                            if ($privileges[$p]['Privilege'] == 'Create') {
                                if (strpos($privileges[$p]['Context'], 'Databases') !== false) {
                                    $create_database_privilege = true;
                                }
                            }
                            if ($privileges[$p]['Privilege'] == 'Drop') {
                                if (strpos($privileges[$p]['Context'], 'Databases') !== false) {
                                    $drop_database_privilege = true;
                                }
                            }
                        }
                        if ($create_database_privilege && $drop_database_privilege) {
                            // check if we are really allowed to create databases
                            $dbname = 'navigate_test_' . time();
                            $create_result = $db_test->exec('CREATE DATABASE ' . $dbname);
                            if ($create_result) {
                                $db_test->exec('DROP DATABASE ' . $dbname);
                            }
                            if (!$create_result) {
                                $create_database_privilege = false;
                            }
                        }
                        $db_test = NULL;
                        echo json_encode(array('databases' => array_values($rs), 'create_database_privilege' => $create_database_privilege));
                    }
                } catch (Exception $e) {
                    echo json_encode(array('error' => $e->getMessage()));
                }
            } else {
                echo json_encode(array('error' => $lang['database_driver_error']));
            }
            exit;
            break;
        case 'database_create':
            $DB = new database();
            if (!$DB->connect()) {
                // try to create the database automatically
                if (PDO_DRIVER == 'mysql') {
                    if (PDO_DATABASE != '') {
                        if (PDO_HOSTNAME != "") {
                            $dsn = "mysql:host=" . PDO_HOSTNAME . ";port=" . PDO_PORT . ";charset=utf8";
                        } else {
                            $dsn = "mysql:unix_socket=" . PDO_SOCKET . ";charset=utf8";
                        }
                        $db_test = new PDO($dsn, PDO_USERNAME, PDO_PASSWORD);
                        $db_test->exec('CREATE DATABASE IF NOT EXISTS `' . PDO_DATABASE . '` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
                        $db_test = NULL;
                    }
                    if (!$DB->connect()) {
                        echo json_encode(array('error' => $DB->get_last_error()));
                    } else {
                        echo json_encode(array('ok' => $lang['database_created']));
                    }
                }
            } else {
                echo json_encode(array('ok' => $lang['database_exists']));
            }
            exit;
            break;
        case 'database_import':
            $DB = new database();
            if (!$DB->connect()) {
                die(json_encode(array('error' => $DB->get_last_error())));
            }
            try {
                $sql = file_get_contents('navigate.sql');
                $sql = str_replace("{#!NAVIGATE_FOLDER!#}", NAVIGATE_PARENT . NAVIGATE_FOLDER, $sql);
                $sql = explode("\n\n", $sql);
                // can't do it in one step => SQLSTATE[HY000]: General error: 2014
                foreach ($sql as $sqlline) {
                    $sqlline = trim($sqlline);
                    if (empty($sqlline)) {
                        continue;
                    }
                    if (!@$DB->execute($sqlline)) {
                        $error = $DB->get_last_error();
                    }
                    if (!empty($error)) {
                        break;
                    }
                }
            } catch (Exception $e) {
                $error = $e->getMessage();
            }
            if (!empty($error) && false) {
                echo json_encode(array('error' => $error));
            } else {
                echo json_encode(array('ok' => $lang['done']));
            }
            exit;
            break;
        case 'create_account':
            // create admin
            try {
                $DB = new database();
                if (!$DB->connect()) {
                    die(json_encode(array('error' => $DB->get_last_error())));
                }
                $user = new user();
                $user->id = 0;
                $user->username = $_SESSION['NAVIGATE-SETUP']['ADMIN_USERNAME'];
                $user->set_password($_SESSION['NAVIGATE-SETUP']['ADMIN_PASSWORD']);
                $user->email = $_SESSION['NAVIGATE-SETUP']['ADMIN_EMAIL'];
                $user->profile = 1;
                $user->skin = 'cupertino';
                $user->language = $_SESSION['navigate_install_lang'];
                $user->blocked = 0;
                $user->timezone = 'UTC';
                $user->date_format = 'Y-m-d H:i';
                $user->decimal_separator = ',';
                $user->thousands_separator = '';
                $user->attempts = 0;
                $user->cookie_hash = '';
                $user->activation_key = '';
                $ok = $user->insert();
                if (!$ok) {
                    throw new Exception($lang['error']);
                }
                // create default website details
                $website = new website();
                $website->create_default();
                $_SESSION['NAVIGATE-SETUP']['WEBSITE_DEFAULT'] = $website->id;
                echo json_encode(array('ok' => $lang['done']));
            } catch (Exception $e) {
                echo json_encode(array('error' => $e->getMessage()));
            }
            exit;
            break;
        case 'install_default_theme':
            try {
                $DB = new database();
                if (!$DB->connect()) {
                    die(json_encode(array('error' => $DB->get_last_error())));
                }
                if (@$_SESSION['NAVIGATE-SETUP']['DEFAULT_THEME'] == 'theme_kit') {
                    $website = new website();
                    $website->load($_SESSION['NAVIGATE-SETUP']['WEBSITE_DEFAULT']);
                    $website->theme = 'theme_kit';
                    $website->languages = array('en' => array('language' => 'en', 'variant' => '', 'code' => 'en', 'system_locale' => 'en_US.utf8'), 'es' => array('language' => 'es', 'variant' => '', 'code' => 'es', 'system_locale' => 'es_ES.utf8'));
                    $website->languages_published = array('en', 'es');
                    $website->save();
                    // default objects (first user, no events bound...)
                    $user = new user();
                    $user->load(1);
                    $events = new events();
                    $zip = new ZipArchive();
                    $zip_open_status = $zip->open(NAVIGATE_PATH . '/themes/theme_kit.zip');
                    if ($zip_open_status === TRUE) {
                        $zip->extractTo(NAVIGATE_PATH . '/themes/theme_kit');
                        $zip->close();
                        $theme = new theme();
                        $theme->load('theme_kit');
                        $theme->import_sample($website);
                    }
                    echo json_encode(array('ok' => $lang['done']));
                } else {
                    // user does not want to install the default theme
                    echo json_encode(array('ok' => $lang['not_selected']));
                }
            } catch (Exception $e) {
                echo json_encode(array('error' => $e->getMessage()));
            }
            exit;
            break;
        case 'apache_htaccess':
            try {
                $nvweb = dirname($_SERVER['REQUEST_URI']) . NAVIGATE_FOLDER . '/web/nvweb.php';
                $nvweb = str_replace('//', '/', $nvweb);
                $data = array();
                $data[] = 'Options +FollowSymLinks';
                $data[] = 'Options -Indexes';
                $data[] = 'RewriteEngine On';
                $data[] = 'RewriteBase /';
                $data[] = 'RewriteCond %{REQUEST_FILENAME} !-f';
                $data[] = 'RewriteCond %{REQUEST_FILENAME} !-d';
                $data[] = 'RewriteRule ^(.+) ' . $nvweb . '?route=$1 [QSA]';
                $data[] = 'RewriteRule ^$ ' . $nvweb . '?route=nv.empty [L,QSA]';
                $ok = @file_put_contents(dirname(NAVIGATE_PATH) . '/.htaccess', implode("\n", $data));
                if (!$ok) {
                    throw new Exception($lang['unexpected_error']);
                }
                echo json_encode('true');
            } catch (Exception $e) {
                echo json_encode(array('error' => $e->getMessage()));
            }
            exit;
            break;
    }
}
Пример #3
0
            if (file_exists('plugins/' . $folderName . '/config.php')) {
                include_once 'plugins/' . $folderName . '/config.php';
            }
        }
    }
}
$account = new account();
$account->getRemember();
//Remember thingy.
//This is to prevent the error "Undefined index: p"
if (!isset($_GET['p'])) {
    $_GET['p'] = 'home';
}
###VOTING SYSTEM####
if (isset($_SESSION['votingUrlID']) && $_SESSION['votingUrlID'] != 0 && $GLOBALS['vote']['type'] == 'confirm') {
    if (website::checkIfVoted((int) $_SESSION['votingUrlID'], $GLOBALS['connection']['webdb']) == TRUE) {
        die("?p=vote");
    }
    $acct_id = account::getAccountID($_SESSION['cw_user']);
    $next_vote = time() + $GLOBALS['vote']['timer'];
    connect::selectDB('webdb');
    mysql_query("INSERT INTO votelog VALUES('','" . (int) $_SESSION['votingUrlID'] . "',\n\t'" . $acct_id . "','" . time() . "','" . $next_vote . "','" . $_SERVER['REMOTE_ADDR'] . "')");
    $getSiteData = mysql_query("SELECT points,url FROM votingsites WHERE id='" . (int) $_SESSION['votingUrlID'] . "'");
    $row = mysql_fetch_assoc($getSiteData);
    if (mysql_num_rows($getSiteData) == 0) {
        header('Location: index.php');
        unset($_SESSION['votingUrlID']);
        exit;
    }
    //Update the points table.
    $add = $row['points'] * $GLOBALS['vote']['multiplier'];
Пример #4
0
    public function navigate_title()
    {
        global $website;
        global $DB;
        $DB->query('SELECT * FROM nv_websites WHERE 1 = 1 ORDER BY name ASC');
        $websites = $DB->result();
        $extruder = '';
        $main_title = '';
        $main_url = '';
        foreach ($websites as $web) {
            $style = ' display: none; ';
            $ws = new website();
            $ws->load_from_resultset(array($web));
            if ($ws->id == $website->id) {
                $style = ' display: block; ';
            }
            $url = $ws->absolute_path(true);
            if ($ws->id == $website->id) {
                $main_title = $ws->name;
                $main_url = $url;
                $main_config_url = '?fid=websites&act=2&id=' . $ws->id;
            } else {
                $extruder .= '<div class="voice {}" style=" display: none; ">
								<a href="' . $url . '" target="_blank"><img align="absmiddle" src="' . NAVIGATE_URL . '/img/icons/silk/house_link.png" width="16px" height="16px" /></a>
								<a class="label" href="?act=0&wid=' . $ws->id . '">' . $ws->name . '</a>								
							  </div>';
            }
        }
        $extruder .= '<div style="clear: both;"></div>';
        if (!empty($main_title)) {
            // mb extruder
            $this->add_content('
			  <div id="navigate-website-selector-top" class="{title:\'' . str_replace("'", "\\'", htmlspecialchars($main_title)) . '\'}">
				' . $extruder . '
			  </div>
			  <a id="navigate-website-main-link" href="' . $main_url . '" target="_blank" style=" margin-right: 5px; display: none; "><img align="absmiddle" src="' . NAVIGATE_URL . '/img/icons/silk/house_link.png" width="16px" height="16px" /></a>
			');
            $this->add_script('
				$("#navigate-website-selector-top").buildMbExtruder(
				{
					positionFixed:true,
					width:400,
					sensibility:800,
					position:"top", // left, right, bottom
					extruderOpacity: 1, // was 0.9 for better integration (FF 8.0 problems)
					flapDim:100,
					textOrientation:"bt", // or "tb" (top-bottom or bottom-top)
					onExtOpen:function() {},
					onExtContentLoad:function(){},
					onExtClose:function(){},
					hidePanelsOnClose:true,
					autoCloseTime:3000, // 0=never
					slideTimer:300
				});
			');
            $this->add_script('
			    $("#navigate-website-selector-top").find(".flapLabel").css("padding-left", "21px");
			    $("#navigate-website-selector-top div.flap").addClass("ui-corner-bottom");
			    $("#navigate-website-selector-top div.flap").css("opacity", 1);
			    $("#navigate-website-selector-top").on("click", ".silk-sprite", function(e)
			    {
			        setTimeout(
			            function()
			            {
			                $("#navigate-website-selector-top").closeMbExtruder();
		                }, 
		                1000
	                );
			    });
			');
        }
    }
Пример #5
0
           |   __|     | | |  |  | -_| | |_ -|
           |_____|_|_|_|___|____/|___|\_/|___|
    Copyright (C) 2013 EmuDevs <http://www.emudevs.com/>
*/
?>
<div class='box_two_title'>Character Reviver</div>
Choose the character you wish to revive. The character will be revived with 1 health.<hr/>
<?php 
$service = "revive";
if ($GLOBALS['service'][$service]['price'] == 0) {
    echo '<span class="attention">Revive is free of charge.</span>';
} else {
    ?>
<span class="attention">Revive costs 
<?php 
    echo $GLOBALS['service'][$service]['price'] . ' ' . website::convertCurrency($GLOBALS['service'][$service]['currency']);
    ?>
</span>
<?php 
    if ($GLOBALS['service'][$service]['currency'] == "vp") {
        echo "<span class='currency'>Vote Points: " . account::loadVP($_SESSION['cw_user']) . "</span>";
    } elseif ($GLOBALS['service'][$service]['currency'] == "dp") {
        echo "<span class='currency'>" . $GLOBALS['donation']['coins_name'] . ": " . account::loadDP($_SESSION['cw_user']) . "</span>";
    }
}
account::isNotLoggedIn();
connect::selectDB('webdb');
$num = 0;
$result = mysql_query('SELECT char_db,name FROM realms ORDER BY id ASC');
while ($row = mysql_fetch_assoc($result)) {
    $acct_id = account::getAccountID($_SESSION['cw_user']);
Пример #6
0
<?php

/*
            _____           ____
           |   __|_____ _ _|    \ ___ _ _ ___
           |   __|     | | |  |  | -_| | |_ -|
           |_____|_|_|_|___|____/|___|\_/|___|
    Copyright (C) 2013 EmuDevs <http://www.emudevs.com/>
*/
account::isNotLoggedIn();
?>

<div class='box_two_title'>Vote</div>

<h4 class="yellow_text">Vote Points: <?php 
echo account::loadVP($_SESSION['cw_user']);
?>
</h4>

<?php 
website::loadVotingLinks();
Пример #7
0
function run()
{
    global $user;
    global $layout;
    global $DB;
    global $website;
    $out = '';
    $item = new website();
    switch ($_REQUEST['act']) {
        case 'json':
        case 1:
            // json data retrieval & operations
            switch ($_REQUEST['oper']) {
                case 'search_links':
                    // active website only!
                    $text = $_REQUEST['text'];
                    $lang = $_REQUEST['lang'];
                    if (empty($lang)) {
                        $lang = array_keys($website->languages)[0];
                    }
                    $DB->query('
						SELECT p.path, d.text
						  FROM nv_paths p, nv_webdictionary d
						 WHERE p.website = ' . protect($website->id) . ' AND
						       p.lang = ' . protect($lang) . ' AND
						       d.website = p.website AND
						       d.node_type = p.type AND
						       d.node_id = p.object_id AND
						       d.lang = p.lang AND
						       d.subtype = "title" AND 
						       (    
						            p.path LIKE ' . protect('%' . $text . '%') . '  OR  
									d.text LIKE ' . protect('%' . $text . '%') . ' 
						       )
						 ORDER BY d.id DESC
						 LIMIT 10
					');
                    $result = $DB->result();
                    echo json_encode($result);
                    core_terminate();
                    break;
                case 'del':
                    // remove rows
                    if ($user->permission('websites.delete') == 'true') {
                        $ids = $_REQUEST['ids'];
                        foreach ($ids as $id) {
                            $item->load($id);
                            $item->delete();
                        }
                        echo json_encode(true);
                    }
                    core_terminate();
                    break;
                default:
                    // list or search
                    $page = intval($_REQUEST['page']);
                    $max = intval($_REQUEST['rows']);
                    $offset = ($page - 1) * $max;
                    $orderby = $_REQUEST['sidx'] . ' ' . $_REQUEST['sord'];
                    $where = " 1=1 ";
                    if ($_REQUEST['_search'] == 'true' || isset($_REQUEST['quicksearch'])) {
                        if (isset($_REQUEST['quicksearch'])) {
                            $where .= $item->quicksearch($_REQUEST['quicksearch']);
                        } else {
                            if (isset($_REQUEST['filters'])) {
                                $where .= navitable::jqgridsearch($_REQUEST['filters']);
                            } else {
                                // single search
                                $where .= ' AND ' . navitable::jqgridcompare($_REQUEST['searchField'], $_REQUEST['searchOper'], $_REQUEST['searchString']);
                            }
                        }
                    }
                    $DB->queryLimit('id,name,subdomain,domain,folder,homepage,permission,favicon', 'nv_websites', $where, $orderby, $offset, $max);
                    $dataset = $DB->result();
                    $total = $DB->foundRows();
                    //echo $DB->get_last_error();
                    $out = array();
                    $permissions = array(0 => '<img src="img/icons/silk/world.png" align="absmiddle" /> ' . t(69, 'Published'), 1 => '<img src="img/icons/silk/world_dawn.png" align="absmiddle" /> ' . t(70, 'Private'), 2 => '<img src="img/icons/silk/world_night.png" align="absmiddle" /> ' . t(81, 'Hidden'));
                    for ($i = 0; $i < count($dataset); $i++) {
                        $homepage = 'http://';
                        $homepage_relative_url = $dataset[$i]['homepage'];
                        if (is_numeric($homepage_relative_url)) {
                            $homepage_relative_url = path::loadElementPaths('structure', $homepage_relative_url);
                            $homepage_relative_url = array_shift($homepage_relative_url);
                        }
                        if (!empty($dataset[$i]['subdomain'])) {
                            $homepage .= $dataset[$i]['subdomain'] . '.';
                        }
                        $homepage .= $dataset[$i]['domain'] . $dataset[$i]['folder'] . $homepage_relative_url;
                        $favicon = '';
                        if (!empty($dataset[$i]['favicon'])) {
                            $favicon = '<img src="' . NVWEB_OBJECT . '?type=img&id=' . $dataset[$i]['favicon'] . '&width=16&height=16" align="absmiddle" height="16" />';
                        }
                        $out[$i] = array(0 => $dataset[$i]['id'], 1 => $favicon, 2 => $dataset[$i]['name'], 3 => '<a href="' . $homepage . '" target="_blank"><img align="absmiddle" src="' . NAVIGATE_URL . '/img/icons/silk/house_link.png"></a> ' . $homepage, 4 => $permissions[$dataset[$i]['permission']]);
                    }
                    navitable::jqgridJson($out, $page, $offset, $max, $total);
                    break;
            }
            session_write_close();
            exit;
            break;
        case 'edit':
        case 2:
            // edit/new form
            if (!empty($_REQUEST['id'])) {
                $item->load(intval($_REQUEST['id']));
            }
            if (isset($_REQUEST['form-sent']) && $user->permission('websites.edit') == 'true') {
                $item->load_from_post();
                try {
                    $item->save();
                    $id = $item->id;
                    unset($item);
                    $item = new website();
                    $item->load($id);
                    $layout->navigate_notification(t(53, "Data saved successfully."), false, false, 'fa fa-check');
                } catch (Exception $e) {
                    $layout->navigate_notification($e->getMessage(), true, true);
                }
                if (!empty($item->id)) {
                    users_log::action($_REQUEST['fid'], $item->id, 'save', $item->name, json_encode($_REQUEST));
                }
            } else {
                if (!empty($item->id)) {
                    users_log::action($_REQUEST['fid'], $item->id, 'load', $item->name);
                }
            }
            $out = websites_form($item);
            break;
        case 'remove':
        case 4:
            if (!empty($_REQUEST['id']) && $user->permission('websites.delete') == 'true') {
                $item->load(intval($_REQUEST['id']));
                if ($item->delete() > 0) {
                    $layout->navigate_notification(t(55, 'Item removed successfully.'), false);
                    if (!empty($item->id)) {
                        users_log::action($_REQUEST['fid'], $item->id, 'remove', $item->name, json_encode($_REQUEST));
                    }
                    // if we don't have any websites, tell user a new one will be created
                    $test = $DB->query_single('id', 'nv_websites');
                    if (empty($test) || !$test) {
                        $layout->navigate_notification(t(520, 'No website found; a default one has been created.'), false, true);
                        $nwebsite = new website();
                        $nwebsite->create_default();
                    }
                    $out = websites_list();
                } else {
                    $layout->navigate_notification(t(56, 'Unexpected error.'), false);
                    $out = websites_form($item);
                }
            }
            break;
        case 5:
            // search an existing path
            $DB->query('SELECT path as id, path as label, path as value
						  FROM nv_paths
						 WHERE path LIKE ' . protect('%' . $_REQUEST['term'] . '%') . '
						   AND website = ' . protect($_REQUEST['wid']) . '
				      ORDER BY path ASC
					     LIMIT 30', 'array');
            echo json_encode($DB->result());
            core_terminate();
            break;
        case 'email_test':
            $website->mail_mailer = $_REQUEST['mail_mailer'];
            $website->mail_server = $_REQUEST['mail_server'];
            $website->mail_port = $_REQUEST['mail_port'];
            $website->mail_address = $_REQUEST['mail_address'];
            $website->mail_user = $_REQUEST['mail_user'];
            $website->mail_security = $_REQUEST['mail_security'] == "true" || $_REQUEST['mail_security'] == "1" ? "1" : "0";
            if (!empty($_REQUEST['mail_password'])) {
                $website->mail_password = $_REQUEST['mail_password'];
            }
            $ok = navigate_send_email(APP_NAME, APP_NAME . '<br /><br />' . NAVIGATE_URL, $_REQUEST['send_to']);
            echo json_encode($ok);
            core_terminate();
            break;
        case 'reset_statistics':
            if ($user->permission('websites.edit') == 'true') {
                $website_id = trim($_REQUEST['website']);
                $website_id = intval($website_id);
                $DB->execute('UPDATE nv_items SET views = 0 WHERE website = ' . $website_id);
                $DB->execute('UPDATE nv_paths SET views = 0 WHERE website = ' . $website_id);
                $DB->execute('UPDATE nv_structure SET views = 0 WHERE website = ' . $website_id);
                echo 'true';
                users_log::action($_REQUEST['fid'], $website_id, 'reset_statistics', "", json_encode($_REQUEST));
            }
            core_terminate();
            break;
        case 'replace_urls':
            $old = trim($_REQUEST['old']);
            $new = trim($_REQUEST['new']);
            $website_id = trim($_REQUEST['website']);
            if (!empty($old) && !empty($new)) {
                // replace occurrences in nv_webdictionary
                $ok = $DB->execute('
					UPDATE nv_webdictionary
					   SET text = replace(text, :old, :new)
					 WHERE website = :wid', array(':old' => $old, ':new' => $new, ':wid' => $website_id));
                // replace occurrences in nv_blocks (triggers & actions)
                $ok = $DB->execute('
					UPDATE nv_blocks
					   SET `trigger` = replace(`trigger`, :old, :new),
					   	   `action` = replace(`action`, :old, :new)
					 WHERE website = :wid', array(':old' => $old, ':new' => $new, ':wid' => $website_id));
                echo $ok ? 'true' : 'false';
                if ($ok) {
                    users_log::action($_REQUEST['fid'], $website_id, 'replace_urls', "", json_encode($_REQUEST));
                }
            } else {
                echo 'false';
            }
            core_terminate();
            break;
        case 'remove_content':
            $website_id = trim($_REQUEST['website']);
            $website_id = intval($website_id);
            $password = trim($_REQUEST['password']);
            $authenticated = $user->authenticate($user->username, $password);
            if ($authenticated) {
                // remove all content except Webusers and Files
                @set_time_limit(0);
                $ok = $DB->execute('
					DELETE FROM nv_blocks WHERE website = ' . $website_id . ';
					DELETE FROM nv_block_groups WHERE website = ' . $website_id . ';
					DELETE FROM nv_comments WHERE website = ' . $website_id . ';
					DELETE FROM nv_structure WHERE website = ' . $website_id . ';
					DELETE FROM nv_feeds WHERE website = ' . $website_id . ';
					DELETE FROM nv_items WHERE website = ' . $website_id . ';
					DELETE FROM nv_notes WHERE website = ' . $website_id . ';
					DELETE FROM nv_paths WHERE website = ' . $website_id . ';
					DELETE FROM nv_properties WHERE website = ' . $website_id . ';
					DELETE FROM nv_properties_items WHERE website = ' . $website_id . ';
					DELETE FROM nv_search_log WHERE website = ' . $website_id . ';
					DELETE FROM nv_webdictionary WHERE website = ' . $website_id . ';
					DELETE FROM nv_webdictionary_history WHERE website = ' . $website_id . ';
				');
                if ($ok) {
                    users_log::action($_REQUEST['fid'], $website_id, 'remove_content', "", json_encode($_REQUEST));
                }
                echo $ok ? 'true' : $DB->error();
            } else {
                echo '';
            }
            core_terminate();
            break;
        case 0:
            // list / search result
        // list / search result
        default:
            $out = websites_list();
            break;
    }
    return $out;
}
Пример #8
0
#/ /__| | | (_| |  _| ||  __/ (_| |\  /\  /  __/ |_) |
#\____/_|  \__,_|_|  \__\___|\__,_| \/  \/ \___|_.__/
#
#		-[ Created by ©Nomsoft
#		  `-[ Original core by Anthony (Aka. CraftedDev)
#
#				-CraftedWeb Generation II-
#			 __                           __ _
#		  /\ \ \___  _ __ ___  ___  ___  / _| |_
#		 /  \/ / _ \| '_ ` _ \/ __|/ _ \| |_| __|
#		/ /\  / (_) | | | | | \__ \ (_) |  _| |_
#		\_\ \/ \___/|_| |_| |_|___/\___/|_|  \__|	- www.Nomsoftware.com -
#                  The policy of Nomsoftware states: Releasing our software
#                  or any other files are protected. You cannot re-release
#                  anywhere unless you were given permission.
#                  © Nomsoftware 'Nomsoft' 2011-2012. All rights reserved.
if ($GLOBALS['enableSlideShow'] == TRUE && !isset($_COOKIE['hideslider']) && $_GET['p'] == 'home') {
    ?>
<div class="main_view">
    <div class="window">
		<div class="slider-wrapper theme-default">
            <div id="slider" class="nivoSlider">
				<?php 
    website::getSlideShowImages();
    ?>
            </div>
        </div>
    </div>
</div>
<?php 
}
Пример #9
0
global $plugins;
global $events;
global $webgets;
$idn = new idna_convert();
$events = new events();
// create database connection
$DB = new database();
if (!$DB->connect()) {
    die(APP_NAME . ' # ERROR<br /> ' . $DB->get_last_error());
}
// global exception catcher
try {
    // which website do we have to load?
    $url = nvweb_self_url();
    if (!empty($_REQUEST['wid'])) {
        $website = new website();
        $website->load(intval($_REQUEST['wid']));
    } else {
        $website = nvweb_load_website_by_url($url);
    }
    if ($website->permission == 2 || $website->permission == 1 && empty($_SESSION['APP_USER#' . APP_UNIQUE])) {
        if (!empty($website->redirect_to)) {
            header('location: ' . $website->redirect_to);
        }
        nvweb_clean_exit();
    }
    // global helper variables
    $session = array();
    // webuser session
    $structure = array();
    // web menu structure
Пример #10
0
function users_form($item)
{
    global $DB;
    global $layout;
    global $current_version;
    $navibars = new navibars();
    $naviforms = new naviforms();
    if (empty($item->id)) {
        $navibars->title(t(15, 'Users') . ' / ' . t(38, 'Create'));
    } else {
        $navibars->title(t(15, 'Users') . ' / ' . t(170, 'Edit') . ' [' . $item->id . ']');
    }
    if (empty($item->id)) {
        $navibars->add_actions(array('<a href="#" onclick="navigate_tabform_submit(1);"><img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '</a>'));
    } else {
        $navibars->add_actions(array('<a href="#" onclick="navigate_tabform_submit(1);"><img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '</a>', '<a href="#" onclick="navigate_delete_dialog();"><img height="16" align="absmiddle" width="16" src="img/icons/silk/cancel.png"> ' . t(35, 'Delete') . '</a>'));
        $delete_html = array();
        $delete_html[] = '<div id="navigate-delete-dialog" class="hidden">' . t(57, 'Do you really want to delete this item?') . '</div>';
        $delete_html[] = '<script language="javascript" type="text/javascript">';
        $delete_html[] = 'function navigate_delete_dialog()';
        $delete_html[] = '{';
        $delete_html[] = '$("#navigate-delete-dialog").removeClass("hidden");';
        $delete_html[] = '$("#navigate-delete-dialog").dialog({
							resizable: true,
							height: 150,
							width: 300,
							modal: true,
							title: "' . t(59, 'Confirmation') . '",
							buttons: {
								"' . t(35, 'Delete') . '": function() {
									$(this).dialog("close");
									window.location.href = "?fid=users&act=4&id=' . $item->id . '";
								},
								"' . t(58, 'Cancel') . '": function() {
									$(this).dialog("close");
								}
							}
						});';
        $delete_html[] = '}';
        $delete_html[] = '</script>';
        $navibars->add_content(implode("\n", $delete_html));
    }
    $navibars->add_actions(array(!empty($item->id) ? '<a href="?fid=users&act=2"><img height="16" align="absmiddle" width="16" src="img/icons/silk/add.png"> ' . t(38, 'Create') . '</a>' : '', '<a href="?fid=users&act=0"><img height="16" align="absmiddle" width="16" src="img/icons/silk/application_view_list.png"> ' . t(39, 'List') . '</a>', 'search_form'));
    $navibars->form();
    $navibars->add_tab(t(43, "Main"));
    $navibars->add_tab_content($naviforms->hidden('form-sent', 'true'));
    $navibars->add_tab_content($naviforms->hidden('id', $item->id));
    $navibars->add_tab_content_row(array('<label>ID</label>', '<span>' . (!empty($item->id) ? $item->id : t(52, '(new)')) . '</span>'));
    $navibars->add_tab_content_row(array('<label>' . t(1, 'User') . '</label>', $naviforms->textfield('user-username', $item->username)));
    $navibars->add_tab_content_row(array('<label>' . t(2, 'Password') . '</label>', '<input type="password" name="user-password" value="" size="32" autocomplete="off" />', '<span class="navigate-form-row-info">' . t(48, "Leave blank to keep the current value") . '</span>'));
    // force removing the browser saved password
    $layout->add_script('
		setTimeout(function() {
			$("input[name=user-password]").val("");
		}, 10);
	');
    $navibars->add_tab_content_row(array('<label>' . t(44, 'E-Mail') . '</label>', '<input type="text" name="user-email" value="' . $item->email . '" size="64" />'));
    // Profile selector
    $DB->query('SELECT id, name FROM nv_profiles');
    $data = $DB->result();
    $select = $naviforms->select_from_object_array('user-profile', $data, 'id', 'name', $item->profile);
    $navibars->add_tab_content_row(array('<label>' . t(45, 'Profile') . '</label>', $select));
    // Language selector
    $DB->query('SELECT code, name FROM nv_languages WHERE nv_dictionary != ""');
    $data = $DB->result();
    $select = $naviforms->select_from_object_array('user-language', $data, 'code', 'name', $item->language);
    $navibars->add_tab_content_row(array('<label>' . t(46, 'Language') . '</label>', $select));
    $timezones = property::timezones();
    if (empty($item->timezone)) {
        $item->timezone = date_default_timezone_get();
    }
    $navibars->add_tab_content_row(array('<label>' . t(97, 'Timezone') . '</label>', $naviforms->selectfield("user-timezone", array_keys($timezones), array_values($timezones), $item->timezone)));
    // Decimal separator
    $data = array(0 => json_decode('{"code": ",", "name": ", ---> 1234,25"}'), 1 => json_decode('{"code": ".", "name": ". ---> 1234.25"}'), 2 => json_decode('{"code": "\'", "name": "\' ---> 1234\'25"}'));
    $select = $naviforms->select_from_object_array('user-decimal_separator', $data, 'code', 'name', $item->decimal_separator);
    $navibars->add_tab_content_row(array('<label>' . t(49, 'Decimal separator') . '</label>', $select));
    // Thousands separator
    $data = array(0 => json_decode('{"code": "", "name": "(' . strtolower(t(581, "None")) . ') ---> 1234567"}'), 1 => json_decode('{"code": ",", "name": ", ---> 1,234,567"}'), 2 => json_decode('{"code": ".", "name": ". ---> 1.234.567"}'));
    $select = $naviforms->select_from_object_array('user-thousands_separator', $data, 'code', 'name', $item->thousands_separator);
    $navibars->add_tab_content_row(array('<label>' . t(644, 'Thousands separator') . '</label>', $select));
    // Date format
    $data = array(0 => json_decode('{"code": "Y-m-d H:i", "name": "' . date(Y) . '-12-31 23:59"}'), 1 => json_decode('{"code": "d-m-Y H:i", "name": "31-12-' . date(Y) . ' 23:59"}'), 2 => json_decode('{"code": "m-d-Y H:i", "name": "12-31-' . date(Y) . ' 23:59"}'), 3 => json_decode('{"code": "Y/m/d H:i", "name": "' . date(Y) . '/12/31 23:59"}'), 4 => json_decode('{"code": "d/m/Y H:i", "name": "31/12/' . date(Y) . ' 23:59"}'), 5 => json_decode('{"code": "m/d/Y H:i", "name": "12/31/' . date(Y) . ' 23:59"}'));
    $layout->add_script('
        $("#user-decimal_separator,#user-thousands_separator").on("change", function()
        {
            $("#user-decimal_separator").parent().find("label:first").removeClass("ui-state-error");
            $("#user-thousands_separator").parent().find("label:first").removeClass("ui-state-error");
        
            if($("#user-decimal_separator").val()==$("#user-thousands_separator").val())
            {
                $("#user-decimal_separator").parent().find("label:first").addClass("ui-state-error");
                $("#user-thousands_separator").parent().find("label:first").addClass("ui-state-error");
            }
        });
        
        $("#user-decimal_separator").trigger("change"); // force checking on load
    ');
    $select = $naviforms->select_from_object_array('user-date_format', $data, 'code', 'name', $item->date_format);
    $navibars->add_tab_content_row(array('<label>' . t(50, 'Date format') . '</label>', $select));
    $navibars->add_tab_content($naviforms->hidden('user-skin', 'cupertino'));
    $navibars->add_tab_content_row(array('<label>' . t(47, 'Blocked') . '</label>', $naviforms->checkbox('user-blocked', $item->blocked)));
    $navibars->add_tab(t(241, "Web sites"));
    $navibars->add_tab_content_row(array('<label>' . t(612, "Manages all websites") . '</label>', $naviforms->checkbox("user-all-websites", empty($item->websites))));
    $websites = website::all();
    if (empty($websites)) {
        $websites = array();
    }
    $navibars->add_tab_content_row(array('<label>' . t(405, "Selection") . '</label>', $naviforms->multiselect('user-websites', array_keys($websites), array_values($websites), $item->websites)), "user-websites-selector", 'style="display: none; padding-bottom: 16px; "');
    $layout->add_script('
		$("#user-all-websites").on("change", function()
		{
			$("#user-websites-selector").hide();
			if(!$(this).is(":checked"))
				$("#user-websites-selector").show();
		});
		$("#user-all-websites").trigger("change");
	');
    $navibars->add_tab(t(17, "Permissions"));
    $navibars->add_tab_content($naviforms->hidden('navigate_permissions_changes', ''));
    $ws_tabs = '<div id="navigate-permissions-websites-tabs"><ul>';
    foreach ($websites as $ws_id => $ws_name) {
        $ws_tabs .= '<li><a href="#navigate-permissions-websites-tab-' . $ws_id . '">' . $ws_name . '</a></li>';
    }
    $ws_tabs .= '</ul>';
    foreach ($websites as $ws_id => $ws_name) {
        $rows = nvweb_permissions_rows($ws_id, 'user', $item->id);
        $ws_tabs .= '<div id="navigate-permissions-websites-tab-' . $ws_id . '" data-website="' . $ws_id . '">';
        $ws_tabs .= '<div id="permissions_list_website_' . $ws_id . '">';
        $ws_tabs .= '<table class="treeTable ui-corner-all">';
        $ws_tabs .= '
            <thead>
                <tr class="ui-state-default ui-th-column">
                    <th width="25%">' . t(159, 'Name') . '</th>
                    <th width="13%">' . t(467, 'Scope') . '</th>
                    <th width="12%">' . t(160, 'Type') . '</th>
                    <th width="50%">' . t(193, 'Value') . '</th>
                </tr>
            </thead>
        ';
        for ($r = 0; $r < count($rows); $r++) {
            $ws_tabs .= '<tr id="' . $rows[$r][0] . '">';
            $ws_tabs .= '    <td>' . $rows[$r][1] . '</td>';
            $ws_tabs .= '    <td>' . $rows[$r][2] . '</td>';
            $ws_tabs .= '    <td>' . $rows[$r][3] . '</td>';
            $ws_tabs .= '    <td>' . $rows[$r][4] . '</td>';
            $ws_tabs .= '</tr>';
        }
        $ws_tabs .= '</table>';
        $ws_tabs .= '</div>';
        $ws_tabs .= '</div>';
        $layout->add_script('
			$("#permissions_list_website_' . $ws_id . '").data("website", ' . $ws_id . ');            
		');
        $scripts_after_load[] = 'navigate_permissions_list_callback($("#permissions_list_website_' . $ws_id . '"));';
        $navibars->add_content(navigate_permissions_structure_selector($ws_id, $ws_name));
    }
    $ws_tabs .= '</div>';
    $navibars->add_tab_content($ws_tabs);
    $layout->add_script('
		$("#navigate-permissions-websites-tabs").tabs({
			heightStyle: "fill",
			activate: function() {
				$(window).trigger("resize");
			}
		});
	');
    $layout->add_script('
		$.getScript("lib/packages/permissions/permissions.js?r=' . $current_version->revision . '", function()
		{
		    navigate_window_resize();
			' . implode("\n", $scripts_after_load) . '
		});
	');
    return $navibars->generate();
}
Пример #11
0
<?php

#   ___           __ _           _ __    __     _
#  / __\ __ __ _ / _| |_ ___  __| / / /\ \ \___| |__
# / / | '__/ _` | |_| __/ _ \/ _` \ \/  \/ / _ \ '_ \
#/ /__| | | (_| |  _| ||  __/ (_| |\  /\  /  __/ |_) |
#\____/_|  \__,_|_|  \__\___|\__,_| \/  \/ \___|_.__/
#
#		-[ Created by ©Nomsoft
#		  `-[ Original core by Anthony (Aka. CraftedDev)
#
#				-CraftedWeb Generation II-
#			 __                           __ _
#		  /\ \ \___  _ __ ___  ___  ___  / _| |_
#		 /  \/ / _ \| '_ ` _ \/ __|/ _ \| |_| __|
#		/ /\  / (_) | | | | | \__ \ (_) |  _| |_
#		\_\ \/ \___/|_| |_| |_|___/\___/|_|  \__|	- www.Nomsoftware.com -
#                  The policy of Nomsoftware states: Releasing our software
#                  or any other files are protected. You cannot re-release
#                  anywhere unless you were given permission.
#                  © Nomsoftware 'Nomsoft' 2011-2012. All rights reserved.
website::getNews();
if ($GLOBALS['enableSlideShow'] == false && $GLOBALS['news']['enable'] == false) {
    buildError("<b>Configuration file error.</b>Neither the slideshow or the news are displayed, the homepage will be empty.");
    echo "Seems like the homepage was empty!";
}
Пример #12
0
function nv_plugin_init()
{
    global $DB;
    global $webuser;
    global $config;
    global $website;
    global $current;
    global $dictionary;
    global $session;
    global $events;
    global $idn;
    // create database connection
    $DB = new database();
    if (!$DB->connect()) {
        die(APP_NAME . ' # ERROR<br /> ' . $DB->get_last_error());
    }
    // global exception catcher
    try {
        $idn = new idna_convert();
        // which website do we have to load?
        $url = nvweb_self_url();
        if (!empty($_REQUEST['wid'])) {
            $website = new website();
            $website->load(intval($_REQUEST['wid']));
        } else {
            $website = nvweb_load_website_by_url($url);
        }
        if ($website->permission == 2 || $website->permission == 1 && empty($_SESSION['APP_USER#' . APP_UNIQUE])) {
            nvweb_clean_exit();
        }
        // global helper variables
        $session = array();
        // user session
        $webuser = new webuser();
        $nvweb_absolute = empty($website->protocol) ? 'http://' : $website->protocol;
        if (!empty($website->subdomain)) {
            $nvweb_absolute .= $website->subdomain . '.';
        }
        $nvweb_absolute .= $website->domain . $website->folder;
        define('NVWEB_ABSOLUTE', $nvweb_absolute);
        define('NVWEB_OBJECT', $nvweb_absolute . '/object');
        if (!defined('NAVIGATE_URL')) {
            define('NAVIGATE_URL', NAVIGATE_PARENT . NAVIGATE_FOLDER);
        }
        if (!isset($_SESSION['nvweb.' . $website->id])) {
            $_SESSION['nvweb.' . $website->id] = array();
            $session['lang'] = nvweb_country_language();
        } else {
            $session = $_SESSION['nvweb.' . $website->id];
            if (empty($session['lang'])) {
                $session['lang'] = nvweb_country_language();
            }
        }
        if (isset($_REQUEST['lang'])) {
            $session['lang'] = $_REQUEST['lang'];
        }
        if (!empty($session['webuser'])) {
            $webuser->load($session['webuser']);
        } else {
            if (!empty($_COOKIE["webuser"])) {
                $webuser->load_by_hash($_COOKIE['webuser']);
            }
        }
        @setlocale(LC_ALL, $website->languages[$session['lang']]['system_locale']);
        // remove the "folder" part of the route
        $route = '';
        if (!empty($_REQUEST['route'])) {
            $route = $_REQUEST['route'];
            // remove the "folder" part of the route (only if this url is really under a folder)
            if (!empty($website->folder) && strpos('/' . $route, $website->folder) === 0) {
                $route = substr('/' . $route, strlen($website->folder) + 1);
            }
        }
        // global data across webgets
        $current = array('lang' => $session['lang'], 'route' => $route, 'object' => '', 'template' => '', 'category' => '', 'webuser' => @$session['webuser'], 'navigate_session' => !empty($_SESSION['APP_USER#' . APP_UNIQUE]), 'html_after_body' => array(), 'js_after_body' => array());
        $dictionary = nvweb_dictionary_load();
        $_SESSION['nvweb.' . $website->id] = $session;
    } catch (Exception $e) {
        ?>
		<html>
			<body>
				ERROR
				<br /><br />
				<?php 
        echo $e->getMessage();
        ?>
			</body>
		</html>
		<?php 
    }
    $events = new events();
    nvweb_plugins_load();
    $events->extension_backend_bindings();
}
Пример #13
0
    public function editorfield($name, $value, $width = "80%", $lang = "es", $website_id = NULL)
    {
        global $layout;
        global $website;
        global $user;
        $height = 400;
        $ws = $website;
        if (!empty($website_id) && $website_id != $website->id) {
            $ws = new website();
            $ws->load($website_id);
        }
        $text = htmlentities($value, ENT_HTML5 | ENT_NOQUOTES, 'UTF-8', true);
        // remove unneeded new lines (to fix a problem of extra spaces in pre/code tags)
        $text = str_replace('&NewLine;', '', $text);
        $out = '<textarea name="' . $name . '" id="' . $name . '" style=" width: ' . $width . '; height: ' . $height . 'px; ">' . $text . '</textarea>';
        $content_css = $ws->content_stylesheets('tinymce', 'content');
        $content_css_selectable = $ws->content_stylesheets('tinymce', 'content_selectable');
        /* disabled for tiny mce 4.x, problems with the compressor
                // remove cache if the server address has changed
                $tinymce_gz = glob(NAVIGATE_PATH.'/lib/external/tinymce4/*.gz');
        
                if(!empty($tinymce_gz))
                {
                    if(file_exists(NAVIGATE_PATH.'/lib/external/tinymce4/server_name'))
                    {
                        $server_name = file_get_contents(NAVIGATE_PATH.'/lib/external/tinymce4/server_name');
                        if($server_name != md5($_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']))
                            @unlink($tinymce_gz[0]);
                    }
                    file_put_contents(NAVIGATE_PATH.'/lib/external/tinymce4/server_name', md5($_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']));
                }
        		*/
        $tinymce_language = $user->language;
        $layout->add_script('    
            tinyMCE.baseURL = "' . NAVIGATE_URL . '/lib/external/tinymce4";
            $("#' . $name . '").tinymce(
            {
                language: "' . $tinymce_language . '",
                
                width: ($("#' . $name . '").width()) + "px",
                height: $("#' . $name . '").height() + "px",
                resize: "both",
                
                menubar: false,
                theme: "modern",
                skin: "navigatecms-cupertino",
                			    
			    plugins: [
				    "compat3x noneditable",
				    "advlist autolink nv_link image lists charmap print preview hr anchor pagebreak",
				    "searchreplace wordcount visualblocks visualchars fullscreen media nonbreaking",
				    "table directionality template textcolor paste textcolor colorpicker textpattern",
				    "codesample codemirror imagetools importcss paste magicline fontawesome nv_rollups" // add fullpage to edit full HTML code with head and body tags
				],
				
				external_plugins: {
				    "loremipsum": "' . NAVIGATE_URL . '/lib/external/tinymce4/plugins/loremipsum/editor_plugin.js",
				    "imgmap": "' . NAVIGATE_URL . '/lib/external/tinymce4/plugins/imgmap/editor_plugin.js",
				    "style": "' . NAVIGATE_URL . '/lib/external/tinymce4/plugins/style/editor_plugin.js",
				    "xhtmlxtras": "' . NAVIGATE_URL . '/lib/external/tinymce4/plugins/xhtmlxtras/editor_plugin.js"
				},
				
				toolbar: [
					"formatselect fontselect fontsizeselect | forecolor | backcolor | removeformat | searchreplace code",
                    "bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | outdent indent blockquote | bullist numlist | nv_rollup_special_char",
                    "styleselect | styleprops attribs | table | nv_rollup_links | image imgmap media codesample | magicline | undo redo"
                ],

				toolbar_items_size: "small",
				
				// forced fix to avoid tinymce adding <p> element on non block elements (span, i, etc)
				// needed mainly for Codemirror plugin, but force_p_newlines is deprecated by the TinyMCE team
				forced_root_block: "",
				force_br_newlines : true,
                force_p_newlines : true,
				
			    browser_spellcheck: true,
                spellchecker_language: "' . $lang . '",
                
                noneditable_noneditable_class: "fa",    // without this, TinyMCE removes the Font Awesome icons when editing the content
                
                media_live_embeds: false, // disable iframe loading (like videos) to allow resizing
                
                magicline_color: "#0070a3",
                magicline_targetedItems: ["DIV", "IMG", "IFRAME", "PRE", "TABLE", "ARTICLE", "UL", "OL", "BLOCKQUOTE"],
                magicline_triggerMargin: 16,
			    
			    codemirror: {
					path:  "' . NAVIGATE_URL . '/lib/external/codemirror",
				    indentOnInit: true,
                    config: {
                        mode: "htmlmixed",
                        lineNumbers: true
                    },
                    jsFiles: [
                        "mode/htmlmixed/htmlmixed.js"
                    ]
				},
				
				image_advtab: true,
				
				automatic_uploads: true,
			    paste_data_images: true,
				images_upload_url: "navigate_upload.php?engine=tinymce&session_id=' . session_id() . '&debug",
				
				fontsize_formats: "8px 9px 10px 11px 12px 13px 14px 15px 16px 17px 18px 20px 24px 26px 28px 30px 32px 36px", 
                
                content_css: "' . $content_css . '",
                
				style_formats_merge: true,
                importcss_append: false,
                importcss_file_filter: function(value) 
                {
                    var files = "' . $content_css_selectable . '";
                    
                    if(files.indexOf(",") > -1)
                    {
                        files = files.split(",");
	                    for(var i=0; i<files.length; i++)
	                    {
	                        if(value.indexOf(files[i]) !== -1)
	                        {
	                            return true;
	                        }
	                    }
	                    return false;
                    }
                    else
                    {
                        return (value==files);
                    }
                },               
                                
                //  https://www.tinymce.com/docs/configure/url-handling
                convert_urls: false,
                relative_urls: true,
                remove_script_host: false,
                
                // https://www.tinymce.com/docs/configure/content-filtering/
                valid_elements: "*[*],+a[*],+p[*],#i",
                custom_elements: "nv,code,pre,nvlist,nvlist_conditional,figure,article,header,footer,post,nav",
                extended_valid_elements: "+nv[*],+pre[*],+code[*],+nvlist[*],+nvlist_conditional[*],+figure[*],+article[*],+nav[*],+i[*],+span[*],+em[*],+b[*],*[*]",
                valid_children: "+a[div|p|li],+body[style|script|nv|nvlist|nvlist_conditional],+code[nv|nvlist|nvlist_conditional]",
                
                paste_as_text: true,
                
                // https://www.tinymce.com/docs/configure/content-filtering/#allow_html_in_named_anchor
                allow_html_in_named_anchor: true,          
                
                // events
                handle_event_callback : "navigate_tinymce_event",
                
                // before rendering this tinymce
                setup: function(editor)
                {
	                editor.on("init", function() 
	                { 
				        $(editor.getWin()).bind("scroll blur focus", function(e)
				        {
                            navigate_tinymce_event(e, "' . $name . '");
				        });
				        
				        // restore last known iframe scroll position
				        navigate_tinymce_event({type: "focus"}, "' . $name . '", true);
	                    setTimeout(function()
	                    {
	                        navigate_tinymce_event({type: "focus"}, "' . $name . '", true);
	                    }, 25);
				    });			    				    
                },
                
                // just after rendering this tinymce 
                init_instance_callback: function(editor)
                {                           
					// find missing images
					$("#' . $name . '").parent().find("iframe").contents().find("img").each(function()
					{
						if( (typeof this.naturalWidth != "undefined" && this.naturalWidth == 0 ) 
					        || this.readyState == "uninitialized" )					         
				        {
					        $(this).addClass("nomagicline");
					    }
					});
                
                    $("#' . $name . '").parent().find("iframe").droppable(
                    {
                        drop: function(event, ui)
                        {
                            if(!$(ui.draggable).attr("id")) // not a file!
                            {
                                $("#' . $name . '_tbl").css("opacity", 1);
                                return;
                            }

                            var file_id = $(ui.draggable).attr("id").substring(5);
                            if(!file_id || file_id=="" || file_id==0) return;
                            var media = $(ui.draggable).attr("mediatype");
                            var mime = $(ui.draggable).attr("mimetype");
                            var web_id = "' . $ws->id . '";
                            navigate_tinymce_add_content($("#' . $name . ':tinymce").attr("id"), file_id, media, mime, web_id, ui.draggable);
                            $("#' . $name . '").parent().find("> .mce-tinymce").css("opacity", 1);
                        },
                        over: function(event, ui)
                        {
                            if(!$(ui.draggable).attr("id")) // not a file!
                                return;

                            $("#' . $name . '").parent().find("> .mce-tinymce").css("opacity", 0.75);
                        },
                        out: function(event, ui)
                        {
                            $("#' . $name . '").parent().find("> .mce-tinymce").css("opacity", 1);
                        }
                    });
                    
                    // deprecated, but the only way we found to set the button on on init
	                tinyMCE.get("' . $name . '").controlManager.setActive("magicline", true);	                
                }
            });
        ');
        $layout->navigate_editorfield_link_dialog();
        return $out;
    }
Пример #14
0
 public static function elements($template, $element = "", $website_id = null)
 {
     global $DB;
     global $website;
     global $theme;
     $data = array();
     if (empty($website_id)) {
         $website_id = $website->id;
     }
     if (is_numeric($template)) {
         // properties attached to a custom template (not a theme template)
         if (!empty($element)) {
             $element = ' AND element = ' . protect($element);
         } else {
             $element = ' AND element != "block"';
         }
         if ($DB->query('
                SELECT *
                FROM nv_properties
                WHERE template = ' . protect($template) . '
                ' . $element . '
                  AND website = ' . $website_id . '
                ORDER BY position ASC, id ASC')) {
             $data = $DB->result();
         }
     } else {
         if ($element == 'webuser') {
             // webuser properties (set in theme definition)
             $data = $theme->webusers['properties'];
         } else {
             if ($element == 'block') {
                 // block type properties
                 for ($b = 0; $b < count($theme->blocks); $b++) {
                     if ($theme->blocks[$b]->id == $template) {
                         $data = $theme->blocks[$b]->properties;
                         break;
                     }
                 }
             } else {
                 if ($element == 'block_group_block') {
                     // block group blocks properties
                     for ($b = 0; $b < count($theme->block_groups); $b++) {
                         if ($theme->block_groups[$b]->id == $template) {
                             $data = array();
                             foreach ($theme->block_groups[$b]->blocks as $bgb) {
                                 // note: properties in block group blocks can't have the same name
                                 if (isset($bgb->properties)) {
                                     $data = array_merge($data, $bgb->properties);
                                 }
                             }
                             break;
                         }
                     }
                 } else {
                     if ($element == 'comment') {
                         // properties of the comments of a certain template type
                         $theme_template = new template();
                         if (!empty($website_id)) {
                             // force loading website information
                             $ws = new website();
                             $ws->load($website_id);
                             $ws_theme = $ws->theme;
                         }
                         $theme_template->load_from_theme($template, $ws_theme);
                         $comments_properties = $theme_template->comments->properties;
                         if (empty($comments_properties)) {
                             $comments_properties = array();
                         }
                         $data = array();
                         for ($p = 0; $p < count($comments_properties); $p++) {
                             $data[] = $comments_properties[$p];
                         }
                     } else {
                         // properties of a theme template
                         $theme_template = new template();
                         if (!empty($website_id)) {
                             // force loading website information
                             $ws = new website();
                             $ws->load($website_id);
                             $ws_theme = $ws->theme;
                         }
                         $theme_template->load_from_theme($template, $ws_theme);
                         $template_properties = $theme_template->properties;
                         if (empty($template_properties)) {
                             $template_properties = array();
                         }
                         $data = array();
                         for ($p = 0; $p < count($template_properties); $p++) {
                             // if we want all properties, no matter the element assigned or
                             // if the property is not assigned to an element, we assume "item", or
                             // if the property is assigned to an element, we check it
                             // note: in this case, "element" is an alias of "item"
                             if (empty($element) || $element == 'item' && empty($template_properties[$p]->element) || $element == 'item' && $template_properties[$p]->element == "element" || $template_properties[$p]->element == $element) {
                                 $data[] = $template_properties[$p];
                             }
                         }
                     }
                 }
             }
         }
     }
     return $data;
 }
Пример #15
0
 public static function hierarchy($id_parent = 0, $ws_id = null)
 {
     global $website;
     global $theme;
     if (empty($ws_id)) {
         $ws_id = $website->id;
     }
     $ws = new website();
     $ws->load($ws_id);
     $flang = $ws->languages_list[0];
     if (empty($flang)) {
         return array();
     }
     $tree = array();
     if ($id_parent == -1) {
         // create the virtual root structure entry (the website)
         $obj = new structure();
         $obj->id = 0;
         $obj->label = $ws->name;
         $obj->_multilanguage_label = $ws->name;
         $obj->parent = -1;
         $obj->children = structure::hierarchy(0, $ws_id);
         $tree[] = $obj;
     } else {
         $tree = structure::loadTree($id_parent, $ws_id);
         $templates = template::elements('structure');
         if (empty($templates)) {
             $templates = array();
         }
         for ($i = 0; $i < count($tree); $i++) {
             $tree[$i]->dictionary = webdictionary::load_element_strings('structure', $tree[$i]->id);
             $tree[$i]->label = $tree[$i]->dictionary[$ws->languages_list[0]]['title'];
             $tree[$i]->template_title = $tree[$i]->template;
             foreach ($templates as $template_def) {
                 if ($template_def->type == $tree[$i]->template) {
                     $tree[$i]->template_title = $template_def->title;
                     break;
                 }
             }
             if (method_exists($theme, "t")) {
                 $tree[$i]->template_title = $theme->t($tree[$i]->template_title);
             }
             for ($wl = 0; $wl < count($ws->languages_list); $wl++) {
                 $lang = $ws->languages_list[$wl];
                 if (empty($tree[$i]->dictionary[$lang]['title'])) {
                     $tree[$i]->dictionary[$lang]['title'] = '[ ? ]';
                 }
                 $style = '';
                 if ($lang != $flang) {
                     $style = 'display: none';
                 }
                 $label[] = '<span class="structure-label" lang="' . $lang . '" style="' . $style . '">' . $tree[$i]->dictionary[$lang]['title'] . '</span>';
                 $bc[$tree[$i]->id][$lang] = $tree[$i]->dictionary[$lang]['title'];
             }
             $children = structure::hierarchy($tree[$i]->id, $ws_id);
             $tree[$i]->children = $children;
         }
     }
     return $tree;
 }
Пример #16
0
    public static function loadVotingLinks()
    {
        connect::selectDB('webdb');
        $result = mysql_query("SELECT * FROM votingsites ORDER BY id DESC");
        if (mysql_num_rows($result) == 0) {
            buildError("Couldnt fetch any voting links from the database. " . mysql_error());
        } else {
            while ($row = mysql_fetch_assoc($result)) {
                ?>
            <div class='votelink'>
            <table width="100%">
                <tr>
                    <td width="20%"><img src="<?php 
                echo $row['image'];
                ?>
" /></td>
                    <td width="50%"><strong><?php 
                echo $row['title'];
                ?>
</strong> (<?php 
                echo $row['points'];
                ?>
 Vote Points)<td>
                    <td width="40%">
					<?php 
                if (website::checkIfVoted($row['id']) == FALSE) {
                    ?>
                    		<input type='submit' value='Vote'  onclick="vote('<?php 
                    echo $row['id'];
                    ?>
',this)">
					<?php 
                } else {
                    $getNext = mysql_query("SELECT next_vote FROM " . $GLOBALS['connection']['webdb'] . ".votelog\n\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE userid='" . account::getAccountID($_SESSION['cw_user']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t AND siteid='" . $row['id'] . "' ORDER BY id DESC LIMIT 1");
                    $row = mysql_fetch_assoc($getNext);
                    $time = $row['next_vote'] - time();
                    echo 'Time until reset: ' . convTime($time);
                }
                ?>
                         </td>
                     </tr>
              </table>
              </div>
			  <?php 
            }
        }
    }
Пример #17
0
if (substr($navigate_url, -1) == '/') {
    $navigate_url = substr($navigate_url, 0, -1);
}
define('NAVIGATE_URL', $navigate_url);
// create database connection
$DB = new database();
if (!$DB->connect()) {
    die(APP_NAME . ' # ERROR<br /> ' . $DB->get_last_error());
}
if (!empty($_SESSION['APP_USER#' . APP_UNIQUE])) {
    session_write_close();
    header('location: ' . NAVIGATE_MAIN);
    exit;
}
$user = new user();
$website = new website();
// only needed for the users log
if (!empty($_COOKIE['navigate-user'])) {
    $nuid = $DB->query_single('id', 'nv_users', 'cookie_hash = ' . protect($_COOKIE['navigate-user']));
    if (!empty($nuid)) {
        $user->load($nuid);
        $_SESSION['APP_USER#' . APP_UNIQUE] = $nuid;
        session_write_close();
        header('location: ' . NAVIGATE_MAIN);
        exit;
    }
}
if (!empty($_POST['login-username']) && !empty($_POST['login-password'])) {
    $error = !$user->authenticate($_POST['login-username'], $_POST['login-password']);
    if (empty($error) && $user->blocked == '1') {
        $error = true;
Пример #18
0
 function metaWeblog_getPost($args)
 {
     global $DB;
     global $session;
     $out = array();
     list($post_id, $username, $password) = $args;
     $item = new item();
     $item->load(intval($post_id));
     $website_id = $item->website;
     $website = new website();
     $website->load($website_id);
     // check auth
     if (metaWeblog_userAllowed($username, $password, $website_id)) {
         if ($item->embedding == 1) {
             $link = nvweb_source_url('structure', $item->category, $session['lang']);
         } else {
             $link = $item->link($session['lang']);
         }
         $category = new structure();
         $category->load($item->category);
         $content = $item->dictionary[$session['lang']]['section-main'];
         $content = nvweb_template_fix_download_paths($content);
         if (empty($item->date_to_display)) {
             $item->date_to_display = $item->date_created;
         }
         $out = array("postid" => $item->id, "userid" => $item->author, "dateCreated" => new IXR_Date($item->date_to_display), "category" => $item->category, "title" => $item->dictionary[$session['lang']]['title'], "description" => $content, "url" => $link, "permalink" => $link, "mt_keywords" => $item->dictionary[$session['lang']]['tags']);
     } else {
         $out = new IXR_Error(401, "User not allowed.");
     }
     return $out;
 }
Пример #19
0
function profiles_form($item)
{
    global $layout;
    global $current_version;
    $navibars = new navibars();
    $naviforms = new naviforms();
    if (empty($item->id)) {
        $navibars->title(t(243, 'Profiles') . ' / ' . t(38, 'Create'));
    } else {
        $navibars->title(t(243, 'Profiles') . ' / ' . t(170, 'Edit') . ' [' . $item->id . ']');
    }
    if (empty($item->id)) {
        $navibars->add_actions(array('<a href="#" onclick="navigate_tabform_submit(1);"><img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '</a>'));
    } else {
        $navibars->add_actions(array('<a href="#" onclick="navigate_tabform_submit(1);"><img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '</a>', '<a href="#" onclick="navigate_delete_dialog();"><img height="16" align="absmiddle" width="16" src="img/icons/silk/cancel.png"> ' . t(35, 'Delete') . '</a>'));
        $layout->add_script('
            function navigate_delete_dialog()
            {
                navigate_confirmation_dialog(
                    function() { window.location.href = "?fid=profiles&act=delete&id=' . $item->id . '"; }, 
                    null, null, "' . t(35, 'Delete') . '"
                );
            }
        ');
    }
    $navibars->add_actions(array(!empty($item->id) ? '<a href="?fid=profiles&act=2"><img height="16" align="absmiddle" width="16" src="img/icons/silk/add.png"> ' . t(38, 'Create') . '</a>' : '', '<a href="?fid=profiles&act=0"><img height="16" align="absmiddle" width="16" src="img/icons/silk/application_view_list.png"> ' . t(39, 'List') . '</a>', 'search_form'));
    $navibars->form();
    $navibars->add_tab(t(43, "Main"));
    $navibars->add_tab_content($naviforms->hidden('form-sent', 'true'));
    $navibars->add_tab_content($naviforms->hidden('id', $item->id));
    $navibars->add_tab_content_row(array('<label>ID</label>', '<span>' . (!empty($item->id) ? $item->id : t(52, '(new)')) . '</span>'));
    $navibars->add_tab_content_row(array('<label>' . t(159, 'Name') . '</label>', $naviforms->textfield('name', $item->name)));
    $navibars->add_tab_content_row(array('<label>' . t(334, 'Description') . '</label>', $naviforms->textarea('description', $item->description)));
    $menus = menu::load_all_menus();
    $sortable_profile = array();
    $sortable_unassigned = array();
    $sortable_profile[] = '<ul id="sortable_profile" class="connectedSortable">';
    $sortable_unassigned[] = '<ul id="sortable_unassigned" class="connectedSortable">';
    // already included menus on the profile
    foreach ($item->menus as $m) {
        foreach ($menus as $menu) {
            if ($menu->id == $m) {
                if ($menu->enabled == '1') {
                    $sortable_profile[] = '<li class="ui-state-highlight" value="' . $menu->id . '" title="' . $menu->notes . '"><img src="' . NAVIGATE_URL . '/' . $menu->icon . '" align="absmiddle" /> ' . t($menu->lid, $menu->lid) . '</li>';
                } else {
                    $sortable_profile[] = '<li class="ui-state-highlight ui-state-disabled" value="' . $menu->id . '" title="' . $menu->notes . '"><img src="' . NAVIGATE_URL . '/' . $menu->icon . '" align="absmiddle" /> ' . t($menu->lid, $menu->lid) . '</li>';
                }
            }
        }
    }
    // the other menus not included on the profile
    if (is_array($menus)) {
        foreach ($menus as $menu) {
            if (!in_array($menu->id, $item->menus)) {
                if ($menu->enabled == '1') {
                    $sortable_unassigned[] = '<li class="ui-state-default" value="' . $menu->id . '" title="' . $menu->notes . '"><img src="' . NAVIGATE_URL . '/' . $menu->icon . '" align="absmiddle" /> ' . t($menu->lid, $menu->lid) . '</li>';
                } else {
                    $sortable_unassigned[] = '<li class="ui-state-default ui-state-disabled" value="' . $menu->id . '" title="' . $menu->notes . '"><img src="' . NAVIGATE_URL . '/' . $menu->icon . '" align="absmiddle" /> ' . t($menu->lid, $menu->lid) . '</li>';
                }
            }
        }
    }
    $sortable_profile[] = '</ul>';
    $sortable_unassigned[] = '</ul>';
    //$navibars->add_tab_content('<pre>'.print_r($item->menus, true).'</pre>');
    $navibars->add_tab_content($naviforms->hidden("profile-menu", implode('#', $item->menus)));
    $navibars->add_tab_content_row(array('<label>' . t(244, 'Menus') . '</label>', implode("\n", $sortable_profile), implode("\n", $sortable_unassigned)));
    $layout->add_script('
		$("#sortable_profile").sortable({
				connectWith: ".connectedSortable",
				receive: function(event, ui)
				{
					$(ui.item).addClass("ui-state-highlight");
					$(ui.item).removeClass("ui-state-default");
				},
				update: function()
				{
					$("#profile-menu").val("");
					$("#sortable_profile li").each(function()
					{
						$("#profile-menu").val($("#profile-menu").val() + $(this).attr("value") + "#");					
					});
				}
			}).disableSelection();
			
		$("#sortable_unassigned").sortable({
				connectWith: ".connectedSortable",
				receive: function(event, ui)
				{
					$(ui.item).addClass("ui-state-default");
					$(ui.item).removeClass("ui-state-highlight");					
				}
			}).disableSelection();			
			
	');
    $websites = website::all();
    $navibars->add_tab(t(17, "Permissions"));
    $navibars->add_tab_content($naviforms->hidden('navigate_permissions_changes', ''));
    $scripts_after_load = array();
    $ws_tabs = '<div id="navigate-permissions-websites-tabs"><ul>';
    foreach ($websites as $ws_id => $ws_name) {
        $ws_tabs .= '<li><a href="#navigate-permissions-websites-tab-' . $ws_id . '">' . $ws_name . '</a></li>';
    }
    $ws_tabs .= '</ul>';
    foreach ($websites as $ws_id => $ws_name) {
        $rows = nvweb_permissions_rows($ws_id, 'profile', $item->id);
        $ws_tabs .= '<div id="navigate-permissions-websites-tab-' . $ws_id . '" data-website="' . $ws_id . '">';
        $ws_tabs .= '<div id="permissions_list_website_' . $ws_id . '">';
        $ws_tabs .= '<table class="treeTable ui-corner-all">';
        $ws_tabs .= '
            <thead>
                <tr class="ui-state-default ui-th-column">
                    <th width="25%">' . t(159, 'Name') . '</th>
                    <th width="13%">' . t(467, 'Scope') . '</th>
                    <th width="12%">' . t(160, 'Type') . '</th>
                    <th width="50%">' . t(193, 'Value') . '</th>
                </tr>
            </thead>
        ';
        for ($r = 0; $r < count($rows); $r++) {
            $ws_tabs .= '<tr id="' . $rows[$r][0] . '">';
            $ws_tabs .= '    <td>' . $rows[$r][1] . '</td>';
            $ws_tabs .= '    <td>' . $rows[$r][2] . '</td>';
            $ws_tabs .= '    <td>' . $rows[$r][3] . '</td>';
            $ws_tabs .= '    <td>' . $rows[$r][4] . '</td>';
            $ws_tabs .= '</tr>';
        }
        $ws_tabs .= '</table>';
        $ws_tabs .= '</div>';
        $ws_tabs .= '</div>';
        $layout->add_script('
			$("#permissions_list_website_' . $ws_id . '").data("website", ' . $ws_id . ');            
		');
        $scripts_after_load[] = 'navigate_permissions_list_callback($("#permissions_list_website_' . $ws_id . '"));';
        $navibars->add_content(navigate_permissions_structure_selector($ws_id, $ws_name));
    }
    $ws_tabs .= '</div>';
    $navibars->add_tab_content($ws_tabs);
    $layout->add_script('
		$("#navigate-permissions-websites-tabs").tabs({
			heightStyle: "fill",
			activate: function() {
				$(window).trigger("resize");
			}
		});
	');
    $layout->add_script('
		$.getScript("lib/packages/permissions/permissions.js?r=' . $current_version->revision . '", function()
		{
			navigate_window_resize();
			' . implode("\n", $scripts_after_load) . '
		});
	');
    return $navibars->generate();
}
Пример #20
0
function nvweb_load_website_by_url($url, $exit = true)
{
    global $DB;
    global $idn;
    $website = new website();
    $parsed = parse_url($url);
    $scheme = $parsed['scheme'];
    // http, https...
    $host = $parsed['host'];
    // subdomain.domain.tld
    $path = $parsed['path'];
    // [/folder]page
    $host = $idn->decode($host);
    // look for website aliases
    $DB->query('SELECT aliases FROM nv_websites', 'array');
    $ars = $DB->result('aliases');
    $aliases = array();
    foreach ($ars as $ajson) {
        if (!is_array($aliases)) {
            $aliases = array();
        }
        $ajson = json_decode($ajson, true);
        if (!is_array($ajson)) {
            continue;
        }
        $aliases = array_merge($aliases, $ajson);
    }
    if (!is_array($aliases)) {
        $aliases = array();
    }
    foreach ($aliases as $alias => $real) {
        $alias_parsed = parse_url($alias);
        if ($alias_parsed['host'] == $host) {
            if (!isset($alias_parsed['path'])) {
                $alias_parsed['path'] = "";
            }
            $rud_path = rawurldecode($alias_parsed['path']);
            // check the path section
            if ($path == $alias_parsed['path'] || $path == '/nvweb.home' && empty($alias_parsed['path']) || !empty($path) && !empty($rud_path) && strpos($path, $rud_path, 0) !== false) {
                // alias path is included in the requested path
                // identify the extra part
                // EXAMPLE
                //
                //    ALIAS           http://themes.navigatecms.com
                //    REQUEST         http://themes.navigatecms.com/en/introduction
                //        EXTRA           /en/introduction
                //
                //    REAL PATH       http://www.navigatecms.com/en/documentation/themes
                //    REAL + EXTRA    http://www.navigatecms.com/en/documentation/themes/introduction
                //
                // note that the language part "en" is placed in different order
                // so our approach is to IGNORE the path sections already existing in the real path
                $extra = substr($path, strlen($alias_parsed['path']));
                $real_parsed = parse_url($real);
                $real_path = explode('/', $real_parsed['path']);
                $extra_path = explode('/', $extra);
                if (!is_array($extra_path)) {
                    $extra_path = array();
                }
                $add_to_real = '';
                foreach ($extra_path as $part) {
                    if ($part == 'nvweb.home') {
                        continue;
                    }
                    if (in_array($part, $real_path)) {
                        continue;
                    }
                    $add_to_real .= '/' . $part;
                }
                // TO DO: maybe in a later version full ALIAS support could be implemented
                //        right now we only redirect to the real path
                $url = $real . $add_to_real;
                header('location: ' . $idn->encode($url));
                nvweb_clean_exit();
            }
        }
    }
    // the host is an IP address or a full domain?
    $isIP = filter_var($host, FILTER_VALIDATE_IP);
    if ($isIP) {
        $domain = $host;
        $subdomain = "";
    } else {
        // do we have a subdomain in the url?
        preg_match('/(?:http[s]*\\:\\/\\/)*(.*?)\\.(?=[^\\/]*\\..{2,5})/i', $url, $parts);
        $subdomain = $parts[1];
        $domain = $host;
        if (empty($subdomain)) {
            // may be NULL
            $subdomain = "";
        } else {
            $domain = substr($host, strlen($subdomain) + 1);
        }
    }
    $DB->query('
		SELECT id, folder
		  FROM nv_websites
		 WHERE subdomain = ' . protect($subdomain) . '
		   AND domain = ' . protect($domain) . '
		 ORDER BY folder DESC
	 ');
    $websites = $DB->result();
    if (empty($websites)) {
        // no 'real' website found using this address
        if ($subdomain == 'nv') {
            /*
            			$website->load(); // first available, it doesn't matter
            			$nvweb_absolute = (empty($website->protocol)? 'http://' : $website->protocol);
            			if(!empty($website->subdomain))
            				$nvweb_absolute .= $website->subdomain.'.';
            			$nvweb_absolute .= $website->domain.$website->folder;
            */
            $nvweb_absolute = NAVIGATE_PARENT . NAVIGATE_FOLDER;
            header('location: ' . $nvweb_absolute);
            nvweb_clean_exit();
        } else {
            header("HTTP/1.1 404 Not Found");
            if ($exit) {
                nvweb_clean_exit();
            } else {
                return false;
            }
        }
    }
    // choose which website based on folder name
    foreach ($websites as $web) {
        // there can only be one subdomain.domain.tld without folder
        if (empty($web->folder)) {
            $website->load($web->id);
            break;
        } else {
            $path_segments = explode('/', $path);
            $folder_segments = explode('/', $web->folder);
            $folder_coincidence = true;
            for ($fs = 0; $fs < count($folder_segments); $fs++) {
                $folder_coincidence = $folder_coincidence && $folder_segments[$fs] == $path_segments[$fs];
            }
            if ($folder_coincidence) {
                $website->load($web->id);
                break;
            }
        }
    }
    // website could not be identified, just load the first available
    if (empty($website->id)) {
        $website->load();
    }
    return $website;
}
Пример #21
0
function navigate_property_layout_scripts($website_id = "")
{
    global $layout;
    global $website;
    global $current_version;
    $ws = $website;
    if (!empty($website_id) && $website->id != $website_id) {
        $ws = new website();
        $ws->load($website_id);
    }
    $ws_languages = $ws->languages();
    $default_language = array_keys($ws_languages);
    $default_language = $default_language[0];
    $naviforms = new naviforms();
    $layout->add_content('
		<div id="navigate-properties-copy-from-dialog" style=" display: none; ">
			<div class="navigate-form-row">
				<label>' . t(191, 'Source') . '</label>
				' . $naviforms->buttonset('navigate_properties_copy_from_dialog_type', array('language' => t(46, 'Language'), 'item' => t(180, 'Item'), 'structure' => t(16, 'Structure')), '0', "navigate_properties_copy_from_change_origin(this);") . '
			</div>
			<div class="navigate-form-row" style=" display: none; ">
				<label>' . t(46, 'Language') . '</label>
				' . $naviforms->selectfield('navigate_properties_copy_from_language_selector', array_keys($ws_languages), array_values($ws_languages), $default_language, "navigate_properties_copy_from_change_language(this);") . '
			</div>

			<div class="navigate-form-row" style=" display: none; ">
				<label>' . t(67, 'Title') . '</label>
				' . $naviforms->textfield('navigate_properties_copy_from_item_title') . '
				<button id="navigate_properties_copy_from_item_reload"><i class="fa fa-repeat"></i></button>
				' . $naviforms->hidden('navigate_properties_copy_from_item_id', '') . '
			</div>

			<div class="navigate-form-row" style=" display: none; ">
				<label>' . t(67, 'Title') . '</label>
				' . $naviforms->textfield('navigate_properties_copy_from_structure_title') . '
				<button id="navigate_properties_copy_from_structure_reload"><i class="fa fa-repeat"></i></button>
				' . $naviforms->hidden('navigate_properties_copy_from_structure_id', '') . '
			</div>

			<div class="navigate-form-row" style=" display: none; ">
				<label>' . t(239, 'Section') . '</label>
				' . $naviforms->select_from_object_array('navigate_properties_copy_from_section', array(), 'code', 'name', '') . '
			</div>
		</div>
	');
    $layout->add_script('
		$.getScript("lib/packages/properties/properties.js?r=' . $current_version->revision . '", function()
		{
			$(".navigate-form-row-property-action").on("click", function(e)
			{
			    var that = this;
			
				e.stopPropagation();
				e.preventDefault();
				
				if(!$(this).parent().hasClass("navigate-form-row"))
				    that = $(this).parent();
				
				navigate_properties_copy_from_dialog(that);
			});
		});
	');
}
Пример #22
0
                    <tr>
                        <td><h3 class="yellow_text"><?php 
            echo $row['title'];
            ?>
</h3></td>
                    </tr>
               </table>
               <table class="news_content" cellpadding="4"> 
                   <tr>
                       <td>
                <?php 
        }
        $text = preg_replace("#((http|https|ftp)://(\\S*?\\.\\S*?))(\\s|\\;|\\)|\\]|\\[|\\{|\\}|,|\"|'|:|\\<|\$|\\.\\s)#ie", "'<a href=\"\$1\" target=\"_blank\">http://\$3</a>\$4'", $row['body']);
        if ($GLOBALS['news']['limitHomeCharacters'] == true) {
            echo website::limit_characters($text, 200);
            $output .= website::limit_characters($row['body'], 200);
        } else {
            echo nl2br($text);
            $output .= nl2br($row['body']);
        }
        $commentsNum = mysql_query("SELECT COUNT(id) FROM news_comments WHERE newsid='" . $row['id'] . "'");
        if ($GLOBALS['news']['enableComments'] == TRUE) {
            $comments = '| <a href="?p=news&amp;newsid=' . $row['id'] . '">Comments (' . mysql_result($commentsNum, 0) . ')</a>';
        } else {
            $comments = NULL;
        }
        echo '
			<br/><br/><br/>
			<i class="gray_text"> Written by ' . $row['author'] . ' | ' . $row['date'] . ' ' . $comments . '</i>
			</td> 
			</tr>
Пример #23
0
<?php

/*
            _____           ____
           |   __|_____ _ _|    \ ___ _ _ ___
           |   __|     | | |  |  | -_| | |_ -|
           |_____|_|_|_|___|____/|___|\_/|___|
    Copyright (C) 2013 EmuDevs <http://www.emudevs.com/>
*/
require '../ext_scripts_class_loader.php';
if (isset($_POST['siteid'])) {
    $siteid = (int) $_POST['siteid'];
    connect::selectDB('webdb');
    if (website::checkIfVoted($siteid, $GLOBALS['connection']['webdb']) == TRUE) {
        die("?p=vote");
    }
    connect::selectDB('webdb');
    $check = mysql_query("SELECT COUNT(*) FROM votingsites WHERE id='" . $siteid . "'");
    if (mysql_result($check, 0) == 0) {
        die("?p=vote");
    }
    if ($GLOBALS['vote']['type'] == 'instant') {
        $acct_id = account::getAccountID($_SESSION['cw_user']);
        if (empty($acct_id)) {
            exit;
        }
        $next_vote = time() + $GLOBALS['vote']['timer'];
        connect::selectDB('webdb');
        mysql_query("INSERT INTO votelog (siteid,userid,timestamp,next_vote,ip)\n\t\tVALUES('" . $siteid . "','" . $acct_id . "','" . time() . "','" . $next_vote . "','" . $_SERVER['REMOTE_ADDR'] . "')");
        $getSiteData = mysql_query("SELECT points,url FROM votingsites WHERE id='" . $siteid . "'");
        $row = mysql_fetch_assoc($getSiteData);
Пример #24
0
 public static function forgotPW($account_name, $account_email)
 {
     $account_name = mysql_real_escape_string($account_name);
     $account_email = mysql_real_escape_string($account_email);
     if (empty($account_name) || empty($account_email)) {
         echo '<b class="red_text">Please enter both fields.</b>';
     } else {
         connect::selectDB('logondb');
         $result = mysql_query("SELECT COUNT('id') FROM account\r\n\t\t\t\t\t\t\t\t   WHERE username='******' AND email='" . $account_email . "'");
         if (mysql_result($result, 0) == 0) {
             echo '<b class="red_text">The username or email is incorrect.</b>';
         } else {
             //Success, lets send an email & add the forgotpw thingy.
             $code = RandomString();
             $emailSent = website::sendEmail($account_email, $GLOBALS['default_email'], 'Forgot Password', "\r\n\t\t\t\tHello there. <br/><br/>\r\n\t\t\t\tA password reset has been requested for the account " . $account_name . " <br/>\r\n\t\t\t\tIf you wish to reset your password, click the following link: <br/>\r\n\t\t\t\t<a href='" . $GLOBALS['website_domain'] . "?p=forgotpw&code=" . $code . "&account=" . account::getAccountID($account_name) . "'>\r\n\t\t\t\t" . $GLOBALS['website_domain'] . "?p=forgotpw&code=" . $code . "&account=" . account::getAccountID($account_name) . "</a>\r\n\r\n\t\t\t\t<br/><br/>\r\n\r\n\t\t\t\tIf you did not request this, just ignore this message.<br/><br/>\r\n\t\t\t\tSincerely, The Management.");
             if ($emailSent) {
                 $account_id = self::getAccountID($account_name);
                 connect::selectDB('webdb');
                 mysql_query("DELETE FROM password_reset WHERE account_id='" . $account_id . "'");
                 mysql_query("INSERT INTO password_reset (code,account_id)\r\n\t\t\t\t    VALUES ('" . $code . "','" . $account_id . "')");
                 echo "An email containing a link to reset your password has been sent to the Email address you specified.\r\n\t\t\t\t\t      If you've tried to send other forgot password requests before this, they won't work. <br/>";
             } else {
                 echo '<h4 class="red_text">Failed to send email! (Check error logs for details)</h4>';
             }
         }
     }
 }
Пример #25
0
        $website = nvweb_load_website_by_url($url, false);
        if (!$website) {
            $website = new Website();
            $website->load();
        }
    }
}
// if there are no websites, auto-create the first one
if (empty($website->id)) {
    $website->create_default();
}
// check allowed websites for this user
$wa = $user->websites;
if (!empty($wa)) {
    if (array_search($website->id, $wa) === false) {
        $website = new website();
        if (!empty($wa[0])) {
            // load first website allowed
            $website->load(intval($wa[0]));
        }
        if (empty($website->id) && $user->permission('websites.edit') == 'false') {
            // NO website allowed AND can't create websites, so auto sign out
            core_session_remove();
            session_start();
            session_write_close();
            header('location: login.php');
            core_terminate();
        }
    }
}
$_SESSION['website_active'] = $website->id;