Beispiel #1
0
function buy_basic($item_sql, $item_max_sql, $item_str, $cost)
{
    global $amount, $user, $user_ship, $db_name, $st, $cw;
    settype($amount, "int");
    //security check
    $ret_str = "";
    if ($user_ship[$item_sql] >= $user_ship[$item_max_sql]) {
        $ret_str .= sprintf($st[1052], $item_str);
    } elseif ($amount < 1) {
        $amount_can_buy = floor($user['cash'] / $cost);
        if ($amount_can_buy > $user_ship[$item_max_sql] - $user_ship[$item_sql]) {
            $amount_can_buy = $user_ship[$item_max_sql] - $user_ship[$item_sql];
        }
        get_var($cw['buy'] . " {$item_str}", 'equip_shop.php', sprintf($st[759], $item_str), 'amount', $amount_can_buy);
    } else {
        $total_cost = $amount * $cost;
        if ($user['cash'] < $total_cost) {
            $ret_str .= $st[1054] . "<b class='b1'>{$item_str}</b>.<p />";
        } elseif ($user_ship[$item_sql] + $amount > $user_ship[$item_max_sql]) {
            $ret_str .= $st[1055] . " <b class='b1'>{$item_str}</b>.<p />";
        } else {
            $ret_str .= "<b>{$amount}</b> <b class='b1'>{$item_str}</b> " . $cw['purchased_for'] . " <b>{$total_cost}</b> " . $cw['credits.'] . "<p />";
            take_cash($total_cost);
            dbn("update {$db_name}_ships set {$item_sql} = {$item_sql} + '{$amount}' where ship_id = '{$user_ship['ship_id']}'");
            $user_ship[$item_sql] += $amount;
        }
    }
    return $ret_str;
}
 function nextmatchs($website = False)
 {
     if (!$website) {
         $this->template = createobject('phpgwapi.Template', PHPGW_TEMPLATE_DIR);
         $this->template->set_file(array('_nextmatchs' => 'nextmatchs.tpl'));
         $this->template->set_block('_nextmatchs', 'nextmatchs');
         $this->template->set_block('_nextmatchs', 'filter');
         $this->template->set_block('_nextmatchs', 'form');
         $this->template->set_block('_nextmatchs', 'icon');
         $this->template->set_block('_nextmatchs', 'link');
         $this->template->set_block('_nextmatchs', 'search');
         $this->template->set_block('_nextmatchs', 'cats');
         $this->template->set_block('_nextmatchs', 'search_filter');
         $this->template->set_block('_nextmatchs', 'cats_search_filter');
     }
     if (isset($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) && (int) $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] > 0) {
         $this->maxmatches = (int) $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
     } else {
         $this->maxmatches = 15;
     }
     $this->_start = (int) get_var('start', array('GLOBAL', 'POST', 'GET'));
     foreach (array('menuaction', 'filter', 'qfield', 'order', 'sort') as $name) {
         $var = '_' . $name;
         $this->{$var} = get_var($name, array('GLOBAL', 'POST', 'GET'));
         if (!preg_match('/^[a-z0-9_. -]*$/i', $this->{$var})) {
             $this->{$var} = '';
         }
     }
     if (!is_object($GLOBALS['phpgw']->html)) {
         $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html');
     }
 }
Beispiel #3
0
 function ds()
 {
     $data['title'] = "Danh sách sản phẩm";
     $data['add'] = 'product/add';
     $cat_id = get_var('cat_id', 'int');
     $key_word = get_var('key');
     $field = get_var('f') ? get_var('f') : 't.id';
     $order = get_var('o') ? get_var('o') : 'desc';
     $get = $this->request->get;
     $str = '';
     foreach ($get as $val => $keys) {
         $str .= '&' . $val . '=' . $keys;
     }
     $str = trim($str, '&');
     $str_get = count($get) ? '?' . $str : '';
     $data['cat_id'] = $cat_id;
     $data['keyword'] = $key_word;
     $data['dscat'] = $this->product->get_all_cat();
     $config['base_url'] = base_url() . 'product/ds';
     $config['suffix'] = '.html' . $str_get;
     $config['total_rows'] = $this->product->get_num_product($key_word, $cat_id);
     $data['num'] = $config['total_rows'];
     $config['per_page'] = 10;
     $config['uri_segment'] = 3;
     $this->load->library('pagination');
     $this->pagination->initialize($config);
     $data['list'] = $this->product->get_all_product($config['per_page'], segment(3, 'int'), $key_word, $cat_id, $field, $order);
     $data['pagination'] = $this->pagination->create_links();
     $this->load->templates('product/ds', $data, 'file');
 }
 function generate_header()
 {
     $GLOBALS['header_template']->set_file(array('header' => 'header.inc.php.template'));
     $GLOBALS['header_template']->set_block('header', 'domain', 'domain');
     $var = array();
     $deletedomain = get_var('deletedomain', array('POST'));
     $domains = get_var('domains', array('POST'));
     @reset($domains);
     while ($domains && (list($k, $v) = @each($domains))) {
         if (isset($deletedomain[$k])) {
             continue;
         }
         //$dom = get_var('setting_'.$k,Array('POST'));
         $dom = $_POST['settings'][$k];
         $GLOBALS['header_template']->set_var('DB_DOMAIN', $v);
         while (list($x, $y) = @each($dom)) {
             $GLOBALS['header_template']->set_var(strtoupper($x), $y);
         }
         $GLOBALS['header_template']->parse('domains', 'domain', True);
     }
     $GLOBALS['header_template']->set_var('domain', '');
     $setting = get_var('setting', array('POST'));
     if (!empty($setting) && is_array($setting)) {
         foreach ($setting as $k => $v) {
             $var[strtoupper($k)] = $v;
         }
     }
     $GLOBALS['header_template']->set_var($var);
     return $GLOBALS['header_template']->parse('out', 'header');
 }
Beispiel #5
0
 function index()
 {
     $data['title'] = "Quản lý Danh Bạ";
     $data['delete'] = true;
     $data['add'] = 'contacts/add';
     $field = get_var('field') ? get_var('field') : 'id';
     $order = get_var('order') ? get_var('order') : 'desc';
     $key_word = $_GET['key'];
     $id_office = get_var('id', 'int');
     $data['key'] = $key_word;
     $data['id_office'] = $id_office;
     $data['field'] = $field;
     $data['order'] = $order;
     $data['page'] = get_var('page', 'int');
     $get = $this->request->get;
     $str = '';
     foreach ($get as $val => $keys) {
         $str .= '&' . $val . '=' . $keys;
     }
     $str = trim($str, '&');
     $str_get = count($get) ? '?' . $str : '';
     $data['listoffice'] = $this->contacts->get_all_office();
     $config['base_url'] = base_url() . 'contacts/' . $this->uri->segment(2) . '/';
     $config['suffix'] = '.html' . $str_get;
     $config['total_rows'] = $this->contacts->get_num_contacts($key_word, $id_office);
     $data['num'] = $config['total_rows'];
     $config['per_page'] = 20;
     $config['uri_segment'] = 3;
     $this->load->library('pagination');
     $this->pagination->initialize($config);
     $data['list'] = $this->contacts->get_all_contacts($config['per_page'], segment(3, 'int'), $field, $order, $key_word, $id_office);
     //var_dump($data['list']);
     $data['pagination'] = $this->pagination->create_links();
     $this->load->templates('index', $data);
 }
Beispiel #6
0
 function execute()
 {
     ob_start();
     $act = get_var($this->rg->get('act'));
     $det = get_var($this->rg->get('det'));
     $api = $this->rg->get('api');
     if ($api) {
         $action = BASEPATH . 'api/' . $api . '/controllers/' . $act . EXT;
         if (file_exists($action)) {
             include_once $action;
             if (class_exists($act)) {
                 $exec = new $act();
                 if ($det) {
                     if (method_exists($exec, $det)) {
                         $exec->{$det}();
                     }
                 } else {
                     if (method_exists($exec, 'execute')) {
                         $exec->execute();
                     }
                 }
             } else {
                 include BASEPATH . 'errors/503' . EXT;
             }
         } else {
             include BASEPATH . 'errors/503' . EXT;
         }
     }
     ob_end_flush();
 }
 function showLinks($name, $app, $id, $only_app = '', $show_unlink = True)
 {
     $value = get_var($name, array('POST'));
     if (!is_array($value)) {
         $value = array();
     }
     list($unlink) = @each($value['unlink']);
     if ($this->debug) {
         echo "<p>uilink.showLinks: app='{$app}',id='{$id}', unlink={$unlink}, {$name} = ";
         _debug_array($value);
     }
     if ($unlink) {
         $this->unlink($unlink, $app, $id);
         //echo "<p>$unlink unlinked</p>\n";
     }
     $etemplate = CreateObject('etemplate.etemplate', 'infolog.linklist_widget');
     $links = $this->get_links($app, $id, $only_app);
     $value = array();
     for ($row = $etemplate->rows - 1; list(, $link) = each($links); ++$row) {
         $value[$row] = $link;
         $value[$row]['title'] = $this->title($link['app'], $link['id']);
     }
     $value['app'] = $app;
     $value['id'] = $id;
     $value['title'] = $this->title($app, $id);
     $out = $etemplate->show($value, '', '', $name);
     $out = str_replace('[]', '', $out);
     return eregi_replace('[</]*table[^>]*>', '', $out);
 }
function check_form_values()
{
    // PHP will automatically replace any dots in incoming
    // variable names with underscores.
    $errors = '';
    $domains = get_var('domains', array('POST'));
    @reset($domains);
    while (list($k, $v) = @each($domains)) {
        $variableName = str_replace('.', '_', $k);
        $deletedomain = get_var('deletedomain', array('POST'));
        if (isset($deletedomain[$variableName])) {
            continue;
        }
        $dom = get_var('setting_' . $variableName, array('POST'));
        if (!$dom['config_pass'] && !$dom['config_password']) {
            $errors .= '<br>' . lang("You didn't enter a config password for domain %1", $v);
        }
        if (!$dom['config_user']) {
            $errors .= '<br>' . lang("You didn't enter a config username for domain %1", $v);
        }
    }
    $setting = get_var('setting', array('POST'));
    if (!$setting['HEADER_ADMIN_PASSWORD'] && !$setting['HEADER_ADMIN_PASS']) {
        $errors .= '<br>' . lang("You didn't enter a header admin password");
    }
    if (!$setting['HEADER_ADMIN_USER']) {
        $errors .= '<br>' . lang("You didn't enter a header admin username");
    }
    if ($errors) {
        $GLOBALS['phpgw_setup']->html->show_header('Error', True);
        echo $errors;
        echo '<p><input type="submit" value="' . lang('Back to the previous screen') . '" onClick="history.back()"></p>';
        exit;
    }
}
function get_filecatname($catid)
{
    $sql_pre = "SELECT `catname` FROM `yxy_filecat` WHERE `id` = ?i";
    $array = array($catid);
    $sql = prepare($sql_pre, $array);
    return get_var($sql);
}
 function editdatabase()
 {
     $GLOBALS['phpgw_info']['flags']['app_header'] = 'SyncML synchronization: Edit database';
     $database_id = get_var('database_id', array('POST', 'GET'));
     $submit = get_var('submit', array('POST'));
     $values = get_var('values', array('POST'));
     if (is_array($values)) {
         if (isset($submit['add']) && $submit['add']) {
             /*
             $this->sodatabases->insert_database(
             	$values['uri'],
             	$values['app'],
             	base64_encode(md5(
             		$account_lid . ':' . $password, true
             	))
             );
             */
         }
         $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'syncml.uisyncml.listdatabases'));
     } else {
         if ($database_id) {
             // todo: get database data from database.
             $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('edit_database' => array('action_url' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'syncml.uisyncml.editdatabase')), 'database_id' => $database_id)));
         }
     }
 }
 function display_section($_menuData)
 {
     $i = 0;
     // reset the value of all_rows
     $this->t->set_var('all_rows', '');
     while (list($key, $value) = each($_menuData)) {
         if (!empty($value['extradata'])) {
             $link = $GLOBALS['phpgw']->link($value['url'], 'account_id=' . get_var('account_id', array('GET', 'POST')) . '&' . $value['extradata']);
         } else {
             $link = $GLOBALS['phpgw']->link($value['url'], 'account_id=' . get_var('account_id', array('GET', 'POST')));
         }
         $this->section_item($link, lang($value['description']), $this->rowColor[$i % 2]);
         $i++;
     }
     $this->t->set_var('th_bg', $GLOBALS['phpgw_info']['theme']['th_bg']);
     if (strpos($_menuData[0]['extradata'], 'user')) {
         $destination = 'users';
     } else {
         $destination = 'groups';
     }
     $this->t->set_var('link_done', $GLOBALS['phpgw']->link('/index.php', 'menuaction=admin.uiaccounts.list_' . $destination));
     $this->t->set_var('lang_done', lang('Back'));
     $this->t->set_var('row_on', $this->rowColor[0]);
     $this->t->parse('out', 'menu_links');
     return $this->t->get('out', 'menu_links');
 }
Beispiel #12
0
/**
 * Checks if current page is a single view page
 */
function is_single()
{
    $action = get_var('action');
    if ($action == 'view' || $action == 'add') {
        return true;
    } else {
        return false;
    }
}
Beispiel #13
0
 final function __construct($id)
 {
     parent::__construct($id);
     $this->_ancho = get_var($this->_info_firma['ancho'], '500px');
     $this->_alto = get_var($this->_info_firma['alto'], '120px');
     if (isset($this->_memoria['dir_actual'])) {
         $this->_multiple = $this->_memoria['multiple'];
     }
 }
 function generate_header()
 {
     // PHP will automatically replace any dots in incoming
     // variable names with underscores.
     $GLOBALS['header_template']->set_file(array('header' => 'header.inc.php.template'));
     $GLOBALS['header_template']->set_block('header', 'domain', 'domain');
     $var = array();
     $deletedomain = get_var('deletedomain', array('POST'));
     $domains = get_var('domains', array('POST'));
     @reset($domains);
     while ($domains && (list($k, $v) = @each($domains))) {
         if (isset($deletedomain[$k])) {
             continue;
         }
         $variableName = str_replace('.', '_', $k);
         $dom = get_var('setting_' . $variableName, array('POST'));
         $GLOBALS['header_template']->set_var('DB_DOMAIN', $v);
         while (list($x, $y) = @each($dom)) {
             if (strtoupper($x) == 'CONFIG_PASS') {
                 $GLOBALS['header_template']->set_var(strtoupper($x), md5($y));
             } else {
                 $GLOBALS['header_template']->set_var(strtoupper($x), $y);
             }
         }
         /* Admin did not type a new password, so use the old one from the hidden field,
          * which is already md5 encoded.
          */
         if ($dom['config_password'] && !$dom['config_pass']) {
             /* Real == hidden */
             $GLOBALS['header_template']->set_var('CONFIG_PASS', $dom['config_password']);
         }
         /* If the admin didn't select a db_port, set to the default */
         if (!$dom['db_port']) {
             $GLOBALS['header_template']->set_var('DB_PORT', $GLOBALS['default_db_ports'][$dom['db_type']]);
         }
         $GLOBALS['header_template']->parse('domains', 'domain', True);
     }
     $GLOBALS['header_template']->set_var('domain', '');
     $setting = get_var('setting', array('POST'));
     while ($setting && (list($k, $v) = @each($setting))) {
         if (strtoupper($k) == 'HEADER_ADMIN_PASSWORD') {
             $var[strtoupper($k)] = md5($v);
         } else {
             $var[strtoupper($k)] = $v;
         }
     }
     /* Admin did not type a new header password, so use the old one from the hidden field,
      * which is already md5 encoded.
      */
     if ($var['HEADER_ADMIN_PASS'] && empty($setting['HEADER_ADMIN_PASSWORD'])) {
         /* Real == hidden */
         $var['HEADER_ADMIN_PASSWORD'] = $var['HEADER_ADMIN_PASS'];
     }
     $GLOBALS['header_template']->set_var($var);
     return $GLOBALS['header_template']->parse('out', 'header');
 }
Beispiel #15
0
 /**
  * 通过标记名获取ID
  *
  * @author boxcore
  * @date   2014-09-17
  * @param  string     $mark 标记
  * @return int        task_id
  */
 public function getIdByMark($mark = '')
 {
     $id = 0;
     $mark = trim($mark);
     if (!empty($mark)) {
         $sql = prepare('SELECT `id` FROM `task_list` WHERE `mark` = ?s LIMIT 1', array($mark));
         $id = get_var($sql);
     }
     return $id;
 }
Beispiel #16
0
 final function __construct($id)
 {
     parent::__construct($id);
     $this->_alto = get_var($this->_info_grafico['alto'], 300);
     $this->_ancho = get_var($this->_info_grafico['ancho'], 650);
     $this->_tipo = get_var($this->_info_grafico['grafico']);
     $this->ini_conf();
     //TODO: Hack para navegacion ajax con windows
     toba_ci::set_navegacion_ajax(false);
 }
Beispiel #17
0
/**
 * 获取品牌ID,无则创建
 *
 * @author boxcore
 * @date   2014-09-17
 * @param  string     $brand_name [description]
 * @return [type]               [description]
 */
function get_brand_id($brand_name = '')
{
    $brand_id = 0;
    $brand_name = trim($brand_name);
    if (!empty($brand_name)) {
        $brand_id = get_var("SELECT `brand_id` FROM `ecs_brand` WHERE `brand_name` = '{$brand_name}' LIMIT 1");
        if (empty($brand_id)) {
            $brand_id = insert('ecs_brand', array('brand_name' => $brand_name));
        }
    }
    return $brand_id;
}
 function list_history()
 {
     $account_id = get_var('account_id', array('GET', 'POST'));
     $start = get_var('start', array('POST'), 0);
     $sort = get_var('sort', array('POST'), 0);
     $order = get_var('order', array('POST'), 0);
     $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin') . ' - ' . lang('View access log');
     if (!@is_object($GLOBALS['phpgw']->js)) {
         $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
     }
     $GLOBALS['phpgw']->js->validate_file('jscode', 'openwindow', 'admin');
     $GLOBALS['phpgw']->common->phpgw_header();
     echo parse_navbar();
     $total_records = $this->bo->total($account_id);
     $var = array('th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], 'nextmatchs_left' => $this->nextmatchs->left('/index.php', $start, $total_records, '&menuaction=admin.uiaccess_history.list_history&account_id=' . $account_id), 'nextmatchs_right' => $this->nextmatchs->right('/index.php', $start, $total_records, '&menuaction=admin.uiaccess_history.list_history&account_id=' . $account_id), 'showing' => $this->nextmatchs->show_hits($total_records, $start), 'lang_loginid' => lang('LoginID'), 'lang_ip' => lang('IP'), 'lang_login' => lang('Login'), 'lang_logout' => lang('Logout'), 'lang_total' => lang('Total'));
     if ($account_id) {
         $var['link_return_to_view_account'] = '<a href="' . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'admin.uiaccounts.view', 'account_id' => $account_id)) . '">' . lang('Return to view account') . '</a>';
         $var['lang_last_x_logins'] = lang('Last %1 logins for %2', $total_records, $GLOBALS['phpgw']->common->grab_owner_name($account_id));
     } else {
         $var['lang_last_x_logins'] = lang('Last %1 logins', $total_records);
     }
     $this->template->set_var($var);
     $records = $this->bo->list_history($account_id, $start, $order, $sort);
     while (is_array($records) && (list(, $record) = each($records))) {
         $this->nextmatchs->template_alternate_row_color($this->template);
         $var = array('row_loginid' => $record['loginid'], 'row_ip' => $record['ip'], 'row_li' => $record['li'], 'row_lo' => $record['account_id'] ? $record['lo'] : '<b>' . lang($record['sessionid']) . '</b>', 'row_total' => $record['lo'] ? $record['total'] : '&nbsp;');
         $this->template->set_var($var);
         $this->template->fp('rows_access', 'row', True);
     }
     if (!$total_records && $account_id) {
         $this->nextmatchs->template_alternate_row_color($this->template);
         $this->template->set_var('row_message', lang('No login history exists for this user'));
         $this->template->fp('rows_access', 'row_empty', True);
     }
     $loggedout = $this->bo->return_logged_out($account_id);
     if ($total_records) {
         $percent = round(10000 * ($loggedout / $total_records) / 100);
     } else {
         $percent = '0';
     }
     $var = array('bg_color' => $GLOBALS['phpgw_info']['themes']['bg_color'], 'footer_total' => lang('Total records') . ': ' . $total_records);
     if ($account_id) {
         $var['lang_percent'] = lang('Percent this user has logged out') . ': ' . $percent . '%';
     } else {
         $var['lang_percent'] = lang('Percent of users that logged out') . ': ' . $percent . '%';
     }
     // create the menu on the left, if needed
     $menuClass = CreateObject('admin.uimenuclass');
     $var['rows'] = $menuClass->createHTMLCode('view_account');
     $this->template->set_var($var);
     $this->template->pfp('out', 'list');
 }
 function boconfig()
 {
     $action = get_var('action', array('GET'));
     $this->debug = False;
     $this->boprojects = CreateObject('projects.boprojects', True, $action);
     $this->soconfig = $this->boprojects->soconfig;
     $this->start = $this->boprojects->start;
     $this->query = $this->boprojects->query;
     $this->filter = $this->boprojects->filter;
     $this->order = $this->boprojects->order;
     $this->sort = $this->boprojects->sort;
     $this->cat_id = $this->boprojects->cat_id;
 }
function randomSequences($count)
{
    $maxID = get_var(V_NUM_SEQUENCES);
    $sql = 'id IN(';
    for ($i = 0; $i < $count; $i++) {
        $sql .= rand(6, $maxID);
        if ($i != $count - 1) {
            $sql .= ',';
        }
    }
    $sql .= ')';
    return $sql;
}
 function pre_run()
 {
     $confirm = get_var('confirm', array('POST'));
     $execute = get_var('execute', array('GET'));
     if (!$execute) {
         $dry_run = True;
     }
     if ($confirm) {
         $this->execute($dry_run, $cron);
     } else {
         $this->confirm($execute = False);
     }
 }
 function init_process()
 {
     $ConfigDomain = get_var('ConfigDomain', array('COOKIE', 'POST'));
     $phpgw_domain = $GLOBALS['phpgw_domain'];
     $GLOBALS['phpgw_setup']->oProc = CreateObject('phpgwapi.schema_proc', $phpgw_domain[$ConfigDomain]['db_type']);
     $GLOBALS['phpgw_setup']->oProc->m_odb = $GLOBALS['phpgw_setup']->db;
     $GLOBALS['phpgw_setup']->oProc->m_odb->Host = $phpgw_domain[$ConfigDomain]['db_host'];
     $GLOBALS['phpgw_setup']->oProc->m_odb->Database = $phpgw_domain[$ConfigDomain]['db_name'];
     $GLOBALS['phpgw_setup']->oProc->m_odb->User = $phpgw_domain[$ConfigDomain]['db_user'];
     $GLOBALS['phpgw_setup']->oProc->m_odb->Password = $phpgw_domain[$ConfigDomain]['db_pass'];
     $GLOBALS['phpgw_setup']->oProc->m_odb->Halt_On_Error = 'report';
     $GLOBALS['phpgw_setup']->oProc->m_odb->connect();
 }
 function boXport($session = False)
 {
     $this->contacts =& $GLOBALS['phpgw']->contacts;
     $this->so = CreateObject('addressbook.soaddressbook');
     if ($session) {
         $this->read_sessiondata();
         $this->use_session = True;
     }
     $_start = get_var('_start', array('POST', 'GET'));
     $_query = get_var('_query', array('POST', 'GET'));
     $_sort = get_var('_sort', array('POST', 'GET'));
     $_order = get_var('_order', array('POST', 'GET'));
     $_filter = get_var('_filter', array('POST', 'GET'));
     $_cat_id = get_var('_cat_id', array('POST', 'GET'));
     $_fcat_id = get_var('_fcat_id', array('POST', 'GET'));
     if (!empty($_start) || $_start == '0' || $_start == 0) {
         if ($this->debug) {
             echo '<br>overriding $start: "' . $this->start . '" now "' . $_start . '"';
         }
         $this->start = $_start;
     }
     if ($_limit) {
         $this->limit = $_limit;
     }
     if (empty($_query) && !empty($this->query) || !empty($_query)) {
         $this->query = $_query;
     }
     if (isset($_POST['fcat_id']) || isset($_POST['fcat_id'])) {
         $this->cat_id = $_fcat_id;
     } else {
         $this->cat_id = -1;
     }
     if (isset($_sort) && !empty($_sort)) {
         if ($this->debug) {
             echo '<br>overriding $sort: "' . $this->sort . '" now "' . $_sort . '"';
         }
         $this->sort = $_sort;
     }
     if (isset($_order) && !empty($_order)) {
         if ($this->debug) {
             echo '<br>overriding $order: "' . $this->order . '" now "' . $_order . '"';
         }
         $this->order = $_order;
     }
     if (isset($_filter) && !empty($_filter)) {
         if ($this->debug) {
             echo '<br>overriding $filter: "' . $this->filter . '" now "' . $_filter . '"';
         }
         $this->filter = $_filter;
     }
 }
 function edit()
 {
     $edit_file = get_var('edit_file', array('GET', 'POST'));
     if (!strlen($edit_file)) {
         $edit_file = $this->bofilemanager->fileman[0];
     }
     //_debug_array($this->bofilemanager->fileman);
     if (isset($_POST['cancel']) && $_POST['cancel']) {
         $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'filemanager' . '.ui' . 'filemanager' . '.index', 'path' => urlencode($this->bofilemanager->path)));
     }
     $data = array('img_up' => array('widget' => array('type' => 'image', 'src' => $GLOBALS['phpgw']->common->image('filemanager', 'up'), 'title' => lang('up'), 'link' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'filemanager' . '.ui' . 'filemanager' . '.index', 'path' => urlencode($this->bofilemanager->lesspath))))), 'help_up' => array('widget' => array('type' => 'help', 'onClick' => $this->bofilemanager->build_help('up'))), 'img_home' => array('widget' => array('type' => 'image', 'src' => $GLOBALS['phpgw']->common->image('filemanager', 'folder_large'), 'title' => lang('go to your home directory'), 'link' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'filemanager' . '.ui' . 'filemanager' . '.index', 'path' => urlencode($this->bofilemanager->homedir))))), 'help_home' => array('widget' => array('type' => 'help', 'onClick' => $this->bofilemanager->build_help('home'))), 'current_dir' => $this->bofilemanager->path);
     if (get_var('edited', array('GET', 'POST'))) {
         $content = get_var('edit_file_content', array('GET', 'POST'));
         if (get_magic_quotes_gpc()) {
             $content = stripslashes($content);
         }
     } else {
         $content = $GLOBALS['phpgw']->vfs->read(array('string' => $edit_file));
     }
     if (isset($_POST['preview'])) {
         $vars[] = array('widget' => array('type' => 'image', 'src' => $GLOBALS['phpgw']->common->image('filemanager', 'pencil'), 'title' => lang('edit'), 'name' => 'edit', 'value' => 'edit'));
     } else {
         $vars[] = array('widget' => array('type' => 'image', 'src' => $GLOBALS['phpgw']->common->image('filemanager', 'preview'), 'title' => lang('preview'), 'name' => 'preview', 'value' => 'preview'));
     }
     $vars[] = array('widget' => array('type' => 'image', 'src' => $GLOBALS['phpgw']->common->image('filemanager', 'filesave'), 'title' => lang('save'), 'name' => 'save', 'value' => 'save'));
     $vars[] = array('widget' => array('type' => 'image', 'src' => $GLOBALS['phpgw']->common->image('filemanager', 'button_cancel'), 'title' => lang('close'), 'name' => 'cancel', 'value' => 'cancel'));
     $data['nav_data'] = $vars;
     $data['lang_edit'] = isset($_POST['preview']) ? lang('preview for') : lang('edit file');
     $data['filename'] = $edit_file;
     $vars = array();
     if (isset($_POST['preview'])) {
         $vars['preview'] = nl2br($content);
         $v[] = array('widget' => array('type' => 'hidden', 'name' => 'edit_file_content', 'value' => $content));
     } elseif (isset($_POST['save'])) {
         if ($GLOBALS['phpgw']->vfs->write(array('string' => $this->bofilemanager->path . '/' . $edit_file, 'relatives' => array(RELATIVE_NONE), 'content' => $content))) {
             $vars['output'] = lang('Saved %1', $this->bofilemanager->path . '/' . $edit_file);
         } else {
             $vars['output'] = lang('Could not save %1', $this->bofilemanager->path . '/' . $edit_file);
         }
     }
     if ($edit_file && $GLOBALS['phpgw']->vfs->file_exists(array('string' => $edit_file, 'relatives' => array(RELATIVE_ALL)))) {
         $v[] = array('widget' => array('type' => 'hidden', 'name' => 'edited', 'value' => 1));
         $v[] = array('widget' => array('type' => 'hidden', 'name' => 'edit_file', 'value' => $edit_file));
         $v[] = array('widget' => array('type' => 'hidden', 'name' => 'fileman[0]', 'value' => $this->bofilemanager->html_encode($edit_file, 1)));
         $vars['form_data'] = $v;
         $vars['file_content'] = $content;
     }
     $output = array('form_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'filemanager' . '.uiaction_edit.edit', 'path' => urlencode($this->bofilemanager->path), 'edit_file' => $edit_file)), 'filemanager_nav' => $data, 'filemanager_edit' => $vars);
     //_debug_array($output);
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('edit' => $output));
 }
 function bo($session = False)
 {
     $this->so = createobject('polls.so');
     $this->load_settings();
     if ($session) {
         $this->read_sessiondata();
         $this->use_session = True;
     }
     $_start = get_var('start', array('POST', 'GET'));
     $_query = get_var('query', array('POST', 'GET'));
     $_sort = get_var('sort', array('POST', 'GET'));
     $_order = get_var('order', array('POST', 'GET'));
     $_limit = get_var('limit', array('POST', 'GET'));
     $_filter = get_var('filter', array('POST', 'GET'));
     if (isset($_start)) {
         if ($this->debug) {
             echo '<br>overriding $start: "' . $this->start . '" now "' . $_start . '"';
         }
         $this->start = $_start;
     }
     if ($_limit) {
         $this->limit = $_limit;
     } else {
         $this->limit = $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
     }
     if (empty($_query) && !empty($this->query) || !empty($_query)) {
         $this->query = $_query;
     }
     if (!empty($_sort)) {
         if ($this->debug) {
             echo '<br>overriding $sort: "' . $this->sort . '" now "' . $_sort . '"';
         }
         $this->sort = $_sort;
     } else {
         $this->sort = 'ASC';
     }
     if (!empty($_order)) {
         if ($this->debug) {
             echo '<br>overriding $order: "' . $this->order . '" now "' . $_order . '"';
         }
         $this->order = $_order;
     } else {
         $this->order = 'poll_title';
     }
     if (!empty($_filter)) {
         if ($this->debug) {
             echo '<br>overriding $filter: "' . $this->filter . '" now "' . $_filter . '"';
         }
         $this->filter = $_filter;
     }
 }
 function check_values($values)
 {
     if ($values['b_create']) {
         $doc_root = get_var('DOCUMENT_ROOT', array('GLOBAL', 'SERVER'));
         if ($values['versions']) {
             if (intval($values['versions']) == 0) {
                 $error[] = lang('Versions can only be a number !');
             }
         }
         if ($values['l_save']) {
             if (!$values['l_path'] && !$values['l_websave']) {
                 $error[] = lang('Please enter the path to the backup dir and/or enable showing archives in eGroupWare !');
             }
         }
         $site_co = $this->get_config();
         if (is_array($site_co)) {
             if (!isset($site_co['php_cgi']) || !isset($site_co['tar']) || !isset($site_co['zip']) || !isset($site_co['bzip2'])) {
                 $error[] = lang('Please enter the path of the needed applications in *Site configuration* !');
             }
             if ($values['b_sql']) {
                 if ($GLOBALS['phpgw_info']['server']['db_type'] == 'mysql') {
                     if (!isset($site_co['mysql'])) {
                         $error[] = lang('Please set the path to the MySQL database dir in *Site configuration* !');
                     }
                 } elseif ($GLOBALS['phpgw_info']['server']['db_type'] == 'pgsql') {
                     if (!isset($site_co['pgsql'])) {
                         $error[] = lang('Please set the path to the PostgreSQL database dir in *Site configuration* !');
                     }
                 } else {
                     $error[] = lang('Your SQL database isnt supported by this application !');
                 }
             }
             if ($values['b_ldap']) {
                 if (!isset($site_co['ldap']) || !isset($site_co['ldap_in'])) {
                     $error[] = lang('Please set the path to the LDAP database dir in *Site configuration* !');
                 }
             }
             if ($values['b_email']) {
                 if (!isset($site_co['maildir'])) {
                     $error[] = lang('Please write down you e-mail for beeing notified');
                 }
             }
         } else {
             $error[] = lang('Please set the values in *Site configuration* !');
         }
     }
     if (is_array($error)) {
         return $error;
     }
 }
function common_var($var_name, $default = NULL)
{
    /*
    return 
        (isset($_POST[$var_name]) 
        ? $_POST[$var_name] 
        :   (isset($_GET[$var_name]) 
            ? $_GET[$var_name] 
            : $default)
        );
    */
    $var = post_var($var_name);
    return !is_null($var) ? $var : get_var($var_name, $default);
}
 function bostatistics()
 {
     $action = get_var('action', array('GET'));
     $this->debug = False;
     $this->sostatistics = CreateObject('projects.sostatistics');
     $this->boprojects = CreateObject('projects.boprojects', True, $action);
     $this->displayCharset = $GLOBALS['phpgw']->translation->charset();
     $this->botranslation = CreateObject('phpgwapi.translation');
     $this->start = $this->boprojects->start;
     $this->query = $this->boprojects->query;
     $this->filter = $this->boprojects->filter;
     $this->order = $this->boprojects->order;
     $this->sort = $this->boprojects->sort;
     $this->cat_id = $this->boprojects->cat_id;
     $this->date_diff = 0;
 }
 function preferences()
 {
     $submit = get_var('submit', array('POST'));
     if ($submit) {
         $GLOBALS['phpgw']->preferences->read();
         $prefs = get_var('prefs', array('POST'));
         if ($prefs['mainscreen_showevents'] == True) {
             $GLOBALS['phpgw']->preferences->add('todo', 'mainscreen_showevents', $prefs['mainscreen_showevents']);
         } else {
             $GLOBALS['phpgw']->preferences->delete('todo', 'mainscreen_showevents');
         }
         $GLOBALS['phpgw']->preferences->save_repository(True);
         Header('Location: ' . $GLOBALS['phpgw']->link('/preferences/index.php'));
         $GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
         exit;
     }
 }
 function boprojecthours()
 {
     $action = get_var('action', array('GET'));
     $this->boprojects = CreateObject('projects.boprojects', True, $action);
     $this->boconfig = CreateObject('projects.boconfig');
     $this->sohours = $this->boprojects->sohours;
     $this->account = $this->boprojects->account;
     $this->grants = $this->boprojects->grants;
     $this->start = $this->boprojects->start;
     $this->query = $this->boprojects->query;
     $this->filter = $this->boprojects->filter;
     $this->order = $this->boprojects->order;
     $this->sort = $this->boprojects->sort;
     $this->status = $this->boprojects->status;
     $this->project_id = $this->boprojects->project_id;
     $this->cat_id = $this->boprojects->cat_id;
     $this->siteconfig = $this->boprojects->siteconfig;
 }