Code Search for Developers
 
 
  

header.php from freePBX at Krugle


Show header.php syntax highlighted

<?php /* $Id: header.php 4993 2007-09-02 22:07:42Z gregmac $ */
//Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca)
//
//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; either version 2
//of the License, or (at your option) any later version.
//
//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.

@header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); 
@header('Expires: Sat, 01 Jan 2000 00:00:00 GMT'); 
@header('Cache-Control: post-check=0, pre-check=0',false); 
@header('Pragma: no-cache'); 
//session_cache_limiter('public, no-store'); 

/** Loads a view (from the views/ directory) with a number of named parameters created as local variables.
 * @param  string   The name of the view.
 * @param  array    The parameters to pass. Note that the key will be turned into a variable name for use by the view.
 *                  For example, passing array('foo'=>'bar'); will create a variable $foo that can be used by
 *                  the code in the view.
 */
function loadview($viewname, $parameters = false) {
	ob_start();
	showview($viewname, $parameters);
	$contents = ob_get_contents();
	ob_end_clean();
	return $contents;
}
/** Outputs the contents of a view.
 * @param  string   The name of the view.
 * @param  array    The parameters to pass. Note that the key will be turned into a variable name for use by the view.
 *                  For example, passing array('foo'=>'bar'); will create a variable $foo that can be used by
 *                  the code in the view.
 */
function showview($viewname, $parameters = false) {
	if (is_array($parameters)) {
		extract($parameters);
	}
	
	$viewname = str_replace('..','.',$viewname); // protect against going to subdirectories
	if (file_exists('views/'.$viewname.'.php')) {
		include('views/'.$viewname.'.php');
	}
}

//get the current file name
$currentFile = $_SERVER["PHP_SELF"];
$parts = explode('/', $currentFile);
//header('Content-type: text/html; charset=utf-8');
$currentFile = $parts[count($parts) - 1];
//todo: can this be removed? what is it used for?


// Emulate gettext extension functions if gettext is not available
if (!function_exists('_')) {
	function _($str) {
		return $str;
	}
}
if (!function_exists('gettext')) {
	function gettext($message) {
		return $message;
	}
}
if (!function_exists('dgettext')) {
	function dgettext($domain, $message) {
		return $message;
	}
}

// setup locale
function set_language() {
	if (extension_loaded('gettext')) {
		if (isset($_COOKIE['lang'])) {
			setlocale(LC_ALL,  $_COOKIE['lang']);
			putenv("LANGUAGE=".$_COOKIE['lang']);
		} else {
			setlocale(LC_ALL,  'en_US');
		}
		bindtextdomain('amp','./i18n');
		bind_textdomain_codeset('amp', 'utf8');
		textdomain('amp');
	}
}
set_language();


// systems running on sqlite3 (or pgsql) this function is not available
// instead of changing the whole code, lets hack our own version of this function.
// according to the documentation found here: http://il2.php.net/mysql_real_escape_string
// this shold be enough.
// Fixes ticket: http://freepbx.org/trac/ticket/1963
if (!function_exists('mysql_real_escape_string')) {
	function mysql_real_escape_string($str) {
		$str = str_replace( "\x00", "\\" . "\x00", $str );
		$str = str_replace( "\x1a", "\\" . "\x1a", $str );
		$str = str_replace( "\n" , "\\". "\n"    , $str );
		$str = str_replace( "\r" , "\\". "\r"    , $str );
		$str = str_replace( "\\" , "\\". "\\"    , $str );
		$str = str_replace( "'" , "\\". "'"      , $str );
		$str = str_replace( '"' , "\\". '"'      , $str );
		return $str;
	}
}

// include base functions
require_once('functions.inc.php');
require_once('common/php-asmanager.php');

// get settings
$amp_conf	= parse_amportal_conf("/etc/amportal.conf");
$asterisk_conf  = parse_asterisk_conf($amp_conf["ASTETCDIR"]."/asterisk.conf");
$astman		= new AGI_AsteriskManager();

// attempt to connect to asterisk manager proxy
if (!isset($amp_conf["ASTMANAGERPROXYPORT"]) || !$res = $astman->connect("127.0.0.1:".$amp_conf["ASTMANAGERPROXYPORT"], $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"])) {
	// attempt to connect directly to asterisk, if no proxy or if proxy failed
	if (!$res = $astman->connect("127.0.0.1:".$amp_conf["ASTMANAGERPORT"], $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"])) {
		// couldn't connect at all
		unset( $astman );
	}
}
// connect to database
require_once('common/db_connect.php'); //PEAR must be installed

// default password check
$nt = notifications::create($db);
if ($amp_conf['AMPMGRPASS'] == $amp_conf_defaults['AMPMGRPASS'][1]) {
	$nt->add_warning('core', 'AMPMGRPASS', _("Default Asterisk Manager Password Used"), _("You are using the default Asterisk Manager password that is widely known, you should set a secure password"));
} else {
	$nt->delete('core', 'AMPMGRPASS');
}

// always run a session
@session_start();

// do authentication - header_auth exits if unauthorized
include('header_auth.php');

?>




See more files for this project here

freePBX

FreePBX is the most powerful GUI (Web Based) configuration tool for Asterisk. It provides everything that a standard legacy phone system can, plus a huge amount of new features. All documentation and information is avalable from http://www.freepbx.org

Project homepage: http://sourceforge.net/projects/amportal
Programming language(s): PHP,Shell Script,SQL
License: other

  cdr/
    css/
      images/
        corner-bl.png
        corner-br.png
        corner-tl.png
        corner-tr.png
      content.css
      docbook.css
      layout.css
    images/
      asterisk.gif
      btn_top_12x12.gif
      button-search.gif
      call-compare.png
      call-logs.png
      excel.png
      fleche-d.gif
      fleche-g.gif
      header-download.png
      header-faq.png
      header-projects.png
      header-search.png
      icon_down_12x12.GIF
      icon_up_12x12.GIF
      jukebox_ti60.gif
      pdf.png
      print.css
      printable.png
      sidenav-selected.gif
      spacer.gif
      th_call-compare.png
      th_call-logs.png
    jpgraph_lib/
      imgdata_balls.inc
      imgdata_bevels.inc
      imgdata_diamonds.inc
      imgdata_pushpins.inc
      imgdata_squares.inc
      imgdata_stars.inc
      jpg-config.inc
      jpgraph.php
      jpgraph_antispam-digits.php
      jpgraph_antispam.php
      jpgraph_bar.php
      jpgraph_canvas.php
      jpgraph_canvtools.php
      jpgraph_error.php
      jpgraph_flags.php
      jpgraph_gantt.php
      jpgraph_gb2312.php
      jpgraph_gradient.php
      jpgraph_iconplot.php
      jpgraph_imgtrans.php
      jpgraph_line.php
      jpgraph_log.php
      jpgraph_pie.php
      jpgraph_pie3d.php
      jpgraph_plotband.php
      jpgraph_plotmark.inc
      jpgraph_polar.php
      jpgraph_radar.php
      jpgraph_regstat.php
      jpgraph_scatter.php
      jpgraph_stock.php
    lib/
      DB-modules/
      font/
      Class.Table.php
      defines.php
      fpdf.php
      iam_csvdump.php
    CHANGELOG.txt
    about.php
    call-comp.php
    call-daily-load.php
    call-last-month.php
    call-log.php
    cdr.php
    counter.txt
    encrypt.js
    export_csv.php
    export_pdf.php
    graph_hourdetail.php
    graph_pie.php
    graph_stat.php
    graph_statbar.php
    info.txt
  common/
    db_connect.php
    ie.css
    interface.dim.js
    jquery-1.1.3.1.js
    jquery.dimensions.js
    jquery.tabs-2.7.4.js
    json.inc.php
    libfreepbx.javascripts.js
    mainstyle-alternative.css
    mainstyle.css
    php-asmanager.php
    script.js.php
    script.legacy.js
    tabber-minimized.js
  i18n/
    de_DE/
    es_ES/
    fr_FR/
    he_IL/
    it_IT/
    pt_PT/
    ru_RU/
    readme.txt
  images/
    accept.png
    amp.png
    arrow_rotate_clockwise.png
    blank.gif
    cancel.png
    category1.png
    database_gear.png
    delete.gif
    freepbx.png
    freepbx_large.png
    freepbx_small.png
    header-back.png
    loading.gif
    logo.png
    modules-current1.png
    modules-hover1.png
    modules1.png
    scrolldown.gif
    scrollup.gif
    shadow-corner.png
    shadow-side-background.png
    shadow-side.png
    shadow-top.png
    tab-first-current.png
    tab-first.png
    tab-hover.png
    tab-select.png
    tab.png
    trash.png
    watermark.png
  modules/
    _cache/
    .htaccess
    import.sh
    modlist.sh
    remove.sh
    status.sh
    update.sh
  views/
    freepbx.php
    freepbx_admin.php
    freepbx_reload.php
    freepbx_reloadbar.php
    loggedout.php
    menuitem_disabled.php
    noaccess.php
    panel.php
    reports.php
    unauthorized.php
    welcome.php
    welcome_nomanager.php
  components.class.php
  config.php
  extensions.class.php
  favicon.ico
  featurecodes.class.php
  functions.inc.php
  header.php
  header_auth.php
  index.php
  page.modules.php
  panel.php
  reports.php