Модераторы: korob2001, ginnie
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> PHP -> Perl 
:(
    Опции темы
Pawnsu
Дата 3.5.2010, 21:39 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 1
Регистрация: 3.5.2010

Репутация: нет
Всего: нет



Здравствуйте.
Помогите пожалуйста переписать простенький скрипт с php на perl.
Возможно на платной основе.
Сам скрипт:
Код

<?php
function gamecp_CreateAccount($params) {

        /* Define all the information here */
        $urlvars = array(
            "action" => "create", 
            "function"   => "createacct",
            "username"   =>  $infoFromYourAPI["User Name"],
            "password"   =>  $infoFromYourAPI["password"],
            "customerid"  => $infoFromYourAPI['userid'],


            "packageid"  => $packageID,


            // profile information
            "emailaddr"  => $infoFromYourAPI['email'],
            "firstname"  => $infoFromYourAPI['firstname'],
            "lastname"   => $infoFromYourAPI['lastname'],
            "address"    => $infoFromYourAPI['address1'],
            "city"       => $infoFromYourAPI['city'],
            "state"      => $infoFromYourAPI['state'],
            "country"    => $infoFromYourAPI['country'],
            "zipcode"    => $infoFromYourAPI['postcode'],
            "phonenum"   => $infoFromYourAPI['phonenumber'],
            // Game server information
            "game_id"     => $infoFromYourAPI["game_id"],
            "max_players" => $infoFromYourAPI['Players'],
            "pub_priv"    => $infoFromYourAPI["pubpriv"],
            "login_path"  => $infoFromYourAPI["no"],
            "sv_location" => $infoFromYourAPI["Location"],

            /* game profile */
            "website"     => $infoFromYourAPI['Website'],
            "hostname"    => $infoFromYourAPI['Host Name'],
            "motd"      => $infoFromYourAPI['MOTD'],
            "rcon_password"    => $infoFromYourAPI['RCON Password'],
            "priv_password"    => $infoFromYourAPI['Server Password'],
            "addons" => serialize($infoFromYourAPI['addons']));


        $args= array(
            "plugin_gamecp_GameCP_URL" => $gamecpURL,
            "plugin_gamecp_Connector_Passphrase" => $gamecpPASSPHRASE,
            "debugging" => $DEBUGGING
        );


    # Code to perform action goes here...
    $r_result=curl2gcp($args, $urlvars);
    $result=checkStatus($r_result);
    if ($result == "completed") $result = "success";

    return $result;
}

function gamecp_TerminateAccount($params) {
    $urlvars = array(
        'action' => 'delete',
            "customerid"  => $userid,
            "packageid"  => $packageID,
    );

    $args= array(
        "plugin_gamecp_GameCP_URL" => $gamecpURL,
        "plugin_gamecp_Connector_Passphrase" => $gamecpPASSPHRASE,
        "debugging" => $DEBUGGING
    );

    # Code to perform action goes here...
    $r_result=curl2gcp($args, $urlvars);
    $result=checkStatus($r_result);
    if ($result == "completed") $result = "success";

    return $result;
}

function gamecp_SuspendAccount($params) {

    $urlvars = array(
        'action' => 'suspend',
            "customerid"  => $userid,
            "packageid"  => $packageID,
    );

    $args= array(
        "plugin_gamecp_GameCP_URL" => $gamecpURL,
        "plugin_gamecp_Connector_Passphrase" => $gamecpPASSPHRASE,
        "debugging" => $DEBUGGING
    );


    # Code to perform action goes here...
    $r_result=curl2gcp($args, $urlvars);
    $result=checkStatus($r_result);
    if ($result == "completed") $result = "success";

    return $result;
}

function gamecp_UnsuspendAccount($params) {

    $urlvars = array(
        'action' => 'unsuspend',
        "customerid"  => $userid,
            "packageid"  => $packageID,
    );

    $args= array(
        "plugin_gamecp_GameCP_URL" => $gamecpURL,
        "plugin_gamecp_Connector_Passphrase" => $gamecpPASSPHRASE,
        "debugging" => $DEBUGGING
    );


    # Code to perform action goes here...
    $r_result=curl2gcp($args, $urlvars);
    $result=checkStatus($r_result);
    if ($result == "completed") $result = "success";

    return $result;
}








function curl2gcp($args, $values) {

    if(!$gamecpURL) return "No GameCP URL defined. Assign one in your product. Please contact GameCP for support.";
    if(!$gamecpPASSPHRASE) return "No GameCP passphrase defined. Assign one in your product. Please contact GameCP for support.";


    if($DEBUGGING == "on") {
        $post = 'passphrase='.urlencode($gamecpPASSPHRASE).'&debugging=true&connector=ce';
    }
    else
    {
        $post = 'passphrase='.urlencode($gamecpPASSPHRASE).'&connector=ce';
    }
    if(is_array($values)){
        foreach ($values as $key => $value) {
            $post .= "&$key=".urlencode(str_replace('\'','',$value));
        }
    }
    $url = $args['plugin_gamecp_GameCP_URL']."/billing/mb/index.php";

    $result = send2curl($url, $post);
    if($DEBUGGING == "on") {
        echo "<strong>Debugging URL:</strong><br>";
        echo '<div style="overflow: auto; height: 100px; width: 400px;">';
        echo $url."?".$post;
        echo '</div>';
        echo "<br><strong>Debugging Result:</strong><br>";
        echo '<div style="overflow: auto; height: 200px; width: 400px;">';
            print_r($result);
        echo '</div>';
    }
    return $result;
}

function checkStatus($r_result){
    
    if(!$r_result){
        return "GameCP did not reply to your command.<br>Please check your package configuration.<br> Please contact GameCP for support.";
    } elseif (preg_match("/Command Execution Result: Ok/i", strip_tags($r_result))){
        return "completed";
    } elseif(preg_match("/Unable to determin IP address/i", strip_tags($r_result))){
        return "GameCP was unable to select an ip address for this server.<br>Please check your machines slot and user quota.<br> Please contact GameCP for support.";
    } elseif (preg_match("/Passed Security Checks: Failed/i", strip_tags($r_result))){
        return "Your GameCP passphrase is incorrect.<br>Check your settings.<br> Please contact GameCP for support.";
    } else {
        print_r($r_result);
        return "There was an unknow problem with the API, check the debugging details below:<br>";
    }        
}

function send2curl($url,$data) { 

    if (!extension_loaded('curl')) return "Curl for php is not installed. Review google for in formation on php-curl, or curl for php.<br>Contact GameCP for support";

    $ch = curl_init($url."?".$data);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($ch);       
    curl_close($ch);
    return $output;
} 






?>

PM MAIL   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Правила форума "Perl"
korob2001
sharq
  • В этом разделе обсуждаются общие вопросы по языку Perl
  • Если ваш вопрос относится к системному программированию, задавайте его здесь
  • Если ваш вопрос относится к CGI программированию, задавайте его здесь
  • Интерпретатор Perl можно скачать здесь ActiveState, O'REILLY, The source for Perl
  • Справочное руководство "Установка perl-модулей", можно скачать здесь


Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, korob2001, sharq.

 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Perl: Общие вопросы | Следующая тема »


 




[ Время генерации скрипта: 0.0387 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.