浏览代码

create bdr

blackc2004 9 年之前
父节点
当前提交
2dbc6b44be
共有 6 个文件被更改,包括 546 次插入0 次删除
  1. 32 0
      bdr/app_config.php
  2. 197 0
      bdr/app_languages.php
  3. 21 0
      bdr/app_menu.php
  4. 184 0
      bdr/bdr.php
  5. 62 0
      bdr/bdr_delete.php
  6. 50 0
      bdr/root.php

+ 32 - 0
bdr/app_config.php

@@ -0,0 +1,32 @@
+<?php
+
+	//application details
+		$apps[$x]['name'] = "BDR Management";
+		$apps[$x]['uuid'] = "399cd584-e2eb-4993-afa9-4292593600a3";
+		$apps[$x]['category'] = "Switch";
+		$apps[$x]['subcategory'] = "";
+		$apps[$x]['version'] = "";
+		$apps[$x]['license'] = "Mozilla Public License 1.1";
+		$apps[$x]['url'] = "http://www.fusionpbx.com";
+		$apps[$x]['description']['en-us'] = "A tool to manage BDR.";
+		$apps[$x]['description']['es-cl'] = "";
+		$apps[$x]['description']['de-de'] = "";
+		$apps[$x]['description']['de-ch'] = "";
+		$apps[$x]['description']['de-at'] = "";
+		$apps[$x]['description']['fr-fr'] = "";
+		$apps[$x]['description']['fr-ca'] = "";
+		$apps[$x]['description']['fr-ch'] = "";
+		$apps[$x]['description']['pt-pt'] = "";
+		$apps[$x]['description']['pt-br'] = "";
+
+	//permission details
+		$y = 0;
+		$apps[$x]['permissions'][$y]['name'] = "bdr_view";
+		$apps[$x]['permissions'][$y]['menu']['uuid'] = "7ed61deb-14dd-49f6-940d-6cf2023f8481";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "bdr_delete";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+
+?>

+ 197 - 0
bdr/app_languages.php

@@ -0,0 +1,197 @@
+<?php
+$text['label-update-complete']['en-us'] = "Update Complete";
+$text['label-update-complete']['es-cl'] = "Actualización Completa";
+$text['label-update-complete']['pt-pt'] = "Actualização Efectuada";
+$text['label-update-complete']['fr-fr'] = "Mise à jour effectuée";
+$text['label-update-complete']['nl-nl'] = "";
+$text['label-update-complete']['pt-br'] = "Atualização efetuada";
+$text['label-update-complete']['pl'] = "Zaktualizowano poprawnie";
+$text['label-update-complete']['sv-se'] = "Uppdatering Klar";
+$text['label-update-complete']['uk'] = "Оновлено";
+$text['label-update-complete']['ro'] = "Actualizare completă";
+$text['label-update-complete']['de-at'] = "Aktualisierung abgeschlossen";
+$text['label-update-complete']['ar-eg'] = "اكتمال التحديث";
+$text['label-update-complete']['he'] = "העדכון הושלם";
+
+$text['label-true']['en-us'] = "True";
+$text['label-true']['es-cl'] = "Verdadero";
+$text['label-true']['pt-pt'] = "Sim";
+$text['label-true']['fr-fr'] = "Oui";
+$text['label-true']['nl-nl'] = "";
+$text['label-true']['pt-br'] = "Sim";
+$text['label-true']['pl'] = "Tak";
+$text['label-true']['sv-se'] = "Sann";
+$text['label-true']['uk'] = "Так";
+$text['label-true']['ro'] = "";
+$text['label-true']['de-at'] = "Ein";
+$text['label-true']['ar-eg'] = "صحيح";
+$text['label-true']['he'] = "חיובי";
+
+$text['label-reject']['en-us'] = "Reject";
+$text['label-reject']['es-cl'] = "Rechazar";
+$text['label-reject']['pt-pt'] = "Rejeitar";
+$text['label-reject']['fr-fr'] = "Rejeter";
+$text['label-reject']['nl-nl'] = "";
+$text['label-reject']['pt-br'] = "Rejeitar";
+$text['label-reject']['pl'] = "Odrzuć ";
+$text['label-reject']['sv-se'] = "Neka";
+$text['label-reject']['uk'] = "Відхилити";
+$text['label-reject']['ro'] = "";
+$text['label-reject']['de-at'] = "Zurückweisen";
+$text['label-reject']['ar-eg'] = "رفض";
+$text['label-reject']['he'] = "לדחות";
+
+$text['label-false']['en-us'] = "False";
+$text['label-false']['es-cl'] = "falso";
+$text['label-false']['pt-pt'] = "Não";
+$text['label-false']['fr-fr'] = "Non";
+$text['label-false']['nl-nl'] = "";
+$text['label-false']['pt-br'] = "Não";
+$text['label-false']['pl'] = "Nie";
+$text['label-false']['sv-se'] = "Falsk";
+$text['label-false']['uk'] = "Ні";
+$text['label-false']['ro'] = "";
+$text['label-false']['de-at'] = "Aus";
+$text['label-false']['ar-eg'] = "";
+$text['label-false']['he'] = "";
+
+$text['label-enabled']['en-us'] = "Enabled";
+$text['label-enabled']['es-cl'] = "Activo";
+$text['label-enabled']['pt-pt'] = "Activado";
+$text['label-enabled']['fr-fr'] = "Actif";
+$text['label-enabled']['nl-nl'] = "";
+$text['label-enabled']['pt-br'] = "Habilitado";
+$text['label-enabled']['pl'] = "Włączony";
+$text['label-enabled']['sv-se'] = "Aktiverad";
+$text['label-enabled']['uk'] = "Включено";
+$text['label-enabled']['ro'] = "";
+$text['label-enabled']['de-at'] = "Aktiv";
+$text['label-enabled']['ar-eg'] = "مفعل";
+$text['label-enabled']['he'] = "";
+
+$text['label-delete-complete']['en-us'] = "Delete Complete";
+$text['label-delete-complete']['es-cl'] = "Eliminar Completo";
+$text['label-delete-complete']['pt-pt'] = "Remoção Efectuada";
+$text['label-delete-complete']['fr-fr'] = "Supprimé";
+$text['label-delete-complete']['nl-nl'] = "";
+$text['label-delete-complete']['pt-br'] = "Remoção efetuada";
+$text['label-delete-complete']['pl'] = "Usunięto poprawnie";
+$text['label-delete-complete']['sv-se'] = "Borttagning Klar";
+$text['label-delete-complete']['uk'] = "Видалено";
+$text['label-delete-complete']['ro'] = "Ștergere completă";
+$text['label-delete-complete']['de-at'] = "Erfolgreich gelöscht";
+$text['label-delete-complete']['ar-eg'] = "اكتمال المسح";
+$text['label-delete-complete']['he'] = "המחיקה הושלמה";
+
+$text['label-action']['en-us'] = "Action";
+$text['label-action']['es-cl'] = "Acción";
+$text['label-action']['pt-pt'] = "Acção";
+$text['label-action']['fr-fr'] = "Action";
+$text['label-action']['nl-nl'] = "";
+$text['label-action']['pt-br'] = "Ação";
+$text['label-action']['pl'] = "Operacja";
+$text['label-action']['sv-se'] = "Åtgärd";
+$text['label-action']['uk'] = "Дія";
+$text['label-action']['ro'] = "Acțiune";
+$text['label-action']['de-at'] = "Aktion";
+$text['label-action']['ar-eg'] = "";
+$text['label-action']['he'] = "פעולה";
+
+$text['confirm-delete']['en-us'] = "Do you really want to delete this?";
+$text['confirm-delete']['es-cl'] = "¿Realmente desea eliminar el número?";
+$text['confirm-delete']['pt-pt'] = "Deseja realmente remover isto?";
+$text['confirm-delete']['fr-fr'] = "Voulez-vous vraiment supprimer cela?";
+$text['confirm-delete']['nl-nl'] = "";
+$text['confirm-delete']['pt-br'] = "Deseja realmente remover isto?";
+$text['confirm-delete']['pl'] = "Czy na pewno chcesz to usunąć?";
+$text['confirm-delete']['sv-se'] = "Vill du verkligen ta bort detta?";
+$text['confirm-delete']['uk'] = "Ви дійсно бажаєте це видалити?";
+$text['confirm-delete']['ro'] = "";
+$text['confirm-delete']['de-at'] = "Wollen Sie das wirklich löschen?";
+$text['confirm-delete']['ar-eg'] = "";
+$text['confirm-delete']['he'] = "?בטוח שאתה רוצה למחוק";
+
+$text['button-view']['en-us'] = "View";
+$text['button-view']['es-cl'] = "Ver";
+$text['button-view']['pt-pt'] = "Vista";
+$text['button-view']['fr-fr'] = "Voir";
+$text['button-view']['nl-nl'] = "";
+$text['button-view']['pt-br'] = "Visualizar";
+$text['button-view']['pl'] = "Widok";
+$text['button-view']['sv-se'] = "Visa";
+$text['button-view']['uk'] = "Перегляд";
+$text['button-view']['ro'] = "Vizualizare";
+$text['button-view']['de-at'] = "Ansicht";
+$text['button-view']['ar-eg'] = "عرض";
+$text['button-view']['he'] = "הצג";
+
+$text['button-save']['en-us'] = "Save";
+$text['button-save']['es-cl'] = "Guardar";
+$text['button-save']['pt-pt'] = "Guardar";
+$text['button-save']['fr-fr'] = "Sauvegarder";
+$text['button-save']['nl-nl'] = "";
+$text['button-save']['pt-br'] = "Salvar";
+$text['button-save']['pl'] = "Zachowaj";
+$text['button-save']['sv-se'] = "Spara";
+$text['button-save']['uk'] = "Зберегти";
+$text['button-save']['ro'] = "Salvează";
+$text['button-save']['de-at'] = "Speichern";
+$text['button-save']['ar-eg'] = "حفظ";
+$text['button-save']['he'] = "שמור";
+
+$text['button-edit']['en-us'] = "Edit";
+$text['button-edit']['es-cl'] = "Editar";
+$text['button-edit']['pt-pt'] = "Editar";
+$text['button-edit']['fr-fr'] = "Editer";
+$text['button-edit']['nl-nl'] = "";
+$text['button-edit']['pt-br'] = "Editar";
+$text['button-edit']['pl'] = "Edytuj";
+$text['button-edit']['sv-se'] = "Editera";
+$text['button-edit']['uk'] = "Редагувати";
+$text['button-edit']['ro'] = "Editează";
+$text['button-edit']['de-at'] = "Bearbeiten";
+$text['button-edit']['ar-eg'] = "تعديل";
+$text['button-edit']['he'] = "ערוך";
+
+$text['button-delete']['en-us'] = "Delete";
+$text['button-delete']['es-cl'] = "Eliminar";
+$text['button-delete']['pt-pt'] = "Remover";
+$text['button-delete']['fr-fr'] = "Supprimer";
+$text['button-delete']['nl-nl'] = "";
+$text['button-delete']['pt-br'] = "Remover";
+$text['button-delete']['pl'] = "Usuń";
+$text['button-delete']['sv-se'] = "Ta Bort";
+$text['button-delete']['uk'] = "Видалити";
+$text['button-delete']['ro'] = "";
+$text['button-delete']['de-at'] = "Löschen";
+$text['button-delete']['ar-eg'] = "مسح";
+$text['button-delete']['he'] = "מחק";
+
+$text['button-back']['en-us'] = "Back";
+$text['button-back']['es-cl'] = "Volver";
+$text['button-back']['pt-pt'] = "Voltar";
+$text['button-back']['fr-fr'] = "Retour";
+$text['button-back']['nl-nl'] = "";
+$text['button-back']['pt-br'] = "Voltar";
+$text['button-back']['pl'] = "Wróć";
+$text['button-back']['sv-se'] = "Tillbaka";
+$text['button-back']['uk'] = "Назад";
+$text['button-back']['ro'] = "Înapoi";
+$text['button-back']['de-at'] = "Zurück";
+$text['button-back']['ar-eg'] = "رجوع";
+$text['button-back']['he'] = "חזרה";
+
+$text['button-add']['en-us'] = "Add";
+$text['button-add']['pt-pt'] = "Adicionar";
+$text['button-add']['fr-fr'] = "Ajouter";
+$text['button-add']['nl-nl'] = "";
+$text['button-add']['pt-br'] = "Adicionar";
+$text['button-add']['pl'] = "Dodaj";
+$text['button-add']['sv-se'] = "Lägg Till";
+$text['button-add']['uk'] = "Додати";
+$text['button-add']['ro'] = "Adaugă";
+$text['button-add']['de-at'] = "Hinzufügen";
+$text['button-add']['ar-eg'] = "اضافة";
+$text['button-add']['he'] = "";
+
+?>

+ 21 - 0
bdr/app_menu.php

@@ -0,0 +1,21 @@
+<?php
+
+$apps[$x]['menu'][0]['title']['en-us'] = "BDR Management";
+$apps[$x]['menu'][0]['title']['es-cl'] = "";
+$apps[$x]['menu'][0]['title']['fr-fr'] = "";
+$apps[$x]['menu'][0]['title']['pt-pt'] = "";
+$apps[$x]['menu'][0]['title']['pt-br'] = "";
+$apps[$x]['menu'][0]['title']['pl'] = "";
+$apps[$x]['menu'][0]['title']['sv-se'] = "";
+$apps[$x]['menu'][0]['title']['uk'] = "";
+$apps[$x]['menu'][0]['title']['ro'] = "";
+$apps[$x]['menu'][0]['title']['de-at'] = "";
+$apps[$x]['menu'][0]['title']['ar-eg'] = "";
+$apps[$x]['menu'][0]['title']['he'] = "";
+$apps[$x]['menu'][0]['uuid'] = "7ed61deb-14dd-49f6-940d-6cf2023f8481";
+$apps[$x]['menu'][0]['parent_uuid'] = "594d99c5-6128-9c88-ca35-4b33392cec0f";
+$apps[$x]['menu'][0]['category'] = "internal";
+$apps[$x]['menu'][0]['path'] = "/app/bdr/bdr.php";
+$apps[$x]['menu'][0]['groups'][] = "superadmin";
+
+?>

+ 184 - 0
bdr/bdr.php

@@ -0,0 +1,184 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "resources/require.php";
+
+//check permissions
+	require_once "resources/check_auth.php";
+	if (permission_exists('bdr_view')) {
+		//access granted
+	}
+	else {
+		echo "access denied";
+		exit;
+	}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+//additional includes
+	require_once "resources/header.php";
+	require_once "resources/paging.php";
+	
+if ($_SESSION['server']['bdr_fusionpbx_enable']['boolean'] == true) {	
+//get the  my node id
+	$sql = "select bdr.bdr_get_local_nodeid()";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll();
+	$result_count = count($result);
+	unset ($prep_statement, $sql);
+	$replace[] = '(';
+	$replace[] = ')';
+	$my_node_id = explode(',',str_replace($replace,'',$result[0]['bdr_get_local_nodeid']));
+
+//get the  node list
+	$sql = "select * from bdr.bdr_nodes";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll();
+	$result_count = count($result);
+	unset ($prep_statement, $sql);
+
+	$sql = "SELECT bdr.bdr_version()";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$resultversion = $prep_statement->fetchAll();
+	unset ($prep_statement, $sql);
+
+	echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+	echo "<tr>\n";
+	echo "<th class='th' colspan='2' align='left'>BDR Information</th>\n";
+	echo "</tr>\n";
+	echo "<tr>\n";
+	echo "<td width='20%' class='vncell' style='text-align: left;'>\n";
+	echo "BDR Version\n";
+	echo "</td>\n";
+	echo "<td class='row_style1'>\n";
+	echo $resultversion[0]['bdr_version'] . "\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "<tr>\n";
+	echo "<td width='20%' class='vncell' style='text-align: left;'>\n";
+	echo "Node Count\n";
+	echo "</td>\n";
+	echo "<td class='row_style1'>\n";
+	echo "	$result_count\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "</table>\n<br/><br/>";
+
+//table headers
+	$c = 0;
+	$row_style["0"] = "row_style0";
+	$row_style["1"] = "row_style1";
+	echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+//	echo "<tr>\n";
+//	echo "<td class=\"th\" colspan=\"8\" align=\"left\">Nodes</td>\n";
+//	echo "</tr>\n";
+	echo "<tr>\n";
+	echo "<th class=\"th\" align=\"left\">ID</th>\n";
+	echo "<th class=\"th\" align=\"left\">Status</th>\n";
+	echo "<th class=\"th\" align=\"left\">Name</th>\n";
+	echo "<th class=\"th\" align=\"left\">Local</th>\n";
+	echo "<th class=\"th\" align=\"left\">Database</th>\n";
+	echo "<th class=\"th\" align=\"left\">Active</th>\n";
+	echo "<th class=\"th\" align=\"left\">Retained Bytes</th>\n";
+	echo "<th class=\"th\" align=\"left\">Lag Bytes</th>\n";
+	echo "<th>&nbsp;</th>\n";
+	echo "</tr>\n";
+	$c = 0;
+	$row_style["0"] = "row_style0";
+	$row_style["1"] = "row_style1";
+	foreach ($result as $row) {
+	
+		//get the status, bytes, database list
+		$sql = "SELECT slot_name, database, active, pg_xlog_location_diff(pg_current_xlog_insert_location(), restart_lsn) AS retained_bytes";
+		$sql .= " FROM pg_replication_slots WHERE plugin = 'bdr'";
+		$sql .= " AND slot_name like '%" . $row['node_sysid'] . "%' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$result1 = $prep_statement->fetchAll();
+		unset ($prep_statement, $sql);
+		
+		//get lag bytes
+		$sql = "select pg_xlog_location_diff(pg_current_xlog_insert_location(), flush_location) AS lag_bytes";
+		$sql .= " FROM pg_stat_replication WHERE ";
+		$sql .= " application_name like '%" . $row['node_sysid'] . "%' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$result2 = $prep_statement->fetchAll();
+		unset ($prep_statement, $sql);
+		
+		echo "<tr>\n";
+		echo "	<td valign='top' class='".$row_style[$c]."'>" . $row['node_sysid'] . "</td>\n";
+		echo "	<td valign='top' class='".$row_style[$c]."'>";
+		if ($row['node_status'] == "r") { 
+			echo "Ready"; 
+		} else if ($row['node_status'] == "k") { 
+			echo "Removed/Killed"; 
+		} else if ($row['node_status'] == "i") { 
+			echo "Initializing"; 
+		} else if ($row['node_status'] == "b") { 
+			echo "Bootstrapping"; 
+		} else if ($row['node_status'] == "c") { 
+			echo "Catching Up"; 
+		} else if ($row['node_status'] == "o") { 
+			echo "Caught Up/Waiting"; 
+		} else { 
+			echo "Unknown"; 
+		}
+		echo "</td>\n";
+		echo "	<td valign='top' class='".$row_style[$c]."'>" . $row['node_name'] . "</td>\n";
+		echo "	<td valign='top' class='".$row_style[$c]."'>";
+		if ($row['node_sysid'] == $my_node_id[0]) { echo "Yes"; $is_current = 1; } else { echo "No"; $is_current = 0; }
+		echo "</td>\n";
+		echo "	<td valign='top' class='".$row_style[$c]."'>" . $result1[0]['database'] . "</td>\n";
+		echo "	<td valign='top' class='".$row_style[$c]."'>";
+		if ($is_current != 1) {if ($result1[0]['active'] == 1) { echo "Yes"; } else { echo "No"; }};
+		echo "</td>\n";
+		echo "	<td valign='top' class='".$row_style[$c]."'>" . $result1[0]['retained_bytes'] . "</td>\n";
+		echo "	<td valign='top' class='".$row_style[$c]."'>" . $result2[0]['lag_bytes'] . "</td>\n";
+		echo "	<td class='list_control_icons'>";
+/*		if (permission_exists('extension_edit')) {
+			echo "<a href='extension_edit.php?id=".$row['extension_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
+		}*/
+		if (permission_exists('bdr_delete')) {
+			echo "<a href='bdr_delete.php?action=delete&id=".$row['node_name']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
+		}
+		echo "</td>\n";
+
+		echo "</tr>\n";
+		if ($c==0) { $c=1; } else { $c=0; }
+	}
+ 	echo "	</table>\n";
+
+}
+//include the footer
+	require_once "resources/footer.php";
+
+?>

+ 62 - 0
bdr/bdr_delete.php

@@ -0,0 +1,62 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+if (permission_exists('bdr_delete')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+//check for the id
+	if (count($_GET) > 0) {
+		$id = check_str($_GET["id"]);
+	}
+	if (strlen($id) > 0) {
+		//get the user_context
+		$sql = "SELECT bdr.bdr_part_by_node_names('$id')";
+//		print_r($sql);
+//		die();
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		unset ($prep_statement);
+
+	}
+
+//redirect the browser
+	$_SESSION["message"] = $text['label-delete-complete'];
+	header("Location: bdr.php");
+	return;
+
+?>

+ 50 - 0
bdr/root.php

@@ -0,0 +1,50 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+// make sure the PATH_SEPARATOR is defined
+	if (!defined("PATH_SEPARATOR")) {
+		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
+	}
+
+// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
+	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
+	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
+	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
+
+// if the project directory exists then add it to the include path otherwise add the document root to the include path
+	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
+	}
+	else {
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
+	}
+
+?>