Exemplo n.º 1
0
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
if (defined('EXPONENT')) {
    return;
}
include_once 'exponent_bootstrap.php';
// Initialize the Imaging Subsystem (this does not need the Exponent Framework to function)
include_once 'subsystems/image.php';
if (isset($_GET['id'])) {
    include_once 'subsystems/config/load.php';
    // Initialize the Database Subsystem
    include_once BASE . 'subsystems/database.php';
    $db = exponent_database_connect(DB_USER, DB_PASS, DB_HOST . ':' . DB_PORT, DB_NAME);
    $file_obj = $db->selectObject('file', 'id=' . intval($_GET['id']));
    $_GET['file'] = $file_obj->directory . '/' . $file_obj->filename;
}
$file = BASE . $_GET['file'];
$thumb = null;
if (isset($_GET['constraint'])) {
    $thumb = exponent_image_scaleToConstraint($file, $_GET['width'], $_GET['height']);
} else {
    if (isset($_GET['width'])) {
        $thumb = exponent_image_scaleToWidth($file, intval($_GET['width']));
    } else {
        if (isset($_GET['height'])) {
            $thumb = exponent_image_scaleToHeight($file, intval($_GET['height']));
        } else {
            if (isset($_GET['scale'])) {
if (exponent_permissions_check('configuration', exponent_core_makeLocation('AdministrationModule'))) {
    if (!defined('SYS_CONFIG')) {
        require_once BASE . 'subsystems/config.php';
    }
    $continue = true;
    if ($user->is_admin == 1) {
        // Only do the database stuff if we are a super admin
        $errors = '';
        $i18n = exponent_lang_loadFile('modules/AdministrationModule/actions/config_save.php');
        // Test the prefix
        if (preg_match("/[^A-Za-z0-9]/", $_POST['c']['DB_TABLE_PREFIX'])) {
            $continue = false;
            $errors .= $i18n['bad_prefix'];
        }
        // Test the database connection
        $newdb = exponent_database_connect($_POST['c']['DB_USER'], $_POST['c']['DB_PASS'], $_POST['c']['DB_HOST'] . ":" . $_POST['c']['DB_PORT'], $_POST['c']['DB_NAME'], $_POST['c']['DB_ENGINE']);
        $newdb->prefix = $_POST['c']['DB_TABLE_PREFIX'] . '_';
        if (!$newdb->isValid()) {
            $continue = false;
            $errors .= $i18n['cant_connect'];
        }
        if ($continue) {
            $status = $newdb->testPrivileges();
            foreach ($status as $type => $flag) {
                if (!$flag) {
                    $continue = false;
                    $errors .= sprintf($i18n['perm_denied'], $type);
                }
            }
        }
    }
 function update($values, $object)
 {
     if (isset($values['_db_config'])) {
         $i18n = exponent_lang_loadFile('datatypes/sharedcore_site.php');
         // Test configuration, and return NULL if it doesn't work.
         if (preg_match('/[^A-Za-z0-9]/', $values['db_table_prefix'])) {
             $post = $values;
             $post['_formError'] = $i18n['bad_prefix'] . '<br />';
             exponent_sessions_set('last_POST', $post);
             return null;
         }
         $linkdb = exponent_database_connect($values['db_user'], $values['db_pass'], $values['db_host'] . ':' . $values['db_port'], $values['db_name'], $values['db_engine'], true);
         $linkdb->prefix = $values['db_table_prefix'] . '_';
         if (!$linkdb->isValid()) {
             $post = $values;
             $post['_formError'] = $i18n['cant_connect'] . '<br />';
             exponent_sessions_set('last_POST', $post);
             return null;
         }
         $status = $linkdb->testPrivileges();
         $failed = false;
         $errors = '';
         foreach ($status as $type => $flag) {
             if (!$flag) {
                 $failed = true;
                 $errors .= sprintf($i18n['perm_denied'], $type) . '<br />';
             }
         }
         if ($failed) {
             $post = $values;
             $post['_formError'] = $errors;
             exponent_sessions_set('last_POST', $post);
             return null;
         }
     }
     $object->name = $values['name'];
     $object->core_id = $values['core_id'];
     if (!isset($object->id)) {
         $object->path = $values['path'];
         if ($object->path[0] != '/') {
             $object->path = '/' . $object->path;
         }
         if (substr($object->path, -1, 1) != '/') {
             $object->path = $object->path . '/';
         }
         $object->relpath = $values['relpath'];
         if ($object->relpath[0] != '/') {
             $object->relpath = '/' . $object->relpath;
         }
         if (substr($object->relpath, -1, 1) != '/') {
             $object->relpath = $object->relpath . '/';
         }
         $object->host = $values['host'];
         if (substr($object->host, 0, 7) != 'http://' && substr($object->host, 0, 8) != 'https://') {
             $object->host = 'http://' . $object->host;
         }
         if (substr($object->host, -1, 1) == '/') {
             $object->host = substr($object->host, 0, -1);
         }
     }
     return $object;
 }
Exemplo n.º 4
0
     if (!in_array($d['name'], $used[$d['type']])) {
         $extension->name = $d['name'];
         $extension->type = $d['type'];
         $db->insertObject($extension, "sharedcore_extension");
         $used[$d['type']][] = $d['name'];
     }
 }
 exponent_sharedcore_link($core, $site, $used);
 // Save database config.
 $values = array("c" => array("db_engine" => $_POST['db_engine'], "db_name" => $_POST['db_name'], "db_user" => $_POST['db_user'], "db_pass" => $_POST['db_pass'], "db_host" => $_POST['db_host'], "db_port" => $_POST['db_port'], "db_table_prefix" => $_POST['db_table_prefix']), "opts" => array(), "activate" => 1, "configname" => "Default");
 if (!defined("SYS_CONFIG")) {
     require_once BASE . "subsystems/config.php";
 }
 exponent_config_saveConfiguration($values, $site->path);
 // Install database for base system
 $newdb = exponent_database_connect($_POST['db_user'], $_POST['db_pass'], $_POST['db_host'] . ':' . $_POST['db_port'], $_POST['db_name'], $_POST['db_engine'], true);
 $newdb->prefix = $_POST['db_table_prefix'] . '_';
 // Following code snipped from modules/AdministrationModule/actions/installtables.php
 $dir = $site->path . "datatypes/definitions";
 if (is_readable($dir)) {
     $tables = array();
     $dh = opendir($dir);
     while (($file = readdir($dh)) !== false) {
         if (is_readable("{$dir}/{$file}") && is_file("{$dir}/{$file}") && substr($file, -4, 4) == ".php" && substr($file, -9, 9) != ".info.php") {
             $tablename = substr($file, 0, -4);
             $dd = (include "{$dir}/{$file}");
             $info = null;
             if (is_readable("{$dir}/{$tablename}.info.php")) {
                 $info = (include "{$dir}/{$tablename}.info.php");
             }
             if (!$newdb->tableExists($tablename)) {
Exemplo n.º 5
0
    }
    echo '</td></tr>';
}
function isAllGood($str)
{
    return !preg_match("/[^A-Za-z0-9]/", $str);
}
exponent_sessions_set("installer_config", $_POST['c']);
$config = $_POST['c'];
$passed = true;
if (preg_match('/[^A-Za-z0-9]/', $config['db_table_prefix'])) {
    echoFailure($i18n['bad_prefix']);
    $passed = false;
}
if ($passed) {
    $db = exponent_database_connect($config['db_user'], $config['db_pass'], $config['db_host'], $config['db_name'], $config['db_engine'], 1);
    $db->prefix = $config['db_table_prefix'] . '_';
    $status = array();
    echoStart($i18n['connecting'] . ':');
    if ($db->connection == null) {
        echoFailure($db->error());
        // FIXME:BETTER ERROR CHECKING
        $passed = false;
    }
}
if ($passed) {
    $tables = $db->getTables();
    if ($db->inError()) {
        echoFailure($db->error());
        $passed = false;
    } else {
Exemplo n.º 6
0
function pathos_database_connect($username, $password, $hostname, $database, $dbclass = '', $new = false)
{
    return exponent_database_connect($username, $password, $hostname, $database, $dbclass, $new);
}