Ejemplo n.º 1
0
    function create_account()
    {
        if ($this->user['type'] != 1) {
            return 0;
        }
        if (strlen($_REQUEST['name']) < 2) {
            $this->html['shipon_account_output'] = "Name is too short.";
        } elseif (strlen($_REQUEST['username']) < 4) {
            $this->html['shipon_account_output'] = "Username must be at least 4 characters (" . strlen($_REQUEST['username']) . ").";
        } elseif (strlen($_REQUEST['password']) < 6) {
            $this->html['shipon_account_output'] = "Password must be at least 6 characters.";
        } else {
            $users_result = query("SELECT id FROM `" . $this->user['database'] . "`.accounts WHERE username=?", array($_REQUEST['username']));
            if (num_rows($users_result) < 1) {
                $id = query_r("INSERT INTO `" . $this->user['database'] . "`.accounts\n\t\t\t\t\t\t\t   (\n\t\t\t\t\t\t\t\t\t\tgroup_id, name, phone, ext, email, username, password, type\n\t\t\t\t\t\t\t   )\n\t\t\t\t\t\t\t   VALUES\n\t\t\t\t\t\t\t   (\n\t\t\t\t\t\t\t\t\t'" . $this->user['group'] . "', ?, ?, ?, ?, ?, ?, 2\n\t\t\t\t\t\t\t   )\n\t\t\t\t\t\t\t", array($_REQUEST['name'], $_REQUEST['phone'], $_REQUEST['ext'], $_REQUEST['email'], $_REQUEST['username'], md5($_REQUEST['password'])));
                query("INSERT INTO `" . $this->user['database'] . "`.sessions\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tid, session_id, timestamp\n\t\t\t\t\t\t)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t'" . $id . "','0','0'\n\t\t\t\t\t\t)\n\t\t\t\t\t");
                $this->html['shipon_account_output'] = '<script type="text/javascript">
                                                                            jQuery("#shipon_account_popup").dialog("close");
                                                                            change_view("manage_accounts");
									</script>';
            } else {
                $this->html['shipon_account_output'] = "User already exists.";
            }
        }
    }
Ejemplo n.º 2
0
 function send_socket_request($request = '')
 {
     global $error_handler;
     $id = query_r("INSERT INTO \n\t\t\t       integration_tx \n\t\t\t       (client,protocol,integration,method) \n\t\t\t       VALUES \n\t\t\t       ('" . $this->client . "',\n\t\t\t\t'" . $this->proto . "',\n\t\t\t\t'" . $this->integration . "', \n\t\t\t\t'send_socket_request')");
     if ($this->request != "ping") {
         $this->request->addChild('trans_id', $id);
     }
     $service_port = $this->custom_link_2;
     $address = $this->custom_link_1;
     $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
     if (!empty($this->sock_timeout)) {
         socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, array('sec' => $this->sock_timeout, 'usec' => 0));
     } else {
         socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, array('sec' => 120, 'usec' => 120));
         socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 120, 'usec' => 120));
     }
     if ($socket === false) {
         $message = "socket_create() failed: " . socket_strerror(socket_last_error());
         $messageString = "<RESPONSE><HANDSHAKE><MESSAGE>" . $message . "</MESSAGE><STATUS>0</STATUS></HANDSHAKE></RESPONSE>";
         $this->response = new SimpleXMLElement($messageString);
         $error_handler->handle_integration_error($message, $this->request->asXML());
         return $this->response;
     } else {
         $result = socket_connect($socket, $address, $service_port);
         if (!$result) {
             $message = "socket_connect() failed ({$result}): " . socket_strerror(socket_last_error($socket));
             $messageString = "<RESPONSE><HANDSHAKE><MESSAGE>" . $message . "</MESSAGE><STATUS>0</STATUS></HANDSHAKE></RESPONSE>";
             $this->response = false;
             if ($this->request != "ping") {
                 $error_handler->handle_integration_error($message, $this->request->asXML());
             } else {
                 $error_handler->handle_integration_error($message, "ping");
             }
             return false;
         } else {
             if ($this->request != "ping") {
                 $request = $this->request->asXML();
             } else {
                 $request = "ping\n\r";
             }
             socket_write($socket, $request, strlen($request));
             $this->response = "";
             $end = false;
             do {
                 $recv = socket_read($socket, '200');
                 $this->response .= mb_convert_encoding($recv, 'UTF-8');
                 if (strpos($this->response, '</RESPONSE>') > 0 || strpos($this->response, 'Pong! ') > 0) {
                     $end = true;
                 }
             } while ($end == false);
             socket_close($socket);
         }
     }
     //$this->response = substr($this->response, 0, -1);
     //$this->response = addslashes($this->response);
     //$this->response = "INTERNAL TEST ONLY! NO SOCKET CONNECTION WAS MADE!";
     //print(strlen($this->response).$this->response);
     query("INSERT INTO `" . $this->user['database'] . "`.integration_tx (trans_id, request, response) VALUES ('" . $id . "',?,?)", array($request, $this->response));
     $response_function = $this->response_function;
     return $this->{$response_function}();
 }
Ejemplo n.º 3
0
function create_new_address(&$info, &$address)
{
    $address['id'] = query_r("INSERT INTO `" . $info['database'] . "`.address_book\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\tgroup_id,\n\t\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t\tcontact,\n\t\t\t\t\t\t\t\t\t\tphone,\n\t\t\t\t\t\t\t\t\t\text,\n\t\t\t\t\t\t\t\t\t\temail,\n\t\t\t\t\t\t\t\t\t\tstreet1,\n\t\t\t\t\t\t\t\t\t\tstreet2,\n\t\t\t\t\t\t\t\t\t\tcity,\n\t\t\t\t\t\t\t\t\t\tprovince,\n\t\t\t\t\t\t\t\t\t\tcountry,\n\t\t\t\t\t\t\t\t\t\tpostal\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t'" . $info['group'] . "',\n\t\t\t\t\t\t\t\t\t'" . $address['name'] . "',\n\t\t\t\t\t\t\t\t\t'" . $address['contact'] . "',\n\t\t\t\t\t\t\t\t\t'" . $address['phone'] . "',\n\t\t\t\t\t\t\t\t\t'" . $address['ext'] . "',\n\t\t\t\t\t\t\t\t\t'" . $address['email'] . "',\n\t\t\t\t\t\t\t\t\t'" . $address['street1'] . "',\n\t\t\t\t\t\t\t\t\t'" . $address['street2'] . "',\n\t\t\t\t\t\t\t\t\t'" . $address['city'] . "',\n\t\t\t\t\t\t\t\t\t'" . $address['province'] . "',\n\t\t\t\t\t\t\t\t\t'" . $address['country'] . "',\n\t\t\t\t\t\t\t\t\t'" . $address['postal'] . "'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t");
}