Example #1
0
function get_image_status($image, $id)
{
    global $ft, $max_photo_width, $rewrite;
    if (empty($image)) {
        // IFDEF: IMAGE_EXIST zwraca pusta wartosc, przechodzimy
        // do warunku ELSE
        $ft->assign(array('IMAGE' => '', 'IMAGE_EXIST' => false, 'IMAGE_NAME' => false));
    } else {
        $img_path = get_root() . '/photos/' . $image;
        if (is_file($img_path)) {
            list($width, $height) = getimagesize($img_path);
            $photo_link = (bool) $rewrite ? 'photo?id=' . $id . '' : 'photo.php?id=' . $id . '';
            // wysoko¶æ, szeroko¶æ obrazka
            $ft->assign(array('WIDTH' => $width, 'HEIGHT' => $height, 'PHOTO_LINK' => $photo_link));
            if ($width > $max_photo_width) {
                $ft->assign(array('UID' => $id, 'IMAGE_NAME' => ''));
            } else {
                $ft->assign('IMAGE_NAME', $image);
            }
            $ft->assign('IMAGE_EXIST', true);
        } else {
            $ft->assign(array('IMAGE_EXIST' => false, 'IMAGE_NAME' => false));
        }
    }
}
Example #2
0
function start_install()
{
    $root = get_root();
    ?>
	<form action="install.php?step=1" method="POST" enctype="multipart/form-data">
	<table width="100%" cellpadding="0" cellspacing="1" border="0">
		<tr class="tcat">
			<td>Installation Check</td>
		</tr>
		<tr class="panel">
			<td>
				PHP Version: <?php 
    echo phpversion();
    if (phpversion() >= 5) {
        echo '<span class="passed">Passed</span>';
    } else {
        echo '<span class="failed">Failed</span>';
        exit;
    }
    ?>
<br />
				SQLite: <?php 
    if (function_exists('sqlite_open')) {
        echo '<span class="passed">Passed</span>';
    } else {
        echo '<span class="failed">Failed</span>';
    }
    ?>
<br />
				MySQL: <?php 
    if (function_exists('mysql_connect')) {
        echo '<span class="passed">Passed</span>';
    } else {
        echo '<span class="failed">Failed</span>';
    }
    ?>
<br />
				PostgreSQL: <?php 
    if (function_exists('pg_connect')) {
        echo '<span class="passed">Passed</span>';
    } else {
        echo '<span class="failed">Failed</span>';
    }
    ?>
<br />
				SPL (Standard PHP Library): <?php 
    if (class_exists('Iterator')) {
        echo '<span class="passed">Passed</span>';
    } else {
        echo '<span class="failed">Not Sure</span>';
    }
    ?>
<br />
			</td>
		</tr>
	</table>
	<table width="100%" cellpadding="0" cellspacing="1" border="0">
		<tr class="tcat">
			<td>Installation Types</td>
		</tr>
		<tr class="panel">
			<td>
				<script language="JavaScript" type="text/javascript">
				//<![CDATA[
				function showInstall(the_select) {
					var install		= document.getElementById('db_info');
					var sqlite		= document.getElementById('sqlite_info');
					var sqlite_dir	= document.getElementById('sqlite_dir');
					if(the_select[the_select.selectedIndex].value == 'mysql' || the_select[the_select.selectedIndex].value == 'pgsql') {
						if(confirm('The MySQL driver is untested and the PostgreSQL driver is generally not working due to my lack of PostgreSQL PHP functions knowlege, are you SURE you want to test drive these babies?')) {
							install.style.display		= 'block';
							sqlite.style.display		= 'none';
							sqlite_dir.style.display	= 'none';
						} else {
							the_select[the_select.selectedIndex] = 0;
							install.style.display		= 'none';
							sqlite.style.display		= 'block';
							sqlite_dir.style.display	= 'block';
						}
					} else {
						install.style.display		= 'none';
						sqlite.style.display		= 'block';
						sqlite_dir.style.display	= 'block';
					} 
				}
				//]]>
				</script>
				<strong>Please choose your installation type</strong>:<br />
				<select name="act" id="act" onChange="return showInstall(this);">
					<option value="1">Install</option>
					<option value="0">Uninstall</option>
				</select>
				<br />
				<strong>Please choose the type of database that you will be installing the software onto</strong>:<br />
				<select name="db" id="db" onChange="showInstall(this)">
					<option value="sqlite">SQLite</option>
					<!--<option value="mysql">MySQL</option>
					<option value="pgsql">PostgreSQL</option>-->
				</select>
				<br />
				<strong>Please choose the Language you would like to install k4 in</strong>:<br />
				<select name="language" id="language">
					<option value="english">English</option>
				</select>
			</td>
		</tr>
		<tr class="tcat">
			<td>Configuration Information</td>
		</tr>
		<tr class="panel">
			<td>
				<fieldset>
				<legend>Legend</legend>
				<span class="waittext">USE ABSOLUTE PATH</span>
				<br />
				<span class="waittext">USE ONLY <strong>/</strong> TO SEPARATE FOLDERS IN PATHS</span>
				<br />
				<strong>Document Root</strong>: Is the <strong>public_html</strong> or <strong>www</strong> folder.<br />
				<strong>Below the document Root</strong>: Is any folder which needs to be put where the Document Root folder is.<br />
				</fieldset>
				<br />
				<div id="sqlite_dir" style="display:block;">
					<strong>SQLite Directory</strong>:<br />
					<span class="minitext">(Below the document root ** USE ABSOLUTE PATH) (** Only needed for SQLite)</span><br />
					<input type="text" name="directory" value="<?php 
    echo $root;
    ?>
sqlite" size="100" /><br /><br />
				</div>
				<strong>Template Directory</strong>:<br />
				<span class="minitext">(Below the document root ** USE ABSOLUTE PATH)</span><br />
				<input type="text" name="path" value="<?php 
    echo $root;
    ?>
templates" size="100" /><br /><br />
				<strong>Current Template Folder</strong>:<br />
				<span class="minitext">(Directory within the 'Template Directory' where your templates are stored. If you're not sure, leave it as 'Descent' ** USE ABSOLUTE PATH)</span><br />
				<input type="text" name="folder" value="Descent" size="100" /><br /><br />
				<strong>Image Folder</strong>:<br />
				<span class="minitext">(The Image folder, it is the current image set you are using. If you are not sure, leave it as 'Descent' ** USE ABSOLUTE PATH)</span><br />
				<input type="text" name="imgfolder" value="Descent" size="100" /><br /><br />
				<strong>Direct Path to Forum Base</strong>:<br />
				<span class="minitext">(This will either be the document root or a folder in it, make sure that you adjust this ** USE ABSOLUTE PATH)</span><br />
				<input type="text" name="forumurl" value="<?php 
    echo $root;
    ?>
public_html" size="100" /><br /><br />
				<strong>Direct Path to Configuration Folder</strong>:<br />
				<span class="minitext">(This is in the 'framework' folder below the document root, this should end in '/framework/config' ** USE ABSOLUTE PATH)</span><br />
				<input type="text" name="configurl" value="<?php 
    echo $root;
    ?>
framework/config" size="100" />
			</td>
		</tr>
		<tbody id="db_info" style="display:none;">
			<tr class="tcat">
				<td>MySQL or PostgreSQL Configuration</td>
			</tr>
			<tr class="panel">
				<td>
					<strong>Database Name</strong>:<br /> <input type="text" name="db_name" id="database name" /><br />
					<strong>Database User Name</strong>:<br /> <input type="text" name="db_user" id="database user name" /><br />
					<strong>Database Password</strong>:<br /> <input type="text" name="db_pass" id="database password" /><br />
					<strong>Database Server</strong>:<br /> <input type="text" name="db_host" id="database server" value="localhost" />
				</td>
			</tr>
		</tbody>
		<tbody id="sqlite_info" style="display:block;" width="100%">
			<tr class="tcat">
				<td width="100%">SQLite Settings</td>
			</tr>
			<tr class="panel">
				<td>
					<strong>Database Name</strong>:<br />
					<input type="text" name="dbname" value="k4_forum" size="40" /><br />
					<strong>Database File</strong>:<br />
					<input type="text" name="database" value="k4_forum.sqlite" size="40" /><br />
				</td>
			</tr>
		</tbody>
		<tr class="tcat">
			<td>FTP Settings</td>
		</tr>
		<tr class="panel">
			<td>
				<strong>Use FTP</strong>:<br />
				<select name="use_ftp" id="use_ftp">
					<option value="true">Yes</option>
					<option value="false">No</option>
				</select><br />
				<strong>FTP Username</strong>:<br />
				<input type="text" name="username" value="" size="40" /><br />
				<strong>FTP Password</strong>:<br />
				<input type="password" name="password" value="" size="40" /><br />
				<strong>FTP Server</strong>:<br />
				<input type="text" name="server" value="" size="40" /><br />
			</td>
		</tr>
		<tr class="tcat">
			<td>Administrator Settings</td>
		</tr>
		<tr class="panel">
			<td>
				<strong>Username</strong>:<br />
				<input type="text" name="admin_username" value="" size="16" maxlength="16" /><br />
				<strong>Email</strong>:<br />
				<input type="text" name="admin_email" value="" size="40" /><br />
				<strong>Password</strong>:<br />
				<input type="password" name="admin_password" value="" size="16" maxlength="16" /><br />
			</td>
		</tr>
		<tr class="tcat">
			<td>Forum Settings</td>
		</tr>
		<tr class="panel">
			<td>
				<strong>Forum Name (The name of your Bulletin Board)</strong>:<br />
				<input type="text" name="forum_name" value="" size="40" /><br />
				<strong>Short Forum Description (The BB's description)</strong>:<br />
				<input type="text" name="forum_description" value="" size="40" /><br />
			</td>
		</tr>
		<tr class="tcat">
			<td>Site Settings</td>
		</tr>
		<tr class="panel">
			<td>
				<strong>Webmasters Email</strong>:<br />
				<input type="text" name="webmaster_email" value="" size="40" /><br />
				<strong>Contact Email</strong>:<br />
				<input type="text" name="contact_email" value="" size="40" /><br />
			</td>
		</tr>
		<tr class="tcat">
			<td>
				<input type="submit" value="Install it Baby!" onClick="javascript:alert('The page will automatically refresh itself several times. Don\'t be alarmed if you see this.');" />
			</td>
		</tr>
	</table>
	</form>
	<?php 
}
 *
 * Copyright (C) 2004-2005 Core Dev Team (more info: docs/AUTHORS).
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation; version 2 only.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 */
require_once 'inc/i18n.php';
require_once 'inc/common_lib.php';
define('PATH_TO_CLASSES', get_root() . '/administration/classes');
require PATH_TO_CLASSES . '/cls_db_mysql.php';
// dodawanie pliku konfigurujacego bibliotekê baz danych
require 'administration/inc/config.php';
$db = new DB_SQL();
$sql = new DB_SQL();
$query = sprintf("\n    CREATE TABLE IF NOT EXIST \n    %1\$s (\n        id int(7) NOT NULL auto_increment, \n        news_id int(7) NOT NULL default '0', \n        category_id int(7) NOT NULL default '0', \n        PRIMARY KEY (id), \n        KEY news_id (news_id, category_id)", TABLE_ASSIGN2CAT);
$db->query($query);
$db->next_record();
$query = sprintf("\n    SELECT \n        id, c_id \n    FROM \n        %1\$s", TABLE_MAIN);
$db->query($query);
while ($db->next_record()) {
    $id = $db->f('id');
    $c_id = $db->f('c_id');
    $query = sprintf("\n        INSERT INTO \n            %1\$s \n        VALUES('', '%2\$d', '%3\$d')", TABLE_ASSIGN2CAT, $id, $c_id);
    $sql->query($query);
Example #4
0
     return $pages_sort > $b ? -1 : 1;
 }
 // sortujemy tablice w porzadku odwrotnym
 uksort($pages_sort, "cmp");
 uksort($pages_id, "cmp");
 // parsujemy menu na podstawie tablicy
 foreach ($pages_sort as $pid => $ptitle) {
     $ft->assign(array('PAGE_LINK' => $CoreRewrite->permanent_page($pages_id[$pid], $rewrite), 'PAGE_TITLE' => $ptitle));
     $ft->parse('BREADCRUMB_ROW', ".breadcrumb_row");
 }
 if (empty($image)) {
     // IFDEF: IMAGE_EXIST zwraca pusta wartosc, przechodzimy
     // do warunku ELSE
     $ft->assign(array('IMAGE' => '', 'IMAGE_EXIST' => false, 'IMAGE_NAME' => false));
 } else {
     $img_path = get_root() . '/photos/' . $image;
     if (is_file($img_path)) {
         list($width, $height) = getimagesize($img_path);
         if ((bool) $rewrite) {
             $photo_link = 'photo?p=5&amp;id=' . $id;
         } else {
             $photo_link = 'photo.php?p=5&amp;id=' . $id;
         }
         // wysoko¶æ, szeroko¶æ obrazka
         $ft->assign(array('WIDTH' => $width, 'HEIGHT' => $height, 'PHOTO_LINK' => $photo_link));
         if ($width > $max_photo_width) {
             $ft->assign(array('UID' => $id, 'IMAGE_NAME' => ''));
         } else {
             $ft->assign('IMAGE_NAME', $image);
         }
         $ft->assign('IMAGE_EXIST', true);
     $text = $_POST['text'];
     $tpl = '../templates/' . $lang . '/main/tpl/' . $template . '.tpl';
     $text = str_replace('{NOTE_ROWS}', '{ROWS}', $text);
     if (is_writeable($tpl)) {
         $fp = fopen($tpl, 'w+');
         fwrite($fp, stripslashes($text));
         fclose($fp);
         $ft->assign('WRITE_ERROR', $i18n['edit_templates'][0]);
     } else {
         $ft->assign('WRITE_ERROR', $i18n['edit_templates'][1]);
     }
     break;
 case "show":
     $ft->define('form_templateedit', "form_templateedit.tpl");
     $tpl = empty($_GET['tpl']) ? '' : $_GET['tpl'];
     $template = sprintf('%s/templates/%s/main/tpl/%s.tpl', get_root(), $lang, '/main/tpl/', $tpl);
     if (!is_writeable($template)) {
         $ft->assign('WRITE_ERROR', $i18n['edit_templates'][3]);
     } else {
         $ft->assign('WRITE_ERROR', '');
     }
     $file_content = @file_get_contents($template);
     if ($file_content) {
         // Sztywna obs³uga </textarea> w szablonie, aby by³
         // on wy¶wietlany poprawnie w polu formularza
         $file_content = str_replace('</textarea>', '&lt;/textarea>', $file_content);
         $file_content = str_replace('{ROWS}', '{NOTE_ROWS}', $file_content);
         // Zabronimy FT ukrywanie nie przydzielonych zmiennych
         // dziêki temu widaæ je przy edycji danego szablonu
         $ft->strict();
         $ft->assign(array('FILE_CONTENT' => $file_content, 'TEMPLATE' => "/ " . $tpl . ".tpl", 'TEMPLATE_NAME' => $tpl));
Example #6
0
/**
 * startup
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Startup
 * @author Henry Ruhs
 */
function startup()
{
    /* ini set */
    if (function_exists('ini_set')) {
        if (error_reporting() == 0) {
            ini_set('display_startup_errors', 0);
            ini_set('display_errors', 0);
        }
        ini_set('session.use_trans_sid', 0);
        ini_set('url_rewriter.tags', 0);
    }
    /* session start */
    session_start();
    /* define general */
    define('FILE', get_file());
    define('ROOT', get_root());
    define('TOKEN', get_token());
    /* prefix and salt */
    define('PREFIX', Redaxscript\Config::get('prefix'));
    define('SALT', Redaxscript\Config::get('salt'));
    /* database connect */
    database_connect(Redaxscript\Config::get('host'), Redaxscript\Config::get('name'), Redaxscript\Config::get('user'), Redaxscript\Config::get('password'));
    /* define session */
    define('DB_CONNECTED', $_SESSION[ROOT . '/db_connected']);
    define('DB_ERROR', $_SESSION[ROOT . '/db_error']);
    define('LOGGED_IN', $_SESSION[ROOT . '/logged_in']);
    define('ATTACK_BLOCKED', $_SESSION[ROOT . '/attack_blocked']);
    /* setup charset */
    if (function_exists('ini_set')) {
        ini_set('default_charset', s('charset'));
    }
    /* define parameter */
    define('FIRST_PARAMETER', get_parameter('first'));
    define('FIRST_SUB_PARAMETER', get_parameter('first_sub'));
    define('SECOND_PARAMETER', get_parameter('second'));
    define('SECOND_SUB_PARAMETER', get_parameter('second_sub'));
    define('THIRD_PARAMETER', get_parameter('third'));
    define('THIRD_SUB_PARAMETER', get_parameter('third_sub'));
    if (LOGGED_IN == TOKEN && FIRST_PARAMETER == 'admin') {
        define('ADMIN_PARAMETER', get_parameter('admin'));
        define('TABLE_PARAMETER', get_parameter('table'));
        define('ID_PARAMETER', get_parameter('id'));
        define('ALIAS_PARAMETER', get_parameter('alias'));
    } else {
        undefine(array('ADMIN_PARAMETER', 'TABLE_PARAMETER', 'ID_PARAMETER', 'ALIAS_PARAMETER'));
    }
    define('LAST_PARAMETER', get_parameter('last'));
    define('LAST_SUB_PARAMETER', get_parameter('last_sub'));
    define('TOKEN_PARAMETER', get_parameter('token'));
    /* define routes */
    define('FULL_ROUTE', get_route(0));
    define('FULL_TOP_ROUTE', get_route(1));
    if (function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules()) == '' || file_exists('.htaccess') == '' || FILE == 'install.php') {
        define('REWRITE_ROUTE', '?p=');
        define('LANGUAGE_ROUTE', '&amp;l=');
        define('TEMPLATE_ROUTE', '&amp;t=');
    } else {
        define('REWRITE_ROUTE', '');
        define('LANGUAGE_ROUTE', '.');
        define('TEMPLATE_ROUTE', '.');
    }
    /* redirect to install */
    if (DB_CONNECTED == 0 && file_exists('install.php')) {
        define('REFRESH_ROUTE', ROOT . '/install.php');
    }
    /* define tables */
    if (FULL_ROUTE == '' || FIRST_PARAMETER == 'admin' && SECOND_PARAMETER == '') {
        /* check for homepage */
        if (s('homepage') > 0) {
            $table = 'articles';
            $id = s('homepage');
        } else {
            $table = 'categories';
            $id = 0;
            /* check order */
            if (s('order') == 'asc') {
                $function = 'min';
            } else {
                if (s('order') == 'desc') {
                    $function = 'max';
                }
            }
            $rank = query_plumb('rank', $table, $function);
            /* if category is published */
            if ($rank) {
                $status = retrieve('status', $table, 'rank', $rank);
                if ($status == 1) {
                    $id = retrieve('id', $table, 'rank', $rank);
                }
            }
        }
        define('FIRST_TABLE', $table);
        define('SECOND_TABLE', '');
        define('THIRD_TABLE', '');
        define('LAST_TABLE', $table);
    } else {
        if (FIRST_PARAMETER) {
            define('FIRST_TABLE', query_table(FIRST_PARAMETER));
        } else {
            define('FIRST_TABLE', '');
        }
        if (FIRST_TABLE) {
            define('SECOND_TABLE', query_table(SECOND_PARAMETER));
        } else {
            define('SECOND_TABLE', '');
        }
        if (SECOND_TABLE) {
            define('THIRD_TABLE', query_table(THIRD_PARAMETER));
        } else {
            define('THIRD_TABLE', '');
        }
        if (LAST_PARAMETER) {
            define('LAST_TABLE', query_table(LAST_PARAMETER));
        } else {
            define('LAST_TABLE', '');
        }
        if (LAST_TABLE) {
            $id = retrieve('id', LAST_TABLE, 'alias', LAST_PARAMETER);
        }
    }
    /* define ids */
    if (LAST_TABLE == 'categories') {
        define('CATEGORY', $id);
        define('ARTICLE', '');
        define('LAST_ID', $id);
    } else {
        if (LAST_TABLE == 'articles') {
            define('CATEGORY', '');
            define('ARTICLE', $id);
            define('LAST_ID', $id);
        } else {
            undefine(array('CATEGORY', 'ARTICLE', 'LAST_ID'));
        }
    }
    /* define content error */
    $aliasValidator = new Redaxscript\Validator\Alias();
    if (LAST_ID == '' && $aliasValidator->validate(FIRST_PARAMETER, Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\Validator::FAILED) {
        define('CONTENT_ERROR', 1);
    } else {
        define('CONTENT_ERROR', 0);
    }
    /* define user */
    define('MY_IP', get_user_ip());
    define('MY_BROWSER', get_user_agent(0));
    define('MY_BROWSER_VERSION', get_user_agent(1));
    define('MY_ENGINE', get_user_agent(2));
    define('MY_MOBILE', get_user_agent(4));
    define('MY_TABLET', get_user_agent(5));
    /* if mobile or tablet */
    if (MY_MOBILE || MY_TABLET) {
        define('MY_DESKTOP', '');
    } else {
        define('MY_DESKTOP', get_user_agent(3));
    }
    /* if logged in */
    if (LOGGED_IN == TOKEN) {
        define('MY_ID', $_SESSION[ROOT . '/my_id']);
        define('MY_NAME', $_SESSION[ROOT . '/my_name']);
        define('MY_USER', $_SESSION[ROOT . '/my_user']);
        define('MY_EMAIL', $_SESSION[ROOT . '/my_email']);
        define('MY_GROUPS', $_SESSION[ROOT . '/my_groups']);
        /* define access */
        $access_array = array('categories', 'articles', 'extras', 'comments', 'groups', 'users');
        foreach ($access_array as $value) {
            define(strtoupper($value) . '_NEW', $_SESSION[ROOT . '/' . $value . '_new']);
            define(strtoupper($value) . '_EDIT', $_SESSION[ROOT . '/' . $value . '_edit']);
            define(strtoupper($value) . '_DELETE', $_SESSION[ROOT . '/' . $value . '_delete']);
            if (TABLE_PARAMETER == 'users' && ID_PARAMETER == MY_ID && $value == 'users') {
                define('USERS_EXCEPTION', 1);
            } else {
                if ($value == 'users') {
                    define('USERS_EXCEPTION', 0);
                }
            }
        }
        define('MODULES_INSTALL', $_SESSION[ROOT . '/modules_install']);
        define('MODULES_EDIT', $_SESSION[ROOT . '/modules_edit']);
        define('MODULES_UNINSTALL', $_SESSION[ROOT . '/modules_uninstall']);
        define('SETTINGS_EDIT', $_SESSION[ROOT . '/settings_edit']);
        define('FILTER', $_SESSION[ROOT . '/filter']);
    } else {
        define('FILTER', 1);
    }
    /* define table access */
    define('TABLE_NEW', constant(strtoupper(TABLE_PARAMETER) . '_NEW'));
    define('TABLE_INSTALL', constant(strtoupper(TABLE_PARAMETER) . '_INSTALL'));
    define('TABLE_EDIT', constant(strtoupper(TABLE_PARAMETER) . '_EDIT'));
    define('TABLE_DELETE', constant(strtoupper(TABLE_PARAMETER) . '_DELETE'));
    define('TABLE_UNINSTALL', constant(strtoupper(TABLE_PARAMETER) . '_UNINSTALL'));
    /* define time */
    define('GMDATE', gmdate('D, d M Y H:i:s') . ' GMT');
    define('GMDATE_PLUS_WEEK', gmdate('D, d M Y H:i:s', strtotime('+1 week')) . ' GMT');
    define('GMDATE_PLUS_YEAR', gmdate('D, d M Y H:i:s', strtotime('+1 year')) . ' GMT');
    define('NOW', date('Y-m-d H:i:s'));
    define('DELAY', date('Y-m-d H:i:s', strtotime('+1 minute')));
    define('TODAY', date('Y-m-d'));
    /* future update */
    define('UPDATE', $_SESSION[ROOT . '/update']);
    if (UPDATE == '') {
        future_update('articles');
        future_update('extras');
        $_SESSION[ROOT . '/update'] = DELAY;
    } else {
        if (UPDATE < NOW) {
            $_SESSION[ROOT . '/update'] = '';
        }
    }
}
 * $components includes  `index.php' on the end, which we want
 * to strip off.  So we subtract two. */
$this_depth = count($components) - 2;
echo "<!-- depth = {$this_depth} -->\n";
/* get rid of first one (empty string) */
for ($i = 0; $i <= $this_depth; $i++) {
    $dir_name[$i] = trim($components[$i + 1]);
}
/*    echo "<div class=menu-title>\n";
    echo "<br>\n";
    echo '<center><font size="+2"><b>';
    echo 'Navigation Menu</b></font></center><br>', "\n";
    echo "</div><br>\n";
*/
/* figure out where our actual (ie, filesystem) start point is */
$my_root = get_root($_SERVER["SCRIPT_FILENAME"], $this_depth);
/* figure out where the virtual (ie, HTTP request path) start is */
$vstart = sprintf("/%s", $dir_name[0]);
menus_from_top($dir_name, 1, $this_depth, $my_root, $vstart, $_SERVER["QUERY_STRING"], "no");
/* will we be in a <ul>?       */
//    echo "<br>\n";
if (file_exists("./printer.php")) {
    if ($_SERVER["QUERY_STRING"] != "") {
        echo '<a href="', "./printer.php?", $_SERVER["QUERY_STRING"], '">';
    } else {
        echo '<a href="', "./printer.php", '">';
    }
    echo "<img \n";
    echo ' style="float: left;" ';
    echo ' src="/~kilroy/MENU_FILES/images/printer2.png" alt="" >';
    echo '<i>printer-<br>friendly<br>version</i>';
Example #8
0
 } else {
     $ft->assign(array('PAGE_PREVIEW' => false));
 }
 // submit formularza
 if (!empty($post)) {
     $query = sprintf("\r\n              UPDATE \r\n                  %1\$s \r\n              SET \r\n                  title           = '%2\$s', \r\n                  text            = '%3\$s', \r\n                  published       = '%4\$s', \r\n                  assigned_tpl    = '%5\$s' \r\n              WHERE \r\n                  id = '%6\$d'", TABLE_PAGES, $_POST['title'], parse_markers($_POST['text'], 1), $_POST['published'], $_POST['template_name'], $_GET['id']);
     $db->query($query);
     // usuwamy istniej±ce zdjêcie
     if (isset($_POST['delete_image']) && $_POST['delete_image'] == 1) {
         $query = sprintf("\r\n                  UPDATE \r\n                      %1\$s \r\n                  SET \r\n                      image = '' \r\n                  WHERE \r\n                      id = '%2\$d'", TABLE_PAGES, $_GET['id']);
         $db->query($query);
     }
     // dodajemy zdjêcie do wpisu
     if (!empty($_FILES['file']['name'])) {
         $up = new upload();
         $upload_dir = get_root() . '/photos';
         // upload pliku na serwer.
         $file = $up->upload_file($upload_dir, 'file', true, true, 0, "jpg|jpeg|gif");
         if ($file == false) {
             echo $up->error;
         } else {
             $query = sprintf("\r\n                      UPDATE \r\n                          %1\$s \r\n                      SET \r\n                          image = '%2\$s' \r\n                      WHERE \r\n                          id = '%3\$d'", TABLE_PAGES, $file, $_GET['id']);
             $db->query($query);
         }
     }
     $ft->assign('CONFIRM', $i18n['edit_page'][0]);
     $ft->parse('ROWS', '.result_note');
     // wyswietlanie noty
 } else {
     $query = sprintf("\r\n              SELECT * FROM \r\n                  %1\$s \r\n              WHERE \r\n                  id = '%2\$d'", TABLE_PAGES, $_GET['id']);
     $db->query($query);
Example #9
0
function traverse($name)
{
    global $anc;
    global $names;
    global $node_stack;
    global $edge_string;
    global $node_string;
    $stack = array();
    $root_id = get_root($name);
    $anc[$root_id] = $root_id;
    //echo $root_id . "\n";
    // start by getting children of root
    $stack[] = array($root_id);
    $stack_counter = 0;
    $done = false;
    while (!$done) {
        $node = $stack[$stack_counter][0];
        pre_visit($node);
        $children = get_children($node);
        if (count($children) > 0) {
            // We have children so add them to stack
            $ancestor = $node;
            $stack[] = $children;
            $stack_counter++;
        } else {
            // No children, so start to unwind stack
            $node_stack[$node]->weight = 1;
            // leaf
            $node_stack[$node]->depth = 0;
            // leaf
            post_visit($node, $stack, $stack_counter);
            // finished with this node
            array_shift($stack[$stack_counter]);
            // go back down tree
            while ($stack_counter > 0 && count($stack[$stack_counter]) == 0) {
                array_pop($stack);
                $stack_counter--;
                $node = $stack[$stack_counter][0];
                post_visit($node, $stack, $stack_counter);
                array_shift($stack[$stack_counter]);
            }
            if ($stack_counter == 0) {
                $done = true;
                echo "graph\n[directed 1\n";
                echo $node_string;
                echo $edge_string;
                echo "]\n";
            }
        }
    }
}
Example #10
0
function get_path($path, $with_domain = false)
{
    return get_root($with_domain) . $path;
}
Example #11
0
function content_image_tag($file, $options = array())
{
    $base = $file[0] == '/' ? '' : get_root() . CONTENT_BASE . '/';
    $file = $base . $file;
    return image_tag($file, $options);
}
Example #12
0
/**
 * Get Tree Root ID of a Child from dbquery_tree() result
 * @param array $index
 * @param       $child_id
 * @return int
 */
function get_root(array $index, $child_id)
{
    foreach ($index as $key => $array) {
        if (in_array($child_id, $array)) {
            if ($key == 0) {
                return $child_id;
            } else {
                return (int) get_root($index, $key);
            }
        }
    }
}
Example #13
0
function redirect($path)
{
    $app = get_app();
    $app->redirect(get_root() . $path);
}