Skip to content

Commit

Permalink
- autoload composer vendor dir
Browse files Browse the repository at this point in the history
- remove global recaptcha keys since google no longer supports them
  • Loading branch information
shaded2 committed May 17, 2015
1 parent b6a6dbc commit 43f8d64
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 59 deletions.
21 changes: 12 additions & 9 deletions config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

// composer autoloading
require_once('vendor/autoload.php');

ini_set('include_path', '.');

define('LOG_FILE','logs/error.log'); // Used by the Admin Panel error log file viewer
Expand Down Expand Up @@ -37,7 +40,7 @@ function stripslashes_deep($value)
foreach ($_GET as $k => $v)
$get[$k] = stripslashes(htmlentities(strip_tags($v),ENT_QUOTES,'UTF-8'));
$get['return'] = addslashes($get['return']);
$main_smarty->assign('get',$get);
$main_smarty->assign('get',$get);
}

// CSFR/XSFR protection
Expand Down Expand Up @@ -66,7 +69,7 @@ function sanit($var){
if ($my_base_url == ''){

define('my_base_url', "http://" . $_SERVER["HTTP_HOST"]);

if(isset($_REQUEST['action'])){
$action = sanit($_REQUEST['action']);
} else {
Expand All @@ -75,7 +78,7 @@ function sanit($var){

$pos = strrpos($_SERVER["SCRIPT_NAME"], "/");
$path = substr($_SERVER["SCRIPT_NAME"], 0, $pos);

if ($path == "/"){
$path = "";
}
Expand All @@ -92,27 +95,27 @@ function sanit($var){

if(isset($_COOKIE['template'])){
$thetemp = str_replace('..','',sanit($_COOKIE['template']));
}
}

// template check
$file = dirname(__FILE__) . '/templates/' . $thetemp . "/pligg.tpl";
unset($errors);
if (!file_exists($file)) {
$errors[]='You may have typed the template name wrong or "'. $thetemp . '" does not exist. Click <a href = "admin/admin_config.php?page=Template">here</a> to fix it.';
if (!file_exists($file)) {
$errors[]='You may have typed the template name wrong or "'. $thetemp . '" does not exist. Click <a href = "admin/admin_config.php?page=Template">here</a> to fix it.';
}

if (isset($errors)) {
// Name of the default Pligg template
$thetemp = "bootstrap";
$file = dirname(__FILE__) . '/templates/' . $thetemp . "/pligg.tpl";
if (!file_exists($file)) {
echo 'The default template "Bootstrap" does not exist anymore. Please fix this by reuploading the Bootstrap template!';
echo 'The default template "Bootstrap" does not exist anymore. Please fix this by reuploading the Bootstrap template!';
die();
}

foreach ($errors as $error) {
$output.="<p><b>Error:</b> $error</p>\n";
}
}

if (strpos($_SERVER['SCRIPT_NAME'], "admin_config.php") == 0 && strpos($_SERVER['SCRIPT_NAME'], "login.php") == 0){
echo "<p><b>Error:</b> $error</p>\n";
Expand Down Expand Up @@ -159,7 +162,7 @@ function sanit($var){
$cached_users = array();

// a simple cache type system for the totals table
// functions related to this are in /libs/html1.php
// functions related to this are in /libs/html1.php
$cached_totals = array();
$cached_votes = array();
$cached_links = array();
Expand Down
24 changes: 12 additions & 12 deletions install/installtables.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ function pligg_createtables($conn) {
UNIQUE KEY `login_username` (`login_ip`,`login_username`)
) DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;";
mysql_query( $sql, $conn );


// echo 'Creating table: \'widgets\'....<br />';
$sql = 'DROP TABLE IF EXISTS `' . table_widgets . '`;';
Expand All @@ -434,14 +434,14 @@ function pligg_createtables($conn) {
UNIQUE KEY `folder` (`folder`)
) ENGINE =MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci";
mysql_query( $sql, $conn );


///////////////////////////////////////////////////////////////////////////

echo '<li>Setting Pligg Version</li>';
$sql = "INSERT INTO `" . table_misc_data . "` ( `name` , `data` ) VALUES ('pligg_version', '2.0.3');";
mysql_query( $sql, $conn );

echo '<li>Setting Captcha Method to SolveMedia</li>';
$sql = "UPDATE `" . table_misc_data . "` SET `data` = 'solvemedia' WHERE `pligg_misc_data`.`name` = 'captcha_method';";
mysql_query($sql,$conn);
Expand All @@ -457,9 +457,9 @@ function pligg_createtables($conn) {
mysql_query($sql,$conn);
$sql = "INSERT INTO `" . table_misc_data . "` ( `name` , `data` ) VALUES ('captcha_method', 'solvemedia');";
mysql_query($sql,$conn);
$sql = "INSERT INTO `" . table_misc_data . "` ( `name` , `data` ) VALUES ('reCaptcha_pubkey', '6LfwKQQAAAAAAPFCNozXDIaf8GobTb7LCKQw54EA');";
$sql = "INSERT INTO `" . table_misc_data . "` ( `name` , `data` ) VALUES ('reCaptcha_pubkey', '');";
mysql_query($sql,$conn);
$sql = "INSERT INTO `" . table_misc_data . "` ( `name` , `data` ) VALUES ('reCaptcha_prikey', '6LfwKQQAAAAAALQosKUrE4MepD0_kW7dgDZLR5P1');";
$sql = "INSERT INTO `" . table_misc_data . "` ( `name` , `data` ) VALUES ('reCaptcha_prikey', '');";
mysql_query($sql,$conn);

//register validation//
Expand Down Expand Up @@ -570,9 +570,9 @@ function pligg_createtables($conn) {
// echo "Adding default 'totals' data</li>";
$sql = "insert into `" . table_totals . "` (`name`, `total`) values ('published', 0);";
mysql_query( $sql, $conn );
$sql = "insert into `" . table_totals . "` (`name`, `total`) values ('new', 0);";
$sql = "insert into `" . table_totals . "` (`name`, `total`) values ('new', 0);";
mysql_query( $sql, $conn );
$sql = "insert into `" . table_totals . "` (`name`, `total`) values ('discard', 0);";
$sql = "insert into `" . table_totals . "` (`name`, `total`) values ('discard', 0);";
mysql_query( $sql, $conn );

echo '<li>Creating About Page</li>';
Expand Down Expand Up @@ -601,7 +601,7 @@ function pligg_createtables($conn) {
ALTER TABLE `pligg_users` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `pligg_votes` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `pligg_categories`
ALTER TABLE `pligg_categories`
CHANGE `category_lang` `category_lang` VARCHAR( 2 ) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'en',
CHANGE `category_name` `category_name` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci,
CHANGE `category_safe_name` `category_safe_name` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci,
Expand Down Expand Up @@ -706,9 +706,9 @@ function pligg_createtables($conn) {
CHANGE `user_location` `user_location` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL ,
CHANGE `user_occupation` `user_occupation` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL ,
CHANGE `user_categories` `user_categories` VARCHAR( 1024 ) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '';";

$stmts = explode("\n", $stmts);

foreach($stmts as $stmt) {
$stmt = str_replace("`pligg_", "`".table_prefix, $stmt);
mysql_query($stmt);
Expand All @@ -729,10 +729,10 @@ function pligg_createtables($conn) {
}
}
}

mysql_query("INSERT INTO `" . table_config . "` ( `var_id` , `var_page` , `var_name` , `var_value` , `var_defaultvalue` , `var_optiontext` , `var_title` , `var_desc` , `var_method` , `var_enclosein` )VALUES (NULL, 'Misc', '\$language', '{$_SESSION['language']}', 'english', 'text', 'Site Language', 'Site Language', 'normal', '\'');");
mysql_query("INSERT INTO `" . table_config . "` ( `var_id` , `var_page` , `var_name` , `var_value` , `var_defaultvalue` , `var_optiontext` , `var_title` , `var_desc` , `var_method` , `var_enclosein` )VALUES (NULL, 'Misc', 'user_language', '0', '0', '1 = yes / 0 = no', 'Select Language', 'Allow users to change Pligg language', 'normal', '\'');");

return 1;
}

Expand Down
64 changes: 32 additions & 32 deletions install/upgrade1.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

if ($_GET['language'])
$language = addslashes(strip_tags($_GET['language']));

if($language == 'arabic'){
include_once('./languages/lang_arabic.php');
} elseif($language == 'catalan'){
Expand Down Expand Up @@ -55,7 +55,7 @@
}

include ('footer.php');

die();

} else {
Expand Down Expand Up @@ -91,19 +91,19 @@
</form>';
} else { //they clicked yes!
$include='../config.php';
if (file_exists($include)) {
if (file_exists($include)) {
include_once($include);
include(mnminclude.'html1.php');
}

// Get Pligg CMS Version as $old_version
$tableexists = checkfortable(table_misc_data);
if ($tableexists) {
$sql = "SELECT data FROM " . table_misc_data . " WHERE name = 'pligg_version'";
$pligg_version = $db->get_var($sql);
$old_version = str_replace('.', '' , $pligg_version);
}

// Language File Upgrade
$languageContent = '../languages/lang_' . $language . '.conf';
$languageContent = file_get_contents($languageContent);
Expand All @@ -129,21 +129,21 @@
$oldLanguage103= "// End 1.0.3 Language File";
$languageContent = str_replace($oldLanguage102 , $oldLanguage103 , $languageContent);
}

if ($old_version < '104'){
$oldLanguage103 = "// End 1.0.3 Language File";
$content = file_get_contents('./languages/updates/lang_' . $language . '_update_104.conf');
if($content)
$languageContent = str_replace($oldLanguage103 , $content , $languageContent);
}

if ($old_version < '105'){
$oldLanguage104 = "// End 1.0.4 Language File";
$content = file_get_contents('./languages/updates/lang_' . $language . '_update_105.conf');
if($content)
$languageContent = str_replace($oldLanguage104 , $content , $languageContent);
}

if ($old_version < '111'){
// No language file changes this release
$oldLanguage110 = "// End 1.1.0 Language File";
Expand All @@ -157,7 +157,7 @@
if($content)
$languageContent = str_replace($oldLanguage111 , $content , $languageContent);
}

if ($old_version < '113'){
$oldLanguage112 = "// End 1.1.2 Language File";
$content = file_get_contents('./languages/updates/lang_' . $language . '_update_113.conf');
Expand All @@ -171,21 +171,21 @@
if($content)
$languageContent = str_replace($oldLanguage113 , $content , $languageContent);
}

if ($old_version < '115'){
$oldLanguage114 = "// End 1.1.4 Language File";
$content = file_get_contents('./languages/updates/lang_' . $language . '_update_115.conf');
if($content)
$languageContent = str_replace($oldLanguage114 , $content , $languageContent);
}

if ($old_version < '120'){
$oldLanguage115 = "// End 1.1.5 Language File";
$content = file_get_contents('./languages/updates/lang_' . $language . '_update_120.conf');
if($content)
$languageContent = str_replace($oldLanguage115 , $content , $languageContent);
}

if ($old_version < '121'){
$oldLanguage120 = "// End 1.2.0 Language File";
$content = file_get_contents('./languages/updates/lang_' . $language . '_update_121.conf');
Expand All @@ -199,35 +199,35 @@
$newLanguage122= "// End 1.2.2 Language File";
$languageContent = str_replace($oldLanguage121 , $newLanguage122 , $languageContent);
}

if ($old_version < '200'){
$oldLanguage122 = "// End 1.2.2 Language File";
$content = file_get_contents('./languages/updates/lang_' . $language . '_update_200.conf');
if($content)
$languageContent = str_replace($oldLanguage122 , $content , $languageContent);
}

if ($old_version < '201'){
// No language file changes this release
$oldLanguage200 = "// End 2.0.0 Language File";
$newLanguage201= "// End 2.0.1 Language File";
$languageContent = str_replace($oldLanguage200 , $newLanguage201 , $languageContent);
}

if ($old_version < '202'){
// No language file changes this release
$oldLanguage201 = "// End 2.0.1 Language File";
$newLanguage202= "// End 2.0.2 Language File";
$languageContent = str_replace($oldLanguage201 , $newLanguage202 , $languageContent);
}

if ($old_version < '203'){
// No language file changes this release
$oldLanguage202 = "// End 2.0.2 Language File";
$newLanguage203= "// End 2.0.3 Language File";
$languageContent = str_replace($oldLanguage202 , $newLanguage203 , $languageContent);
}

// echo $languageContent;

// Point to the file that's going to be written to.
Expand Down Expand Up @@ -256,50 +256,50 @@
// End Language File Upgrade

echo '<p>'.$lang['UpgradingTables'] . '<ul>';

$tableexists = checkfortable(table_misc_data);
if ($tableexists) {
// Get version-specific updates
$sql = "SELECT data FROM " . table_misc_data . " WHERE name = 'pligg_version'";
$pligg_version = $db->get_var($sql);
$old_version = str_replace('.', '' , $pligg_version);
}

if (!$tableexists) {
$sql = "CREATE TABLE `" . table_misc_data . "` (
`name` VARCHAR( 20 ) NOT NULL ,
`data` TEXT NOT NULL ,
PRIMARY KEY ( `name` )
) ENGINE = MyISAM;";
$db->query($sql);

// Add Pligg version
$sql = "INSERT INTO `" . table_misc_data . "` ( `name` , `data` ) VALUES ('pligg_version', '2.0.3');";
$db->query($sql);

//Captcha upgrade:
$sql = "INSERT INTO `" . table_misc_data . "` ( `name` , `data` ) VALUES ('captcha_method', 'solvemedia');";
$db->query($sql);
$sql = "INSERT INTO `" . table_misc_data . "` ( `name` , `data` ) VALUES ('reCaptcha_pubkey', '6LfwKQQAAAAAAPFCNozXDIaf8GobTb7LCKQw54EA');";
$sql = "INSERT INTO `" . table_misc_data . "` ( `name` , `data` ) VALUES ('reCaptcha_pubkey', '');";
$db->query($sql);
$sql = "INSERT INTO `" . table_misc_data . "` ( `name` , `data` ) VALUES ('reCaptcha_prikey', '6LfwKQQAAAAAALQosKUrE4MepD0_kW7dgDZLR5P1');";
$sql = "INSERT INTO `" . table_misc_data . "` ( `name` , `data` ) VALUES ('reCaptcha_prikey', '');";
$db->query($sql);

} else {

include_once('version/1.x.php');
include_once('version/2.0.0rc1.php');
include_once('version/2.0.0rc2.php');
include_once('version/2.0.0.php');
include_once('version/2.0.1.php');
include_once('version/2.0.2.php');
include_once('version/2.0.3.php');

}

echo '<li>Regenerating the totals table</li>';
totals_regenerate();

echo '<li>Clearing /cache directory</li>';
include_once('../internal/Smarty.class.php');
$smarty = new Smarty;
Expand All @@ -308,23 +308,23 @@
$smarty->template_dir = "../templates";
$smarty->config_dir = "..";
$smarty->clear_compiled_tpl();

include(mnminclude.'admin_config.php');
$config = new pliggconfig;
$config->create_file("../settings.php");

echo '</ul></p><div class="alert alert-info">' . $lang['IfNoError'] . '</div></p>';

//end of if post submit is Yes.
}
//end of no errors
}
else {
else {
echo DisplayErrors($errors);
echo '<p>' . $lang['PleaseFix'] . '</p>';
}

echo '</div>'; // .well
echo '</div>'; // .well

$include='footer.php'; if (file_exists($include)) { include_once($include); }
?>
Loading

0 comments on commit 43f8d64

Please sign in to comment.