Ejemplo n.º 1
0
function local_extension($id)
{
    global $next_extension_id, $Ajax, $path_to_root;
    $exts = get_company_extensions();
    $exts[$next_extension_id++] = array('package' => $id, 'name' => $id, 'version' => '-', 'available' => '', 'type' => 'extension', 'path' => 'modules/' . $id, 'active' => false);
    if (file_exists($path_to_root . '/modules/' . clean_file_name($id) . '/hooks.php')) {
        include_once $path_to_root . '/modules/' . clean_file_name($id) . '/hooks.php';
    }
    $hooks_class = 'hooks_' . $id;
    if (class_exists($hooks_class, false)) {
        $hooks = new $hooks_class();
        $hooks->install_extension(false);
    }
    $Ajax->activate('ext_tbl');
    // refresh settings display
    if (!update_extensions($exts)) {
        return false;
    }
    return true;
}
 public function upload($user_id, $field = 'userfile')
 {
     $user_id = (int) $user_id;
     $this->load->helper('file');
     $this->data = array();
     $this->errors = array();
     $this->load->library('upload');
     $this->upload = $this->ci->upload;
     $this->lang->load('upload');
     $file_selected = isset($_FILES[$field]) && isset($_FILES[$field]['name']) && $_FILES[$field]['name'] != '';
     if ($file_selected == '') {
         return $this;
     }
     // Ivan: The uploaded file may not be valid, but I have to delete the previous file at this point.
     $this->_delete($user_id);
     $file_name = clean_file_name($_FILES[$field]['name']);
     $file_name = md5($user_id) . '.' . strtolower(extension($file_name));
     $config['file_name'] = $file_name;
     $config['upload_path'] = $this->upload_path;
     $config['allowed_types'] = $this->allowed_types;
     $config['max_size'] = $this->max_size;
     $config['max_width'] = $this->max_width;
     $config['max_height'] = $this->max_height;
     $config['overwrite'] = true;
     $this->upload->initialize()->initialize($config, false);
     if (!$this->upload->do_upload($field)) {
         $this->errors = $this->upload->error_msg;
         return $this;
     }
     $this->data = $this->upload->data();
     if (!$this->data['is_image']) {
         $this->errors[] = $this->lang->line('ui_invalid_image_format');
         return $this;
     }
     $this->users->update($user_id, array('photo' => $this->data['file_name']));
     return $this;
 }
Ejemplo n.º 3
0
$page_security = 'SA_SETUPDISPLAY';
$path_to_root = "..";
include $path_to_root . "/includes/session.inc";
page(_($help_context = "Display Setup"));
include_once $path_to_root . "/includes/date_functions.inc";
include_once $path_to_root . "/includes/ui.inc";
include_once $path_to_root . "/admin/db/company_db.inc";
//-------------------------------------------------------------------------------------------------
if (isset($_POST['setprefs'])) {
    if (!is_numeric($_POST['query_size']) || $_POST['query_size'] < 1) {
        display_error($_POST['query_size']);
        display_error(_("Query size must be integer and greater than zero."));
        set_focus('query_size');
    } else {
        $_POST['theme'] = clean_file_name($_POST['theme']);
        $chg_theme = user_theme() != $_POST['theme'];
        $chg_lang = $_SESSION['language']->code != $_POST['language'];
        $chg_date_format = user_date_format() != $_POST['date_format'];
        $chg_date_sep = user_date_sep() != $_POST['date_sep'];
        set_user_prefs(get_post(array('prices_dec', 'qty_dec', 'rates_dec', 'percent_dec', 'date_format', 'date_sep', 'tho_sep', 'dec_sep', 'print_profile', 'theme', 'page_size', 'language', 'startup_tab', 'show_gl' => 0, 'show_codes' => 0, 'show_hints' => 0, 'rep_popup' => 0, 'graphic_links' => 0, 'sticky_doc_date' => 0, 'query_size' => 10.0)));
        if ($chg_lang) {
            $_SESSION['language']->set_language($_POST['language']);
        }
        // refresh main menu
        flush_dir(company_path() . '/js_cache');
        if ($chg_theme && $allow_demo_mode) {
            $_SESSION["wa_current_user"]->prefs->theme = $_POST['theme'];
        }
        if ($chg_theme || $chg_lang || $chg_date_format || $chg_date_sep) {
            meta_forward($_SERVER['PHP_SELF']);
Ejemplo n.º 4
0
function download_file($filename)
{
    if (empty($filename) || !file_exists($filename)) {
        display_error(_('Select backup file first.'));
        return false;
    }
    $saveasname = basename($filename);
    header('Content-type: application/octet-stream');
    header('Content-Length: ' . filesize($filename));
    header('Content-Disposition: attachment; filename="' . $saveasname . '"');
    readfile($filename);
    return true;
}
$db_name = $_SESSION["wa_current_user"]->company;
$conn = $db_connections[$db_name];
$backup_name = clean_file_name(get_post('backups'));
$backup_path = BACKUP_PATH . $backup_name;
if (get_post('creat')) {
    generate_backup($conn, get_post('comp'), get_post('comments'));
    $Ajax->activate('backups');
}
if (get_post('restore')) {
    if ($backup_name) {
        if (db_import($backup_path, $conn)) {
            display_notification(_("Restore backup completed."));
        }
        refresh_sys_prefs();
        // re-read system setup
    } else {
        display_error(_("Select backup file first."));
    }
Ejemplo n.º 5
0
function set_filename($path, $filename)
{
    $filename = clean_file_name($filename);
    $file_ext = GetExtension($filename);
    if (!file_exists($path . $filename)) {
        return $filename;
    }
    $new_filename = str_replace('.' . $file_ext, '', $filename);
    for ($i = 1; $i < 300; $i++) {
        if (!file_exists($path . $new_filename . '_' . $i . '.' . $file_ext)) {
            $new_filename .= '_' . $i . '.' . $file_ext;
            break;
        }
    }
    return $new_filename;
}
Ejemplo n.º 6
0
         $result = unlink($filename);
         if (!$result) {
             display_error(_('The existing image could not be removed'));
             $input_error = 1;
         }
     }
     if ($input_error != 1) {
         $result = move_uploaded_file($_FILES['pic']['tmp_name'], $filename);
         $_POST['coy_logo'] = clean_file_name($_FILES['pic']['name']);
         if (!$result) {
             display_error(_('Error uploading logo file'));
         }
     }
 }
 if (check_value('del_coy_logo')) {
     $filename = company_path() . "/images/" . clean_file_name($_POST['coy_logo']);
     if (file_exists($filename)) {
         $result = unlink($filename);
         if (!$result) {
             display_error(_('The existing image could not be removed'));
             $input_error = 1;
         }
     }
     $_POST['coy_logo'] = "";
 }
 if ($_POST['add_pct'] == "") {
     $_POST['add_pct'] = -1;
 }
 if ($_POST['round_to'] <= 0) {
     $_POST['round_to'] = 1;
 }