if (TRUE) { // test 4: post $test = new Request("http://curl.kdyby.org/dump_post.php", $config); echo "<hr>test 4: post ... init ok<hr>", "<h2>Setup:</h2>"; proxy($test); // for debbuging at school dump($test); $response = $test->post(array('var1' => 'Lorem ipsum dot sit amet', 'var2' => 0, 'var3' => 23, 'var4' => True, 'var5' => False)); echo "<h2>Response headers:</h2>"; dump($response->getHeaders()); echo "<h2>Response:</h2>", "<pre>"; var_dump(htmlspecialchars($response->getResponse())); echo "</pre>"; } if (TRUE) { // test 5: download $test = new Request("http://curl.kdyby.org/prevodnik.asm.zdrojak", $config); echo "<hr>test 5: download ... init ok<hr>", "<h2>Setup:</h2>"; proxy($test); // for debbuging at school dump($test); $test->setDownloadFolder(realpath('./download')); $response = $test->download(); echo "<h2>Response headers:</h2>"; dump($response->getHeaders()); echo "<h2>Response:</h2>", "<pre>"; $fp = $response->openFile(); var_dump(htmlspecialchars(fread($fp, $response->getHeader('Content-Length')))); fclose($fp); echo "</pre>"; }
//The software stuff case 'softwares': include_once $globals['adminfiles'] . '/softwares.php'; softwares(); break; //Email Settings //Email Settings case 'email': include_once $globals['adminfiles'] . '/email.php'; email(); break; //Email Settings //Email Settings case 'proxy': include_once $globals['adminfiles'] . '/proxy.php'; proxy(); break; //Maintenance Mode //Maintenance Mode case 'maintenance': include_once $globals['adminfiles'] . '/maintenance.php'; maintenance(); break; // Installations // Installations case 'installations': include_once $globals['adminfiles'] . '/installations.php'; installations(); break; // Suggest // Suggest
function set_logdate($date) { if ($date == get_session('logdate')) { return; } set_session('logdate', $date); $domain = 'http://support.jkysoftware.com/index.php/api'; // $domain = 'http://support/index.php/api'; $postvars = 'data={"method":"get_expire", "company_id":' . COMPANY_ID . '}'; $return = json_decode(proxy($domain, $postvars), true); if ($return['status'] == 'ok') { set_control_value('System Keys', 'Expire Date', $return['expire_date']); set_control_value('System Keys', 'Expire Key', $return['expire_key']); } set_valid_days($date); }
if (preg_match('/^Content-Length/i', $Hs[$i])) { continue; } if (preg_match('/^Transfer-Encoding: chunked/i', $Hs[$i])) { // Transfer-Encoding: chunked carp("chunked response"); $sReponse = unchunck($sReponse); continue; } #carp("header=[$Hs[$i]]"); header($Hs[$i]); } header("Content-Length: " . strlen($sReponse)); print $sReponse; } // ---------------------------------------------------------- // programme principal: // on accept que GET/POST (pour l'instant) if (($_SERVER["REQUEST_METHOD"] === 'GET' or $_SERVER["REQUEST_METHOD"] === 'POST') && (isset($_REQUEST["url"]) && strlen($_REQUEST["url"]) > 0)) { $sUrl = substr($_SERVER["QUERY_STRING"], 4); carp("Proxying:{$sUrl}"); proxy($sUrl); exit; } // on ne traite pas la demande : carp("REQUEST_METHOD:" . $_SERVER["REQUEST_METHOD"] . " QUERY_STRING:" . $_SERVER["QUERY_STRING"]); if ($debug) { phpinfo(INFO_VARIABLES); } exit; // ----------------------------------------------------------
/** * invoice to Dyer from ShipDyer * * @param int shipdyer_id * @return int count of Records generated */ function JKY_invoice_dyer($the_id) { $domain = get_config_value('NFe Dyer', 'domain'); $my_return = json_decode(proxy($domain, 'data={"method":"check_status"}'), true); if (!isset($my_return['status'])) { JKY_echo_error('domain [' . $domain . '] is not active'); return; } if ($my_return['status'] != 'ok') { JKY_echo_error($my_return['message']); return; } $db = Zend_Registry::get('db'); $ship_dyer = db_get_row('ShipDyers', 'id=' . $the_id); $dyer = db_get_row('Contacts', 'id=' . $ship_dyer['dyer_id']); $company['pessoa'] = $dyer['is_company'] == 'Yes' ? 'J' : 'F'; $company['name'] = $dyer['full_name']; $company['fantasia'] = $dyer['nick_name']; $company['email'] = $dyer['email']; $company['phone'] = $dyer['phone']; $company['fax'] = $dyer['fax']; $company['cnpj'] = $dyer['cnpj']; $company['ie'] = $dyer['ie']; $company['district'] = $dyer['district']; $company['number'] = $dyer['st_number']; $company['cpl'] = $dyer['st_cpl']; $company['street1'] = $dyer['street1']; $company['street2'] = $dyer['street2']; $company['zip'] = $dyer['zip']; $company['city'] = $dyer['city']; $company['state'] = $dyer['state']; $company['country'] = $dyer['country']; $my_return = json_decode(proxy($domain, 'data={"method":"add_company", "row":' . json_encode($company) . '}'), true); $my_id = $my_return['id']; log_sql('Dyer', 'INSERT', $my_id); $transport = db_get_row('Contacts', 'id=' . $ship_dyer['transport_id']); $company['pessoa'] = $transport['is_company'] == 'Yes' ? 'J' : 'F'; $company['name'] = $transport['full_name']; $company['fantasia'] = $transport['nick_name']; $company['email'] = $transport['email']; $company['phone'] = $transport['phone']; $company['fax'] = $transport['fax']; $company['cnpj'] = $transport['cnpj']; $company['ie'] = $transport['ie']; $company['district'] = $transport['district']; $company['number'] = $transport['st_number']; $company['cpl'] = $transport['st_cpl']; $company['street1'] = $transport['street1']; $company['street2'] = $transport['street2']; $company['zip'] = $transport['zip']; $company['city'] = $transport['city']; $company['state'] = $transport['state']; $company['country'] = $transport['country']; $my_return = json_decode(proxy($domain, 'data={"method":"add_company", "row":' . json_encode($company) . '}'), true); $my_id = $my_return['id']; log_sql('Transport', 'INSERT', $my_id); $i = 0; $total_volume = 0; $items = array(); $loadouts = db_get_rows('LoadOuts', 'shipdyer_id=' . $the_id); foreach ($loadouts as $loadout) { $loadquots = db_get_rows('LoadQuotations', 'loadout_id=' . $loadout['id']); foreach ($loadquots as $loadquot) { $pieces = db_get_rows('Pieces', 'load_quot_id=' . $loadquot['id']); $order = db_get_row('Orders', 'id=' . $pieces[0]['order_id']); $ftp = db_get_row('FTPs', 'id=' . $order['ftp_id']); $prod = db_get_row('Products', 'id=' . $order['product_id']); $total_weight = 0; foreach ($pieces as $piece) { $total_volume++; $total_weight += $piece['checkin_weight']; } $item['NFe_id'] = 'null'; $item['cProd'] = get_config_value('NFe Dyer', 'cProd'); $item['xProd'] = $prod['product_name']; $item['cor_code'] = get_config_value('NFe Dyer', 'cor_code'); $item['cor_type'] = get_config_value('NFe Dyer', 'cor_type'); $item['composicao'] = $ftp['composition']; $item['NCM'] = get_config_value('NFe Dyer', 'NCM'); $item['CFOP'] = get_config_value('NFe Dyer', 'CFOP'); $item['uCom'] = get_config_value('NFe Dyer', 'uCom'); $item['qCom'] = $total_weight; $item['vUnCom'] = get_config_value('NFe Dyer', 'vUnCom'); $item['orig'] = get_config_value('NFe Dyer', 'orig'); $item['CST_ICMS'] = get_config_value('NFe Dyer', 'CST_ICMS'); $item['CST_IPI'] = get_config_value('NFe Dyer', 'CST_IPI'); $item['pIPI'] = get_config_value('NFe Dyer', 'pIPI'); $item['pPIS'] = get_config_value('NFe Dyer', 'pPIS'); $item['pCOFINS'] = get_config_value('NFe Dyer', 'pCOFINS'); $items[$i] = $item; $i++; $product['product_code'] = get_config_value('NFe Dyer', 'cProd'); $product['product_cf'] = get_config_value('NFe Dyer', 'NCM'); $product['IPI_code'] = get_config_value('NFe Dyer', 'CST_IPI'); $product['IPI_aliquota'] = get_config_value('NFe Dyer', 'pIPI'); $product['product_title'] = $prod['product_name']; $product['composicao'] = $ftp['composition']; $my_return = json_decode(proxy($domain, 'data={"method":"add_product", "row":' . json_encode($product) . '}'), true); $my_id = $my_return['id']; log_sql('Product', 'INSERT', $my_id); } } $my_count = 0; $nfe['dEmi'] = get_date(); $nfe['dSaiEnt'] = get_date(); $nfe['tpNF'] = get_config_value('NFe Dyer', 'tpNF'); $nfe['natOp'] = get_config_value('NFe Dyer', 'natOp'); $nfe['dxNome'] = $dyer['full_name']; $nfe['txNome'] = $transport['full_name']; $nfe['modFrete'] = get_config_value('NFe Dyer', 'modFrete'); $nfe['qVol'] = $total_volume; $nfe['esp'] = get_config_value('NFe Dyer', 'esp'); $nfe['marca'] = get_config_value('NFe Dyer', 'marca'); $nfe['pesoL'] = '0'; $nfe['infCpl'] = get_config_value('NFe Dyer', 'infCpl'); log_sql('NFe', 'BEFORE INSERT', json_encode($nfe)); $my_return = json_decode(proxy($domain, 'data={"method":"add_nfe", "row":' . json_encode($nfe) . '}'), true); $my_nfe_id = $my_return['id']; if ($my_nfe_id) { $my_count++; } log_sql('NFe', 'INSERT', $my_nfe_id); foreach ($items as $item) { $item['NFe_id'] = $my_nfe_id; $my_return = json_decode(proxy($domain, 'data={"method":"add_nfeitem", "row":' . json_encode($item) . '}'), true); $my_id = $my_return['id']; if ($my_id) { $my_count++; } log_sql('NFeItem', 'INSERT', $my_id); } $sql = 'UPDATE ShipDyers' . ' SET status = "Active"' . ' WHERE id = ' . $the_id; log_sql('ShipDyers', 'UPDATE', $sql); $db->query($sql); insert_changes($db, 'ShipDyers', $the_id); JKY_echo_count($my_count); }
function test2(...$args) { return proxy(...$args); }
/** * Fast & easy proxifying, it handles redirects and output to client. * * Example: just call proxify ('http', 'example.com') * and everything else will happen magically. * * @param $scheme * @param $host * @param $plugin. optional - specify a plugin name to handle site-specific requirements * the filename should be [plugin name].plugin.php * a function [plugin name]_init() must be present. * @param $plugin_filename. optional plugin filename instead of [plugin_name].plugin.php * @return mixed */ function proxify($scheme, $host, $plugin = false, $plugin_filename = false) { // build URL $url = $scheme . '://' . $host . $_SERVER['REQUEST_URI']; // request the webpage and store the response $response = proxy($url); // effective URL = the actual URL after redirects $eff_url = parse_url($response['eff_url']); // effective request = request path & query (without the hostname) $eff_req = $eff_url['path'] . (isset($eff_url['query']) ? '?' . $eff_url['query'] : ''); if ($eff_url['host'] != $host) { // if an external redirect has been made, display a warning echo '<h2>The page redirects outside the proxified host.</h2><p>To na' . 'vigate there, <a href="' . $response['eff_url'] . '" target="_blank">click here</a>.</p>'; die; } else { if ($eff_req != $_SERVER['REQUEST_URI']) { // if an internal (within the proxified host) has been made, just go there echo proxy($response['eff_url'], true); header('Location: ' . $eff_req); } } if ($plugin) { // execute user plugin require_once $plugin_filename ? $plugin_filename : $plugin . '.plugin.php'; echo call_user_func($plugin . '_init', $response); die; } else { // default = set original content-type and echo the response. header('Content-Type: ' . $response['content_type']); print $response['body']; die; } }
function build() { $unix = new unix(); $sock = new sockets(); $checkrad = $unix->find_program("checkrad"); $EnableMikrotik = $sock->GET_INFO("EnableMikrotik"); echo "Starting FreeRadius.............: checkrad: `{$checkrad}`\n"; $ListenIP = $sock->GET_INFO("FreeRadiusListenIP"); $FreeRadiusListenPort = $sock->GET_INFO("FreeRadiusListenPort"); if ($ListenIP == null) { $ListenIP = "*"; } if (!is_numeric($FreeRadiusListenPort)) { $FreeRadiusListenPort = 1812; } echo "Starting FreeRadius.............: Listen addr: `{$ListenIP}:{$FreeRadiusListenPort}`\n"; $IsMySQL = IsMySQL(); $UseMySQL = false; if ($IsMySQL > 0) { $UseMySQL = true; } $f[] = "prefix = /usr"; $f[] = "exec_prefix = /usr"; $f[] = "sysconfdir = /etc"; $f[] = "localstatedir = /var"; $f[] = "sbindir = \${exec_prefix}/sbin"; $f[] = "logdir = /var/log/freeradius"; $f[] = "raddbdir = /etc/freeradius"; $f[] = "radacctdir = \${logdir}/radacct"; $f[] = "name = freeradius"; $f[] = "confdir = \${raddbdir}"; $f[] = "run_dir = \${localstatedir}/run/\${name}"; $f[] = "db_dir = \${raddbdir}"; $f[] = "libdir = /usr/lib/freeradius"; $f[] = "pidfile = /var/run/freeradius/freeradius.pid"; $f[] = "user = root"; $f[] = "group = root"; $f[] = "max_request_time = 30"; $f[] = "cleanup_delay = 5"; $f[] = "max_requests = {$FreeRadiusListenPort}"; $f[] = "listen {"; $f[] = "\ttype = auth"; $f[] = "\tport = 1812"; $f[] = "\tipaddr = {$ListenIP}"; $f[] = "#\tclients = per_socket_clients"; $f[] = "}"; $f[] = ""; $f[] = ""; $f[] = "listen {"; $f[] = "\tport = 0"; $f[] = "\ttype = acct"; $f[] = "\tipaddr = {$ListenIP}"; $f[] = "#\tinterface = eth0"; $f[] = "#\tclients = per_socket_clients"; $f[] = "}"; $f[] = ""; $f[] = ""; $f[] = "hostname_lookups = no"; $f[] = "allow_core_dumps = no"; $f[] = "regular_expressions\t= yes"; $f[] = "extended_expressions\t= yes"; $f[] = ""; $f[] = "log {"; $f[] = "\tdestination = syslog"; $f[] = "\tfile = \${logdir}/radius.log"; $f[] = "\tsyslog_facility = daemon"; $f[] = "\tstripped_names = no"; $f[] = "\tauth = yes"; $f[] = "\tauth_badpass = yes"; $f[] = "\tauth_goodpass = no"; $f[] = "}"; $f[] = ""; $f[] = "checkrad = {$checkrad}"; $f[] = ""; $f[] = "security {"; $f[] = "\tmax_attributes = 200"; $f[] = "\treject_delay = 1"; $f[] = "\tstatus_server = yes"; $f[] = "}"; $f[] = ""; $f[] = "proxy_requests = yes"; $f[] = "\$INCLUDE proxy.conf"; $f[] = "\$INCLUDE clients.conf"; $f[] = ""; $f[] = "thread pool {"; $f[] = "\tstart_servers = 5"; $f[] = "\tmax_servers = 32"; $f[] = "\tmin_spare_servers = 3"; $f[] = "\tmax_spare_servers = 10"; $f[] = "\tmax_requests_per_server = 0"; $f[] = "}"; $f[] = "pap {"; $f[] = "\tencryption_scheme = clear"; $f[] = "}"; $f[] = ""; $f[] = "modules {"; $f[] = "\t\$INCLUDE \${confdir}/modules/"; $f[] = "\t\$INCLUDE eap.conf"; if ($UseMySQL) { $f[] = "\t\$INCLUDE sql.conf"; } $f[] = "#\t\$INCLUDE sql/mysql/counter.conf"; $f[] = "#\t\$INCLUDE sqlippool.conf"; $f[] = "}"; $f[] = ""; $f[] = ""; $f[] = "instantiate {"; $f[] = "\texpr"; $f[] = "#\tdaily"; $f[] = "\texpiration"; $f[] = "\tlogintime"; $f[] = "}"; $f[] = ""; $f[] = "\$INCLUDE policy.conf"; $f[] = "\$INCLUDE sites-enabled/"; //$f[]="\$INCLUDE dictionary"; dictionary(); echo "Starting FreeRadius.............: /etc/freeradius/radiusd.conf done...\n"; @mkdir("/etc/freeradius", 0755, true); @file_put_contents("/etc/freeradius/radiusd.conf", @implode("\n", $f)); attrs_access_reject(); eap(); pap(); proxy(); ntlm_auth(); build_sql_connections(); module_ldap(); inner_tunnel(); site_default(); confusers(); clients(); mschap(); microtik(); }