Ejemplo n.º 1
0
 function update($VAR)
 {
     $type = "update";
     $this->method["{$type}"] = explode(",", $this->method["{$type}"]);
     $db = new CORE_database();
     $db->update($VAR, $this, $type);
 }
Ejemplo n.º 2
0
 function update($VAR)
 {
     $this->newsletter_construct();
     $type = "update";
     $this->method["{$type}"] = split(",", $this->method["{$type}"]);
     $db = new CORE_database();
     $db->update($VAR, $this, $type);
 }
Ejemplo n.º 3
0
 function update($VAR)
 {
     $this->construct();
     # provisioning data;
     if (!empty($VAR['product_host_provision_plugin_data'])) {
         $VAR['service_host_provision_plugin_data'] = $VAR['product_host_provision_plugin_data'];
         $s = serialize($VAR['service_host_provision_plugin_data']);
     }
     # product plugin data;
     if (!empty($VAR['product_prod_plugin_data'])) {
         $VAR['service_prod_plugin_data'] = $VAR['product_prod_plugin_data'];
     }
     # check if any changes were made that calls for edit queue status
     $queue = true;
     # get the previous data
     $db =& DB();
     $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'service WHERE
                    id           =  ' . $db->qstr($VAR['service_id']) . ' AND
                    site_id      =  ' . $db->qstr(DEFAULT_SITE);
     $rs = $db->Execute($sql);
     if (!empty($VAR['queue_force'])) {
         $queue = false;
     } elseif (!empty($VAR['service_host_provision_plugin_data'])) {
         # compare username
         if ($rs->fields['host_username'] != $VAR['service_host_username']) {
             $VAR['service_queue'] = 'edit';
             # compare password
         } elseif ($rs->fields['host_password'] != $VAR['service_host_password']) {
             $VAR['service_queue'] = 'edit';
             # compare ip
         } elseif (!empty($VAR['service_host_ip']) && $rs->fields['host_ip'] != $VAR['service_host_ip']) {
             $VAR['service_queue'] = 'edit';
             # compare plugin data
         } elseif ($rs->fields['host_provision_plugin_data'] != $s) {
             $VAR['service_queue'] = 'edit';
         } else {
             # suspend/unsuspend
             if ($VAR['service_active'] == 0 && $VAR['service_active'] != $rs->fields['active']) {
                 $VAR['service_queue'] = 'inactive';
             } elseif ($VAR['service_active'] == 1 && $VAR['service_active'] != $rs->fields['active']) {
                 $VAR['service_queue'] = 'active';
             } else {
                 $VAR['service_queue'] = $rs->fields['queue'];
                 $queue = false;
             }
         }
     } else {
         # suspend/unsuspend
         if ($VAR['service_active'] == 0 && $VAR['service_active'] != $rs->fields['active']) {
             $VAR['service_queue'] = 'inactive';
         } elseif ($VAR['service_active'] == 1 && $VAR['service_active'] != $rs->fields['active']) {
             $VAR['service_queue'] = 'active';
         } else {
             $VAR['service_queue'] = $rs->fields['queue'];
             $queue = false;
         }
     }
     # update record
     $type = "update";
     $this->method["{$type}"] = explode(",", $this->method["{$type}"]);
     $db = new CORE_database();
     $db->update($VAR, $this, $type);
     # Run queue now
     if ($queue) {
         $this->queue_one($VAR['service_id'], false);
         return true;
     }
 }
Ejemplo n.º 4
0
    function update($VAR)
    {
        global $C_list, $C_debug;
        if (!$this->checkLimits()) {
            return false;
        }
        // check account limits
        // validate the tax_id
        global $VAR;
        require_once PATH_MODULES . 'tax/tax.inc.php';
        $taxObj = new tax();
        $tax_arr = @$VAR['account_admin_tax_id'];
        if (is_array($tax_arr)) {
            foreach ($tax_arr as $country_id => $tax_id) {
                if ($country_id == $VAR['account_admin_country_id']) {
                    $exempt = @$VAR["account_tax_id_exempt"][$country_id];
                    if (!($txRs = $taxObj->TaxIdsValidate($country_id, $tax_id, $exempt))) {
                        $this->validated = false;
                        global $C_translate;
                        $this->val_error[] = array('field' => 'account_admin_tax_id', 'field_trans' => $taxObj->errField, 'error' => $C_translate->translate('validate_general', "", ""));
                    }
                    if ($exempt) {
                        $VAR['account_admin_tax_id'] = false;
                    } else {
                        $VAR['account_admin_tax_id'] = $tax_id;
                    }
                }
            }
        }
        ####################################################################
        ### Get required static_Vars and validate them... return an array
        ### w/ ALL errors...
        ####################################################################
        require_once PATH_CORE . 'static_var.inc.php';
        $static_var = new CORE_static_var();
        if (!isset($this->val_error)) {
            $this->val_error = false;
        }
        $all_error = $static_var->validate_form('account', $this->val_error);
        if ($all_error != false && gettype($all_error) == 'array') {
            $this->validated = false;
        } else {
            $this->validated = true;
        }
        ####################################################################
        # If validation was failed, skip the db insert &
        # set the errors & origonal fields as Smarty objects,
        # and change the page to be loaded.
        ####################################################################
        if (!$this->validated) {
            global $smarty;
            # set the errors as a Smarty Object
            $smarty->assign('form_validation', $all_error);
            # set the page to be loaded
            if (!defined("FORCE_PAGE")) {
                define('FORCE_PAGE', $VAR['_page_current']);
            }
            return;
        }
        ### Get the old username ( for db mapping )
        $db =& DB();
        $sql = 'SELECT username FROM ' . AGILE_DB_PREFIX . 'account WHERE
					site_id     = ' . $db->qstr(DEFAULT_SITE) . ' AND
					id          = ' . $db->qstr($VAR['account_admin_id']);
        $result = $db->Execute($sql);
        if ($result->RecordCount() > 0) {
            $old_username = $result->fields['username'];
        }
        ### Update the password:
        $update_password = false;
        if (!empty($VAR['_password'])) {
            $VAR['account_admin_password'] = $VAR['_password'];
            /* check if new password is ok */
            if ($C_list->is_installed('account_password_history')) {
                include_once PATH_MODULES . 'account_password_history/account_password_history.inc.php';
                $accountHistory = new account_password_history();
                if (!$accountHistory->getIsPasswordOk($VAR['account_admin_id'], $VAR['account_admin_password'], false)) {
                    $C_debug->alert("The password you have selected has been used recently and cannot be used again at this time for security purposes.");
                    unset($VAR['account_admin_password']);
                } else {
                    $update_password = true;
                }
            }
        }
        ### Update the record
        $type = "update";
        $this->method["{$type}"] = explode(",", $this->method["{$type}"]);
        $db = new CORE_database();
        $ok = $db->update($VAR, $this, $type);
        if ($ok) {
            /* password logging class */
            if ($update_password && is_object($accountHistory)) {
                $accountHistory->setNewPassword($VAR['account_admin_id'], $VAR["account_admin_password"], false);
            }
            ### Update the static vars:
            $static_var->update($VAR, 'account', $VAR['account_admin_id']);
            ### Do any db_mapping
            if ($C_list->is_installed('db_mapping')) {
                include_once PATH_MODULES . 'db_mapping/db_mapping.inc.php';
                $db_map = new db_mapping();
                if (!empty($VAR['account_admin_password'])) {
                    $db_map->plaintext_password = $VAR['account_admin_password'];
                } else {
                    $db_map->plaintext_password = false;
                }
                $db_map->account_edit($VAR['account_admin_id'], $old_username);
            }
            // remove login lock
            if ($VAR['account_admin_status']) {
                $db =& DB();
                $delrs = $db->Execute($sql = sqlDelete($db, "login_lock", "account_id={$VAR['account_admin_id']}"));
                $delrs = $db->Execute($sql = sqlDelete($db, "login_log", "account_id={$VAR['account_admin_id']} AND status=0"));
            }
            return true;
        }
    }
Ejemplo n.º 5
0
 function update($VAR)
 {
     global $_FILES;
     ####################################################################
     ### Validate the thumbnail upoad:
     if (isset($_FILES['upload_file1']) && $_FILES['upload_file1']['size'] > 0) {
         $VAR['product_cat_thumbnail'] = "cat_thmb_" . $_FILES['upload_file1']['name'];
     } elseif ($VAR['delthumb'] == 1) {
         $VAR['product_cat_thumbnail'] = "";
     }
     ### Validate the image upoad:
     if (isset($_FILES['upload_file2']) && $_FILES['upload_file2']['size'] > 0) {
         $VAR['product_cat_image'] = "cat_img_" . $_FILES['upload_file2']['name'];
     } elseif ($VAR['delimg'] == 1) {
         $VAR['product_cat_image'] = "";
     }
     $type = "update";
     $this->method["{$type}"] = explode(",", $this->method["{$type}"]);
     $db = new CORE_database();
     $result = $db->update($VAR, $this, $type);
     ####################################################################
     ### Copy the image(s)
     if ($result) {
         ### Copy 1ST file upoad:
         if (isset($_FILES['upload_file1']) && $_FILES['upload_file1']['size'] > 0) {
             copy($_FILES['upload_file1']['tmp_name'], PATH_IMAGES . "cat_thmb_" . $_FILES['upload_file1']['name']);
         }
         ### Copy the 2ND file upoad:
         if (isset($_FILES['upload_file2']) && $_FILES['upload_file2']['size'] > 0) {
             copy($_FILES['upload_file2']['tmp_name'], PATH_IMAGES . "cat_img_" . $_FILES['upload_file2']['name']);
         }
     }
 }
Ejemplo n.º 6
0
 function update($VAR)
 {
     global $_FILES;
     $imgarr = array('jpeg', 'jpg', 'gif', 'bmp', 'tif', 'tiff', 'png');
     if (isset($_FILES['upload_file1']) && $_FILES['upload_file1']['size'] > 0) {
         for ($i = 0; $i < count($imgarr); $i++) {
             if (eregi($imgarr[$i] . '$', $_FILES['upload_file1']['name'])) {
                 $filename = eregi_replace(',', '', 'prod_thmb_' . @$VAR["id"] . "." . $imgarr[$i]);
                 $i = 10;
             }
         }
     } elseif (@$VAR['delimg'] == 1) {
         $filename = "";
     }
     ### Validate the thumbnail upoad:
     if (isset($filename)) {
         $VAR['product_thumbnail'] = $filename;
     }
     $this->product_construct();
     $type = "update";
     $this->method["{$type}"] = explode(",", $this->method["{$type}"]);
     $db = new CORE_database();
     $result = $db->update($VAR, $this, $type);
     ### Copy the thumbnail
     if ($result && isset($filename)) {
         ### Copy 1ST file upoad:
         copy($_FILES['upload_file1']['tmp_name'], PATH_IMAGES . "" . $filename);
     }
 }
Ejemplo n.º 7
0
 function update($VAR)
 {
     ####################################################################
     ### Get required static_Vars and validate them... return an array
     ### w/ ALL errors...
     ####################################################################
     require_once PATH_CORE . 'static_var.inc.php';
     $static_var = new CORE_static_var();
     if (!isset($this->val_error)) {
         $this->val_error = false;
     }
     $all_error = $static_var->validate_form('affiliate', $this->val_error);
     if ($all_error != false && gettype($all_error) == 'array') {
         $this->validated = false;
     } else {
         $this->validated = true;
     }
     ####################################################################
     # If validation was failed, skip the db insert &
     # set the errors & origonal fields as Smarty objects,
     # and change the page to be loaded.
     ####################################################################
     if (!$this->validated) {
         global $smarty;
         # set the errors as a Smarty Object
         $smarty->assign('form_validation', $all_error);
         # set the page to be loaded
         if (!defined("FORCE_PAGE")) {
             define('FORCE_PAGE', $VAR['_page_current']);
         }
         return;
     }
     # special handling for the affiliate data array
     if (isset($VAR['affiliate_plugin_data']) && is_array($VAR['affiliate_plugin_data'])) {
         while (list($key, $val) = each($VAR['affiliate_plugin_data'])) {
             if (get_magic_quotes_gpc()) {
                 $VAR['affiliate_plugin_data']["{$key}"] = htmlentities(stripcslashes($val), ENT_QUOTES);
             }
         }
     }
     $type = "update";
     $this->method["{$type}"] = explode(",", $this->method["{$type}"]);
     $db = new CORE_database();
     $db->update($VAR, $this, $type);
     ### Update the static vars:
     $static_var->update($VAR, 'affiliate', $VAR['affiliate_id']);
 }
Ejemplo n.º 8
0
 function update($VAR)
 {
     if ($VAR['setup_currency_id'] != DEFAULT_CURRENCY) {
         $curr = true;
     } else {
         $curr = false;
     }
     # make sure the index.php file is not included at the end:
     if (!empty($VAR['setup_ssl_url'])) {
         $VAR['setup_ssl_url'] = eregi_replace('index.php', '', $VAR['setup_ssl_url']);
     }
     if (!empty($VAR['setup_nonssl_url'])) {
         $VAR['setup_nonssl_url'] = eregi_replace('index.php', '', $VAR['setup_nonssl_url']);
     }
     # Validate trailing slash is on the end of the URL:
     if (!empty($VAR['setup_ssl_url']) && !ereg('/$', $VAR['setup_ssl_url'])) {
         $VAR['setup_ssl_url'] .= '/';
     }
     # Validate trailing slash is on the end of the URL:
     if (!empty($VAR['setup_nonssl_url']) && !ereg('/$', $VAR['setup_nonssl_url'])) {
         $VAR['setup_nonssl_url'] .= '/';
     }
     $type = "update";
     $this->method["{$type}"] = explode(",", $this->method["{$type}"]);
     $db = new CORE_database();
     $rs = $db->update($VAR, $this, $type);
     if ($rs && $curr) {
         /* Start: Update all sessions & accounts */
         $db =& DB();
         $sql = "UPDATE " . AGILE_DB_PREFIX . "session \n\t\t\t\t\tSET\n\t\t\t\t\tcurrency_id = " . $db->qstr($VAR['setup_currency_id']) . "\n\t\t\t\t\tWHERE\n\t\t\t\t\tsite_id \t= " . $db->qstr(DEFAULT_SITE) . " AND\n\t\t\t\t\tcurrency_id != " . $db->qstr($VAR['setup_currency_id']);
         $rs = $db->Execute($sql);
         $sql = "UPDATE " . AGILE_DB_PREFIX . "account \n\t\t\t\t\tSET\n\t\t\t\t\tcurrency_id = " . $db->qstr($VAR['setup_currency_id']) . "\n\t\t\t\t\tWHERE\n\t\t\t\t\tsite_id \t= " . $db->qstr(DEFAULT_SITE) . " AND\n\t\t\t\t\tcurrency_id != " . $db->qstr($VAR['setup_currency_id']);
         $rs = $db->Execute($sql);
         /* End: SQL Insert Statement */
     }
     # Clear out the cache entry
     if (defined("AGILE_CORE_CACHE_DIR") && AGILE_CORE_CACHE_DIR != '') {
         $tfile = AGILE_CORE_CACHE_DIR . "core-setup";
         if (file_exists($tfile)) {
             unlink(AGILE_CORE_CACHE_DIR . "core-setup");
         }
     }
 }
Ejemplo n.º 9
0
 function update($VAR)
 {
     // delete assoc faxdata records
     $this->associated_DELETE[] = array('table' => 'voip_fax_data', 'field' => 'fax_id');
     $type = "update";
     $this->method["{$type}"] = split(",", $this->method["{$type}"]);
     $db = new CORE_database();
     $db->update($VAR, $this, $type);
 }
Ejemplo n.º 10
0
 function update($VAR)
 {
     $this->construct();
     $db =& DB();
     # get current department
     $rs = $db->Execute(sqlSelect($db, "ticket", "ticket_department_id", "id=::" . $VAR['ticket_id'] . "::"));
     @($old_ticket_department_id = $rs->fields[0]);
     $type = "update";
     $this->method["{$type}"] = split(",", $this->method["{$type}"]);
     $db = new CORE_database();
     $db->update($VAR, $this, $type);
     # if the ticket was moved to a new department, send email notice to staff members
     if ($old_ticket_department_id != $VAR['ticket_department_id']) {
         $this->send_staff_emails($VAR['ticket_id'], SESS_ACCOUNT, $old_ticket_department_id, 'change');
     }
 }
Ejemplo n.º 11
0
    function update($VAR)
    {
        global $VAR;
        ### Check that user is logged in:
        if (SESS_LOGGED != '1') {
            echo "Sorry, you must be logged in!";
        }
        /* check for sub account */
        $issubaccount = false;
        if (!empty($VAR['account_id']) && $VAR['account_id'] != SESS_ACCOUNT) {
            if ($this->isParentAccount($VAR['account_id'])) {
                $VAR['id'] = $VAR['account_id'];
                global $smarty;
                $issubaccount = true;
            } else {
                return false;
            }
        } else {
            $VAR['id'] = SESS_ACCOUNT;
            $VAR['account_id'] = SESS_ACCOUNT;
        }
        $VAR['account_date_last'] = time();
        // validate the tax_id
        require_once PATH_MODULES . 'tax/tax.inc.php';
        $taxObj = new tax();
        $tax_arr = @$VAR['account_tax_id'];
        if (is_array($tax_arr)) {
            foreach ($tax_arr as $country_id => $tax_id) {
                if ($country_id == $VAR['cid']) {
                    $exempt = @$VAR["account_tax_id_exempt"][$country_id];
                    if (!($txRs = $taxObj->TaxIdsValidate($country_id, $tax_id, $exempt))) {
                        $this->validated = false;
                        global $C_translate;
                        $this->val_error[] = array('field' => 'account_tax_id', 'field_trans' => $taxObj->errField, 'error' => $C_translate->translate('validate_general', "", ""));
                    }
                    if ($exempt) {
                        $VAR['account_tax_id'] = false;
                    } else {
                        $VAR['account_tax_id'] = $tax_id;
                    }
                }
            }
        }
        ####################################################################
        ### Get required static_Vars and validate them... return an array
        ### w/ ALL errors...
        ####################################################################
        require_once PATH_CORE . 'static_var.inc.php';
        $static_var = new CORE_static_var();
        if (!isset($this->val_error)) {
            $this->val_error = false;
        }
        $all_error = $static_var->validate_form('account', $this->val_error);
        if ($all_error != false && gettype($all_error) == 'array') {
            $this->validated = false;
        } else {
            $this->validated = true;
        }
        ####################################################################
        # If validation was failed, skip the db insert &
        # set the errors & origonal fields as Smarty objects,
        # and change the page to be loaded.
        ####################################################################
        if (!$this->validated) {
            global $smarty;
            # set the errors as a Smarty Object
            $smarty->assign('form_validation', $all_error);
            # set the page to be loaded
            if (!defined("FORCE_PAGE")) {
                define('FORCE_PAGE', $VAR['_page_current']);
            }
            return;
        }
        ### Change password
        $password_changed = false;
        if (isset($VAR['account_password']) && $VAR['account_password'] != "") {
            if (isset($VAR['confirm_password']) && $VAR['account_password'] == $VAR['confirm_password']) {
                $password = $VAR['account_password'];
                unset($VAR['account_password']);
                @($VAR["account_password"] = $password);
                ### Alert: the password has been changed!
                global $C_debug, $C_translate;
                $C_debug->alert($C_translate->translate('password_changed', 'account', ''));
                $password_changed = true;
                /* check if new password is ok */
                global $C_list;
                if ($C_list->is_installed('account_password_history')) {
                    include_once PATH_MODULES . 'account_password_history/account_password_history.inc.php';
                    $accountHistory = new account_password_history();
                    if (!$accountHistory->getIsPasswordOk(SESS_ACCOUNT, $VAR['account_password'], false)) {
                        $C_debug->alert("The password you have selected has been used recently and cannot be used again at this time for security purposes.");
                        unset($VAR["account_password"]);
                        $password_changed = false;
                    }
                }
            } else {
                ### ERROR: The passwords provided do not match!
                global $C_debug, $C_translate;
                $C_debug->alert($C_translate->translate('password_change_match', 'account', ''));
                unset($VAR["account_password"]);
            }
        } else {
            unset($VAR["account_password"]);
        }
        ### Change theme
        if (isset($VAR['tid']) && $VAR['tid'] != "") {
            @($VAR["account_theme_id"] = $VAR['tid']);
        }
        ### Change Language
        if (isset($VAR['lid']) && $VAR['lid'] != "") {
            @($VAR["account_language_id"] = $VAR['lid']);
        }
        ### Change country
        if (isset($VAR['cid']) && $VAR['cid'] != "") {
            @($VAR["account_country_id"] = $VAR['cid']);
        }
        ### Change currency
        if (isset($VAR['cyid']) && $VAR['cyid'] != "") {
            @($VAR["account_currency_id"] = $VAR['cyid']);
        }
        ### Get the old username ( for db mapping )
        $db =& DB();
        $sql = 'SELECT username FROM ' . AGILE_DB_PREFIX . 'account WHERE
					site_id     = ' . $db->qstr(DEFAULT_SITE) . ' AND
					id          = ' . $db->qstr(SESS_ACCOUNT);
        $result = $db->Execute($sql);
        if ($result->RecordCount() > 0) {
            $old_username = $result->fields['username'];
        }
        ### Update the record
        $this->account_construct();
        $type = "update";
        $this->method["{$type}"] = split(",", $this->method["{$type}"]);
        $db = new CORE_database();
        $db->update($VAR, $this, $type);
        /* password logging class */
        if ($password_changed && is_object($accountHistory)) {
            $accountHistory->setNewPassword(SESS_ACCOUNT, $VAR['account_password'], false);
        }
        ### Update the static vars:
        $static_var->update($VAR, 'account', SESS_ACCOUNT);
        ### Do any db_mapping
        global $C_list;
        if ($C_list->is_installed('db_mapping')) {
            include_once PATH_MODULES . 'db_mapping/db_mapping.inc.php';
            $db_map = new db_mapping();
            if (!empty($password)) {
                $db_map->plaintext_password = $password;
            } else {
                $db_map->plaintext_password = false;
            }
            $db_map->account_edit(SESS_ACCOUNT, $old_username);
        }
        /* update groups for subaccount */
        if ($issubaccount) {
            $db =& DB();
            $db->Execute(sqlDelete($db, "account_group", "group_id>2 and \n\t\t\t\t(service_id is null or service_id=0 or service_id='') \n\t\t\t\tand account_id=" . $db->qstr($VAR['account_id'])));
            if (!empty($VAR['groups'])) {
                global $C_auth;
                foreach ($VAR['groups'] as $gid => $val) {
                    if ($gid == $val && $C_auth->auth_group_by_id($gid)) {
                        $fields = array('account_id' => $VAR['account_id'], 'group_id' => $gid, 'active' => 1, 'date_orig' => time());
                        $db->Execute(sqlInsert($db, "account_group", $fields));
                    }
                }
            }
        }
    }
Ejemplo n.º 12
0
 function update($VAR)
 {
     $type = "update";
     $this->method["{$type}"] = split(",", $this->method["{$type}"]);
     $db = new CORE_database();
     if ($db->update($VAR, $this, $type)) {
         ### Update the static vars:
         require_once PATH_CORE . 'static_var.inc.php';
         $static_var = new CORE_static_var();
         $static_var->update($VAR, 'newsletter_subscriber', $VAR['id']);
     }
 }
Ejemplo n.º 13
0
 function update($VAR)
 {
     # Validate the files
     for ($i = 1; $i <= 12; $i++) {
         if (isset($_FILES['upload_file' . $i]) && $_FILES['upload_file' . $i]['size'] > 0) {
             $VAR['campaign_type' . $i] = $_FILES['upload_file' . $i]['type'];
             $VAR['campaign_file' . $i] = $_FILES['upload_file' . $i]['name'];
         }
     }
     # Store the record
     $type = "update";
     $this->method["{$type}"] = explode(",", $this->method["{$type}"]);
     $db = new CORE_database();
     $rs = $db->update($VAR, $this, $type);
     ### Copy the files
     if ($rs) {
         for ($i = 1; $i <= 12; $i++) {
             if (isset($_FILES['upload_file' . $i]) && $_FILES['upload_file' . $i]['size'] > 0) {
                 if (!copy($_FILES['upload_file' . $i]['tmp_name'], PATH_FILES . 'campaign_' . $VAR['campaign_id'] . '_' . $i . '.dat')) {
                     ### ERROR:
                 }
             }
         }
     }
 }
Ejemplo n.º 14
0
    function update($VAR)
    {
        global $C_translate, $C_debug;
        $this->validated = true;
        ### Change the path...
        if (isset($VAR['htaccess_dir_path']) && $VAR['htaccess_dir_path'] != '') {
            # trim whitspaces
            $VAR['htaccess_dir_path'] = trim($VAR['htaccess_dir_path']);
            # replace all forward slashes with back slashes
            $VAR['htaccess_dir_path'] = ereg_replace('\\\\', '/', $VAR['htaccess_dir_path']);
            # add the final trailing slash if missing
            if (!ereg('[/]$', $VAR['htaccess_dir_path'])) {
                $VAR['htaccess_dir_path'] = $VAR['htaccess_dir_path'] . '/';
            }
        }
        ### Change the .htaccess data
        if (isset($VAR['htaccess_dir_path']) && $VAR['htaccess_dir_path'] != '') {
            ################################################################
            ### VERIFY LOCAL PATH & WRITABILITY!
            @($filename = $VAR['htaccess_dir_path'] . '.htaccess');
            @($php_filename = $VAR['htaccess_dir_path'] . 'htaccess_index.php');
            @($id = $VAR['htaccess_dir_htaccess_id']);
            $db =& DB();
            $sql = 'SELECT name FROM ' . AGILE_DB_PREFIX . 'htaccess WHERE
							site_id     = ' . $db->qstr(DEFAULT_SITE) . ' AND
							id          = ' . $db->qstr($id);
            $result = $db->Execute($sql);
            @($name = $result->fields['name']);
            ### Check path
            $path = $VAR['htaccess_dir_path'];
            if (is_dir($path)) {
                ### Check if is writable!
                if (is_writable($path)) {
                    ### GENERATE THE EXCLUDE LIST
                    $exclude_list = $this->exclude_list();
                    $nl = "\n";
                    /*
                    $data = $this->htaccess_extra .
                    		'RewriteEngine on'                          . $nl .
                    		'RewriteRule   ^(.*)/.*$      -                  [L]' . $nl .
                    		'RewriteRule '                              .
                    		'' . $exclude_list . '$ '           .
                    		'htaccess_index.php'                              .
                    		'?_HTACCESS_ID='.$id.'&_HTACCESS_DIR_ID='.$VAR["htaccess_dir_id"];
                    */
                    $data = $this->htaccess_extra . 'RewriteEngine on' . $nl;
                    if (empty($VAR['htaccess_dir_recursive'])) {
                        $data .= 'RewriteRule   ^(.*)/.*$      -                  [L]' . $nl;
                    }
                    $data .= 'RewriteRule ' . $exclude_list . '$ htaccess_index.php?_HTACCESS_ID=' . $id . '&_HTACCESS_DIR_ID=' . $VAR["htaccess_dir_id"];
                    ### Set the .htaccess var for the db
                    $VAR['htaccess_dir_htaccess'] = $data;
                } else {
                    ## Path not writable!
                    $this->validated = false;
                    $this->val_error[] = array('field' => 'none', 'field_trans' => $C_translate->translate('error', 'core', ""), 'error' => $C_translate->translate('path_auth', 'htaccess_dir', ""));
                }
            } else {
                ### Path broken!
                $this->validated = false;
                $this->val_error[] = array('field' => 'none', 'field_trans' => $C_translate->translate('error', 'core', ""), 'error' => $C_translate->translate('path_broke', 'htaccess_dir', ""));
            }
        }
        ####################################################################
        ### If validation was failed, skip the db insert &
        ### set the errors & origonal fields as Smarty objects,
        ### and change the page to be loaded.
        ####################################################################
        if (!$this->validated) {
            global $smarty;
            # set the errors as a Smarty Object
            $smarty->assign('form_validation', $this->val_error);
            # set the page to be loaded
            if (!defined("FORCE_PAGE")) {
                define('FORCE_PAGE', $VAR['_page']);
            }
            return;
        }
        ### Update the db record
        $type = "update";
        $this->method["{$type}"] = explode(",", $this->method["{$type}"]);
        $db = new CORE_database();
        $dir = $db->update($VAR, $this, $type);
        if ($dir != false) {
            ### UPDATE THE LOCAL .HTACCESS FILE
            $fp = fopen($filename, "w+");
            fwrite($fp, $data);
            fclose($fp);
            ### UPDATE THE LOCAL htaccess_index.php
            $data = $this->create_php();
            $fp = fopen($php_filename, "w+");
            fwrite($fp, $data);
            fclose($fp);
        }
    }
Ejemplo n.º 15
0
    function update($VAR)
    {
        $type = "update";
        $this->method["{$type}"] = split(",", $this->method["{$type}"]);
        $db = new CORE_database();
        $result = $db->update($VAR, $this, $type);
        if ($result) {
            $id = $VAR['htaccess_id'];
            # Update the php index file for the Apache mod_auth_remote module:
            $GroupArray = '';
            for ($i = 0; $i < count($VAR['htaccess_group_avail']); $i++) {
                if ($i > 0) {
                    $GroupArray .= ',';
                }
                $GroupArray .= $VAR['htaccess_group_avail'][$i];
            }
            $data = '<?php
$Status = ' . @$VAR['htaccess_status'] . ';
$GroupArray = Array(' . $GroupArray . ');
if($Status != "1") { header(\'WWW-Authenticate: Basic realm="Failed"\'); header("HTTP/1.0 401 Unauthorized"); exit; }
include_once("../../../config.inc.php");
require_once(PATH_ADODB  . "adodb.inc.php");
require_once(PATH_CORE   . "database.inc.php");
require_once(PATH_MODULES. "htaccess/mod_auth_remote.inc.php"); 
?>';
            # add dir:
            $dir = PATH_FILES . 'htaccess_' . $id;
            if (!is_dir($dir)) {
                mkdir($dir, '755');
            }
            $file = PATH_FILES . 'htaccess_' . $id . '/index.php';
            $fp = fopen($file, "w+");
            fputs($fp, $data);
            fclose($fp);
        }
    }
 function update($VAR)
 {
     $this->static_page_category_construct();
     $type = "update";
     $this->method["{$type}"] = explode(",", $this->method["{$type}"]);
     $db = new CORE_database();
     $db->update($VAR, $this, $type);
 }
Ejemplo n.º 17
0
 function update($VAR)
 {
     #remove any group ids <= 1001 from the VAR array:
     global $C_debug, $C_auth;
     $id_list = '';
     if (isset($VAR["delete_id"])) {
         $id = explode(',', $VAR["delete_id"]);
     } elseif (isset($VAR["id"])) {
         $id = explode(',', $VAR["id"]);
     }
     for ($i = 0; $i < count($id); $i++) {
         if (!empty($id[$i]) && $id[$i] > 1001) {
             if ($i == 0) {
                 $id_list .= $id[$i];
             } else {
                 $id_list .= ',' . $id[$i];
             }
             # Check if group allowed:
             if (!$C_auth->auth_group_by_id($id[$i])) {
                 $C_debug->alert('The selected group cannot be modified as your account is not authorized for it.');
                 return;
             }
         } else {
             $C_debug->alert('The selected group is part of the CORE and cannot be edited.');
             return;
         }
     }
     $type = "update";
     $this->method["{$type}"] = explode(",", $this->method["{$type}"]);
     $db = new CORE_database();
     $db->update($VAR, $this, $type);
 }
 function update($VAR)
 {
     global $C_translate, $C_debug;
     /* load database object */
     $db = new CORE_database();
     $this->construct();
     $type = "update";
     /* conditional fields for cc/eft */
     $dbx =& DB();
     $rs = $dbx->Execute(sqlSelect($dbx, "account_billing", "card_type,id,checkout_plugin_id", "id=::{$VAR['id']}::"));
     if (!$rs || !$rs->RecordCount()) {
         return false;
     }
     $billing_id = $rs->fields['id'];
     $checkout_plugin_id = $rs->fields['checkout_plugin_id'];
     if ($rs->fields['card_type'] == 'eft') {
         /* EFT   */
         $this->method["{$type}"] = $db->ignore_fields(array('card_exp_month', 'card_exp_year', 'card_num'), $this->method["{$type}"]);
         /* last four */
         @($VAR['account_billing_card_num4'] = substr($VAR['account_billing_eft_check_acct'], strlen($VAR['account_billing_eft_check_acct']) - 4, 4));
     } else {
         /* CC   */
         # Validate the exp date
         if (mktime(0, 0, 0, $VAR['account_billing_card_exp_month'], date('d'), $VAR['account_billing_card_exp_year']) <= time()) {
             $msg = $C_translate->translate('val_exp', 'account_billing', '');
             $C_debug->alert($msg);
             return false;
         }
         # Validate the card against the card type
         include_once PATH_CORE . 'validate.inc.php';
         $validate = new CORE_validate();
         if (!$validate->validate_cc(@$VAR['account_billing_card_num'], 'card_num', @$VAR['account_billing_card_type'], false)) {
             $msg = $C_translate->translate('val_cc', 'account_billing', '');
             $C_debug->alert($msg);
             return false;
         }
         $this->method["{$type}"] = $db->ignore_fields(array('eft_trn', 'eft_check_acct'), $this->method["{$type}"]);
         /* last four */
         @($VAR['account_billing_card_num4'] = substr($VAR['account_billing_card_num'], strlen($VAR['account_billing_card_num']) - 4, 4));
     }
     if ($db->update($VAR, $this, $type)) {
         # Update any invoices using this billing record
         $dba =& DB();
         $sql = "UPDATE " . AGILE_DB_PREFIX . "invoice SET\n\t\t\t\t\t\tcheckout_plugin_id \t= " . $dba->qstr($checkout_plugin_id) . "\n\t\t\t\t\t\tWHERE site_id\t\t\t\t= " . $dba->qstr(DEFAULT_SITE) . "\n\t\t\t\t\t\tAND account_billing_id\t= " . $dba->qstr($billing_id);
         $result = $dba->Execute($sql);
         return true;
     }
     return false;
 }
Ejemplo n.º 19
0
 function update($VAR)
 {
     $type = "update";
     $this->method["{$type}"] = explode(",", $this->method["{$type}"]);
     $db = new CORE_database();
     $db->update($VAR, $this, $type);
     # update the voip_sip table fields
     $db =& DB();
     $rs = $db->Execute(sqlSelect($db, "voip_did", "did", "id=::" . $VAR['id'] . "::"));
     #echo "<pre>".print_r($VAR,true)."</pre>";
     $f[0]['username'] = $VAR['sip_username'];
     $f[1]['secret'] = $VAR['sip_secret'];
     $f[2]['qualify'] = $VAR['sip_qualify'];
     $f[3]['mailbox'] = $VAR['sip_mailbox'];
     $f[4]['incominglimit'] = $VAR['sip_incominglimit'];
     $f[5]['dtmfmode'] = $VAR['sip_dtmfmode'];
     $f[6]['canreinvite'] = $VAR['sip_canreinvite'];
     $f[7]['callerid'] = $VAR['sip_callerid'];
     $f[8]['nat'] = $VAR['sip_nat'];
     for ($i = 0; $i < 9; $i++) {
         #echo "<pre>".print_r($f[$i],true)."</pre>";
         $k = key($f[$i]);
         $v = $f[$i][$k];
         if (empty($v)) {
             $sql = "DELETE FROM " . AGILE_DB_PREFIX . "voip_sip WHERE sip=" . $db->qstr($rs->fields['did']) . " and keyword=" . $db->qstr($k) . " and site_id=" . DEFAULT_SITE;
         } else {
             $rs2 = $db->Execute(sqlSelect($db, "voip_sip", "id", "sip=::" . $rs->fields['did'] . ":: AND keyword=::" . $k . "::"));
             if ($rs2 && $rs2->fields[0] > 0) {
                 $sql = "UPDATE " . AGILE_DB_PREFIX . "voip_sip SET data=" . $db->qstr($v) . " WHERE sip=" . $db->qstr($rs->fields['did']) . " and keyword=" . $db->qstr($k) . " and site_id=" . DEFAULT_SITE;
             } else {
                 $flds['data'] = $v;
                 $flds['keyword'] = $k;
                 $flds['sip'] = $rs->fields['did'];
                 $sql = sqlInsert($db, "voip_sip", $flds);
                 # $sql = "INSERT INTO ".AGILE_DB_PREFIX."voip_sip SET data=".$db->qstr($v)." WHERE sip=".$db->qstr($rs->fields['did'])." and keyword=".$db->qstr($k)." and site_id=".DEFAULT_SITE;
             }
         }
         if (!$db->Execute($sql)) {
             echo $db->ErrorMsg();
         }
     }
 }