Example #1
0
function connect_to_daemon(&$socket, $host, $port, $pwd, $enc, $timeout = 0)
{
    set_time_limit($timeout);
    if (!@socket_connect($socket, $host, $port)) {
        return "ERR_CONNECT";
    }
    @recv_all($socket, $recv_buf);
    if (substr($recv_buf, 0, 3) == "100") {
        return "SUCCESS";
    }
    @send_all($socket, "ENCRYPT");
    $rnd = "";
    @recv_all($socket, $rnd);
    $result = "";
    if (substr($rnd, 0, 3) != "102") {
        $rnd .= $pwd;
        $enc_passwd = md5($rnd, true);
        send_all($socket, $enc_passwd);
        recv_all($socket, $result);
    } else {
        // use plain-text if allowed
        if ($enc == "0") {
            socket_close($socket);
            $socket = socket_create(AF_INET, SOCK_STREAM, 0);
            if (!@socket_connect($socket, $host, $port)) {
                return "ERR_CONNECT";
            }
            recv_all($socket, $recv_buf);
            send_all($socket, $pw);
            recv_all($socket, $result);
        }
    }
    if (substr($result, 0, 3) != "100") {
        return "ERR_PASSWD";
    } else {
        return "SUCCESS";
    }
}
Example #2
0
<?php

// Connect to Daemon
$socket = socket_create(AF_INET, SOCK_STREAM, 0);
$connect = connect_to_daemon($socket, $_COOKIE['ddclient_host'], $_COOKIE['ddclient_port'], $_COOKIE['ddclient_passwd'], $_COOKIE['ddclient_enc'], 5);
// Site Vars
$err_message = '';
$dlist = '';
send_all($socket, "DDP DL LIST");
recv_all($socket, $dlist);
$dlist = explode("\n", $dlist);
for ($i = 0; $i < count($dlist); $i++) {
    $curr_line = explode_escaped('|', $dlist[$i]);
    if ($curr_line[0] == "PACKAGE" && $curr_line[1] == $_GET['pkg_id']) {
        $tpl_vars['OLD_PKG_NAME'] = $curr_line[2];
        $tpl_vars['OLD_PKG_PASS'] = $curr_line[3];
    }
}
$tpl_vars['PKG_ID'] = $_GET["pkg_id"];
$tpl_vars['DL_ID'] = $_GET["id"];
Example #3
0
if ($connect != 'SUCCESS') {
    $err_msg = msg_generate($LANG[$connect], 'error');
} else {
    $content = '';
    if (isset($_POST['apply'])) {
        $buf = '';
        send_all($socket, 'DDP PREMIUM SET ' . $_POST['host'] . ' ' . $_POST['user'] . ';' . $_POST['pass']);
        recv_all($socket, $buf);
        if ($buf == '100 SUCCESS') {
            $err_message .= msg_generate($LANG['L_Premium_SUCCESS'], 'success');
        } else {
            $err_message .= msg_generate($LANG['L_Premium_FAIL'], 'error');
        }
    }
    $buf = '';
    send_all($socket, 'DDP PREMIUM LIST');
    recv_all($socket, $buf);
    $host_list = explode("\n", $buf);
    $user_list = '';
    $content .= 'Host: ';
    $content .= '<select name="host">';
    $content .= '<option value=""></option>';
    for ($i = 0; $i != count($host_list); $i++) {
        $content .= '<option value="' . $host_list[$i] . '"';
        $content .= '>' . $host_list[$i] . '</option>';
    }
    $content .= '</select>';
    $content .= '<br /><br />';
    $content .= 'Username: <input type="text" name="user" /><br />';
    $content .= 'Password: <input type="password" name="pass" /><br />';
    $content .= '<input type="submit" name="apply" value="Apply" id="apply" class="submit" />';
Example #4
0
    $content .= 'Router Model: ';
    $content .= '<select name="router_model">';
    $content .= '<option value=""></option>';
    for ($i = 0; $i != count($model_list); $i++) {
        $content .= '<option value="' . $model_list[$i] . '"';
        if ($model_list[$i] == $model) {
            $content .= ' SELECTED ';
        }
        $content .= '>' . $model_list[$i] . '</option>';
    }
    $content .= '</select>';
    $content .= '<br /><br />';
    $buf = '';
    send_all($socket, 'DDP ROUTER GET router_ip');
    recv_all($socket, $buf);
    $content .= 'Router IP: <input type="text" name="router_ip" value="' . $buf . '" /><br />';
    send_all($socket, 'DDP ROUTER GET router_username');
    recv_all($socket, $buf);
    $content .= 'Username: <input type="text" name="router_username" value="' . $buf . '" /><br />';
    $content .= 'Password: <input type="text" name="router_password" ';
    if (strlen($buf) > 0) {
        $content .= 'value="****" ';
    }
    $content .= '/><br />';
    $content .= '<br /><input type="submit" name="apply" value="Apply" id="apply" class="submit" /><br />';
}
$tpl_vars['content'] = $content;
$tpl_vars['err_message'] = $err_message;
$tpl_vars['L_Conf_general'] = $LANG['Conf_general'];
$tpl_vars['L_Conf_reconnect'] = $LANG['Conf_reconnect'];
$tpl_vars['L_Conf_premium'] = $LANG['Conf_premium'];
Example #5
0
    $debug .= '>Warning</option>';
    $debug .= '<option value="SEVERE" ';
    if ($log_lvl == 'SEVERE') {
        $debug .= 'selected="selected" ';
    }
    $debug .= '>Severe</option>';
    $debug .= '<option value="OFF" ';
    if ($log_lvl == 'OFF') {
        $debug .= 'selected="selected" ';
    }
    $debug .= '>Off</option></select>';
    $log_file = '';
    send_all($socket, 'DDP VAR GET log_file');
    recv_all($socket, $log_file);
    $max_dl_speed = '';
    send_all($socket, 'DDP VAR GET max_dl_speed');
    recv_all($socket, $max_dl_speed);
}
$tpl_vars['T_Enable_Button'] = $enable_button;
$tpl_vars['L_Conf_general'] = $LANG['Conf_general'];
$tpl_vars['L_Conf_reconnect'] = $LANG['Conf_reconnect'];
$tpl_vars['L_Conf_premium'] = $LANG['Conf_premium'];
$tpl_vars['L_Change_PWD'] = $LANG['Change_PWD'];
$tpl_vars['L_Add_multi_DL_Desc'] = $LANG['Add_multi_DL_Desc'];
$tpl_vars['L_Old_PWD'] = $LANG['Old_PWD'];
$tpl_vars['L_New_PWD'] = $LANG['New_PWD'];
$tpl_vars['L_RT_PWD'] = $LANG['RT_PWD'];
$tpl_vars['L_en_di'] = $LANG['en_di'];
$tpl_vars['L_gen_conf'] = $LANG['gen_conf'];
$tpl_vars['L_start_end_desc'] = $LANG['start_end_desc'];
$tpl_vars['L_st_time'] = $LANG['st_time'];
Example #6
0
<?php

// Connect to Daemon
$socket = socket_create(AF_INET, SOCK_STREAM, 0);
$connect = connect_to_daemon($socket, $_COOKIE['ddclient_host'], $_COOKIE['ddclient_port'], $_COOKIE['ddclient_passwd'], $_COOKIE['ddclient_enc'], 5);
if (isset($_POST['submit_adv_form'])) {
    foreach ($_POST as $var => $val) {
        if ($var != "submit_adv_form") {
            $buf = "";
            send_all($socket, "DDP VAR SET " . $var . " = " . $val);
            recv_all($socket, $buf);
        }
    }
    header("Location: index.php?site=config");
}
$res = "";
send_all($socket, "DDP VAR LIST");
recv_all($socket, $res);
$Variables = explode("\n", $res);
$tpl_vars['L_Conf_general'] = $LANG['Conf_general'];
$tpl_vars['L_Conf_reconnect'] = $LANG['Conf_reconnect'];
$tpl_vars['L_Conf_premium'] = $LANG['Conf_premium'];
Example #7
0
            $err_message .= msg_generate($LANG['SUCC_ADD_MULTI'], 'success');
        }
    }
} elseif (isset($_FILES['dlcfile'])) {
    $path_info = pathinfo($_FILES['dlcfile']['name']);
    $extension = $path_info['extension'];
    $tmpfn = $_FILES['dlcfile']['tmp_name'];
    //echo "extension = " . $extension;
    $fh = fopen($tmpfn, "r");
    $data = fread($fh, filesize($tmpfn));
    if ($extension == "RSDF" || $extension == "rsdf") {
        send_all($socket, "DDP PKG CONTAINER RSDF:" . $data);
    } elseif ($extension == "ccf" || $extension == "CCF") {
        send_all($socket, "DDP PKG CONTAINER CCF:" . $data);
    } else {
        send_all($socket, "DDP PKG CONTAINER DLC:" . $data);
    }
    $recv = "";
    recv_all($socket, $recv);
    // we can ignore this.. DD doesn't really check for success, because it would take too long
}
$download_index[] = array();
$download_index = explode("\n", $list);
for ($i = 0; $i < count($download_index); $i++) {
    if (strpos($download_index[$i], "PACKAGE|") === 0) {
        $pkg = explode("|", $download_index[$i]);
        $content .= "<option value=\"" . $pkg[1] . "\">" . $pkg[2] . "</option>";
    }
}
$tpl_vars['L_Title'] = $LANG['Title'];
$tpl_vars['L_URL'] = $LANG['URL'];
Example #8
0
<?php

// Connect to Daemon
$socket = socket_create(AF_INET, SOCK_STREAM, 0);
$connect = connect_to_daemon($socket, $_COOKIE['ddclient_host'], $_COOKIE['ddclient_port'], $_COOKIE['ddclient_passwd'], $_COOKIE['ddclient_enc'], 5);
$err_message = '';
if (isset($_GET['id'])) {
    $buf = "";
    if (isset($_GET['result'])) {
        send_all($socket, "DDP CAPTCHA SOLVE " . $_GET['id'] . " " . $_GET['result']);
        recv_all($socket, $buf);
        header("Location: " . $tpl_vars['T_SITE_URL'] . "index.php?site=manage");
    }
    $cap = "";
    send_all($socket, "DDP CAPTCHA REQUEST " . $_GET['id']);
    recv_all($socket, $cap);
    $parts = explode("|", $cap, 3);
    if (count($parts) != 3) {
        die;
    }
    if (isset($_GET['what'])) {
        if ($_GET['what'] == "qestion") {
            die($parts[1]);
        }
        if ($_GET['what'] == "image") {
            header("Content-Type: image/" . $parts[0]);
            die($parts[2]);
        }
    } else {
        $tpl_vars['T_Question'] = $parts[1];
        $tpl_vars['T_Image'] = "index.php?site=get_captcha&raw=1&what=image&id=" . $_GET['id'];
Example #9
0
         break;
     case 'DOWNLOAD_RECONNECTING':
         $any_download_running = true;
         $dl_status .= 'Reconnecting...';
         break;
     default:
         $dl_status .= 'Status not detected';
 }
 if ($exp_dls[$i][4] == "DOWNLOAD_INACTIVE") {
     $activate_button = '';
 } else {
     $activate_button = 'de';
 }
 $buf = "";
 if (CHECK_FILE_STATUS) {
     send_all($socket, "DDP FILE GETPATH " . $exp_dls[$i][0]);
     recv_all($socket, $buf);
 }
 if ($buf != "" || !CHECK_FILE_STATUS) {
     $del_file = '<a href="index.php?site=manage&amp;action=del_file&amp;id={T_DL_ID}" title="{L_Delete_File}"><img src="{T_SITE_URL}/templates/default/css/images/delete_file.png" alt="{L_Delete_File}" /></a>';
 } else {
     $del_file = '';
 }
 $tpl_manage_vars = array('T_Activate_Button' => $activate_button, 'T_DelFile_Button' => $del_file, 'T_TR_CLASS' => $tr_class, 'T_PKG_ID' => '', 'T_DL_ID' => $exp_dls[$i][0], 'T_DL_Date' => $exp_dls[$i][1], 'T_DL_Title' => $exp_dls[$i][2], 'T_DL_Title_short' => substr($exp_dls[$i][2], 0, 15), 'T_DL_URL' => $exp_dls[$i][3], 'T_DL_URL_short' => substr($exp_dls[$i][3], 0, 20) . "..." . substr($exp_dls[$i][3], -20, 20), 'T_DL_Class' => strtolower($exp_dls[$i][4]), 'T_DL_Status' => $dl_status, 'T_DL_Percent' => $percent, 'T_SITE_URL' => $tpl_vars['T_SITE_URL'], 'L_Activate' => $LANG['Activate'], 'L_Delete' => $LANG['Delete'], 'L_Move' => $LANG['Move'], 'L_Delete_File' => $LANG['Delete_File'], 'T_EDIT_SITE' => 'dl_edit');
 if (strlen($tpl_manage_vars['T_DL_URL']) <= 42) {
     $tpl_manage_vars['T_DL_URL_short'] = $tpl_manage_vars['T_DL_URL'];
 }
 if (strlen($tpl_manage_vars['T_DL_Title']) > 15) {
     $tpl_manage_vars['T_DL_Title_short'] .= "...";
 }
 $dl_list .= template_parse('manage_line', $tpl_manage_vars);