Skip to content

Commit

Permalink
Changed various include variables / URL references
Browse files Browse the repository at this point in the history
Changed various include variables / URL references to allow for more
flexible deployment (basically, to any subdirectory).
  • Loading branch information
Patricio Aguilar committed Jul 30, 2013
1 parent 9ae6411 commit d57e8ab
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 130 deletions.
32 changes: 16 additions & 16 deletions admin/import.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
include '../classes/database.php';
include '../classes/table.php';
include '../classes/variable.php';
include dirname(__FILE__) . '/../classes/database.php';
include dirname(__FILE__) . '/../classes/table.php';
include dirname(__FILE__) . '/../classes/variable.php';

function convert_string($string) {
//converts smart quotes / dashes to normal quotes / dashes.
Expand All @@ -10,7 +10,7 @@ function convert_string($string) {
return str_replace($search, $replace, $string);
}

include 'include/header.php';
include dirname(__FILE__) . '/include/header.php';
?>
<script>
$(document).ready(function() {
Expand All @@ -23,11 +23,11 @@ function convert_string($string) {
<?php
if (!isset($_POST['posted'])) {
?>
Sample Files: <a href="/CSR_Meta.txt">CSR_Meta.txt</a> - <a href="/NSR_TBLS.txt">NSR_TBLS.txt</a><br />
Sample Files: <a href="./CSR_Meta.txt">CSR_Meta.txt</a> - <a href="./NSR_TBLS.txt">NSR_TBLS.txt</a><br />
<br />
Choose your Meta Data file and then click on the submit button.

<form action="../admin/import.php" method="post" enctype="multipart/form-data">
<form action="import.php" method="post" enctype="multipart/form-data">
1. <input type="file" name="database_descriptions_file" /><br /><br />
<input type="hidden" name="posted" />
2. <input type="submit" value="submit" />
Expand Down Expand Up @@ -179,7 +179,7 @@ function convert_string($string) {
print "$key = $val\n";

//open DB
include '../include/dbconnopen.php';
include dirname(__FILE__) . '/../include/dbconnopen.php';
$imported_record = mysqli_query($cnnCDD, "Call 0_Import_Database__Create_Database('"
. addslashes($val)
. "','" //. addslashes($description)
Expand All @@ -198,7 +198,7 @@ function convert_string($string) {
}

//close DB
include ('../include/dbconnclose.php');
include dirname(__FILE__) . '/../include/dbconnclose.php';
}
//print_r($dbs);

Expand All @@ -210,7 +210,7 @@ function convert_string($string) {
}

//open DB
include '../include/dbconnopen.php';
include dirname(__FILE__) . '/../include/dbconnopen.php';
$imported_record = mysqli_query($cnnCDD, "Call 0_Import_Table__Create_Table('"
. addslashes($val[1])
. "','" //. addslashes($table_description)
Expand All @@ -225,7 +225,7 @@ function convert_string($string) {
}

//close DB
include ('../include/dbconnclose.php');
include dirname(__FILE__) . '/../include/dbconnclose.php';
}
//print_r($tables);

Expand All @@ -237,7 +237,7 @@ function convert_string($string) {
}

//open DB
include '../include/dbconnopen.php';
include dirname(__FILE__) . '/../include/dbconnopen.php';
$imported_record = mysqli_query($cnnCDD, "Call 0_Import_Variable__Create_Variable('"
. addslashes($val[1])
. "','" . addslashes($val[2])
Expand All @@ -255,7 +255,7 @@ function convert_string($string) {
}

//close DB
include ('../include/dbconnclose.php');
include dirname(__FILE__) . '/../include/dbconnclose.php';
}
//print_r($variables);
echo "</pre>";
Expand Down Expand Up @@ -294,7 +294,7 @@ function convert_string($string) {
*/

//open DB
include '../include/dbconnopen.php';
include dirname(__FILE__) . '/../include/dbconnopen.php';

//overwrite / skip existing records
if ($_POST['table_descriptions_overwrite_skip'] == 'Overwrite') {
Expand Down Expand Up @@ -327,7 +327,7 @@ function convert_string($string) {
}

//close DB
include ('../include/dbconnclose.php');
include dirname(__FILE__) . '/../include/dbconnclose.php';
}

echo "<a href=\"import.php\">Import Another</a>";
Expand Down Expand Up @@ -365,7 +365,7 @@ function convert_string($string) {
echo "Comments: " . ((isset($data[8])) ? $data[8] : "") . "<br /><br />";

//open DB
include '../include/dbconnopen.php';
include dirname(__FILE__) . '/../include/dbconnopen.php';

//overwrite / skip existing records
if ($_POST['variable_overwrite_skip'] == 'Overwrite') {
Expand Down Expand Up @@ -404,7 +404,7 @@ function convert_string($string) {
}

//close DB
include ('../include/dbconnclose.php');
include dirname(__FILE__) . '/../include/dbconnclose.php';
}

echo "<a href=\"import.php\">Import Another</a>";
Expand Down
92 changes: 86 additions & 6 deletions admin/include/header.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
<?php
//debug
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);

include 'widgets.php';
include_once dirname(__FILE__) . '/../../classes/user.php';

//get user_info if they exist
if (isset($_COOKIE['user_id'])) {
$user_info = User::get_user_info($_COOKIE['user_id']);
}

//get permissions if they exist
if (isset($_COOKIE['users_user_types'])) {
$users_user_types = unserialize(base64_decode($_COOKIE['users_user_types']));
}

//if the page is in the admin section
if (substr($_SERVER['PHP_SELF'], 0, 7) == '/admin/') {
//if user is logged in
if (!isset($users_user_types)) {
header("Location: /");
} else {
//permissions test
if (!in_array('Administrator', $users_user_types)) {
header("Location: /");
}
}
}

include dirname(__FILE__) . '/widgets.php';
?>

<!DOCTYPE html>
Expand Down Expand Up @@ -28,7 +56,30 @@
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->



<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script type="text/javascript">
$(document).ajaxStart(function() {
$('#ajax_loader').fadeIn('slow');
});

$(document).ajaxStop(function() {
$('#ajax_loader').fadeOut('slow');
});
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-8633108-15']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>

<body>
Expand All @@ -49,6 +100,35 @@
<img src="../images/metalicious_banner.png" /> </a>

<div class="nav-collapse">
<ul class="nav pull-right">
<li class="dropdown">
<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
<i class="icon-user"></i>
<?php echo $user_info['First_Name'] . " " . $user_info['Last_Name']; ?>
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<?php
if (isset($users_user_types)) {
//permissions test
if (in_array('Administrator', $users_user_types)) {
?>
<li>
<a href="./">Admin</a>
</li>
<li>
<a href="./import.php">Import</a>
</li>
<?php
}
}
?>
<li class="divider"></li>
<li><a href="../login.php?action=logout">Logout</a></li>
</ul>
</li>
</ul>
<!--
<ul class="nav pull-right">
<li class="dropdown">

Expand Down Expand Up @@ -77,10 +157,10 @@

</li>
</ul>
<form class="navbar-search pull-right">
<input type="text" class="search-query" placeholder="Search">
</form>
-->
<form class="navbar-search pull-right" method="post" action="../search.php">
<input type="text" class="search-query" placeholder="Search" id="search_criteria" name="search_criteria" />
</form>

</div><!--/.nav-collapse -->

Expand Down
6 changes: 3 additions & 3 deletions admin/include/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
/* The 'include' statements below do not point to the correct path. Including the correct path will create a "cannot redeclare class" error. Right now, it will generate a "Failed opening" warning.
*/

include '../../classes/database.php';
include '../../classes/table.php';
include '../../classes/variable.php';
include_once dirname(__FILE__) . '/../../classes/database.php';
include_once dirname(__FILE__) . '/../../classes/table.php';
include_once dirname(__FILE__) . '/../../classes/variable.php';

/*********************************
* Base class for admin widgets.
Expand Down
6 changes: 3 additions & 3 deletions business_functions.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
include '/classes/business_function.php';
include dirname(__FILE__) . '/classes/business_function.php';

include '/include/header.php';
include dirname(__FILE__) . '/include/header.php';
?>
<script>
$(document).ready(function() {
Expand Down Expand Up @@ -60,4 +60,4 @@
?>
</div>

<?php include '/include/footer.php'; ?>
<?php include dirname(__FILE__) . '/include/footer.php'; ?>
Loading

0 comments on commit d57e8ab

Please sign in to comment.