public function testcreate_client()
 {
     $network = "Testnet";
     $private = $this->getMock('Bitpay\\PrivateKey');
     $private->expects($this->any())->method('__toString')->will($this->returnValue('3a1cb093db55fc9cc6f2e1efc3938e4e498d8b2557a975249a49e2aec70ad471'));
     $public = $this->getMock('Bitpay\\PublicKey');
     $public->expects($this->any())->method('__toString')->will($this->returnValue('03bb80b4391db1a7ba344fbe5421d87952a4b8934ca0865ae70591d1614e0f6fc8'));
     $client = create_client($network, $public, $private);
     $expected_client = new \Bitpay\Client\Client();
     $expected_client->setNetwork(new Bitpay\Network\Testnet());
     $expected_client->setPublicKey($public);
     $expected_client->setPrivateKey($private);
     $expected_client->setAdapter(new Bitpay\Client\Adapter\CurlAdapter());
     $this->assertTrue($expected_client == $client);
 }
Пример #2
0
/** import family information from csv version of the excel master database
 */
function import_family($last_name, $first_name, $dob, $address, $telephone, $family_size, $seniors, $adults, $children, $delivery, $dietary, $second_fourth_both, $wages, $unemployment, $wic, $welfare, $head_start, $afdc, $veterans_aid, $social_security, $ssi, $other, $fuel, $food_stamps, $cooking, $start, $comments, $name2, $dob2, $name3, $dob3, $name4, $dob4, $name5, $dob5, $name6, $dob6, $name7, $dob7, $name8, $dob8, $name9, $dob9, $name10, $dob10, $sep2009, $oct2009, $nov2009, $dec2009, $jan2010, $feb2010, $mar2010, $apr2010)
{
    $root = create_client(null, $first_name, $last_name, '0', convert_date($dob));
    $second = false;
    $fourth = false;
    if ($second_fourth_both == '2nd') {
        $second = true;
    } else {
        if ($second_fourth_both == '4th') {
            $fourth = true;
        } else {
            if ($second_fourth_both == 'Both') {
                $second = $fourth = true;
            }
        }
    }
    // Create Family
    $fid = create_family($root, $family_size, $address, $telephone, $fuel == 'Y', false, $delivery == 'Y', $dietary == 'Y', $second, $fourth, $cooking == 'Y', convert_date($start), $comments);
    // Import Family Members
    for ($i = 2; $i < 11; $i++) {
        $name_var = 'name' . $i;
        $dob_var = 'dob' . $i;
        $name = ${$name_var};
        $dob = ${$dob_var};
        if ($name == '') {
            break;
        }
        create_client($fid, $name, '', true, convert_date($dob));
    }
    // Add Family Financial Aids
    // $wages, $unemployment, $wic, $welfare, $head_start, $afdc, $veterans_aid, $social_security, $ssi, $other, $fuel, $food_stamps
    $aids = get_all_aids();
    $aidid = '-1';
    $amount = '0';
    foreach ($aids as $aid) {
        switch ($aid['name']) {
            case 'Wages':
                $amount = $wages;
                break;
            case 'Unemployment':
                $amount = $unemployment;
                break;
            case 'WIC':
                $amount = $wic;
                break;
            case 'Welfare':
                $amount = $welfare;
                break;
            case 'Head Start':
                $amount = $head_start;
                break;
            case 'AFDC':
                $amount = $afdc;
                break;
            case 'Veterans Aid':
                $amount = $veterans_aid;
                break;
            case 'Social Security':
                $amount = $social_security;
                break;
            case 'SSI':
                $amount = $ssi;
                break;
            case 'Other Amount':
                $amount = $other;
                break;
            case 'Fuel Assistance':
                $amount = $fuel;
                break;
            case 'Food Stamps':
                $amount = $food_stamps;
                break;
            default:
                $amount = '0';
                break;
        }
        if ($amount == 'Y') {
            $amount = "0";
        }
        if (is_numeric(trim($amount, "\$"))) {
            set_financial_aid($fid, $aid['aidid'], trim($amount, "\$"));
        }
    }
    $members = get_all_family_members($fid);
    $import_size = count($members) + 1;
    if ($import_size != $family_size) {
        echo "Missed family members for family " . $fid . " and name: " . $last_name . " imported " . $import_size . " and there were " . $family_size . "<br/>";
    }
}
Пример #3
0
                 redirect($g["abs_url"] . '/error/invalid-page');
         }
     } else {
         redirect($g["abs_url"] . '/error/invalid-page');
     }
     echo "An error occurred.";
     exit;
     break;
 case 'ajax':
     if (isset($client_command) && in_array($client_command, $ajax_commands)) {
         switch ($client_command) {
             case 'family_members':
                 if (isset($action_command)) {
                     switch ($action_command) {
                         case 'new':
                             create_client(post('id'), post('name'), '', post('gender'), post('dob'));
                             exit;
                             break;
                         case 'save':
                             edit_client(post('id'), post('name'), '', post('gender'), post('dob'));
                             exit;
                             break;
                         case 'delete':
                             delete_client(post('id'));
                             exit;
                             break;
                         default:
                             redirect($g["abs_url"] . '/error/invalid-page');
                     }
                 } else {
                     redirect($g["abs_url"] . '/error/invalid-page');
function pair_and_get_token($pairing_code, $network)
{
    try {
        list($private, $public, $sin) = generate_keys();
        $client = create_client($network, $public, $private);
        $token = pairing($pairing_code, $client, $sin);
        save_keys($token, $network, $private, $public, $sin);
    } catch (\Exception $e) {
        debuglog('[Error] In Bitpay plugin, pair_and_get_token() function on line ' . $e->getLine() . ', with the error "' . $e->getMessage() . '" .');
        throw $e;
    }
}
Пример #5
0
 if (subdomain_exists($subdomain)) {
     $errors["subdomain"] = "Subdomain này đã có người đăng ký";
 } else {
     $re = "/^([a-zA-Z]+)\$/i";
     if (preg_match_all($re, $subdomain, $matches)) {
         if (client_email_exists($client_email)) {
             $errors["client_email"] = "Email này đã có người đăng ký";
         } else {
             if (is_email($client_email)) {
                 if (empty($client_username)) {
                     $errors["client_username"] = "******";
                 } else {
                     if (strlen($client_password) < 6) {
                         $errors["client_password"] = "******";
                     } else {
                         $create_client_result = create_client($subdomain, $client_name, $client_username, $client_email, $client_password);
                         if ($create_client_result !== false) {
                             $register_success = true;
                             $crm_domain = "http://" . $subdomain . "." . CRM_DOMAIN;
                             echo "<p>Chúc mừng, bạn đã đăng ký thành công</p>";
                             echo "<p>Bạn có thể đăng nhập vào hệ thống ngay bây giờ</p>";
                             echo "<p><a href='{$crm_domain}' class='btn btn-success'>Đăng nhập</a></p>";
                         } else {
                             $errors["message"] = "Rất tiếc, có lỗi xảy ra";
                         }
                     }
                 }
             } else {
                 $errors["client_email"] = "Địa chỉ email không hợp lệ";
             }
         }