Example #1
0
 function p_new()
 {
     # get the common server class and set login details
     include_once PATH_MODULES . 'host_server/host_server.inc.php';
     $host = new host_server();
     if ($this->service['host_username'] == '' || $this->service['host_password'] == '') {
         $this->login = $host->generate_login($this->service, $this->account, 4, 4, false);
     } else {
         $this->login['username'] = $this->service['host_username'];
     }
     #include the Helm class (sorry, that file is encoded)
     include_once PATH_CORE . 'helm.inc.php';
     $helm = new HELM();
     $helm->ssl = true;
     $helm->cookie_path = PATH_FILES . 'HELM_COOKIE.dat';
     $helm->host = $this->server_cfg['host'];
     $helm->user = $this->server_cfg['user'];
     $helm->pass = $this->server_cfg['pass'];
     $helm->debug = $this->server['debug'];
     $result = $helm->add($this->server_cfg['reseller'], $this->login['username'], $this->service['domain_name'], $this->service['domain_tld'], $this->plugin_data['plan'], $this->service['sku'], $this->account['first_name'], $this->account['last_name'], $this->account['company'], $this->account['address1'], $this->account['city'], $this->account['state'], $this->account['zip'], $this->account['email']);
     # send the user the details
     include_once PATH_MODULES . 'email_template/email_template.inc.php';
     $email = new email_template();
     $email->send('host_new_user', $this->account['id'], $this->service_id, '', '');
     return $result;
 }
Example #2
0
 function p_new()
 {
     # get the common server class and set login details
     include_once PATH_MODULES . 'host_server/host_server.inc.php';
     $host = new host_server();
     if (empty($this->service['host_username'])) {
         # set the limits
         $pass_len = 8;
         $user_len = 8;
         # Generate a new username/login:
         $domain = $this->service['domain_name'] . $this->service['domain_tld'];
         # set the username
         $username = trim($domain);
         $username = eregi_replace("[-_\\.]", "", $username);
         if (strlen($username) < $user_len) {
             $rand = md5(md5($username) . time());
             $diff = $user_len - strlen($username);
             $username = $username . substr($rand, 0, $diff);
         } else {
             $rand = md5(microtime() . md5($username) . microtime());
             $username = substr($username, 0, $user_len - 5);
             $username = $username . substr($rand, 0, 5);
         }
         # Set the password
         $password = substr(md5(md5(time()) . $domain . $username), 0, $pass_len);
         # Set the user/pass
         $this->login['username'] = strtolower($username);
         $this->login['password'] = $password;
     } else {
         # Validate
         $this->login['username'] = strtolower($this->service['host_username']);
         $this->login['password'] = $this->service['host_password'];
     }
     $result = createacct($this->server_cfg['host'], $this->server_cfg['account'], $this->server_cfg['accesshash'], $this->usessl, $this->service['domain_name'] . "." . $this->service['domain_tld'], $this->login['username'], $this->login['password'], $this->plugin_data['plan']);
     if ($this->server['debug']) {
         echo "<pre> {$result} </pre>";
     }
     if (!eregi("Account Creation Complete", @$result)) {
         return false;
     } else {
         $db =& DB();
         $id = $this->service_id;
         $sql = "SELECT * FROM " . AGILE_DB_PREFIX . "service WHERE id = {$id}";
         $rs = $db->Execute($sql);
         $plugin_data = unserialize($rs->fields['host_provision_plugin_data']);
         $insert = array('host_provision_plugin_data' => serialize($plugin_data), 'host_username' => $this->login['username'], 'host_password' => $this->login['password']);
         $sql = $db->GetUpdateSQL($rs, $insert);
         $result = $db->Execute($sql);
         if ($result === false) {
             global $C_debug;
             $C_debug->error('WHM.php', 'p_new()', $db->ErrorMsg() . "\r\n\r\n" . $sql);
         }
         # send the user the details
         include_once PATH_MODULES . 'email_template/email_template.inc.php';
         $email = new email_template();
         $email->send('host_new_user', $this->account['id'], $this->service_id, '', '');
     }
     return true;
 }
Example #3
0
 function send($VAR)
 {
     $VAR_ORIG = $VAR;
     $db =& DB();
     $dbm = new CORE_database();
     $sql = $dbm->sql_select("email_queue", "*", "status = 0", "", $db);
     $rs = $db->Execute($sql);
     if ($rs != false && $rs->RecordCount() > 0) {
         require_once PATH_MODULES . 'email_template/email_template.inc.php';
         while (!$rs->EOF) {
             # Get values
             global $VAR;
             $VAR = unserialize($rs->fields['var']);
             $sql1 = $rs->fields['sql1'];
             $sql2 = $rs->fields['sql2'];
             $sql3 = $rs->fields['sql3'];
             if (!empty($sql1)) {
                 if (ereg("^a:", $sql1) && is_array(unserialize($sql1))) {
                     $sql1 = unserialize($sql1);
                 }
             } else {
                 $sql1 = false;
             }
             if (!empty($sql2)) {
                 if (ereg("^a:", $sql2) && is_array(unserialize($sql2))) {
                     $sql2 = unserialize($sql2);
                 }
             } else {
                 $sql2 = false;
             }
             if (!empty($sql3)) {
                 if (ereg("^a:", $sql3) && is_array(unserialize($sql3))) {
                     $sql3 = unserialize($sql3);
                 }
             } else {
                 $sql3 = false;
             }
             # Send email
             $mail = new email_template();
             $result = $mail->send($rs->fields['email_template'], $rs->fields['account_id'], $sql1, $sql2, $sql3, false);
             # Update to sent status
             if ($result) {
                 $sql = "UPDATE " . AGILE_DB_PREFIX . "email_queue SET\n\t\t\t\t\t\t\tstatus = 1\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tid\t\t= {$rs->fields['id']}\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\tsite_id\t= " . DEFAULT_SITE;
                 $db->Execute($sql);
             }
             $rs->MoveNext();
         }
     }
     $VAR = $VAR_ORIG;
 }
Example #4
0
 function p_new()
 {
     # generate a password
     $pass_len = 8;
     $password = substr(md5(md5(time()) . $this->domain_name), 0, $pass_len);
     $this->login['password'] = $password;
     // connect to api
     $rserver = new RRADServer($this->server_cfg['user'], $this->server_cfg['pass']);
     if (!$rserver->authenticate()) {
         if ($this->server['debug']) {
             print "Couldn't authenticate against server b/c: " . $rserver->getMessage();
         }
         return false;
     }
     if ($this->server['debug']) {
         print "RServer Msg: " . $rserver->getMessage() . "<br>";
     }
     $con_svc = $rserver->getConvenienceService();
     // set properties
     $properties = array("FirstName" => $this->account['first_name'], "LastName" => $this->account['last_name'], "Email" => $this->account['email'], "Company" => $this->account['company']);
     // send command
     $result = $con_svc->newDomain($this->domain_name, $this->login['password'], $this->plugin_data['package'], $properties);
     if ($this->server['debug']) {
         print "RServer Msg: " . $rserver->getMessage() . "<br>";
     }
     // return results
     if ($result) {
         // add service
         $con_svc->addService($this->domain_name, $this->plugin_data['service']);
         // update service record
         $db =& DB();
         $rs =& $db->Execute(sqlSelect($db, "service", "*", "id={$this->service_id}"));
         $plugin_data = unserialize($rs->fields['host_provision_plugin_data']);
         $insert = array('host_provision_plugin_data' => serialize($plugin_data), 'host_username' => $this->domain_name, 'host_password' => $this->login['password']);
         $sql = $db->GetUpdateSQL($rs, $insert);
         $result = $db->Execute($sql);
         # send the user the details
         include_once PATH_MODULES . 'email_template/email_template.inc.php';
         $email = new email_template();
         $email->send('host_new_user', $this->account['id'], $this->service_id, '', '');
         return true;
     }
     return false;
 }
Example #5
0
 function p_new()
 {
     # get the common server class and set login details
     include_once PATH_MODULES . 'host_server/host_server.inc.php';
     $host = new host_server();
     if ($this->service['host_username'] == '' && $this->service['host_password'] == '') {
         $this->login = $host->generate_login($this->service, $this->account, 4, 4, false);
     } else {
         $this->login['username'] = $this->service['host_username'];
         $this->login['password'] = $this->service['host_password'];
     }
     # get ip address
     if ($this->plugin_data['hst_type'] == '0') {
         $this->ip = $host->useipaddress($this->service, $this->server);
     } else {
         $this->ip = $this->server['name_based_ip'];
         $this->plugin_data['enssl'] = 0;
     }
     #include the easyAdmin class (sorry, that file is encoded)
     include_once PATH_CORE . 'easyadmin.inc.php';
     $e = new EASYADMIN();
     $e->cookiepath = PATH_FILES . 'easyCookie.txt';
     $e->debug = $this->server['debug'];
     $e->host = $this->server_cfg['host'];
     $e->user = $this->server_cfg['user'];
     $e->pass = $this->server_cfg['pass'];
     $e->reseller = $this->server_cfg['reseller'];
     $e->domain = $this->service['domain_name'] . '.' . $this->service['domain_tld'];
     $e->username = $this->login['username'];
     $e->passwd = $this->login['password'];
     $e->email = $this->account['email'];
     $e->ip = $this->ip;
     $e->prod = array('users' => $this->plugin_data['users'], 'quota' => $this->plugin_data['quota'], 'enfp' => $this->plugin_data['enfp'], 'enphp' => $this->plugin_data['enphp'], 'enshell' => $this->plugin_data['enshell'], 'enssi' => $this->plugin_data['enssi'], 'encgi' => $this->plugin_data['encgi'], 'ensuexec' => $this->plugin_data['ensuexec'], 'enthrottle' => $this->plugin_data['enthrottle'], 'enraw' => $this->plugin_data['enraw'], 'enmiva' => $this->plugin_data['enmiva'], 'enssl' => $this->plugin_data['enssl'], 'enfilter' => $this->plugin_data['enfilter'], 'limit' => $this->plugin_data['limit'], 'bwunit' => $this->plugin_data['bwunit'], 'duration' => $this->plugin_data['duration'], 'durationunit' => $this->plugin_data['durationunit']);
     # add
     $result = $e->add();
     # send the user the details
     include_once PATH_MODULES . 'email_template/email_template.inc.php';
     $email = new email_template();
     $email->send('host_new_user', $this->account['id'], $this->service_id, '', '');
     return $result;
 }
Example #6
0
 function p_new()
 {
     # get the common server class and set login details
     include_once PATH_MODULES . 'host_server/host_server.inc.php';
     $host = new host_server();
     if ($this->service['host_username'] == '' && $this->service['host_password'] == '') {
         $this->login = $host->generate_login($this->service, $this->account, 4, 4, false);
     } else {
         $this->login['username'] = $this->service['host_username'];
         $this->login['password'] = $this->service['host_password'];
     }
     # get ip address
     if ($this->plugin_data['network_interface'] == '1') {
         $this->ip = $host->useipaddress($this->service, $this->server);
     } else {
         $this->ip = $this->server['name_based_ip'];
     }
     #include the webmin class (sorry, that file is encoded)
     include_once PATH_CORE . 'webmin.inc.php';
     $e = new WEBMIN();
     $e->debug = $this->server['debug'];
     $e->host = $this->server_cfg['host'];
     $e->user = $this->server_cfg['user'];
     $e->pass = $this->server_cfg['pass'];
     $e->port = $this->server_cfg['port'];
     $e->ssl = $this->server_cfg['ssl'];
     $e->domain = $this->service['domain_name'] . '.' . $this->service['domain_tld'];
     $e->username = $this->login['username'];
     $e->password = $this->login['password'];
     $e->email = $this->account['email'];
     $e->ip = $this->ip;
     $e->prod = $this->plugin_data;
     # add
     $result = $e->add();
     # send the user the details
     include_once PATH_MODULES . 'email_template/email_template.inc.php';
     $email = new email_template();
     $email->send('host_new_user', $this->account['id'], $this->service_id, '', '');
     return $result;
 }
 function sendEmail($ids, $account, $date)
 {
     if (empty($account)) {
         return;
     }
     //echo "<br> $account - $ids - $date";
     /* send e-mail to user */
     include_once PATH_MODULES . 'email_template/email_template.inc.php';
     $mail = new email_template();
     $mail->send('invoice_pregen_notice', $account, $ids, DEFAULT_CURRENCY, $date);
     /* update service.invoice_advance_notified=1 to stop future notifications */
     $db =& DB();
     $db->Execute("UPDATE " . AGILE_DB_PREFIX . "service SET invoice_advance_notified=1 WHERE site_id=" . DEFAULT_SITE . " AND id in ({$ids})");
 }
Example #8
0
 function renew()
 {
     # compose the message:
     $msg = $this->emailCompose('REGISTER', $this->domain_name, $this->term, $this->ns1, $this->ns2, $this->nsip1, $this->nsip2);
     # get the account id of the staff member to e-mail to:
     $db =& DB();
     $q = "SELECT account_id FROM  " . AGILE_DB_PREFIX . "staff WHERE\n\t\t\t\tid\t\t\t= " . $db->qstr($this->registrar['manual_renew_email']) . " AND\n\t\t\t\tsite_id     = " . $db->qstr(DEFAULT_SITE);
     $rs = $db->Execute($q);
     if ($rs->RecordCount() == 0) {
         return false;
     } else {
         $account_id = $rs->fields['account_id'];
         include_once PATH_MODULES . 'email_template/email_template.inc.php';
         $mail = new email_template();
         $mail->send('registrar_manual_admin', $account_id, $this->domainrs['account_id'], '', $msg);
     }
     return true;
 }
 function p_one($id)
 {
     global $C_debug;
     # Get the service details
     $db =& DB();
     $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'service WHERE
                id               =  ' . $db->qstr($id) . ' AND
                site_id          =  ' . $db->qstr(DEFAULT_SITE);
     $rs = $db->Execute($sql);
     if ($rs->RecordCount() == 0) {
         return false;
     }
     $this->service = $rs->fields;
     @($this->plugin_data = unserialize($this->service['host_provision_plugin_data']));
     # Get the account details
     $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'account WHERE
                 id           =  ' . $db->qstr($this->service['account_id']) . ' AND
                 site_id      =  ' . $db->qstr(DEFAULT_SITE);
     $acct = $db->Execute($sql);
     $this->account = $acct->fields;
     # Get the server details
     $db =& DB();
     $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'host_server WHERE
                id           =  ' . $db->qstr($this->service['host_server_id']) . ' AND
                site_id      =  ' . $db->qstr(DEFAULT_SITE);
     $rs = $db->Execute($sql);
     if (@$rs->RecordCount() == 0) {
         return false;
     } else {
         $this->server = $rs->fields;
         @($this->server_cfg = unserialize($rs->fields['provision_plugin_data']));
     }
     # determine the correct action
     switch ($this->service['queue']) {
         # new
         case 'new':
             $result = $this->p_new();
             # send the user the details
             include_once PATH_MODULES . 'email_template/email_template.inc.php';
             $email = new email_template();
             $email->send('host_new_user', $this->account['id'], $rs->fields['id'], '', '');
             break;
             # active
         # active
         case 'active':
             $result = $this->p_active();
             # send the user the details
             #include_once(PATH_MODULES.'email_template/email_template.inc.php');
             #$email = new email_template;
             #$email->send('host_edit_user', $this->account['id'], $rs->fields['id'], '', '');
             break;
             # inactive
         # inactive
         case 'inactive':
             $result = $this->p_inactive();
             break;
             # edit
         # edit
         case 'edit':
             if ($this->service['active'] == 1) {
                 $result = $this->p_active();
             } else {
                 $result = $this->p_inactive();
             }
             break;
             # delete
         # delete
         case 'delete':
             $result = $this->p_delete();
             break;
     }
     # update service record
     if (@$result != false) {
         # update
         $sql = 'UPDATE ' . AGILE_DB_PREFIX . 'service SET
                     queue        =  ' . $db->qstr('none') . ',
                     date_last    =  ' . $db->qstr(time()) . '
                     WHERE
                     id           =  ' . $db->qstr($rs->fields['id']) . ' AND
                     site_id      =  ' . $db->qstr(DEFAULT_SITE);
         $upd = $db->Execute($sql);
     } else {
         # error log
         $C_debug->error($this->name . 'php', $this->service['queue'], @$result);
     }
 }
    function p_new()
    {
        # get the common server class and set login details
        include_once PATH_MODULES . 'host_server/host_server.inc.php';
        $host = new host_server();
        if ($this->service['host_username'] == '' || $this->service['host_password'] == '') {
            # set the limits
            $pass_len = 10;
            $user_len = 12;
            # Generate a new username/login:
            $domain = $this->service['domain_name'] . $this->service['domain_tld'];
            # set the username
            $username = trim($domain);
            $username = preg_replace("/[-_\\.]/", "", $username);
            if (strlen($username) < $user_len) {
                $rand = md5(md5($username) . time());
                $diff = $user_len - strlen($username);
                $username = $username . substr($rand, 0, $diff);
            } else {
                $rand = md5(microtime() . md5($username) . microtime());
                $username = substr($username, 0, $user_len - 5);
                $username = $username . substr($rand, 0, 5);
            }
            # Set the password
            $password = substr(md5(md5(time()) . $domain . $username), 0, 10);
            # Set the user/pass for the XML queries
            $this->login['username'] = $username;
            $this->login['password'] = $password;
        } else {
            # Validate
            $this->login['username'] = $this->service['host_username'];
            $this->login['password'] = $this->service['host_password'];
        }
        # get ip address
        if ($this->plugin_data['ip_based'] == '1') {
            $this->ip = $host->useipaddress($this->service, $this->server);
        } else {
            $this->ip = $this->server['name_based_ip'];
        }
        ####################################################
        ### Assemble the XML for the account creation:	####
        $data = <<<EOF
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
\t\t<packet version="{$this->proto}">
\t\t\t<client> 
\t\t\t\t<add>
\t\t\t\t\t<gen_info> 
\t\t\t\t\t\t<pname>{$this->account['first_name']} {$this->account['last_name']} ({$this->login['username']})</pname>
\t\t\t\t\t\t<login>{$this->login['username']}</login>
\t\t\t\t\t\t<passwd>{$this->login['password']}</passwd> 
\t\t\t\t\t\t<email>{$this->account['email']}</email> 
\t\t\t\t\t\t<pcode>00000</pcode>
\t\t\t\t\t\t<country>US</country> 
\t\t\t\t\t\t<status>0</status>
\t\t\t\t\t\t<phone>18005551212</phone> \t\t\t\t\t
\t\t\t\t\t</gen_info>\t 
\t\t\t\t\t<limits> 
\t\t\t\t\t\t<max_webapps>{$this->plugin_data['max_webapps']}</max_webapps>
\t\t\t\t\t\t<max_maillists>{$this->plugin_data['max_maillists']}</max_maillists>
\t\t\t\t\t\t<max_resp>{$this->plugin_data['max_resp']}</max_resp>
\t\t\t\t\t\t<max_mg>{$this->plugin_data['max_mg']}</max_mg>
\t\t\t\t\t\t<max_redir>{$this->plugin_data['max_redir']}</max_redir>
\t\t\t\t\t\t<mbox_quota>{$this->plugin_data['mbox_quota']}</mbox_quota>
\t\t\t\t\t\t<max_box>{$this->plugin_data['max_box']}</max_box>
\t\t\t\t\t\t<max_db>{$this->plugin_data['max_db']}</max_db>
\t\t\t\t\t\t<max_wu>{$this->plugin_data['max_wu']}</max_wu>
\t\t\t\t\t\t<max_traffic>{$this->plugin_data['max_traffic']}</max_traffic>
\t\t\t\t\t\t<disk_space>{$this->plugin_data['disk_space']}</disk_space>
\t\t\t\t\t\t<max_subdom>{$this->plugin_data['max_subdom']}</max_subdom>
\t\t\t\t\t\t<max_dom>{$this->plugin_data['max_dom']}</max_dom> 
\t\t\t\t\t</limits>\t\t\t\t\t\t
\t\t\t\t</add>   
\t\t\t</client>
</packet>
EOF;
        # Connect & get response:
        $result = $this->connect($this->server_cfg['host'], $this->server_cfg['port'], $this->server_cfg['user'], $this->server_cfg['pass'], $data);
        # Debug:
        $this->debug($data, $result);
        # Get the account id
        $cl_id = $this->getid($result);
        ################################################
        ### SET CLIENT PERMISSIONS & ADD IP TO POOL: ###
        # Loop through the values below and convert to true or false:
        $tf_arr = array('create_domains', 'manage_phosting', 'manage_sh_access', 'manage_not_chroot_shell', 'manage_quota', 'manage_subdomains', 'manage_log', 'manage_anonftp', 'manage_crontab', 'site_builder', 'change_limits', 'manage_dns', 'manage_webapps', 'manage_maillists', 'manage_drweb', 'make_dumps', 'fp', 'fp_auth', 'fp_ssl', 'ssl', 'shell', 'php', 'ssi', 'cgi', 'mod_perl', 'mod_python', 'asp', 'asp_dot_net', 'coldfusion', 'webstat', 'errdocs', 'at_domains');
        for ($i = 0; $i < count($tf_arr); $i++) {
            if ($this->plugin_data["{$tf_arr[$i]}"] == 1) {
                $this->plugin_data["{$tf_arr[$i]}"] = 'true';
            } else {
                $this->plugin_data["{$tf_arr[$i]}"] = 'false';
            }
        }
        $data = <<<EOF
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
\t\t<packet version="{$this->proto}">
\t\t\t<client> 
\t\t\t\t<set>
\t\t\t\t\t<filter>
\t\t\t\t\t\t<id>{$cl_id}</id>
\t\t\t\t\t</filter>
\t\t\t        <values>
\t\t\t          <permissions> 
\t\t\t            <create_domains>{$this->plugin_data['create_domains']}</create_domains>
\t\t\t            <manage_phosting>false</manage_phosting>
\t\t\t            <manage_sh_access>{$this->plugin_data['manage_sh_access']}</manage_sh_access>
\t\t\t            <manage_not_chroot_shell>{$this->plugin_data['manage_not_chroot_shell']}</manage_not_chroot_shell>
\t\t\t            <manage_quota>{$this->plugin_data['manage_quota']}</manage_quota>
\t\t\t            <manage_subdomains>{$this->plugin_data['manage_subdomains']}</manage_subdomains> 
\t\t\t            <manage_log>{$this->plugin_data['manage_log']}</manage_log>
\t\t\t            <manage_anonftp>{$this->plugin_data['manage_anonftp']}</manage_anonftp>
\t\t\t            <manage_crontab>{$this->plugin_data['manage_crontab']}</manage_crontab>
\t\t\t            <site_builder>{$this->plugin_data['site_builder']}</site_builder>
\t\t\t            <change_limits>{$this->plugin_data['change_limits']}</change_limits>
\t\t\t            <manage_dns>{$this->plugin_data['manage_dns']}</manage_dns> 
\t\t\t            <manage_webapps>{$this->plugin_data['manage_webapps']}</manage_webapps>
\t\t\t            <manage_maillists>{$this->plugin_data['manage_maillists']}</manage_maillists>
\t\t\t            <manage_drweb>{$this->plugin_data['manage_drweb']}</manage_drweb>
\t\t\t            <make_dumps>{$this->plugin_data['make_dumps']}</make_dumps>
\t\t\t          </permissions> 
\t\t\t        </values>
\t\t\t\t</set>\t
\t\t\t\t<ippool_add_ip> 
\t\t\t\t\t<client_id>{$cl_id}</client_id>
\t\t\t\t\t<ip_address>{$this->ip}</ip_address>
\t\t\t\t</ippool_add_ip>\t\t\t  
\t\t\t</client>
</packet>
EOF;
        # Connect & get response:
        $result = $this->connect($this->server_cfg['host'], $this->server_cfg['port'], $this->server_cfg['user'], $this->server_cfg['pass'], $data);
        # Debug:
        $this->debug($data, $result);
        # Calculate limits
        @($ftp_quota = ceil($this->plugin_data['ftp_quota']) * 1024 * 1024);
        @($disk_space = ceil($this->plugin_data['disk_space']) * 1024 * 1024);
        @($max_traffic = ceil($this->plugin_data['max_traffic']) * 1024 * 1024);
        @($mbox_quota = ceil($this->plugin_data['mbox_quota']) * 1024);
        if ($this->plugin_data['shell'] == 1) {
            $shell = 'true';
        } else {
            $shell = '/bin/false';
        }
        ###################################
        ### ADD NEW DOMAIN AND LIMITS:	###
        $data = <<<EOF
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
\t\t<packet version="{$this->proto}">
\t\t\t<domain> 
\t\t\t\t<add>
\t\t\t\t\t<gen_setup>
\t\t\t\t\t\t<name>{$this->service['domain_name']}.{$this->service['domain_tld']}</name>
\t\t\t\t\t\t<client_id>{$cl_id}</client_id> 
\t\t\t\t\t\t<ip_address>{$this->ip}</ip_address>
\t\t\t\t\t\t<htype>vrt_hst</htype>
\t\t\t\t\t\t<status /> 
\t\t\t\t\t</gen_setup> 
\t\t\t\t\t<hosting>
\t\t\t\t\t\t<vrt_hst>
\t\t\t\t\t\t\t<ip_address>{$this->ip}</ip_address>
\t\t\t\t\t\t\t<ftp_login>{$this->login['username']}</ftp_login>
\t\t\t\t\t\t\t<ftp_password>{$this->login['password']}</ftp_password>
\t\t\t\t\t\t\t<ftp_quota>{$ftp_quota}</ftp_quota>
\t\t\t\t\t\t\t<fp>{$this->plugin_data['fp']}</fp>
\t\t\t\t\t\t\t<fp_ssl>{$this->plugin_data['fp_ssl']}</fp_ssl>
\t\t\t\t\t\t\t<fp_auth>{$this->plugin_data['fp_auth']}</fp_auth> 
\t\t\t\t\t\t\t<fp_admin_login>{$this->login['username']}</fp_admin_login>
\t\t\t\t\t\t\t<fp_admin_password>{$this->login['password']}</fp_admin_password>
\t\t\t\t\t\t\t<ssl>{$this->plugin_data['ssl']}</ssl>
\t\t\t\t\t\t\t<shell>{$shell}</shell>
\t\t\t\t\t\t\t<php>{$this->plugin_data['php']}</php>
\t\t\t\t\t\t\t<ssi>{$this->plugin_data['ssi']}</ssi>
\t\t\t\t\t\t\t<cgi>{$this->plugin_data['cgi']}</cgi>
\t\t\t\t\t\t\t<mod_perl>{$this->plugin_data['mod_perl']}</mod_perl>
\t\t\t\t\t\t\t<mod_python>{$this->plugin_data['mod_python']}</mod_python>
\t\t\t\t\t\t\t<asp>{$this->plugin_data['asp']}</asp>
\t\t\t\t\t\t\t<asp_dot_net>{$this->plugin_data['asp_dot_net']}</asp_dot_net>
\t\t\t\t\t\t\t<coldfusion>{$this->plugin_data['coldfusion']}</coldfusion>
\t\t\t\t\t\t\t<webstat>{$this->plugin_data['webstat']}</webstat>
\t\t\t\t\t\t\t<errdocs>{$this->plugin_data['errdocs']}</errdocs>
\t\t\t\t\t\t\t<at_domains>{$this->plugin_data['at_domains']}</at_domains>
\t\t\t\t\t\t</vrt_hst> 
\t\t\t\t\t</hosting>
\t\t\t\t\t<limits>
\t\t\t\t\t\t<max_subdom>{$this->plugin_data['max_subdom']}</max_subdom>
\t\t\t\t\t\t<disk_space>{$disk_space}</disk_space>
\t\t\t\t\t\t<max_traffic>{$max_traffic}</max_traffic>
\t\t\t\t\t\t<max_wu>{$this->plugin_data['max_wu']}</max_wu>
\t\t\t\t\t\t<max_db>{$this->plugin_data['max_db']}</max_db>
\t\t\t\t\t\t<max_box>{$this->plugin_data['max_box']}</max_box>
\t\t\t\t\t\t<mbox_quota>{$mbox_quota}</mbox_quota>
\t\t\t\t\t\t<max_redir>{$this->plugin_data['max_redir']}</max_redir>
\t\t\t\t\t\t<max_mg>{$this->plugin_data['max_mg']}</max_mg>
\t\t\t\t\t\t<max_resp>{$this->plugin_data['max_resp']}</max_resp> 
\t\t\t\t\t\t<max_maillists>{$this->plugin_data['max_maillists']}</max_maillists>
\t\t\t\t\t\t<max_webapps>{$this->plugin_data['max_webapps']}</max_webapps> \t\t\t\t\t\t\t\t\t\t\t\t
\t\t\t\t\t</limits>
\t\t\t\t\t<prefs>
\t\t\t\t\t\t<www>true</www> 
\t\t\t\t\t</prefs>\t 
\t\t\t\t</add>\t  
\t\t\t</domain>
</packet>
EOF;
        # Connect & get response:
        $result = $this->connect($this->server_cfg['host'], $this->server_cfg['port'], $this->server_cfg['user'], $this->server_cfg['pass'], $data);
        # Debug:
        $this->debug($data, $result);
        # Get the account id
        if (!($domain_id = $this->getid($result))) {
            return false;
        } else {
            $db =& DB();
            $id = $this->service_id;
            $sql = "SELECT * FROM " . AGILE_DB_PREFIX . "service WHERE id = {$id}";
            $rs = $db->Execute($sql);
            $plugin_data = unserialize($rs->fields['host_provision_plugin_data']);
            $plugin_data['account_id'] = $cl_id;
            $plugin_data['domain_id'] = $domain_id;
            $insert = array('host_provision_plugin_data' => serialize($plugin_data), 'host_username' => $this->login['username'], 'host_password' => $this->login['password']);
            $sql = $db->GetUpdateSQL($rs, $insert);
            $result = $db->Execute($sql);
            if ($result === false) {
                global $C_debug;
                $C_debug->error('PLESK_RELOADED_7_5.php', 'plgn_prov_PLESK_RELOADED_7_5 :: p_new()', $db->ErrorMsg() . "\r\n\r\n" . $sql);
            }
            # send the user the details
            include_once PATH_MODULES . 'email_template/email_template.inc.php';
            $email = new email_template();
            $email->send('host_new_user', $this->account['id'], $this->service_id, '', '');
        }
        return true;
    }
    function add($VAR)
    {
        if (!$this->checkLimits()) {
            return false;
        }
        // check account limits
        global $C_translate, $C_debug, $smarty;
        ### Set the hidden values:
        $VAR['account_admin_date_orig'] = time();
        $VAR['account_admin_date_last'] = time();
        if (!empty($VAR["account_admin_date_expire"])) {
            include_once PATH_CORE . 'validate.inc.php';
            $val = new CORE_validate();
            $date_expire = $val->DateToEpoch(false, $VAR["account_admin_date_expire"]);
        } else {
            $date_expire = 0;
        }
        ### Determine the proper account status:
        if (!isset($VAR['account_admin_status']) || $VAR['account_admin_status'] != "1") {
            $status = 0;
        } else {
            $status = 1;
        }
        ### DEFINE A USERNAME:
        if (empty($VAR['account_admin_username'])) {
            $length = 4;
            srand((double) microtime() * 1000000);
            $vowels = array("a", "e", "i", "o", "u");
            $cons = array("b", "c", "d", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "u", "v", "w", "tr", "cr", "br", "fr", "th", "dr", "ch", "ph", "wr", "st", "sp", "sw", "pr", "sl", "cl");
            $num_vowels = count($vowels);
            $num_cons = count($cons);
            for ($i = 0; $i < $length; $i++) {
                @($VAR['account_admin_username'] .= $cons[rand(0, $num_cons - 1)] . $vowels[rand(0, $num_vowels - 1)]);
            }
        }
        ## Single field login:
        if (defined('SINGLE_FIELD_LOGIN') && SINGLE_FIELD_LOGIN == true && empty($VAR['account_admin_password'])) {
            $VAR['account_admin_password'] = '******';
            $passwd = 'none';
        }
        ### DEFINE A PASSWORD:
        if (empty($VAR['account_admin_password'])) {
            srand((double) microtime() * 1000000);
            $UniqID = md5(uniqid(rand()));
            @($VAR['account_admin_password'] = substr(md5(uniqid(rand())), 0, 10));
            $passwd = '********';
        } else {
            $passwd = $VAR['account_admin_password'];
            /* hash the password */
            if (defined('PASSWORD_ENCODING_SHA')) {
                $VAR['account_admin_password'] = sha1($VAR['account_admin_password']);
            } else {
                $VAR['account_admin_password'] = md5($VAR['account_admin_password']);
            }
        }
        ####################################################################
        ### loop through the field list to validate the required fields
        ####################################################################
        $type = 'add';
        $this->method["{$type}"] = explode(",", $this->method["{$type}"]);
        $arr = $this->method["{$type}"];
        include_once PATH_CORE . 'validate.inc.php';
        $validate = new CORE_validate();
        $this->validated = true;
        while (list($key, $value) = each($arr)) {
            # get the field value
            $field_var = $this->module . '_' . $value;
            $field_name = $value;
            ####################################################################
            ### perform any field validation...
            ####################################################################
            # check if this value is unique
            if (isset($this->field["{$value}"]["unique"]) && isset($VAR["{$field_var}"])) {
                if (!$validate->validate_unique($this->table, $field_name, "record_id", $VAR["{$field_var}"])) {
                    $this->validated = false;
                    $this->val_error[] = array('field' => $this->table . '_' . $field_name, 'field_trans' => $C_translate->translate('field_' . $field_name, $this->module, ""), 'error' => $C_translate->translate('validate_unique', "", ""));
                }
            }
            # check if the submitted value meets the specifed requirements
            if (isset($this->field["{$value}"]["validate"])) {
                if (isset($VAR["{$field_var}"])) {
                    if ($VAR["{$field_var}"] != '') {
                        if (!$validate->validate($field_name, $this->field["{$value}"], $VAR["{$field_var}"], $this->field["{$value}"]["validate"])) {
                            $this->validated = false;
                            $this->val_error[] = array('field' => $this->module . '_' . $field_name, 'field_trans' => $C_translate->translate('field_' . $field_name, $this->module, ""), 'error' => $validate->error["{$field_name}"]);
                        }
                    } else {
                        $this->validated = false;
                        $this->val_error[] = array('field' => $this->module . '_' . $field_name, 'field_trans' => $C_translate->translate('field_' . $field_name, $this->module, ""), 'error' => $C_translate->translate('validate_any', "", ""));
                    }
                } else {
                    $this->validated = false;
                    $this->val_error[] = array('field' => $this->module . '_' . $field_name, 'field_trans' => $C_translate->translate('field_' . $field_name, $this->module, ""), 'error' => $C_translate->translate('validate_any', "", ""));
                }
            }
        }
        // validate the tax_id
        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 (!$taxObj->TaxIdsValidate($country_id, $tax_id, $exempt)) {
                        $this->validated = false;
                        $this->val_error[] = array('field' => 'account_admin_tax_id', 'field_trans' => $taxObj->errField, 'error' => $C_translate->translate('validate_general', "", ""));
                    }
                    if ($exempt) {
                        $account_admin_tax_id = false;
                    } else {
                        $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']);
            }
            # Stripslashes
            global $C_vars;
            $C_vars->strip_slashes_all();
            return;
        }
        # Get default invoice options
        $db =& DB();
        $invopt = $db->Execute(sqlSelect($db, "setup_invoice", "*", ""));
        if ($invopt && $invopt->RecordCount()) {
            $invoice_delivery = $invopt->fields['invoice_delivery'];
            $invoice_format = $invopt->fields['invoice_show_itemized'];
        }
        ####################################################################
        ### Insert the account record
        ####################################################################
        $this->account_id = $db->GenID(AGILE_DB_PREFIX . 'account_id');
        $validation_str = time();
        /** get parent id */
        @($parent_id = @$VAR["account_admin_parent_id"]);
        if (empty($parent_id)) {
            $parent_id = $this->account_id;
        }
        $sql = '
			INSERT INTO ' . AGILE_DB_PREFIX . 'account SET
			id              = ' . $db->qstr($this->account_id) . ',
			site_id         = ' . $db->qstr(DEFAULT_SITE) . ',
			date_orig       = ' . $db->qstr($validation_str) . ',
			date_last       = ' . $db->qstr(time()) . ',
			date_expire     = ' . $db->qstr($date_expire) . ',
			language_id     = ' . $db->qstr($VAR["account_admin_language_id"]) . ',
			country_id      = ' . $db->qstr($VAR["account_admin_country_id"]) . ',
			parent_id	    = ' . $db->qstr($parent_id) . ',
			affiliate_id    = ' . $db->qstr(@$VAR["account_admin_affiliate_id"]) . ',
			reseller_id     = ' . $db->qstr(@$VAR["account_admin_reseller_id"]) . ',
			currency_id     = ' . $db->qstr($VAR["account_admin_currency_id"]) . ',
			theme_id        = ' . $db->qstr($VAR["account_admin_theme_id"]) . ',
			username        = '******',
			password        = '******',
			status          = ' . $db->qstr($status) . ',
			first_name      = ' . $db->qstr($VAR["account_admin_first_name"]) . ',
			middle_name     = ' . $db->qstr($VAR["account_admin_middle_name"]) . ',
			last_name       = ' . $db->qstr($VAR["account_admin_last_name"]) . ',
			company         = ' . $db->qstr($VAR["account_admin_company"]) . ',
			title           = ' . $db->qstr($VAR["account_admin_title"]) . ',
			email           = ' . $db->qstr($VAR["account_admin_email"]) . ',
			address1		= ' . $db->qstr($VAR["account_admin_address1"]) . ',
			address2		= ' . $db->qstr($VAR["account_admin_address2"]) . ',
			city			= ' . $db->qstr($VAR["account_admin_city"]) . ',
			state			= ' . $db->qstr($VAR["account_admin_state"]) . ',
			zip				= ' . $db->qstr($VAR["account_admin_zip"]) . ',
			misc			= ' . $db->qstr($VAR["account_admin_misc"]) . ',
			email_type      = ' . $db->qstr($VAR["account_admin_email_html"]) . ',
			invoice_delivery= ' . $db->qstr(@$invoice_delivery) . ',
			invoice_show_itemized=' . $db->qstr(@$invoice_format) . ',
			invoice_advance_gen	= ' . $db->qstr(MAX_INV_GEN_PERIOD) . ',
			invoice_grace		= ' . $db->qstr(GRACE_PERIOD) . ',
			tax_id			= ' . $db->qstr(@$account_tax_id);
        $result = $db->Execute($sql);
        ### error reporting:
        if ($result === false) {
            global $C_debug;
            $C_debug->error('account_admin.inc.php', 'add', $db->ErrorMsg());
            if (isset($this->trigger["{$type}"])) {
                include_once PATH_CORE . 'trigger.inc.php';
                $trigger = new CORE_trigger();
                $trigger->trigger($this->trigger["{$type}"], 0, $VAR);
            }
            return;
        }
        /* password logging class */
        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();
            $accountHistory->setNewPassword($this->account_id, $VAR["account_admin_password"]);
        }
        ### Add the account to the default group:
        $this->add_account_groups($VAR['groups'], $this->account_id, $VAR['account_admin_date_expire']);
        ### Insert the static vars:
        $static_var->add($VAR, 'account', $this->account_id);
        ### Mail the new user
        if (!empty($VAR['welcome_email'])) {
            require_once PATH_MODULES . 'email_template/email_template.inc.php';
            $my = new email_template();
            if ($status == "1") {
                $my->send('account_add_staff_active', $this->account_id, '', '', $passwd);
            } else {
                $validation_str = strtoupper($validation_str . ':' . $this->account_id);
                $my->send('account_add_staff_inactive', $this->account_id, $this->account_id, '', $validation_str);
            }
        }
        ### 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($passwd)) {
                $db_map->plaintext_password = $passwd;
            } else {
                $db_map->plaintext_password = false;
            }
            $db_map->account_add($this->account_id);
        }
        ### Display the welcome message
        if ($status == "1") {
            $C_debug->alert($C_translate->translate("staff_add_active", "account_admin", ""));
        } else {
            $C_debug->alert($C_translate->translate("staff_add_inactive", "account_admin", ""));
        }
        #$VAR["id"] = $this->account_id;
        $url = '?_page=' . $VAR['_page'] . '&id=' . $this->account_id;
        if (!empty($VAR['id'])) {
            $url .= '&_escape=1';
        }
        if (!empty($VAR['field'])) {
            $url .= '&field=' . $VAR['field'];
            $url .= '&name=' . $VAR['account_admin_first_name'] . ' ' . $VAR['account_admin_last_name'];
        }
        define('REDIRECT_PAGE', $url);
        ### Affiliate Auto Creation
        if (AUTO_AFFILIATE == 1 && $C_list->is_installed("affiliate")) {
            $VAR['affiliate_account_id'] = $this->account_id;
            $VAR['affiliate_template_id'] = DEFAULT_AFFILIATE_TEMPLATE;
            @($VAR['affiliate_parent_affiliate_id'] = $VAR['account_admin_affiliate_id']);
            include_once PATH_MODULES . 'affiliate/affiliate.inc.php';
            $affiliate = new affiliate();
            $affiliate->add($VAR, $affiliate);
        }
        return;
    }
 public function callbackAction()
 {
     // Убедимся что кеш выключен
     Zend_Registry::get('target')->enable_cache(0);
     // Проверим: а правильно ли пришли данные?
     $gift = new gift(@$_POST["gift_id"]);
     if (!$gift->get('id') || !isset($_POST["phone"])) {
         die(json_encode(array('msg' => 'Извините, заказ звонка не удался')));
     }
     $_POST["email"] = $_POST["email"] == 'Email' ? '' : $_POST["email"];
     //Преобразовываем номер телефона к единому виду.В номере телефона оставляем только цифры.
     $_POST["phone"] = preg_replace("/\\D/", "", $_POST["phone"]);
     // Расчитаем стоимость заказа обратного звонка
     $_POST['price_call'] = floor($_POST['gift_price'] * Zend_Registry::get('config')->callback->percent / 25) / 4;
     //Проверяем что бы цена звонка была не меньше заданой в конфиге минимальной стоимости звонка
     $_POST['price_call'] = $_POST['price_call'] >= Zend_Registry::get('config')->callback->min_price_call ? $_POST['price_call'] : Zend_Registry::get('config')->callback->min_price_call;
     $_POST['price_call'] = $_POST['price_call'] <= Zend_Registry::get('config')->callback->max_price_call ? $_POST['price_call'] : Zend_Registry::get('config')->callback->max_price_call;
     $_POST['ip'] = $_SERVER["REMOTE_ADDR"];
     $_POST['user_agent'] = $_SERVER["HTTP_USER_AGENT"];
     // Первым делом отправляем письмо юзеру - чтобы не волновался, по идее будем еще ему слать СМС
     $shops = new shop((int) $_POST['shop_id']);
     if (!empty($_POST["email"])) {
         $work_time = $shops->get('work_time');
         $et = new email_template('callback_user');
         $et->assign('USER_NAME', $_POST["name"])->assign('GIFT_NAME', $gift->get('display_name'))->assign('SHOP_NAME', $shops->get('display_name'))->assign('URL_GIFT', "http://{$_SERVER['SERVER_NAME']}/" . $gift->get('local_url') . '/?utm_source=email&utm_medium=user&utm_campaign=callback_user')->assign('WORK_TIME', !empty($work_time) ? 'Время работы магазина: <strong>' . $work_time . '</strong>' : '')->send($_POST["email"], $_POST["name"])->send('*****@*****.**');
     }
     //Записываем заказ звонка в таблицу p_stat_out в любом случае
     $stat = new stat();
     $stat_id = $stat->insert(array('gift_id' => (int) $_POST["gift_id"], 'category_id' => (int) @$_POST["category_id"], 'gift_name' => $gift->get('display_name'), 'cpc' => (double) $_POST['price_call'], 'price' => (int) $_POST['gift_price'], 'partner_id' => (int) $shops->get('partner_id'), 'ip' => $_POST["ip"], 'user_agent' => $_POST["user_agent"], 'from_url' => $gift->get('local_url'), 'to_url' => $_POST["url"], 'click_type' => 2));
     $callback = new p_callback();
     //Проверяем наличие одинаковых записей за временный интервал
     $exist_reserves = $callback->select($count, array('filter' => array('gift_id' => (int) $_POST["gift_id"], 'name' => $_POST["name"], 'phone' => $_POST["phone"], 'email' => $_POST["email"], 'interval' => Zend_Registry::get('config')->callback->interval_order)));
     if (empty($exist_reserves)) {
         //Записываем заказ звонка в таблицу p_callback
         $callback->insert(array('name' => $_POST["name"], 'phone' => $_POST["phone"], 'email' => $_POST["email"], 'stat_id' => (int) $stat_id, 'gift_id' => (int) $_POST["gift_id"], 'gift_name' => $gift->get('display_name'), 'gift_price' => (int) $_POST['gift_price'], 'shop_id' => (int) $_POST['shop_id'], 'partner_id' => (int) $shops->get('partner_id'), 'to_url' => $_POST["url"], 'price_call' => (double) $_POST['price_call'], 'ip' => $_POST["ip"], 'user_agent' => $_POST["user_agent"], 'comment' => !empty($_POST['comment']) ? $_POST['comment'] : ''));
         //Отправляем письмо партнеру
         $et = new email_template('callback');
         $et->assign('GIFT_NAME', $gift->get('display_name'))->assign('BUYER_NAME', $_POST["name"])->assign('PHONE', $_POST["phone"])->assign('EMAIL', $_POST["email"])->assign('SHOP_NAME', $shops->get('display_name'))->assign('URL_GIFT', $_POST["url"])->assign('STAT_URL', "http://{$_SERVER['SERVER_NAME']}/stat/callback/?utm_source=email&utm_medium=partner&utm_campaign=callback")->assign('COMMENT', !empty($_POST['comment']) ? $_POST['comment'] : '')->send(Zend_Registry::get('config')->server->enviroment == 'live' ? $shops->get('callback_email') : Zend_Registry::get('config')->log->error_email)->send('*****@*****.**');
     }
     die(json_encode(array('msg' => 'Заказ звонка принят, спасибо')));
 }
Example #13
0
 function register()
 {
     # compose the message:
     $msg = $this->emailCompose();
     # send the e-mail
     if ($this->staff_account_id) {
         include_once PATH_MODULES . 'email_template/email_template.inc.php';
         $mail = new email_template();
         $mail->send('registrar_nominet_admin', $this->staff_account_id, '', strtoupper($this->registrar['nominet_tag']), $msg);
         return true;
     }
     return false;
 }
Example #14
0
    function verify_resend($VAR)
    {
        global $C_translate, $C_debug;
        ### Is the username & email both set?
        if (!isset($VAR["account_email"]) && !isset($VAR["account_username"])) {
            #### ERROR: You must enter either your username or e-mail address!
            $C_debug->alert($C_translate->translate('verify_resend_req', 'account', ''));
            return;
        } else {
            if ($VAR["account_email"] == "" && $VAR["account_username"] == "") {
                #### ERROR: You must enter either your username or e-mail address!
                $C_debug->alert($C_translate->translate('verify_resend_req', 'account', ''));
                return;
            }
        }
        $db =& DB();
        if (isset($VAR["account_email"]) && $VAR["account_email"] != "") {
            $sql = ' email = ' . $db->qstr($VAR["account_email"], get_magic_quotes_gpc());
        } else {
            if (isset($VAR["account_username"]) && $VAR["account_username"] != "") {
                $sql = ' username = '******'SELECT id,date_orig,status,email,first_name,last_name FROM ' . AGILE_DB_PREFIX . 'account
				 WHERE ' . $sql . ' AND
				 site_id     = ' . $db->qstr(DEFAULT_SITE);
        $result = $db->Execute($q);
        if ($result->RecordCount() == 0) {
            ### ERROR: No matches found!
            $C_debug->alert($C_translate->translate('password_reset_no_match', 'account', ''));
            return;
        }
        $account = $result->fields["id"];
        $status = $result->fields["status"];
        $validation_str = strtoupper($result->fields['date_orig'] . ':' . $result->fields['id']);
        if ($status == "1") {
            ### ERROR: This account is already active!
            $C_debug->alert($C_translate->translate('verify_resend_active', 'account', ''));
            return;
        }
        ### Resend the pending email:
        require_once PATH_MODULES . 'email_template/email_template.inc.php';
        $my = new email_template();
        $my->send('account_registration_inactive', $account, $account, '', $validation_str);
        ### Notice that the email is sent:
        $C_debug->alert($C_translate->translate("user_add_inactive_welcome", "account", ""));
    }
Example #15
0
    function add($VAR)
    {
        global $C_debug, $C_translate;
        ## Verify the account id passed:
        if (empty($VAR['affiliate_account_id'])) {
            $C_debug->alert($C_translate->translate('error_acct_req', 'affiliate', ''));
            return;
        }
        ## Get the affiliate template details:
        $db =& DB();
        $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'affiliate_template WHERE
					site_id     = ' . $db->qstr(DEFAULT_SITE) . ' AND
					id  = ' . $db->qstr($VAR['affiliate_template_id']);
        $result = $db->Execute($sql);
        if ($result->RecordCount() == 0) {
            $C_debug->alert($C_translate->translate('error_template_invalid', 'affiliate', ''));
            return;
        }
        ## Verify that this account does not have an affiliate account already:
        $sql = 'SELECT account_id FROM ' . AGILE_DB_PREFIX . 'affiliate WHERE
					site_id     = ' . $db->qstr(DEFAULT_SITE) . ' AND
					account_id  = ' . $db->qstr($VAR['affiliate_account_id']);
        $acctc = $db->Execute($sql);
        if ($acctc->RecordCount() > 0) {
            $C_debug->alert($C_translate->translate('error_acct_aff_exist', 'affiliate', ''));
            return;
        }
        ## Get the affiliate id that referred this account:
        $sql = 'SELECT affiliate_id FROM ' . AGILE_DB_PREFIX . 'account WHERE
					site_id     = ' . $db->qstr(DEFAULT_SITE) . ' AND
					id  = ' . $db->qstr($VAR['affiliate_account_id']);
        $ref = $db->Execute($sql);
        ## Create the record
        $this->record_id = $db->GenID(AGILE_DB_PREFIX . "" . 'affiliate_id');
        $this->record_id = $this->id_prefix . "" . $this->record_id;
        ## Generate the full query
        $sql = "INSERT INTO " . AGILE_DB_PREFIX . "affiliate\n\t\t\t\t\tSET\n\t\t\t\t\tid                    = " . $db->qstr($this->record_id) . ",\n\t\t\t\t\tsite_id               = " . $db->qstr(DEFAULT_SITE) . ",\n\t\t\t\t\taccount_id            = " . $db->qstr($VAR['affiliate_account_id']) . ",\n\t\t\t\t\tparent_affiliate_id   = " . $db->qstr($ref->fields['affiliate_id']) . ",\n\t\t\t\t\tstatus                = " . $db->qstr("1") . ",\n\t\t\t\t\taffiliate_plugin      = " . $db->qstr($result->fields['affiliate_plugin']) . ",\n\t\t\t\t\tavail_campaign_id     = " . $db->qstr($result->fields['avail_campaign_id']) . ",\n\t\t\t\t\tmax_tiers             = " . $db->qstr($result->fields['max_tiers']) . ",\n\t\t\t\t\tcommission_minimum    = " . $db->qstr($result->fields['commission_minimum']) . ",\n\t\t\t\t\tnew_commission_type   = " . $db->qstr($result->fields['new_commission_type']) . ",\n\t\t\t\t\tnew_commission_rate   = " . $db->qstr($result->fields['new_commission_rate']) . ",\t\t        \t  \t\n\t\t\t\t\trecurr_commission_type =" . $db->qstr($result->fields['recurr_commission_type']) . ",\n\t\t\t\t\trecurr_commission_rate =" . $db->qstr($result->fields['recurr_commission_rate']) . ",\n\t\t\t\t\trecurr_max_commission_periods = " . $db->qstr($result->fields['recurr_max_commission_periods']) . ",\t\t        \t  \t\n\t\t\t\t\tdate_orig             = " . $db->qstr(time()) . ",\n\t\t\t\t\tdate_last             = " . $db->qstr(time());
        $result2 = $db->Execute($sql);
        if ($result != false) {
            ## Load the affiliate plugin and run the "Add" method:
            $sql = "SELECT file FROM " . AGILE_DB_PREFIX . "affiliate_plugin WHERE\n\t\t\t\t\tid                    = " . $db->qstr($result->fields['affiliate_plugin']) . " AND\n\t\t\t\t\tsite_id               = " . $db->qstr(DEFAULT_SITE);
            $plgn = $db->Execute($sql);
            @($pluginfile = PATH_PLUGINS . 'affiliate/' . $plgn->fields['file'] . '.php');
            if (@(include_once $pluginfile)) {
                eval('$_PLGN_AFF = new plgn_aff_' . strtoupper($plgn->fields['file']) . ';');
                $_PLGN_AFF->add(SESS_ACCOUNT, $this->record_id);
            }
            ## Send the affiliate e-mail:
            require_once PATH_MODULES . 'email_template/email_template.inc.php';
            $my = new email_template();
            $my->send('affiliate_staff_add', $VAR['affiliate_account_id'], '', '', $this->record_id);
            ## Redirect
            global $VAR;
            $VAR['id'] = $this->record_id;
            define('FORCE_PAGE', $VAR['_page']);
        } else {
            $C_debug->alert('There was an error and the affiliate account could not be added.');
            define('FORCE_PAGE', $VAR['_page_current']);
        }
    }
Example #16
0
 /**
  * Postback for Redirect Pay 
  */
 function postback($arr)
 {
     global $C_debug;
     if (empty($arr['invoice_id'])) {
         return false;
     }
     if (empty($arr['transaction_id'])) {
         return false;
     }
     if (empty($arr['amount'])) {
         return false;
     }
     if (eregi("MULTI-", $arr['invoice_id'])) {
         $this->postback_multiple($arr);
         return;
     }
     # Get the latest invoice info:
     $db =& DB();
     $sql1 = "";
     if (!empty($arr['subscription_id'])) {
         $sql1 = "checkout_plugin_data = " . $db->qstr(trim($arr['subscription_id'])) . "  OR ";
     }
     $q = "SELECT * FROM " . AGILE_DB_PREFIX . "invoice WHERE\n\t       \t\t\t( \n\t\t\t\t\t\t{$sql1}\n\t       \t\t\t\tparent_id = " . $db->qstr(@$arr['invoice_id']) . "\n\t\t\t\t\t\tOR\n\t\t\t\t\t\tid        = " . $db->qstr(@$arr['invoice_id']) . "  \n\t\t\t\t\t)  \n\t\t\t\t\tAND\n\t       \t\t\tbilling_status != 1\n\t\t\t\t\tAND \n\t       \t\t\tsite_id = " . $db->qstr(DEFAULT_SITE) . "\n\t       \t\t\tORDER BY date_orig\n\t       \t\t\tLIMIT 0,1";
     $invoice = $db->Execute($q);
     if ($invoice === false || $invoice->RecordCount() == 0) {
         $C_debug->error('checkout.inc.php', 'postback', $q . " | " . @$db->ErrorMsg());
     }
     if ($invoice->RecordCount() == 0) {
         return false;
     }
     $invoice_id = $invoice->fields['id'];
     # Validate the currency
     $billed_currency_id = $invoice->fields['billed_currency_id'];
     $total_amt = $invoice->fields['total_amt'];
     $billed_amt = $invoice->fields['billed_amt'];
     $actual_billed_amt = $invoice->fields['actual_billed_amt'];
     $currency_iso = @$arr['currency'];
     if (empty($currency_iso) || !$currency_iso) {
         # same as billed_currency_id
         $this->billed_amt = $arr['amount'] + $billed_amt;
         $this->actual_billed_amt = $arr['amount'] + $billed_amt;
         $this->actual_billed_currency_id = $billed_currency_id;
     } else {
         # Get the actual billed currency id currency info:
         $q = "SELECT * FROM " . AGILE_DB_PREFIX . "currency WHERE\n\t        \t\t\tthree_digit\t= " . $db->qstr($currency_iso) . " AND\n\t        \t\t\tsite_id = " . $db->qstr(DEFAULT_SITE);
         $result = $db->Execute($q);
         if ($result === false) {
             $C_debug->error('checkout.inc.php', 'postback', $q . " | " . @$db->ErrorMsg());
         }
         $actual_billed_currency_id = $result->fields['id'];
         if (is_string($result->fields["convert_array"])) {
             $convert = unserialize($result->fields["convert_array"]);
         } else {
             $convert = false;
         }
         $this->format_currency[$actual_billed_currency_id] = array('symbol' => $result->fields["symbol"], 'convert' => $convert, 'iso' => $result->fields["three_digit"]);
         if ($result->RecordCount() == 0 || $actual_billed_currency_id == $billed_currency_id) {
             # same as billed_currency_id
             $this->billed_amt = $arr['amount'] + $billed_amt;
             $this->actual_billed_amt = $arr['amount'] + $billed_amt;
             $this->actual_billed_currency_id = $actual_billed_currency_id;
         } else {
             # Get the billed currency id currency info:
             $q = "SELECT * FROM " . AGILE_DB_PREFIX . "currency WHERE\n\t\t        \t\t\tid   \t= " . $db->qstr($billed_currency_id) . " AND\n\t\t        \t\t\tsite_id = " . $db->qstr(DEFAULT_SITE);
             $result = $db->Execute($q);
             if ($result === false) {
                 $C_debug->error('checkout.inc.php', 'postback', $q . " | " . @$db->ErrorMsg());
             }
             $this->format_currency[$billed_currency_id] = array('symbol' => $result->fields["symbol"], 'convert' => unserialize($result->fields["convert_array"]), 'iso' => $result->fields["three_digit"]);
             # Convert the invoice amount to the actual billed currency amount
             $due_amount = $invoice->fields['total_amt'] - $invoice->fields['billed_amt'];
             $conversion = $this->format_currency[$billed_currency_id]["convert"][$actual_billed_currency_id]["rate"];
             $this->billed_amt = $billed_amt + ($arr['amount'] /= $conversion);
             $this->actual_billed_amt = $actual_billed_amt + $arr['amount'];
             $this->actual_billed_currency_id = $actual_billed_currency_id;
         }
     }
     # Check for any subscription_id
     if (!empty($arr['subscription_id'])) {
         $this->subscription_id = trim($arr['subscription_id']);
     } else {
         $this->subscription_id = trim($invoice->fields['checkout_plugin_data']);
     }
     # Check for the checkout_id
     if (!empty($arr['checkout_id'])) {
         $this->checkout_id = $arr['checkout_id'];
     } else {
         $this->checkout_id = $invoice->fields['checkout_plugin_id'];
     }
     # Check for the billing status:
     if ($this->billed_amt >= $invoice->fields['total_amt']) {
         $this->billing_status = '1';
     } else {
         $this->billing_status = '0';
     }
     # Check if this transaction_id has already been processed:
     $q = "SELECT id FROM " . AGILE_DB_PREFIX . "invoice_memo WHERE\n        \t\t\tinvoice_id \t= " . $db->qstr($invoice_id) . " AND\n        \t\t\ttype\t\t= " . $db->qstr('postback') . " AND\n        \t\t\tmemo\t\t= " . $db->qstr($arr['transaction_id']) . " AND\n        \t\t\tsite_id \t= " . $db->qstr(DEFAULT_SITE);
     $memo = $db->Execute($q);
     if ($memo === false) {
         $C_debug->error('checkout.inc.php', 'postback', $q . " | " . @$db->ErrorMsg());
     }
     if ($memo->RecordCount() > 0) {
         # duplicate post:
         $C_debug->error('Duplicate Postback', 'checkout.inc.php :: postback()', "Duplicate postback for invoice {$arr['invoice_id']} & transaction id {$arr['transaction_id']}");
     } else {
         # Create the invoice memo:
         $memo_id = $db->GenID(AGILE_DB_PREFIX . 'invoice_memo_id');
         $q = "INSERT INTO\n\t        \t\t\t" . AGILE_DB_PREFIX . "invoice_memo \n\t        \t      SET\n\t        \t\t\tid \t\t\t\t\t= " . $db->qstr($memo_id) . ",\n\t        \t\t\tsite_id \t\t\t= " . $db->qstr(DEFAULT_SITE) . ",\n\t        \t\t\tdate_orig \t\t\t= " . $db->qstr(time()) . ", \n\t        \t\t\tinvoice_id\t \t\t= " . $db->qstr($invoice_id) . ", \n\t        \t\t\taccount_id\t\t\t= " . $db->qstr(0) . ", \n\t        \t\t\ttype\t\t\t\t= " . $db->qstr('postback') . ", \n\t        \t\t\tmemo\t\t\t\t= " . $db->qstr($arr['transaction_id']);
         $memosql = $db->Execute($q);
         if ($memosql === false) {
             $C_debug->error('checkout.inc.php', 'postback', $q . " | " . @$db->ErrorMsg());
         }
         # Update the invoice billing info:
         $q = "UPDATE\n\t        \t\t\t" . AGILE_DB_PREFIX . "invoice \n\t        \t      SET\n\t        \t\t\tdate_last \t\t\t= " . $db->qstr(time()) . ", \n\t        \t\t\tbilling_status \t\t= " . $db->qstr($this->billing_status) . ", \n\t        \t\t\tcheckout_plugin_id\t= " . $db->qstr($this->checkout_id) . ", \n\t        \t\t\tcheckout_plugin_data = " . $db->qstr($this->subscription_id) . ", \n\t        \t\t\tbilled_amt\t\t\t= " . $db->qstr($this->billed_amt) . ", \n\t        \t\t\tactual_billed_amt\t= " . $db->qstr($this->actual_billed_amt) . ", \n\t        \t\t\tactual_billed_currency_id = " . $db->qstr($this->actual_billed_currency_id) . "\n\t        \t\t   WHERE\n\t        \t\t\tid \t\t\t= " . $db->qstr($invoice_id) . " AND\n\t        \t\t\tsite_id \t= " . $db->qstr(DEFAULT_SITE);
         $memosql = $db->Execute($q);
         if ($memosql === false) {
             $C_debug->error('checkout.inc.php', 'postback', $q . " | " . @$db->ErrorMsg());
         }
         # Update the invoice approval status
         $VAR['id'] = $invoice_id;
         include_once PATH_MODULES . 'invoice/invoice.inc.php';
         $inv = new invoice();
         if (!$arr['status']) {
             # void
             $inv->voidInvoice($VAR);
             # create a record of the viod in an invoice memo:
             $memo_id = $db->GenID(AGILE_DB_PREFIX . 'invoice_memo_id');
             $q = "INSERT INTO\n\t\t        \t\t\t" . AGILE_DB_PREFIX . "invoice_memo \n\t\t        \t      SET\n\t\t        \t\t\tid \t\t\t\t\t= " . $db->qstr($memo_id) . ",\n\t\t        \t\t\tsite_id \t\t\t= " . $db->qstr(DEFAULT_SITE) . ",\n\t\t        \t\t\tdate_orig \t\t\t= " . $db->qstr(time()) . ", \n\t\t        \t\t\tinvoice_id\t \t\t= " . $db->qstr($invoice_id) . ", \n\t\t        \t\t\taccount_id\t\t\t= " . $db->qstr(0) . ", \n\t\t        \t\t\ttype\t\t\t\t= " . $db->qstr('void') . ", \n\t\t        \t\t\tmemo\t\t\t\t= " . $db->qstr("Voided due to postback: " . $arr['transaction_id']);
             $rsql = $db->Execute($q);
             if ($rsql === false) {
                 $C_debug->error('checkout.inc.php', 'postback', $q . " | " . @$db->ErrorMsg());
             }
         } else {
             # approve
             $inv->autoApproveInvoice($invoice_id);
             # User invoice payment confirmation
             include_once PATH_MODULES . 'email_template/email_template.inc.php';
             $email = new email_template();
             $email->send('invoice_paid_user', $invoice->fields['account_id'], $invoice_id, DEFAULT_CURRENCY, '');
             # Admin alert of payment processed
             $email = new email_template();
             $email->send('admin->invoice_paid_admin', $invoice->fields['account_id'], $invoice_id, DEFAULT_CURRENCY, '');
         }
     }
     return true;
 }
 function login($account_id, $username)
 {
     # Check if account is exempt:
     if (!empty($this->exempt) && is_array($this->exempt)) {
         for ($i = 0; $i < count($this->exempt); $i++) {
             if ($this->exempt[$i] == $username) {
                 return true;
             }
         }
     }
     # Determine current subnet to match:
     @($arr = explode('.', USER_IP));
     # Validate values
     if (!is_array($arr) || !is_numeric($this->subnets) || $this->subnets > 4) {
         return true;
     }
     # Subnet...
     $subnet = '';
     for ($i = 0; $i < $this->subnets; $i++) {
         $subnet .= $arr[$i];
         if ($i < 3) {
             $subnet .= '.';
         }
     }
     # time limit...
     $limit = time() - 86400 * $this->range;
     # Generate SQL query
     $db =& DB();
     $sql = "SELECT DISTINCT \n\t\t\t\t\tip \n\t\t\t\tFROM " . AGILE_DB_PREFIX . "login_log\n\t\t\t\tWHERE\n\t\t\t\t\tdate_orig > {$limit}\n\t\t\t\tAND\n\t\t\t\t\tip NOT LIKE '{$subnet}%'\n\t\t\t\tAND\n\t\t\t\t\taccount_id = {$account_id}\n\t\t\t\tAND\n\t\t\t\t\tsite_id\t   = " . DEFAULT_SITE;
     $rs = $db->Execute($sql);
     if ($this->max_subnets > 0 && $rs->RecordCount() >= $this->max_subnets - 1) {
         $subnets["{$subnet}"] = true;
         $count = 0;
         while (!$rs->EOF) {
             @($arr = explode('.', $rs->fields['ip']));
             $subnet1 = '';
             for ($i = 0; $i < $this->subnets; $i++) {
                 $subnet1 .= $arr[$i];
                 if ($i < 3) {
                     $subnet1 .= '.';
                 }
             }
             if (empty($subnets["{$subnet1}"])) {
                 $subnets["{$subnet1}"] = true;
             }
             if (!empty($subnets) && count($subnets) >= $this->max_subnets) {
                 break;
             }
             $rs->MoveNext();
         }
         # over limit?
         if (!empty($subnets) && count($subnets) >= $this->max_subnets) {
             # Deactivate account:
             $sql = "UPDATE " . AGILE_DB_PREFIX . "account\n\t\t\t\t\t\tSET\n\t\t\t\t\t\t\tstatus \t= 0\n\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\tsite_id\t= " . DEFAULT_SITE . "\n\t\t\t\t\t\tAND\n\t\t\t\t\t\t\tid = {$account_id}";
             $db->Execute($sql);
             # send e-mail alerts
             include_once PATH_MODULES . 'email_template/email_template.inc.php';
             # send user alert
             $email = new email_template();
             $email->send('login_share_ban_user', $account_id, '', $this->max_subnets, count($subnets));
             # send admin alert
             $email = new email_template();
             $email->send('admin->login_share_ban_admin', $account_id, '', $this->max_subnets, count($subnets));
             return false;
         } else {
             return true;
         }
     } else {
         return true;
     }
 }
Example #18
0
    function user_add($VAR)
    {
        $this->construct();
        global $C_debug, $C_translate, $C_vars, $smarty;
        ### Strip Slashes
        global $VAR;
        $C_vars->strip_slashes_all();
        ####################################################################
        ### Check that the required fields are set:
        ### ticket_department_id, ticket_subject, ticket_body
        ####################################################################
        $fields = array('priority', 'department_id', 'subject', 'body');
        for ($i = 0; $i < count($fields); $i++) {
            $field = $fields[$i];
            $field_name = $this->table . '_' . $field;
            if (!isset($VAR["{$field_name}"]) || trim($VAR["{$field_name}"]) == "") {
                $this->val_error[] = array('field' => $this->table . '_' . $field, 'field_trans' => $C_translate->translate('field_' . $field, $this->module, ""), 'error' => $C_translate->translate('validate_any', "", ""));
            }
        }
        ####################################################################
        ### 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($this->module, $this->val_error);
        if ($all_error != false && gettype($all_error) == 'array') {
            $this->validated = false;
        } else {
            $this->validated = true;
        }
        ### Validate e-mail
        if (!SESS_LOGGED) {
            include_once PATH_CORE . 'validate.inc.php';
            $C_validate = new CORE_validate();
            if (empty($VAR['ticket_email'])) {
                $this->validated = false;
                $smarty->assign('ticket_email', true);
                $all_error[] = array('field' => 'ticket_email', 'field_trans' => $C_translate->translate('field_email', "ticket", ""), 'error' => $C_translate->translate('validate_any', "", ""));
            } elseif (!$C_validate->validate_email(@$VAR['ticket_email'], false)) {
                $this->validated = false;
                $smarty->assign('ticket_email', true);
                $all_error[] = array('field' => 'ticket_email', 'field_trans' => $C_translate->translate('field_email', "ticket", ""), 'error' => $C_translate->translate('validate_email', "", ""));
            }
            $this->email = $VAR['ticket_email'];
        } else {
            # Get the e-mail addy from the user's account
            $db =& DB();
            $sql = 'SELECT email FROM ' . AGILE_DB_PREFIX . 'account WHERE
	                        site_id     = ' . $db->qstr(DEFAULT_SITE) . ' AND
	                        id          = ' . $db->qstr(SESS_ACCOUNT);
            $result = $db->Execute($sql);
            $VAR['ticket_email'] = $result->fields['email'];
            $this->email = $result->fields['email'];
        }
        ###################################################################
        ### Check that the user is authorized for this department
        $db =& DB();
        $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'ticket_department WHERE
                        site_id     = ' . $db->qstr(DEFAULT_SITE) . ' AND
                        id          = ' . $db->qstr($VAR['ticket_department_id']) . ' AND
                        status      = ' . $db->qstr('1');
        $result = $db->Execute($sql);
        if ($result->RecordCount() == 0) {
            ###################################################################
            ### ERROR: The selected department is inactive or invalid
            $C_debug->alert($C_translate->translate('department_invalid', 'ticket', ''));
            return false;
        }
        global $C_auth;
        $i = 0;
        $dept_auth = false;
        while (!$result->EOF) {
            $arr = unserialize($result->fields['group_id']);
            if (!SESS_LOGGED) {
                ### Check if the specified department is authorized for the 'All Users' group (0):
                for ($i = 0; $i < count($arr); $i++) {
                    if ($arr[$i] == '0') {
                        $dept_auth = true;
                    }
                }
                if (!$dept_auth) {
                    $C_debug->alert($C_translate->translate('login_required', '', ''));
                    return false;
                }
            } else {
                for ($i = 0; $i < count($arr); $i++) {
                    if ($C_auth->auth_group_by_id($arr[$i])) {
                        $dept_auth = true;
                    }
                }
            }
            $result->MoveNext();
        }
        if (!$dept_auth) {
            ###################################################################
            ### ERROR: The current user does not have access to the selected department!
            $C_debug->alert($C_translate->translate('department_not_auth', 'ticket', ''));
            return false;
        } else {
            ####################################################################
            # 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']);
                }
                global $C_vars;
                $C_vars->strip_slashes_all();
                return;
            }
            ###################################################################
            ### Assemble the SQL & Insert the ticket
            $db =& DB();
            $id = $db->GenID(AGILE_DB_PREFIX . 'ticket_id');
            $sql = 'INSERT INTO ' . AGILE_DB_PREFIX . 'ticket SET
                            site_id     = ' . $db->qstr(DEFAULT_SITE) . ',
                            id          = ' . $db->qstr($id) . ',
                            date_orig   = ' . $db->qstr(time()) . ',
                            date_last   = ' . $db->qstr(time()) . ',
                            date_expire = ' . $db->qstr(time() + 86400 * 7) . ',
                            account_id  = ' . $db->qstr(SESS_ACCOUNT) . ',
                            department_id=' . $db->qstr($VAR['ticket_department_id']) . ',
                            status      = ' . $db->qstr(0) . ',
                            last_reply  = 0,
                            priority    = ' . $db->qstr($VAR['ticket_priority']) . ',
                            subject     = ' . $db->qstr($VAR['ticket_subject']) . ',
                            email		= ' . $db->qstr($VAR['ticket_email']) . ',
                            body        = ' . $db->qstr(htmlspecialchars($VAR['ticket_body']));
            $result = $db->Execute($sql);
            # error reporting:
            if ($result === false) {
                global $C_debug;
                $C_debug->error('ticket.inc.php', 'user_add', $db->ErrorMsg());
                return false;
            }
            ###################################################################
            ### Insert the static vars...
            $static_var->add($VAR, $this->module, $id);
            ###################################################################
            ### Mail the user the new_ticket email template
            require_once PATH_MODULES . 'email_template/email_template.inc.php';
            $VAR['email'] = trim($this->email);
            $VAR['key'] = $this->key($this->email);
            $my = new email_template();
            $my->send('ticket_user_add', $this->email, $id, '', '');
            unset($VAR['key']);
            unset($VAR['email']);
            ###################################################################
            ### Get any staff members who should be mailed
            $db =& DB();
            $sql = 'SELECT id,account_id,department_avail FROM ' . AGILE_DB_PREFIX . 'staff
                            WHERE
                            site_id     = ' . $db->qstr(DEFAULT_SITE) . ' AND
                            notify_new  = ' . $db->qstr("1");
            $result = $db->Execute($sql);
            if ($result->RecordCount() > 0) {
                while (!$result->EOF) {
                    @($avail = unserialize($result->fields['department_avail']));
                    for ($i = 0; $i < count($avail); $i++) {
                        if ($avail[$i] == $VAR['ticket_department_id']) {
                            ###################################################################
                            ### Mail staff members the new_ticket email template
                            $my = new email_template();
                            $my->send('ticket_user_add_staff', $result->fields['account_id'], $id, $avail[$i], 'sql3');
                            $i = count($avail);
                        }
                    }
                    $result->MoveNext();
                }
            }
        }
        global $C_debug, $C_translate;
        $C_debug->alert($C_translate->translate('user_add_success', 'ticket', ''));
    }
Example #19
0
 /** Run checkout plugin for billing
  */
 function checkoutnow($VAR)
 {
     global $C_translate, $smarty, $C_list, $VAR;
     # Validate user logged in:
     if (SESS_LOGGED != '1') {
         echo '<script language="JavaScript">alert("You must be logged in to complete this purchase! Please refresh this page in your browser to login now...");</script>';
         return false;
     }
     $db =& DB();
     if (preg_match("/MULTI-/", @$VAR['invoice_id'])) {
         // get multi-invoice details
         $total = $this->multiple_invoice_total(@$VAR['invoice_id'], SESS_ACCOUNT);
         if (!$total) {
             return false;
         }
         $recur_amt = false;
         $recur_arr = false;
         $account_id = SESS_ACCOUNT;
         $this->invoice[] = $VAR['invoice_id'];
         $this->invoice_id = $VAR['invoice_id'];
         $CURRENCY = DEFAULT_CURRENCY;
         $multi = true;
     } else {
         # Validate the invoice selected, & get the totals:
         $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'invoice WHERE site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND id = ' . $db->qstr($VAR['invoice_id']);
         $result = $db->Execute($sql);
         if (!$result || $result->RecordCount() == 0) {
             return false;
         }
         # Determine the price & currency
         if ($result->fields['billed_currency_id'] != $result->fields['actual_billed_currency_id']) {
             global $C_list;
             $CURRENCY = $result->fields['actual_billed_currency_id'];
             if ($result->fields['billed_amt'] <= 0) {
                 $total = $C_list->format_currency_decimal($result->fields['total_amt'], $CURRENCY);
             } else {
                 $total = $C_list->format_currency_decimal($result->fields['total_amt'], $CURRENCY) - $result->fields['actual_billed_amt'];
             }
         } else {
             $CURRENCY = $result->fields['billed_currency_id'];
             $total = $result->fields['total_amt'] - $result->fields['billed_amt'];
         }
         $recur_amt = $result->fields['recur_amt'];
         if ($recur_amt > 0) {
             $recur_amt = $C_list->format_currency_decimal($recur_amt, $CURRENCY);
         }
         @($recur_arr = unserialize($result->fields['recur_arr']));
         $account_id = $result->fields['account_id'];
         $this->invoice_id = $result->fields['id'];
         $this->invoice[] = $result->fields['id'];
         $multi = false;
     }
     $amount = round($total, 2);
     # Get the account details:
     $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'account WHERE site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND id = ' . $db->qstr($account_id);
     $account = $db->Execute($sql);
     if (!$account || !$account->RecordCount()) {
         return false;
     }
     # Validate checkout option selected is allowed for purchase:
     $q = "SELECT * FROM " . AGILE_DB_PREFIX . "checkout WHERE site_id = " . $db->qstr(DEFAULT_SITE) . " AND id = " . $db->qstr(@$VAR['option']) . " AND active = 1 AND ";
     if ($recur_amt > 0 && @$billed_amt == 0) {
         $q .= "allow_recurring = 1 ";
     } else {
         $q .= "allow_new = 1 ";
     }
     $chopt = $db->Execute($q);
     if (!$chopt || !$chopt->RecordCount()) {
         return false;
     }
     if ($chopt && $chopt->RecordCount()) {
         $show = true;
         if (@$chopt->fields["total_maximum"] != "" && $total > $chopt->fields["total_maximum"]) {
             $show = false;
         }
         if (@$chopt->fields["total_miniumum"] != "" && $total < $chopt->fields["total_miniumum"]) {
             $show = false;
         }
     }
     if (!$show) {
         echo '<script language=Javascript> alert("Unable to checkout with the selected method, please select another."); </script> ';
         return false;
     }
     # Load the checkout plugin:
     $plugin_file = PATH_PLUGINS . 'checkout/' . $chopt->fields["checkout_plugin"] . '.php';
     include_once $plugin_file;
     eval('$PLG = new plg_chout_' . $chopt->fields["checkout_plugin"] . '("' . @$VAR["option"] . '");');
     if (!empty($VAR['account_billing_id']) && @$VAR['new_card'] == 2) {
         /* validate credit card on file details */
         $account_billing_id = $VAR['account_billing_id'];
         if (!$PLG->setBillingFromDB($account_id, $account_billing_id, $VAR['option'])) {
             global $C_debug;
             $C_debug->alert("Sorry, we cannot use that billing record for this purchase.");
             return false;
         }
     } else {
         /* use passed in vars */
         $PLG->setBillingFromParams($VAR);
     }
     # Set Invoice Vars:
     $this->total_amt = $amount;
     $this->currency_iso = $C_list->currency_iso($CURRENCY);
     $this->currency_iso_admin = $C_list->currency_iso($CURRENCY);
     $this->account_id = $account_id;
     $this->actual_billed_currency_id = $CURRENCY;
     $this->billed_currency_id = $CURRENCY;
     $this->checkout_plugin_id = @$VAR["option"];
     # Run the plugin bill_checkout() method:
     $this->checkout_plugin_data = $PLG->bill_checkout($amount, $this->invoice_id, $this->currency_iso, $account->fields, $recur_amt, $recur_arr);
     # redirect
     if (!empty($this->checkout_plugin_data['redirect'])) {
         echo $this->checkout_plugin_data['redirect'];
     }
     # determine results
     if ($this->checkout_plugin_data === false) {
         if (!empty($PLG->redirect)) {
             echo $PLG->redirect;
         }
         return false;
     } elseif ($PLG->type == "gateway" && empty($PLG->redirect)) {
         if (empty($this->admin_checkout)) {
             $VAR['_page'] = "invoice:thankyou";
         } else {
             $VAR['_page'] = "invoice:view";
         }
     } elseif ($PLG->type == "redirect") {
         echo "<html><head></head><body><center>\n\t\t\t\tPlease wait while we redirect you to the secure payment site....\n\t\t\t\t{$PLG->redirect}</center></body></html>";
     }
     # Call the Plugin method for storing the checkout data, if new data entered:
     $this->account_billing_id = $PLG->store_billing($VAR, $PLG);
     # Load the email template module
     include_once PATH_MODULES . 'email_template/email_template.inc.php';
     $mail = new email_template();
     # Update billing details for this invoice, if realtime billing succeeded:
     if ($PLG->type == 'gateway' || $amount == 0) {
         $q = "UPDATE " . AGILE_DB_PREFIX . "invoice\n\t\t        \t\tSET\n\t\t        \t\t\taccount_billing_id\t\t= " . $db->qstr($this->account_billing_id) . ",\n\t\t        \t\t\tbilling_status\t\t\t= " . $db->qstr(1) . ",\n\t\t        \t\t\tbilled_amt \t\t  \t\t= " . $db->qstr($total) . ",\n\t\t        \t\t\tactual_billed_amt \t\t= " . $db->qstr($amount) . ",\n\t\t        \t\t\tdate_last\t\t  \t\t= " . $db->qstr(time()) . ",\n\t\t        \t\t\tcheckout_plugin_id\t\t= " . $db->qstr($this->checkout_plugin_id) . ",\n\t\t        \t\t\tcheckout_plugin_data\t= " . $db->qstr(serialize($this->checkout_plugin_data)) . "\n\t\t        \t\tWHERE\n\t\t        \t\t\tsite_id   = " . $db->qstr(DEFAULT_SITE) . " AND\n\t\t        \t\t\tid \t\t  = " . $db->qstr($this->invoice_id);
         $rst = $db->Execute($q);
         if ($rst === false) {
             global $C_debug;
             $C_debug->error('invoice.inc.php', 'checkoutnow', $db->ErrorMsg());
             return false;
         }
         // loop through each invoice paid
         foreach ($this->invoice as $this->invoice_id) {
             # Send billed e-mail notice to user
             $email = new email_template();
             $email->send('invoice_paid_user', $this->account_id, $this->invoice_id, $this->currency_iso, '');
             # Admin alert of payment processed
             $email = new email_template();
             $email->send('admin->invoice_paid_admin', $this->account_id, $this->invoice_id, $this->currency_iso_admin, '');
             # Submit the invoice for approval
             $arr['id'] = $this->invoice_id;
             $this->approveInvoice($arr, $this);
         }
     } else {
         # Just update the last_date and plugin data
         $q = "UPDATE " . AGILE_DB_PREFIX . "invoice\n\t\t        \t\tSET \n\t\t        \t\t\taccount_billing_id\t\t= " . $db->qstr($this->account_billing_id) . ",\n\t\t        \t\t\tdate_last\t\t  \t\t= " . $db->qstr(time()) . ",\n\t\t        \t\t\tcheckout_plugin_id\t\t= " . $db->qstr($this->checkout_plugin_id) . ",\n\t\t        \t\t\tcheckout_plugin_data\t= " . $db->qstr(serialize($this->checkout_plugin_data)) . "\n\t\t        \t\tWHERE\n\t\t        \t\t\tsite_id   = " . $db->qstr(DEFAULT_SITE) . " AND\n\t\t        \t\t\tid \t\t  = " . $db->qstr($this->invoice_id);
         $rst = $db->Execute($q);
         if ($rst === false) {
             global $C_debug;
             $C_debug->error('invoice.inc.php', 'checkoutnow', $db->ErrorMsg());
             return false;
         }
         # Admin e-mail alert of manual payment processing
         if ($PLG->name == 'MANUAL') {
             $date_due = $C_list->date(time());
             foreach ($this->invoice as $this->invoice_id) {
                 $email = new email_template();
                 $email->send('admin->invoice_due_admin', $this->account_id, $this->invoice_id, '', $date_due);
             }
             global $C_debug;
             $C_debug->alert($C_translate->translate('manual_alert', 'checkout'));
         }
     }
 }
    function p_all($VAR)
    {
        global $C_debug;
        # Error checking
        if (empty($VAR['key'])) {
            echo 'REM Server Key Missing!';
            exit;
        }
        # Get the server details
        $db =& DB();
        $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'host_server WHERE
                   keycode      =  ' . $db->qstr($VAR['key']) . ' AND
                   site_id      =  ' . $db->qstr(DEFAULT_SITE);
        $rs = $db->Execute($sql);
        if (@$rs->RecordCount() <= 0) {
            echo 'REM Server ID does not exist';
            exit;
        } else {
            $this->server = $rs->fields;
            @($this->server_cnfg = unserialize($rs->fields['provision_plugin_data']));
        }
        # Check that this server is using this plugin
        if ($this->server['provision_plugin'] != @$this->name) {
            echo 'REM Wrong plugin for this server ';
            exit;
        }
        # Check the auth for this post
        if (!empty($VAR['key']) && $VAR['key'] == $this->server['keycode']) {
            # authorized!
        } else {
            echo 'REM Unauthorized Key! ';
            exit;
        }
        # Get the service details
        $db =& DB();
        $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'service WHERE
                   type             =  ' . $db->qstr('host') . ' OR
                   type             =  ' . $db->qstr('host_group') . ' AND
                   host_server_id   =  ' . $db->qstr($this->server['id']) . ' AND
                   queue           !=  ' . $db->qstr('none') . ' AND
                   site_id          =  ' . $db->qstr(DEFAULT_SITE);
        $rs = $db->Execute($sql);
        if ($rs->RecordCount() == 0) {
            echo 'REM No Records To Add/Update ';
            exit;
        }
        $i = 0;
        while (!$rs->EOF) {
            # set details
            $this->service = $rs->fields;
            # Get the hosting plan plugin data for this product
            $this->plugin_data = unserialize($this->service['host_provision_plugin_data']);
            # Get the account details
            $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'account WHERE
                       id           =  ' . $db->qstr($this->service['account_id']) . ' AND
                       site_id      =  ' . $db->qstr(DEFAULT_SITE);
            $acct = $db->Execute($sql);
            $this->account = $acct->fields;
            # determine the correct action
            switch ($this->service['queue']) {
                # new
                case 'new':
                    $result = $this->p_new();
                    # send the user the details
                    include_once PATH_MODULES . 'email_template/email_template.inc.php';
                    $email = new email_template();
                    $email->send('host_new_user', $this->account['id'], $rs->fields['id'], '', '');
                    break;
                    # active
                # active
                case 'active':
                    $result = $this->p_active();
                    # send the user the details
                    include_once PATH_MODULES . 'email_template/email_template.inc.php';
                    $email = new email_template();
                    $email->send('host_edit_user', $this->account['id'], $rs->fields['id'], '', '');
                    break;
                    # inactive
                # inactive
                case 'inactive':
                    $result = $this->p_inactive();
                    break;
                    # edit
                # edit
                case 'edit':
                    $result = $this->p_edit();
                    break;
                    # delete
                # delete
                case 'delete':
                    $result = $this->p_delete();
                    break;
            }
            # formatting
            if (@$result != false) {
                if ($i > 0) {
                    echo $this->nl;
                }
                echo $result;
                $i++;
            }
            # check if we need to update the status after an edit
            if ($this->service['queue'] == 'edit') {
                if ($this->service['active'] == 1) {
                    echo $this->nl . $this->p_active();
                } else {
                    echo $this->nl . $this->p_inactive();
                }
            }
            # update service record
            if (@$result != false) {
                if ($this->service['queue'] == "delete") {
                    # delete
                    $sql = 'DELETE FROM ' . AGILE_DB_PREFIX . 'service WHERE
	                           id           =  ' . $db->qstr($rs->fields['id']) . ' AND
	                           site_id      =  ' . $db->qstr(DEFAULT_SITE);
                    $upd = $db->Execute($sql);
                } else {
                    # update
                    $sql = 'UPDATE ' . AGILE_DB_PREFIX . 'service SET
	                           queue        =  ' . $db->qstr('none') . ',
	                           date_last    =  ' . $db->qstr(time()) . '
	                           WHERE
	                           id           =  ' . $db->qstr($rs->fields['id']) . ' AND
	                           site_id      =  ' . $db->qstr(DEFAULT_SITE);
                    $upd = $db->Execute($sql);
                }
            } else {
                # error log
                $C_debug->error($this->name . 'php', $this->service['queue'], @$result);
            }
            $rs->MoveNext();
        }
    }
Example #21
0
 function renew()
 {
     # compose the message:
     $msg = $this->emailCompose('R');
     # send the e-mail
     if ($this->staff_account_id) {
         include_once PATH_MODULES . 'email_template/email_template.inc.php';
         $mail = new email_template();
         $mail->send('registrar_bulkregister_admin', $this->staff_account_id, '', '', $msg);
         return true;
     }
     return false;
 }
Example #22
0
 /** provision ani */
 function provision_ani_new($obj)
 {
     $db =& DB();
     // default field values:
     if (!empty($obj->product_attr['expire']) && !empty($obj->product_attr['expire_days'])) {
         $fields['expire_days'] = $obj->product_attr['expire_days'];
     }
     $fields['date_expire'] = 0;
     // check if ani exists already in db
     $pin = $obj->prod_attr_cart['ani_new'];
     if (!empty($pin)) {
         $pinexists = $db->Execute(sqlSelect($db, "voip_prepaid", "*", "pin = ::{$pin}:: AND ani=1"));
     }
     if ($pinexists && $pinexists->RecordCount() > 0) {
         // update existing pin:
         $fields['balance'] = $obj->service['price'] + $pinexists->fields['balance'];
         $rs = $db->Execute(sqlUpdate($db, "voip_prepaid", $fields, "pin = ::{$pin}:: AND ani=1"));
         return true;
     } elseif (!empty($obj->prod_attr_cart['ani_old'])) {
         // existing ani provided by user
         $pin = $obj->prod_attr_cart['ani_old'];
         $pinrs = $db->Execute(sqlSelect($db, "voip_prepaid", "*", "pin = ::{$pin}:: AND ani=1"));
         if ($pinrs && $pinrs->RecordCount() == 1) {
             // update existing pin:
             $fields['balance'] = $obj->service['price'] + $pinexists->fields['balance'];
             $rs = $db->Execute(sqlUpdate($db, "voip_new_prepaid_did", $fields, "pin = ::{$pin}:: AND ani=1"));
             return true;
         }
     }
     // the balance from the invoice line item (not including setup fee)
     $itemid = $obj->service['invoice_item_id'];
     $invoiceItem = $db->Execute(sqlSelect($db, "invoice_item", "price_base", "id = {$itemid}"));
     if ($invoiceItem && $invoiceItem->RecordCount() > 0) {
         $balance = $invoiceItem->fields['price_base'];
     } else {
         $balance = $obj->service['price'];
     }
     // still here? generate a new ani prepaid record
     $pin = $obj->prod_attr_cart['ani_new'];
     $fields = array('account_id' => $obj->account['id'], 'product_id' => $obj->service['product_id'], 'pin' => trim($pin), 'balance' => $balance, 'in_use' => 0, 'ani' => 1);
     if (!empty($obj->product_attr['expire']) && !empty($obj->product_attr['expire_days'])) {
         $fields['expire_days'] = $obj->product_attr['expire_days'];
     }
     $pin_id = sqlGenID($db, "voip_prepaid");
     $sql = sqlInsert($db, "voip_prepaid", $fields, $pin_id);
     $rs = $db->Execute($sql);
     if ($rs) {
         # send the user the details
         include_once PATH_MODULES . 'email_template/email_template.inc.php';
         $email = new email_template();
         $email->send('voip_new_prepaid_ani', $obj->account['id'], $pin_id, $pin_id, $obj->plugin_data['number']);
     } else {
         return false;
     }
     return true;
 }
Example #23
0
 function p_delete()
 {
     # recycle the IP if ip_based:
     if ($this->plugin_data['ipinfo_namebased'] == '1') {
         include_once PATH_MODULES . 'host_server/host_server.inc.php';
         $host = new host_server();
         $this->ip = $host->unuseipaddress($this->server, $this->service['host_ip']);
     }
     # send the admin delete notice
     include_once PATH_MODULES . 'email_template/email_template.inc.php';
     $email = new email_template();
     $email->send('admin->host_delete_admin', $this->account['id'], $this->service['id'], '', '');
     return true;
 }
Example #24
0
 function cancelservice($VAR)
 {
     if (!isset($VAR['id'])) {
         return false;
     }
     # Update service status
     $db =& DB();
     $q = "UPDATE " . AGILE_DB_PREFIX . "service SET\n                    suspend_billing = " . $db->qstr('1') . " WHERE\n                    id          = " . $db->qstr($VAR['id']) . " AND\n                    site_id     = " . $db->qstr(DEFAULT_SITE);
     $db->Execute($q);
     # get the account id
     $sql = 'SELECT id,account_id FROM ' . AGILE_DB_PREFIX . 'service WHERE
                    id           =  ' . $db->qstr($VAR['id']) . ' AND
                    site_id      =  ' . $db->qstr(DEFAULT_SITE);
     $service = $db->Execute($sql);
     # send user email
     include_once PATH_MODULES . 'email_template/email_template.inc.php';
     $email = new email_template();
     $email->send('service_cancel_user', $service->fields['account_id'], $service->fields['id'], '', '');
     # send admin email only if user canceled
     if (isset($VAR['user'])) {
         $email = new email_template();
         $email->send('admin->service_cancel_admin', $service->fields['account_id'], $service->fields['id'], '', '');
     }
     # Create a memo
     $fields = array('date_orig' => time(), 'staff_id' => SESS_ACCOUNT, 'service_id' => $VAR['id'], 'type' => 'cancel', 'memo' => "Staff Canceled Service");
     $db->Execute($sql = sqlInsert($db, "service_memo", $fields));
 }
 public function check_decline_price_giftsAction()
 {
     $decline = new p_decline_price_gifts();
     $decline_price_gifts = $decline->select($count, array('filter' => array('find_decline_prices' => true, 'status' => 0)));
     if (!empty($decline_price_gifts)) {
         $i = 1;
         foreach ($decline_price_gifts as $decline) {
             $gift = new gift($decline->gift_id);
             $id[] = $decline->id;
             $email = new email_template('decline_price_gift');
             $email->assign('GIFT_NAME', $gift->get('display_name'))->assign('OLD_PRICE', $decline->old_price)->assign('PRICE', $decline->price)->assign('LINK', "http://{$_SERVER['HTTP_HOST']}/" . $gift->get('local_url') . '/?utm_source=email&utm_medium=user&utm_campaign=decline_price_gifts')->assign('USER_NAME', $decline->user_name)->send($decline->email, $decline->user_name)->send('*****@*****.**');
             $list .= $i . '.&nbsp;<a href="http://' . $_SERVER["HTTP_HOST"] . '/' . $gift->get('local_url') . '/"><b>' . $gift->get('display_name') . "</b></a> {$decline->user_name} &lt;{$decline->email}&gt;<br>Старая цена: {$decline->old_price}&nbsp;руб.<br>Новая цена: <b>{$decline->price}</b>&nbsp;руб.<br><br>";
             $i++;
         }
         $decline->set_status(1, $id);
         $em = new email_template('decline_price_gift_us');
         $em->assign('COUNT', count($id))->assign('LIST', !empty($list) ? $list : '')->send('*****@*****.**');
     }
     die('OK');
 }
Example #26
0
    function p_new()
    {
        # get the common server class and set login details
        include_once PATH_MODULES . 'host_server/host_server.inc.php';
        $host = new host_server();
        if ($this->service['host_username'] == '' || $this->service['host_password'] == '') {
            # set the limits
            $pass_len = 10;
            $user_len = 12;
            # Generate a new username/login:
            $domain = $this->service['domain_name'] . $this->service['domain_tld'];
            # set the username
            $username = trim($domain);
            $username = preg_replace("/[-_\\.]/", "", $username);
            if (strlen($username) < $user_len) {
                $rand = md5(md5($username) . time());
                $diff = $user_len - strlen($username);
                $username = $username . substr($rand, 0, $diff);
            } else {
                $rand = md5(microtime() . md5($username) . microtime());
                $username = substr($username, 0, $user_len - 5);
                $username = $username . substr($rand, 0, 5);
            }
            # Set the password
            $password = substr(md5(md5(time()) . $domain . $username), 0, 10);
            # Set the user/pass for the XML queries
            $this->login['username'] = $username;
            $this->login['password'] = $password;
        } else {
            # Validate
            $this->login['username'] = $this->service['host_username'];
            $this->login['password'] = $this->service['host_password'];
        }
        # get ip address
        if ($this->plugin_data['ip_based'] == '1') {
            $this->ip = $host->useipaddress($this->service, $this->server);
        } else {
            $this->ip = $this->server['name_based_ip'];
        }
        ####################################################
        ### Assemble the XML for the account creation:	####
        $data = <<<EOF
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
\t\t<packet version="{$this->proto}">
\t\t\t<client>
\t\t\t\t<add>
\t\t\t\t\t<gen_info>
\t\t\t\t\t\t<pname>{$this->account['first_name']} {$this->account['last_name']} ({$this->login['username']})</pname>
\t\t\t\t\t\t<login>{$this->login['username']}</login>
\t\t\t\t\t\t<passwd>{$this->login['password']}</passwd>
\t\t\t\t\t\t<email>{$this->account['email']}</email>
\t\t\t\t\t\t<pcode>00000</pcode>
\t\t\t\t\t\t<country>US</country>
\t\t\t\t\t\t<status>0</status>
\t\t\t\t\t\t<phone>18005551212</phone>
\t\t\t\t\t</gen_info>
\t\t\t\t\t<template-name>{$this->plugin_data['client_template_name']}</template-name>
\t\t\t\t</add>
\t\t\t</client>
</packet>
EOF;
        # Connect & get response:
        $result = $this->connect($this->server_cfg['host'], $this->server_cfg['port'], $this->server_cfg['user'], $this->server_cfg['pass'], $data);
        # Debug:
        $this->debug($data, $result);
        # Get the account id
        if (!($cl_id = $this->getid($result))) {
            return false;
        }
        ##############################
        ### ADD IP TO CLIENT POOL: ###
        $data = <<<EOF
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
\t\t<packet version="{$this->proto}">
\t\t\t<client>
\t\t\t\t<ippool_add_ip>
\t\t\t\t\t<client_id>{$cl_id}</client_id>
\t\t\t\t\t<ip_address>{$this->ip}</ip_address>
\t\t\t\t</ippool_add_ip>
\t\t\t</client>
</packet>
EOF;
        # Connect & get response:
        $result = $this->connect($this->server_cfg['host'], $this->server_cfg['port'], $this->server_cfg['user'], $this->server_cfg['pass'], $data);
        # Debug:
        $this->debug($data, $result);
        #######################
        ### ADD NEW DOMAIN: ###
        $data = <<<EOF
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
\t\t<packet version="{$this->proto}">
\t\t\t<domain>
\t\t\t\t<add>
\t\t\t\t\t<gen_setup>
\t\t\t\t\t\t<name>{$this->service['domain_name']}.{$this->service['domain_tld']}</name>
\t\t\t\t\t\t<client_id>{$cl_id}</client_id>
\t\t\t\t\t\t<htype>vrt_hst</htype>
\t\t\t\t\t\t<ip_address>{$this->ip}</ip_address>
\t\t\t\t\t\t<status />
\t\t\t\t\t</gen_setup>
\t\t\t\t\t<hosting>
\t\t\t\t\t\t<vrt_hst>
\t\t\t\t\t\t\t<ftp_login>{$this->login['username']}</ftp_login>
\t\t\t\t\t\t\t<ftp_password>{$this->login['password']}</ftp_password>
\t\t\t\t\t\t\t<ip_address>{$this->ip}</ip_address>
\t\t\t\t\t\t</vrt_hst>
\t\t\t\t\t</hosting>
\t\t\t\t\t<template-name>{$this->plugin_data['domain_template_name']}</template-name>
\t\t\t\t</add>
\t\t\t</domain>
</packet>
EOF;
        # Connect & get response:
        $result = $this->connect($this->server_cfg['host'], $this->server_cfg['port'], $this->server_cfg['user'], $this->server_cfg['pass'], $data);
        # Debug:
        $this->debug($data, $result);
        # Get the account id
        if (!($domain_id = $this->getid($result))) {
            return false;
        } else {
            $db =& DB();
            $id = $this->service_id;
            $sql = "SELECT * FROM " . AGILE_DB_PREFIX . "service WHERE id = {$id}";
            $rs = $db->Execute($sql);
            $plugin_data = unserialize($rs->fields['host_provision_plugin_data']);
            $plugin_data['account_id'] = $cl_id;
            $plugin_data['domain_id'] = $domain_id;
            $insert = array('host_provision_plugin_data' => serialize($plugin_data), 'host_username' => $this->login['username'], 'host_password' => $this->login['password']);
            $sql = $db->GetUpdateSQL($rs, $insert);
            $result = $db->Execute($sql);
            if ($result === false) {
                global $C_debug;
                $C_debug->error('PLESK_8.php', 'plgn_prov_PLESK_8 :: p_new()', $db->ErrorMsg() . "\r\n\r\n" . $sql);
            }
            # send the user the details
            include_once PATH_MODULES . 'email_template/email_template.inc.php';
            $email = new email_template();
            $email->send('host_new_user', $this->account['id'], $this->service_id, '', '');
        }
        return true;
    }
Example #27
0
 function p_new()
 {
     #echo 'p_new<br />';
     $db =& DB();
     if (empty($this->prod_attr_cart['parent_service_id'])) {
         $this->prod_attr_cart['parent_service_id'] = 0;
     }
     #echo 'Retrieving did.<br />';
     $ported = false;
     $did = $this->getDID($ported);
     #echo 'DID is: '.$did.'<br />';
     switch (@$this->plugin_data['voip_platform']) {
         case 'ser':
             $vp = new ser_voip_provisioning($this);
             #echo 'Created ser<br />';
             break;
         case 'asterisk':
         default:
             $vp = new asterisk_voip_provisioning($this);
             #echo 'Created asterisk<br />';
     }
     if ($this->plugin_data['rate_accountcode']) {
         return true;
     }
     # figure out which object to load
     #echo 'Creating voipDID.<br />';
     $didClass = new voipDID();
     if ($this->prod_attr_cart['parent_service_id'] && !$this->plugin_data['virtual_number']) {
         $didClass->load($this->get_parent_did($this->prod_attr_cart['parent_service_id']));
     } else {
         # new did needs create
         $didClass->setDID($did);
         $didClass->setAccountID($this->account['id']);
         $didClass->setServiceID($this->service['id']);
         $didClass->setServiceParentID($this->prod_attr_cart['parent_service_id']);
         $didClass->setActive(1);
         $didClass->insert();
         #echo 'Loading didClass.<br />';
         $didClass->load($did);
         # go ahead and call the did plugin's purchase method,
         # if the number isn't ported
         if ($ported == false && $vp->call_did_plugin($didClass, 'purchase') == false) {
             # purchase method failed. Post an error message and bomb out
             $didClass->delete();
             return false;
         }
         if ($this->plugin_data['virtual_number']) {
             # provision a virtual number
             $vp->addVirtualDID($didClass);
         } else {
             # provision a regular number
             $vp->addDID($didClass);
         }
     }
     #echo 'Set channel and features.<br />';
     # set the channel type
     $didClass->setChannel('SIP');
     if (@$this->plugin_data['provision_channel'] == 1) {
         $didClass->setChannel('IAX2');
     }
     # set all of the features entailed with this account
     if (@$this->plugin_data['cnam_enabled']) {
         $didClass->setCNAM(1);
     }
     if (@$this->plugin_data['blacklist_enabled']) {
         $didClass->setBlacklist(1);
     }
     if (@$this->plugin_data['anirouting_enabled']) {
         $didClass->setANIRouting(1);
     }
     if (@$this->plugin_data['can_failover']) {
         $didClass->setFailover(1);
     }
     if (@$this->plugin_data['remote_call_forwarding']) {
         $didClass->setRemoteCallForwarding(1);
     }
     if (@$this->plugin_data['fax_account']) {
         $didClass->setFax(1, $this->account['email']);
     }
     if (@$this->plugin_data['meetme_account']) {
         $didClass->setConference(1, $this->plugin_data['meetme_min_limit']);
     }
     if (@$this->plugin_data['faxdetection_enabled']) {
         $didClass->setFaxDetection(1, $this->account['email']);
     }
     if (@$this->plugin_data['callwaiting_enabled']) {
         $didClass->setCallWaiting(1);
     }
     # Callforward and Busycallforward are missing!
     if (@$this->plugin_data['voicemail_enabled']) {
         # provision voicemail to this account
         $didClass->setVoicemail(1);
         $vp->add_voicemail($didClass);
     }
     # Call custom handler
     # SER -> add entries to 'group' table
     $vp->addCustom($didClass);
     $didClass->save();
     #echo 'Called save voipDID.<br />';
     if ($this->plugin_data['innetwork_enabled']) {
         # set this number to innetwork
         $vp->add_in_network($didClass);
     }
     # send the user the details
     include_once PATH_MODULES . 'email_template/email_template.inc.php';
     $email = new email_template();
     $email->send('voip_new_service', $this->account['id'], $this->service_id, $did, $did);
     # send the admin the provisioning details
     include_once PATH_MODULES . 'email_template/email_template.inc.php';
     $email = new email_template();
     $email->send('admin->voip_manual', $this->account['id'], $this->service_id, $did, 'Provision VoIP Adaptor');
     return true;
 }
 /**
  * Task to detect credit cards that are expiring soon and e-mail the user a notice to update the card
  */
 function task($VAR)
 {
     include_once PATH_MODULES . 'email_template/email_template.inc.php';
     $sql = '';
     for ($i = 1; $i < 3; $i++) {
         $exp = mktime(0, 0, 0, date('m') + $i, date('d'), date('Y'));
         $month = date("m", $exp);
         $year = preg_replace("/^20/", "", date("Y", $exp));
         if (!empty($sql)) {
             $sql .= " OR ";
         }
         $sql .= " ( card_exp_month = '{$month}' AND card_exp_year = '{$year}' ) ";
     }
     $db =& DB();
     $rs = $db->Execute($qq = sqlSelect($db, "account_billing", "id,account_id,notify_count", " ( {$sql} ) AND notify_count < 4"));
     if ($rs && $rs->RecordCount()) {
         while (!$rs->EOF) {
             $email = new email_template();
             $email->send('account_billing_exp_soon', $rs->fields['account_id'], $rs->fields['id'], '', '');
             $fields = array('notify_count' => $rs->fields["notify_count"] + 1);
             $db->Execute(sqlUpdate($db, "account_billing", $fields, "id = {$rs->fields['id']}"));
             $rs->MoveNext();
         }
     }
 }
Example #29
0
 function task($VAR)
 {
     require_once PATH_MODULES . 'email_template/email_template.inc.php';
     require_once PATH_MODULES . 'invoice/invoice.inc.php';
     $invoice = new invoice();
     # get active net terms
     $db =& DB();
     $rs =& $db->Execute($sql = sqlSelect($db, "net_term", "*", "status=1"));
     if ($rs && $rs->RecordCount() > 0) {
         // loop through net terms
         while (!$rs->EOF) {
             $id = $rs->fields['id'];
             $last_interval = mktime(0, 0, 0, date('m'), date('d') - $rs->fields['terms'], date('Y'));
             $i =& $db->Execute($sql = sqlSelect($db, "invoice", "id,account_id,total_amt,billed_amt,due_date,net_term_date_last,net_term_intervals", "net_term_id = {$id} AND\n\t\t\t\t\t (suspend_billing = 0 OR suspend_billing IS NULL) AND\n\t\t\t\t\t (billing_status = 0 OR billing_status IS NULL) AND \n\t\t\t\t\t due_date <= {$last_interval} AND\n\t\t\t\t\t net_term_date_last <= {$last_interval}"));
             if ($i && $i->RecordCount() > 0) {
                 // loop through invoices
                 while (!$i->EOF) {
                     $terms = $rs->fields['terms'];
                     echo "<BR>" . ($start_interval = $i->fields['net_term_date_last']);
                     echo "<BR>" . ($stop_interval = $start_interval + 86400 * $terms);
                     echo "<BR>" . date(UNIX_DATE_FORMAT, $start_interval);
                     // charge or suspend?
                     if (!empty($i->fields['net_term_intervals']) && $rs->fields['suspend_intervals'] < $i->fields['net_term_intervals']) {
                         // suspend invoice
                         $arr['id'] = $i->fields['id'];
                         $na =& $invoice->voidInvoice($arr, $invoice);
                         // suspend billing status
                         $fields = array('suspend_billing' => 1);
                         $db->Execute($sql = sqlUpdate($db, "invoice", $fields, "id = {$i->fields['id']}"));
                         // send suspend e-mail
                         if ($rs->fields['enable_emails']) {
                             $email = new email_template();
                             $email->send('net_term_suspend', $i->fields['account_id'], $i->fields['id'], $rs->fields['suspend_intervals'], $i->fields['net_term_intervals']);
                         }
                     } else {
                         // calc late fee
                         if ($rs->fields['fee_type'] == 1) {
                             $fee = $rs->fields['fee'];
                         } else {
                             $fee = ($i->fields['total_amt'] - $i->fields['billed_amt']) * $rs->fields['fee'];
                         }
                         // create late charge
                         if ($fee > 0) {
                             $fields = array('date_orig' => time(), 'status' => 0, 'account_id' => $i->fields['account_id'], 'amount' => $fee, 'sweep_type' => $rs->fields['sweep_type'], 'taxable' => $this->taxable, 'quantity' => 1, 'attributes' => "Name=={$rs->fields['name']}\r\nInterval==" . date(UNIX_DATE_FORMAT, $start_interval) . " - " . date(UNIX_DATE_FORMAT, $stop_interval), 'description' => $rs->fields['sku']);
                             $db->Execute($sql = sqlInsert($db, "charge", $fields));
                             // update invoice
                             $_fields['net_term_intervals'] = $i->fields['net_term_intervals'] + 1;
                             $_fields['net_term_date_last'] = $stop_interval;
                             $db->Execute($sql = sqlUpdate($db, "invoice", $_fields, "id={$i->fields['id']}"));
                             echo "<BR><BR>{$sql}";
                         }
                         // send late fee/payment reminder e-mail:
                         if ($rs->fields['enable_emails']) {
                             $email = new email_template();
                             $email->send('net_term_late_notice', $i->fields['account_id'], $i->fields['id'], number_format($fee, 2), number_format($rs->fields['suspend_intervals'] - $i->fields['net_term_intervals']));
                         }
                     }
                     $i->MoveNext();
                 }
             }
             $rs->MoveNext();
         }
     }
 }