Ejemplo n.º 1
0
    function login($VAR, $md5 = true)
    {
        global $C_translate, $C_debug;
        # check that the username/password are both set
        if ($VAR['_username'] == '' || $VAR['_password'] == '') {
            $C_debug->alert($C_translate->translate('login_enter_both', '', ''));
            return;
        }
        # md5 the password
        if ($md5) {
            $pass = md5($VAR['_password']);
        } else {
            $pass = $VAR['_password'];
        }
        # check the database for a match
        $db =& DB();
        $q = "SELECT id,status,username,password,date_expire FROM " . AGILE_DB_PREFIX . "account WHERE\n\t\t\t\tpassword = '******' AND\n\t\t\t\tusername = '******'_username'] . "' AND\n\t\t\t\tsite_id  = '" . DEFAULT_SITE . "'";
        $result = $db->Execute($q);
        # get the account id
        $id = $result->fields['id'];
        # check that their is no lock on this account id or IP address:
        if ($this->locked($id)) {
            $C_debug->alert($C_translate->translate('login_locked', '', ''));
            return;
        }
        # verify the username/password match.
        if ($result->fields['username'] == $VAR['_username']) {
            if ($result->fields['password'] !== $VAR['_password'] && $result->fields['password'] != $pass) {
                # no match
                $C_debug->alert($C_translate->translate('login_pw_failed', '', ''));
                # log as a failed login
                $this->lock_check($VAR, "0", $id);
                return;
            }
        } else {
            # no username match
            $C_debug->alert($C_translate->translate('login_un_pw_failed', '', ''));
            # reload the login page
            $VAR["_page"] = 'account:login';
            # log as a failed login
            $this->lock_check($VAR, "0", $VAR['_username']);
            return;
        }
        if ($result->fields['date_expire'] == "0" || $result->fields['date_expire'] == "") {
            $date_expire = time() + 99;
        } else {
            $date_expire = $result->fields['date_expire'];
        }
        # check that it is an active account
        if ($result->fields['status'] != "1" || $date_expire <= time()) {
            # inactive account
            $C_debug->alert($C_translate->translate('login_inactive', '', ''));
            # log as failed login
            $this->lock_check($VAR, "0", $id);
            return;
        } else {
            # active account - check for password sharing if login_share module is installed
            include_once PATH_CORE . 'list.inc.php';
            $C_list = new CORE_list();
            if ($C_list->is_installed('login_share')) {
                include_once PATH_MODULES . 'login_share/login_share.inc.php';
                $share = new login_share();
                if (!$share->login($id, $VAR['_username'])) {
                    # shared account alert
                    $C_debug->alert($C_translate->translate('shared_account', 'login_share', ''));
                    # log as failed login
                    $this->lock_check($VAR, "0", $id);
                    return;
                }
            }
        }
        # set the expiry date of the login session
        $date_expire = time() + SESSION_EXPIRE * 60;
        # update the DB
        $db =& DB();
        $q = "UPDATE " . AGILE_DB_PREFIX . "session\n\t\t\t\tSET\n\t\t\t\tip= '" . USER_IP . "',\n\t\t\t\tdate_expire = '{$date_expire}',\n\t\t\t\tlogged = '1',\n\t\t\t\taccount_id = '{$id}'\n\t\t\t\tWHERE\n\t\t\t\tid = '" . SESS . "'\n\t\t\t\tAND\n\t\t\t\tsite_id = '" . DEFAULT_SITE . "'";
        $result = $db->Execute($q);
        # delete any old sessions for this account
        $db =& DB();
        $q = "DELETE FROM " . AGILE_DB_PREFIX . "session   WHERE\n\t\t\t\taccount_id = '{$id}' \tAND\n\t\t\t\tid != '" . SESS . "' AND\n\t\t\t\tsite_id = '" . DEFAULT_SITE . "'";
        $result = $db->Execute($q);
        #return logged in message
        $C_debug->alert($C_translate->translate('login_success', '', ''));
        # Get the last successful login:
        $db =& DB();
        $q = "SELECT * FROM  " . AGILE_DB_PREFIX . "login_log   WHERE\n\t\t\t  account_id    = " . $db->qstr($id) . " \tAND\n\t\t\t  status        = " . $db->qstr(1) . "      AND\n\t\t\t  site_id       = " . $db->qstr(DEFAULT_SITE) . "\n\t\t\t  ORDER BY date_orig DESC LIMIT 1";
        $result = $db->Execute($q);
        if ($result->RecordCount() != 0) {
            $ip = $result->fields["ip"];
            $date = $result->fields["date_orig"];
            $date1 = date(UNIX_DATE_FORMAT, $date);
            $date1 .= "  " . date(DEFAULT_TIME_FORMAT, $date);
            $message = $C_translate->translate('login_log_success', '', '');
            $message = ereg_replace('%date%', $date1, $message);
            $message = ereg_replace('%ip%', $ip, $message);
            $C_debug->alert($message);
        }
        # log the successful login
        $this->lock_check($VAR, "1", $id);
        ####################################################################
        ### Do any db_mapping
        ####################################################################
        $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'module WHERE
					site_id     = ' . $db->qstr(DEFAULT_SITE) . ' AND
					name        = ' . $db->qstr('db_mapping') . ' AND
					status      = ' . $db->qstr("1");
        $result = $db->Execute($sql);
        if ($result->RecordCount() > 0) {
            include_once PATH_MODULES . 'db_mapping/db_mapping.inc.php';
            $db_map = new db_mapping();
            $db_map->login($id);
        }
    }
Ejemplo n.º 2
0
    function view_form($module, $record_id)
    {
        global $VAR, $C_translate;
        ####################################################################
        ### $Method is the method name called to add records, so we know if we
        ### should use the error class, i.e: 'user_add'
        ### $record_id is the record to retrieve values for
        ####################################################################
        ### Get the Id for this module
        $db =& DB();
        $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'module WHERE
					site_id     = ' . $db->qstr(DEFAULT_SITE) . ' AND
					name        = ' . $db->qstr($module);
        $result = $db->Execute($sql);
        if ($result->RecordCount() == 0) {
            return false;
        } else {
            $module_id = $result->fields['id'];
        }
        ####################################################################
        ### Get all the associated STATIC RELATION records
        $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'static_relation WHERE
					site_id     = ' . $db->qstr(DEFAULT_SITE) . ' AND
					module_id   = ' . $db->qstr($module_id) . ' ORDER BY sort_order';
        $relation = $db->Execute($sql);
        if ($relation->RecordCount() == 0) {
            return false;
        } else {
            $i = 0;
            while (!$relation->EOF) {
                ################################################################
                ### Get the primary settings for this field
                $id = $relation->fields['id'];
                $static_var_id = $relation->fields['static_var_id'];
                ############################################################
                ### Get the extended details for this field from the STATIC
                ### VAR records
                $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'static_var WHERE
						   site_id     = ' . $db->qstr(DEFAULT_SITE) . ' AND
						   id          = ' . $db->qstr($static_var_id);
                $var = $db->Execute($sql);
                $format = $var->fields['input_format'];
                $validation = $var->fields['validation_type'];
                $convert = $var->fields['convert_type'];
                $this_name = $var->fields['name'];
                ############################################################
                ### Get the value for this record, if any...
                $sql = 'SELECT value FROM ' . AGILE_DB_PREFIX . 'static_var_record
						   WHERE
						   site_id      = ' . $db->qstr(DEFAULT_SITE) . ' AND
						   record_id    = ' . $db->qstr($record_id) . ' AND
						   static_var_id= ' . $db->qstr($static_var_id) . ' AND
						   static_var_relation_id = ' . $db->qstr($id) . ' AND
						   module_id = ' . $db->qstr($module_id);
                $value = $db->Execute($sql);
                $static_value = $value->fields['value'];
                ############################################################
                ### Create the HTML
                if ($format == 'small_text') {
                    if ($display == 'update') {
                        ### SMALL TEXT FIELD
                        $this_html = '<input type="text" size="8" name="' . $static_relation . '" value="' . $static_value . '" class="' . $css . '">';
                    } else {
                        if ($static_value != '') {
                            $this_html = $static_value;
                        }
                    }
                } else {
                    if ($format == 'medium_text') {
                        if ($display == 'update') {
                            ### MEDIUM TEXT FIELD
                            $this_html = '<input type="text" size="32" name="' . $static_relation . '" value="' . $static_value . '">';
                        } else {
                            if ($static_value != '') {
                                $this_html = $static_value;
                            }
                        }
                    } else {
                        if ($format == 'large_text') {
                            if ($display == 'update') {
                                ### LARGE TEXT FIELD
                                $this_html = '<textarea name="' . $static_relation . '" cols="40" rows="5">' . $static_value . '</textarea>';
                            } else {
                                if ($static_value != '') {
                                    $return = '
';
                                    $this_html = ereg_replace($return, '<br>', $static_value);
                                }
                            }
                        } else {
                            if ($format == 'dropdown_list') {
                                if ($display == 'update') {
                                    ### MENU LIST
                                    $this_html = '<select name="' . $static_relation . '">';
                                    if (isset($default_value) && $default_value != '') {
                                        $option = split(',', $default_value);
                                        for ($i = 0; $i < count($option); $i++) {
                                            $this_html .= '<option value="' . $option[$i] . '"';
                                            if (!isset($VAR["static_relation"]["{$id}"]) || $VAR["static_relation"]["{$id}"] == $option[$i]) {
                                                $this_html .= ' selected';
                                            }
                                            $this_html .= '>' . $option[$i] . '</option>';
                                        }
                                    } else {
                                        $this_html .= '<option value=""></>';
                                    }
                                    $this_html .= '</select>';
                                } else {
                                    if ($static_value != '') {
                                        $this_html = $static_value;
                                    }
                                }
                            } else {
                                if ($format == 'calendar') {
                                    if ($display == 'update') {
                                        ### SHOW DATE SELECTOR
                                        $C_list = new CORE_list();
                                        $this_html = $C_list->calender_add_static_var($static_relation, $static_value, $css);
                                    } else {
                                        if ($static_value != '') {
                                            $date = date(UNIX_DATE_FORMAT, $static_value);
                                            $this_html = $date;
                                        }
                                    }
                                } else {
                                    if ($format == 'file_upload') {
                                        if ($display == 'update') {
                                            ### FILE UPLOAD
                                            $this_html = 'File upload not yet supported!';
                                        } else {
                                            if ($static_value != '') {
                                                $this_html = '';
                                            }
                                        }
                                    } else {
                                        if ($format == 'status') {
                                            if ($display == 'update') {
                                                ### BOOLEAN TRUE/FALSE
                                                $C_list = new CORE_list();
                                                $this_html = $C_list->bool_static_var($static_relation, $static_value, $css_menu);
                                            } else {
                                                if ($static_value != '') {
                                                    if ($static_value == 1) {
                                                        $this_html = $C_translate->translate('true', '', '');
                                                    } else {
                                                        $this_html = $C_translate->translate('false', '', '');
                                                    }
                                                }
                                            }
                                        } else {
                                            if ($format == 'checkbox') {
                                                if ($display == 'update') {
                                                    ### CHECKBOX
                                                    if ($static_value == '1') {
                                                        $this_html = '<input type="checkbox" name="' . $static_relation . '" value="1" checked>';
                                                    } else {
                                                        $this_html = '<input type="checkbox" name="' . $static_relation . '" value="1">';
                                                    }
                                                } else {
                                                    if ($static_value != '') {
                                                        if ($static_value == 1) {
                                                            $this_html = $C_translate->translate('true', '', '');
                                                        } else {
                                                            $this_html = $C_translate->translate('false', '', '');
                                                        }
                                                    }
                                                }
                                            } else {
                                                if ($format == 'hidden' && $static_value != '') {
                                                    ### HIDDEN FIELD
                                                    $this_html = $static_value;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                ### add to the array
                if ($static_value != '') {
                    $arr[] = array('name' => $this_name, 'html' => $this_html);
                    $i++;
                }
                $relation->MoveNext();
            }
        }
        return $arr;
    }
Ejemplo n.º 3
0
 *
 * This body of work is free software; you can redistribute it and/or
 * modify it under the terms of the Open AgileBill License
 * License as published at http://www.agileco.com/agilebill/license1-4.txt
 * 
 * For questions, help, comments, discussion, etc., please join the
 * Agileco community forums at http://forum.agileco.com/ 
 *
 * @link http://www.agileco.com/
 * @copyright 2004-2008 Agileco, LLC.
 * @license http://www.agileco.com/agilebill/license1-4.txt
 * @author Tony Landis <*****@*****.**> 
 * @package AgileBill
 * @version 1.4.93
 */
$list = new CORE_list();
# get version
$fp = @fopen(PATH_AGILE . 'Version.txt', "r");
if ($fp) {
    $ver = fread($fp, 255);
    fclose($fp);
} else {
    $ver = "SVN";
}
# get latest version
$fp = fopen('http://agileco.com/Version.txt', "r");
$abv = fread($fp, 255);
fclose($fp);
# get encoding version
require_once 'includes/pear/Compat/Function/file_get_contents.php';
$tmp = file_get_contents(PATH_AGILE . 'index.php');
Ejemplo n.º 4
0
 function send($template, $acct, $sql1, $sql2, $sql3, $queue = true)
 {
     global $VAR, $C_debug;
     $db =& DB();
     # Send to admin only?
     $admin_only = false;
     if (eregi('admin->', $template)) {
         $admin_only = true;
         $template = eregi_replace('admin->', '', $template);
     }
     ############################################################
     ### Get the template settings
     $q = "SELECT * FROM " . AGILE_DB_PREFIX . "email_template WHERE\n\t\t\t\tsite_id     = " . $db->qstr(DEFAULT_SITE) . " AND\n\t\t\t\tname        = " . $db->qstr($template);
     $template = $db->Execute($q);
     if ($template->fields['status'] != '1') {
         return;
     }
     $E['priority'] = $template->fields["priority"];
     ############################################################
     ### Get the setup_email settings
     if (empty($template->fields["setup_email_id"])) {
         $setup_email_id = DEFAULT_SETUP_EMAIL;
     } else {
         $setup_email_id = $template->fields["setup_email_id"];
     }
     $q = "SELECT * FROM " . AGILE_DB_PREFIX . "setup_email WHERE\n\t\t\t\tsite_id     = " . $db->qstr(DEFAULT_SITE) . " AND\n\t\t\t\tid          = " . $db->qstr($setup_email_id);
     $setup_email = $db->Execute($q);
     ### E-mail queue?
     if ($setup_email->fields['queue'] == 1 && $queue) {
         # Set sql vars
         if (is_array($sql1)) {
             $sql1 = serialize($sql1);
         }
         if (is_array($sql2)) {
             $sql2 = serialize($sql2);
         }
         if (is_array($sql3)) {
             $sql3 = serialize($sql3);
         }
         if (is_array($VAR)) {
             $var = serialize($VAR);
         }
         if (@$admin_only) {
             $sql_template = "admin->" . $template->fields['name'];
         } else {
             $sql_template = $template->fields['name'];
         }
         # Check that this email is not already in the queue:
         $q = "SELECT id FROM " . AGILE_DB_PREFIX . "email_queue WHERE\n\t\t\t\t\tsite_id     = " . $db->qstr(DEFAULT_SITE) . " AND\n\t\t\t\t\tstatus\t\t= 0 AND\n\t\t\t\t\taccount_id\t= '{$acct}' AND\n\t\t\t\t\temail_template= " . $db->qstr($sql_template) . " AND\n\t\t\t\t\tsql1\t\t= " . $db->qstr(@$sql1) . " AND\n\t\t\t\t\tsql2\t\t= " . $db->qstr(@$sql2) . " AND\n\t\t\t\t\tsql3\t\t= " . $db->qstr(@$sql3);
         $duplicates = $db->Execute($q);
         if ($duplicates != false && $duplicates->RecordCount() > 0) {
             return;
         }
         # queue this e-mail:
         $id = $db->GenID(AGILE_DB_PREFIX . 'email_queue_id');
         $sql = "INSERT INTO " . AGILE_DB_PREFIX . "email_queue SET\n\t\t\t\t\tid \t\t\t= {$id},\n\t\t\t\t\tsite_id \t= " . DEFAULT_SITE . ",\n\t\t\t\t\tdate_orig\t= " . time() . ",\n\t\t\t\t\tdate_last\t= " . time() . ",\n\t\t\t\t\tstatus\t\t= 0,\n\t\t\t\t\taccount_id\t= '{$acct}',\n\t\t\t\t\temail_template= " . $db->qstr($sql_template) . ",\n\t\t\t\t\tsql1\t\t= " . $db->qstr(@$sql1) . ",\n\t\t\t\t\tsql2\t\t= " . $db->qstr(@$sql2) . ",\n\t\t\t\t\tsql3\t\t= " . $db->qstr(@$sql3) . ", \n\t\t\t\t\tvar\t\t\t= " . $db->qstr(@$var);
         $db->Execute($sql);
         return;
     }
     if ($setup_email->fields['type'] == 0) {
         $type = 0;
     } else {
         $type = 1;
         $E['server'] = $setup_email->fields['server'];
         $E['account'] = $setup_email->fields['username'];
         $E['password'] = $setup_email->fields['password'];
     }
     $E['from_name'] = $setup_email->fields['from_name'];
     $E['from_email'] = $setup_email->fields['from_email'];
     if ($setup_email->fields['cc_list'] != '') {
         $E['cc_list'] = split(',', $setup_email->fields['cc_list']);
     }
     if ($setup_email->fields['bcc_list'] != '') {
         $E['bcc_list'] = split(',', $setup_email->fields['bcc_list']);
     }
     ############################################################
     ### Get the account settings
     $q = "SELECT * FROM " . AGILE_DB_PREFIX . "account WHERE\n\t\t\t\tsite_id     = " . $db->qstr(DEFAULT_SITE) . " AND\n\t\t\t\t(\n\t\t\t\temail\t\t= " . $db->qstr($acct) . " OR\n\t\t\t\tid          = " . $db->qstr($acct) . "\n\t\t\t\t)";
     $account = $db->Execute($q);
     if ($account == false) {
         $C_debug->error('email_template.inc.php', 'send1', $db->ErrorMsg() . " " . $sql);
         return false;
     } else {
         if ($admin_only == false) {
             if ($account->RecordCount() > 0) {
                 $E['to_email'] = $account->fields['email'];
                 $E['to_name'] = $account->fields['first_name'] . ' ' . $account->fields['last_name'];
                 $this->ab_account = true;
             } else {
                 $E['to_email'] = $acct;
                 $E['to_name'] = $acct;
                 $this->ab_account = false;
             }
         } else {
             $E['to_email'] = $setup_email->fields['from_email'];
             $E['to_name'] = $setup_email->fields['from_name'];
             $this->ab_account = true;
         }
     }
     ############################################################
     ### Get the template translation for the specified account for text/htm
     if (@$this->ab_account && @$account->fields["language_id"] != "") {
         $language_id = $account->fields["language_id"];
     } else {
         $language_id = DEFAULT_LANGUAGE;
     }
     $q = "SELECT * FROM " . AGILE_DB_PREFIX . "email_template_translate WHERE\n\t\t\t\tsite_id             = " . $db->qstr(DEFAULT_SITE) . " AND\n\t\t\t\tlanguage_id         = " . $db->qstr($language_id) . " AND\n\t\t\t\temail_template_id   = " . $db->qstr($template->fields["id"]);
     $setup_email = $db->Execute($q);
     if (!$setup_email || !$setup_email->RecordCount()) {
         # get the default translation for this email:
         $q = "SELECT * FROM " . AGILE_DB_PREFIX . "email_template_translate WHERE\n\t\t\t\t\tsite_id             = " . $db->qstr(DEFAULT_SITE) . " AND\n\t\t\t\t\tlanguage_id         = " . $db->qstr(DEFAULT_LANGUAGE) . " AND\n\t\t\t\t\temail_template_id   = " . $db->qstr($template->fields["id"]);
         $setup_email = $db->Execute($q);
     }
     if (!$setup_email || !$setup_email->RecordCount()) {
         # unable to locate translation!
         global $C_debug;
         $message = 'Unable to locate translation for Email Template "' . $template->fields['name'] . '" and Language "' . $language_id . '" OR "' . DEFAULT_LANGUAGE . '"';
         $C_debug->error('email_template.inc.php', 'send', $message);
         return;
     }
     # set the subject:
     $E['subject'] = $setup_email->fields['subject'];
     # determine whether to send HTML or not...
     if (@$this->ab_account && $account->fields['email_type'] == 1) {
         if (!empty($setup_email->fields['message_html'])) {
             $E['body_html'] = $setup_email->fields['message_html'];
             $E['html'] = '1';
         } else {
             $E['body_html'] = false;
             $E['html'] = '0';
         }
     } else {
         $E['html'] = '0';
     }
     $E['body_text'] = $setup_email->fields['message_text'];
     ### Get the date-time
     include_once PATH_CORE . 'list.inc.php';
     $C_list = new CORE_list();
     $date = $C_list->date_time(time());
     ### Url formatting...
     if ($admin_only) {
         $site_url = URL . 'admin.php';
         $site_ssl_url = SSL_URL . 'admin.php';
     } else {
         $site_url = URL;
         $site_ssl_url = SSL_URL;
     }
     ### Get the replace vars from the email template:
     $replace = array('%site_name%' => $E['from_name'], '%site_email%' => $E['from_email'], '%url%' => $site_url, '%date%' => $date, '%ssl_url%' => $site_ssl_url);
     ### Get the replace vars from the $VAR variable:
     reset($VAR);
     while (list($key, $value) = each($VAR)) {
         $re_this = "%var_" . $key . "%";
         $replace[$re_this] = $value;
     }
     ### Get the replace vars from the account:
     $replace['%acct_id%'] = $acct;
     if (@$this->ab_account) {
         while (list($key, $value) = each($account->fields)) {
             $re_this = "%acct_" . $key . "%";
             $replace[$re_this] = $value;
         }
     }
     ############################################################
     ### Get the SQL1 Query/Arrays
     if (!empty($template->fields["sql_1"]) && !empty($sql1) && !is_array($sql1)) {
         $sql = eregi_replace('%DB_PREFIX%', AGILE_DB_PREFIX, $template->fields["sql_1"]);
         $sql = eregi_replace('%SQL1%', $db->qstr($sql1), $sql);
         if (!is_array($sql2)) {
             $sql = eregi_replace('%SQL2%', $db->qstr($sql2), $sql);
         }
         if (!is_array($sql3)) {
             $sql = eregi_replace('%SQL3%', $db->qstr($sql3), $sql);
         }
         $sql .= " AND site_id     = " . $db->qstr(DEFAULT_SITE);
         $SQL_1 = $db->Execute($sql);
         if ($SQL_1 == false) {
             ### return the error message
             global $C_debug;
             $C_debug->error('email_template.inc.php', 'send', $db->ErrorMsg() . " " . $sql);
         } else {
             if ($SQL_1->RecordCount() > 0) {
                 ### Get the replace vars from the sql results:
                 while (list($key, $value) = each($SQL_1->fields)) {
                     $re_this = "%sql1_" . $key . "%";
                     $replace[$re_this] = $value;
                 }
             }
         }
     } elseif (is_array($sql1)) {
         while (list($key, $value) = each($sql1[$i])) {
             $replace[$key] = $value;
         }
     } elseif (!empty($sql1)) {
         $replace['%sql1%'] = $sql3;
     }
     ############################################################
     ### Get the SQL2 Query/Arrays
     if (!empty($template->fields["sql_2"]) && !empty($sql2) && !is_array($sql2)) {
         $sql = eregi_replace('%DB_PREFIX%', AGILE_DB_PREFIX, $template->fields["sql_2"]);
         $sql = eregi_replace('%SQL1%', $db->qstr($sql1), $sql);
         if (!is_array($sql2)) {
             $sql = eregi_replace('%SQL2%', $db->qstr($sql2), $sql);
         }
         if (!is_array($sql3)) {
             $sql = eregi_replace('%SQL3%', $db->qstr($sql3), $sql);
         }
         $sql .= " AND site_id     = " . $db->qstr(DEFAULT_SITE);
         $SQL_2 = $db->Execute($sql);
         if ($SQL_2 == false) {
             ### return the error message
             global $C_debug;
             $C_debug->error('email_template.inc.php', 'send', $db->ErrorMsg() . " " . $sql);
         } else {
             if ($SQL_2->RecordCount() > 0) {
                 ### Get the replace vars from the sql results:
                 while (list($key, $value) = each($SQL_2->fields)) {
                     $re_this = "%sql2_" . $key . "%";
                     $replace[$re_this] = $value;
                 }
             }
         }
     } elseif (is_array($sql2)) {
         while (list($key, $value) = each($sql2[$i])) {
             $replace[$key] = $value;
         }
     } elseif (!empty($sql2)) {
         $replace['%sql2%'] = $sql2;
     }
     ############################################################
     ### Get the SQL3 Query/Arrays
     if (!empty($template->fields["sql_3"]) && !empty($sql3) && !is_array($sql3)) {
         $sql = eregi_replace('%DB_PREFIX%', AGILE_DB_PREFIX, $template->fields["sql_3"]);
         $sql = eregi_replace('%SQL1%', $db->qstr($sql1), $sql);
         if (!is_array($sql2)) {
             $sql = eregi_replace('%SQL2%', $db->qstr($sql2), $sql);
         }
         if (!is_array($sql3)) {
             $sql = eregi_replace('%SQL3%', $db->qstr($sql3), $sql);
         }
         $sql .= " AND site_id     = " . $db->qstr(DEFAULT_SITE);
         $SQL_3 = $db->Execute($sql);
         if ($SQL_3 == false) {
             ### return the error message
             global $C_debug;
             $C_debug->error('email_template.inc.php', 'send', $db->ErrorMsg() . " " . $sql);
         } else {
             if ($SQL_3->RecordCount() > 0) {
                 ### Get the replace vars from the sql results:
                 while (list($key, $value) = each($SQL_3->fields)) {
                     $re_this = "%sql3_" . $key . "%";
                     $replace[$re_this] = $value;
                 }
             }
         }
     } elseif (is_array($sql3)) {
         while (list($key, $value) = each($sql3)) {
             $replace[$key] = $value;
         }
     } elseif (!empty($sql3)) {
         $replace['%sql3%'] = $sql3;
     }
     ### Replace the $replace vars in the body and subject
     while (list($key, $value) = each($replace)) {
         $E['subject'] = eregi_replace($key, $value, $E['subject']);
         $E['body_text'] = eregi_replace($key, $value, $E['body_text']);
         if (!empty($E['body_html'])) {
             $E['body_html'] = eregi_replace($key, $value, $E['body_html']);
         }
     }
     ### Remove any unparsed vars from the body text and html:
     if (!empty($E['body_html']) && ereg('%', $E['body_html'])) {
         @($E['body_html'] = ereg_replace("%[a-zA-Z0-9_]{1,}%", '', $E['body_html']));
     }
     if (!empty($E['body_text']) && ereg("%", $E['body_text'])) {
         @($E['body_text'] = ereg_replace("%[a-zA-Z0-9_]{1,}%", '', $E['body_text']));
     }
     ### Set any attachments (not currently supported)
     $E['attatchments'] = '';
     /* email log? */
     global $C_list;
     if (is_object($C_list) && $C_list->is_installed('email_log')) {
         include_once PATH_MODULES . 'email_log/email_log.inc.php';
         $log = new email_log();
         $log->add($acct, $E['subject'], $E['body_text'], $E['to_email'], false, $E['priority']);
     }
     ### Call the mail class
     require_once PATH_CORE . 'email.inc.php';
     $email = new CORE_email();
     $email->debug = $this->debug;
     if ($type == 0) {
         return $email->PHP_Mail($E);
     } else {
         return $email->SMTP_Mail($E);
     }
 }
Ejemplo n.º 5
0
 function getLineItemDesc($sku, $id, $domain = false, $item_name)
 {
     if (!empty($item_name)) {
         return $item_name;
     }
     global $C_translate;
     if (!empty($sku) && $sku == 'DOMAIN-PARK' || $sku == 'DOMAIN-TRANSFER' || $sku == 'DOMAIN-REGISTER' || $sku == 'DOMAIN-RENEW') {
         if ($sku == 'DOMAIN-REGISTER') {
             $name = $C_translate->translate('register', 'cart', '');
         } elseif ($sku == 'DOMAIN-TRANSFER') {
             $name = $C_translate->translate('transfer', 'cart', '');
         } elseif ($sku == 'DOMAIN-PARK') {
             $name = $C_translate->translate('park', 'cart', '');
         } elseif ($sku == 'DOMAIN-RENEW') {
             $name = $C_translate->translate('renew', 'cart', '');
         }
         if ($domain) {
             return "{$domain} \r\n ( {$name} )";
         } else {
             return $name;
         }
     } else {
         include_once PATH_CORE . 'list.inc.php';
         $C_list = new CORE_list();
         if (empty($this->product_desc["{$id}"])) {
             $desc = $C_list->translate("product_translate", "name", "product_id", $id, "translate_product");
             $this->product_desc["{$id}"] = $desc['name'];
         }
         if (!empty($this->product_desc["{$id}"])) {
             return $this->product_desc["{$id}"];
         } else {
             return $sku;
         }
     }
     return $sku;
 }
Ejemplo n.º 6
0
 function dbmap()
 {
     global $C_list;
     if (!is_object($C_list)) {
         include_once PATH_CORE . 'list.inc.php';
         $C_list = new CORE_list();
     }
     if ($C_list->is_installed('db_mapping')) {
         # Update the db_mapping accounts
         include_once PATH_MODULES . 'db_mapping/db_mapping.inc.php';
         $db_map = new db_mapping();
         $db_map->account_group_sync($this->rs['account_id']);
     }
 }