Example #1
0
 protected function perform_update_start()
 {
     $this->turn_on_maintenance_mode();
     //restore innodb tables in case of db reimport
     if (DB::is_mysql()) {
         $tbls = DB::MetaTables('TABLE', true);
         foreach ($tbls as $t) {
             $tbl = DB::GetRow('SHOW CREATE TABLE ' . $t);
             if (!isset($tbl[1]) || preg_match('/ENGINE=myisam/i', $tbl[1])) {
                 DB::Execute('ALTER TABLE ' . $t . ' ENGINE = INNODB');
             }
         }
     }
 }
Example #2
0
 private function _check_table()
 {
     $tables_db = DB::MetaTables();
     if (!in_array('patches', $tables_db)) {
         DB::CreateTable('patches', "id C(32) KEY NOTNULL");
     }
     //md5 id
 }
Example #3
0
function clean_database()
{
    require_once 'include/config.php';
    require_once 'include/database.php';
    $tables_db = DB::MetaTables();
    $tables = array();
    if (DB::is_mysql()) {
        DB::Execute('SET FOREIGN_KEY_CHECKS=0');
    }
    if (DB::is_postgresql() && strpos(DB::GetOne('SELECT version()'), 'PostgreSQL 8.2') !== false) {
        foreach ($tables_db as $t) {
            $idxs = DB::Execute('SELECT t.tgargs as args FROM pg_trigger t,pg_class c,pg_proc p WHERE t.tgenabled AND t.tgrelid = c.oid AND t.tgfoid = p.oid AND p.proname = \'RI_FKey_check_ins\' AND c.relname = \'' . strtolower($t) . '\' ORDER BY t.tgrelid');
            $matches = array(1 => array());
            while ($i = $idxs->FetchRow()) {
                $data = explode(chr(0), $i[0]);
                $matches[1][] = $data[0];
            }
            $num_keys = count($matches[1]);
            for ($i = 0; $i < $num_keys; $i++) {
                DB::Execute('ALTER TABLE ' . $t . ' DROP CONSTRAINT ' . $matches[1][$i]);
            }
        }
    }
    foreach ($tables_db as $t) {
        DB::DropTable($t);
    }
    if (DB::is_mysql()) {
        DB::Execute('SET FOREIGN_KEY_CHECKS=1');
    }
}
Example #4
0
}
if (!is_writable(DATA_DIR)) {
    die('Cannot write into "' . DATA_DIR . '" directory. Please fix privileges.');
}
// require_once('include/include_path.php');
require_once 'include/config.php';
require_once 'include/maintenance_mode.php';
require_once 'include/error.php';
require_once 'include/misc.php';
require_once 'include/database.php';
require_once 'include/variables.php';
if (epesi_requires_update()) {
    header('Location: update.php');
    exit;
}
$tables = DB::MetaTables();
if (!in_array('modules', $tables) || !in_array('variables', $tables) || !in_array('session', $tables)) {
    die('Database structure you are using is apparently out of date or damaged. If you didn\'t perform application update recently you should try to restore the database. Otherwise, please refer to EPESI documentation in order to perform database update.');
}
ob_start();
if (IPHONE) {
    if (!isset($_GET['force_epesi'])) {
        ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta name="robots" content="NOINDEX, NOARCHIVE">
	<meta id="viewport" name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
	<title><?php 
        print EPESI;
<?php

defined("_VALID_ACCESS") || die('Direct access forbidden');
if (in_array('base_lang_trans_contrib', DB::MetaTables())) {
    return;
}
DB::CreateTable('base_lang_trans_contrib', 'id I4 AUTO KEY,' . 'user_id I4,' . 'allow I1,' . 'first_name C(64),' . 'last_name C(64)', array());
Example #6
0
 protected function perform_update_start()
 {
     $this->cli_msg("Update from " . $this->system_version . " to " . $this->current_version . "...");
     $this->turn_on_maintenance_mode();
     //restore innodb tables in case of db reimport
     $mysql = stripos(DATABASE_DRIVER, 'mysql') !== false;
     if ($mysql) {
         $tbls = DB::MetaTables('TABLE', true);
         foreach ($tbls as $t) {
             $tbl = DB::GetRow('SHOW CREATE TABLE ' . $t);
             if (!isset($tbl[1]) || preg_match('/ENGINE=myisam/i', $tbl[1])) {
                 DB::Execute('ALTER TABLE ' . $t . ' ENGINE = INNODB');
             }
         }
     }
 }
Example #7
0
<?php

defined("_VALID_ACCESS") || die('Direct access forbidden');
if (ModuleManager::is_installed('Utils_RecordBrowser') == -1) {
    return;
}
if (DB::GetOne('SELECT 1 FROM contact_field WHERE field=%s', array('Username'))) {
    return;
}
$tables = DB::GetAssoc('SELECT tab, tab FROM recordbrowser_table_properties');
if (!in_array('aro', DB::MetaTables())) {
    return;
}
if (!function_exists('get_acl_user_id')) {
    function get_acl_user_id($user_id)
    {
        $sql = 'SELECT id FROM aro WHERE section_value=' . DB::qstr('Users') . ' AND value=' . DB::qstr($user_id);
        return DB::GetOne($sql);
    }
    function is_user_in_group($uid, $group)
    {
        // $groups_arr = Acl::$gacl->get_object_groups($uid);
        $object_id = $uid;
        $object_type = 'aro';
        $group_table = 'aro_groups';
        $map_table = 'groups_aro_map';
        $query = 'SELECT gm.group_id FROM ' . $map_table . ' gm ';
        $query .= 'WHERE gm.' . $object_type . '_id=' . $object_id;
        $rs = DB::Execute($query);
        $groups_arr = array();
        while ($row = $rs->FetchRow()) {
Example #8
0
	public static function record_processing($tab, $base, $mode, $clone=null) {
        self::check_table_name($tab);
        $tables_db = DB::MetaTables();
        if(!in_array('recordbrowser_processing_methods',$tables_db)) return $base;
		static $cache = array();
		if (!isset($cache[$tab])) {
			$ret = DB::Execute('SELECT * FROM recordbrowser_processing_methods WHERE tab=%s', array($tab));
			$cache[$tab] = array();
			while ($row = $ret->FetchRow()) {
				$callback = explode('::',$row['func']);
				if (is_callable($callback))
					$cache[$tab][] = $callback;
			}
		}
		$current = $base;
		if ($mode=='display') $result = array();
		else $result = $base;
		foreach ($cache[$tab] as $callback) {
			if ($mode=='cloned') $current = array('original'=>$clone, 'clone'=>$current);
			$return = call_user_func($callback, $current, $mode);
			if ($return===false) return false;
			if ($return) {
				if ($mode!='display') $current = $return;
				else $result = array_merge_recursive($result, $return);
			}
		}
		if ($mode!='display') $result = $current;
		return $result;
	}
<?php

defined("_VALID_ACCESS") || die('Direct access forbidden');
if (in_array('base_acl_permission', DB::MetaTables())) {
    return;
}
DB::CreateTable('base_acl_permission', 'id I4 AUTO KEY,' . 'name C(255)', array('constraints' => ''));
DB::CreateTable('base_acl_rules', 'id I4 AUTO KEY,' . 'permission_id I', array('constraints' => ', FOREIGN KEY (permission_id) REFERENCES base_acl_permission(id)'));
DB::CreateTable('base_acl_rules_clearance', 'id I4 AUTO KEY,' . 'rule_id I,' . 'clearance C(64)', array('constraints' => ', FOREIGN KEY (rule_id) REFERENCES base_acl_rules(id)'));
$permissions = array('Apps_ActivityReport' => array('View Activity Report', array('ACCESS:employee', 'ACCESS:manager')), 'Apps_Shoutbox' => array('Shoutbox', array('ACCESS:employee')), 'Base_Dashboard' => array('Dashboard', array('ACCESS:employee')), 'Base_Search' => array('Search', array('ACCESS:employee')), 'Base_User_Settings' => array('Advanced User Settings', array('ACCESS:employee')), 'CRM_Calendar' => array('Calendar', array('ACCESS:employee')), 'CRM_Filters' => array('Manage Perspective', array('ACCESS:employee')), 'Premium_Import' => array('Import', array('SUPERADMIN')), 'Premium_Warehouse_Items_Orders' => array('Inventory - Sell at loss', array('ACCESS:employee', 'ACCESS:manager')), 'Utils_Attachment' => array('Attachments - view full download history', array('ACCESS:employee')), 'Utils_Messenger' => array('Messenger Alerts', array('ACCESS:employee')), 'CRM_Fax' => array('Fax - Browse', array('ACCESS:employee')), 'CRM_Fax' => array('Fax - Send', array('ACCESS:employee')), 'Premium_Warehouse_eCommerce_Allegro' => array('Inventory - Allegro Settings', array('ACCESS:employee')));
foreach ($permissions as $module => $params) {
    if (ModuleManager::is_installed($module) >= 0) {
        Base_AclCommon::add_permission($params[0], $params[1]);
    }
}