Jump to content

kkroo

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Everything posted by kkroo

  1. alright, i got that error done with. now there is another error, it gzips the data and saves it to a directory name backups. I open the file and it is 0 bytes. but in the script i echo filesize(filename) and it returns 811632. Why is this happening? NVM solved
  2. I can echo $backup after here $backup = "#\n"; $backup .= "# Automatic phpBB Backup Script\n"; $backup .= "#\n"; $backup .= "# Dump of tables for $dbname\n"; $backup .= "#\n# DATE : " . gmdate("d-m-Y H:i:s", $time) . " GMT\n"; $backup .= "#\n"; $backup .= "\n"; but not after here
  3. i have a automatic backup script for phpBB this dude who has my script is getting blank backups, i got access to the script on his server and saw that i can echo the data but not put it into variables, u know what might cause this? ive been working with it for like 3 hours, i am out of ideas and anything after defining the variable in the script it cut off and there are no syntax or fatal errors could this be with mod interference? the same exact code works on a fresh install of phpBB on the same server here is where the script screws up: // // Build the sql script file... // $backup = "#\n"; $backup .= "# Automatic phpBB Backup Script\n"; $backup .= "#\n"; $backup .= "# Dump of tables for $dbname\n"; $backup .= "#\n# DATE : " . gmdate("d-m-Y H:i:s", $time) . " GMT\n"; $backup .= "#\n"; $backup .= "\n"; for($i = 0; $i < count($tables); $i++) { $table_name = $tables[$i]; switch (SQL_LAYER) { case 'postgresql': $table_def_function = "get_table_def_postgresql"; $table_content_function = "get_table_content_postgresql"; break; case 'mysql': case 'mysql4': $table_def_function = "get_table_def_mysql"; $table_content_function = "get_table_content_mysql"; break; } if ( !empty($table_name) ) { if($backup_type != 'data') { $backup .= "#\n# TABLE: " . $table_name . "\n#\n"; $backup .= $table_def_function($table_name, "\n") . "\n"; } if($backup_type != 'structure') { $backup .= $table_content_function($table_name, "output_table_content"); } } } if i change the part were it defines $backup it to
  4. kkroo

    bin2hex

    I think i found out the problem, the script sets a content length, and when it is encoded, it triples the length of the page so it will cut off the page at the set content length. so what i have to do is modify the set_content_length function.
  5. kkroo

    bin2hex

    I tested a page without the encoding and it loads fine, tried the same exact page with the encoding, and it was incomplete so i think it is from the encoding
  6. kkroo

    bin2hex

    These pages are pages that work without the encodingk, it is just wen i encode the page, it doesn't print the end of the page meaning this part: "));</script> but it does print the content.
  7. kkroo

    bin2hex

    like php, javascript requires strings to be in quotes so that didnt work, I added quotes, and it still didnt work. try accessing it now.
  8. kkroo

    bin2hex

    I have a proxy and i want to encode the page so that it cant be read by bots, so i am ecoding it using bin2hex, and decoding in javascript using unescape. ex: <script type="text/javascript"> document.write(unescape('datainhex')); </script> Well the problem that i am having is that some pages work perfectly fine and others just dont finish, this is what happens: <script type="text/javascript"> document.write(unescape('datainhex so it is missing the ')); </script> Live example: a working page: [a href=\"http://kkroo.dyndns.org:81/poxy\" target=\"_blank\"]http://kkroo.dyndns.org:81/poxy[/a] [a href=\"http://localhost:81/poxy/index.php?q=bG9jYWxob3N0OjgxL3JvdW5kY3ViZW1haWw-&hl=1111101001\" target=\"_blank\"]http://localhost:81/poxy/index.php?q=bG9jY...-&hl=1111101001[/a] a page that will not work: [a href=\"http://kkroo.dyndns.org:81/poxy/index.php?q=bG9jYWxob3N0OjgxL2ZvcnVt&hl=1111101001\" target=\"_blank\"]http://kkroo.dyndns.org:81/poxy/index.php?...t&hl=1111101001[/a] I am using PHProxy, and here is the modified code of the index page: [code]<?php @set_time_limit(0); @error_reporting(0); $data = ''; function escape ($str)     {        $encoded = bin2hex("$str");        $encoded = chunk_split($encoded, 2, '%');        $encoded = '%' . substr($encoded, 0, strlen($encoded) - 1);           $content = '<script type="text/javascript">'."\n"."document.write(unescape('%s'));"."\n".'</script>';       return sprintf($content, $encoded); } require 'PHProxy.class.php'; $config = array (     'url_var_name'             => 'q',     'flags_var_name'           => 'hl',     'get_form_name'            => '__script_get_form',     'proxy_url_form_name'      => 'poxy_url_form',     'proxy_settings_form_name' => 'poxy_settings_form',     'max_file_size'            => -1 ); $flags = 'prev'; if (isset($_GET[$config['flags_var_name']])) {     $flags = $_GET[$config['flags_var_name']]; } $PHProxy = & new PHProxy($config, $flags); if (isset($_GET[$PHProxy->config['get_form_name']])) {     $url = decode_url($_GET[$PHProxy->config['get_form_name']]);     $qstr = preg_match('#\\?#', $url) ? (strpos($url, '?') === strlen($url) ? '' : '&') : '?';     $arr = explode('&', $_SERVER['QUERY_STRING']);     if (preg_match('#^'.$PHProxy->config['get_form_name'].'#', $arr[0]))     {         array_shift($arr);     }     $url .= $qstr . implode('&', $arr);     $PHProxy->start_transfer(encode_url($url));     $data .= $PHProxy->return_response();     $str = $data; $encrypted = escape($str); echo $str;     exit; } if (isset($_GET[$PHProxy->config['url_var_name']]) ) {     $PHProxy->start_transfer($_GET[$PHProxy->config['url_var_name']]);     $data .= $PHProxy->return_response();     $responce = $PHProxy->return_response();     $str = $data; $encrypted = escape($str); echo $str;    exit; } if (isset($_GET['action'], $_GET['delete']) && $_GET['action'] == 'cookies' ) {     $PHProxy->delete_cookies($_GET['delete']);     header("Location: $PHProxy->script_url?action=cookies");    exit; } if (isset($_POST['username'], $_POST['password'], $_POST['server'], $_POST['realm'], $_POST['auth_url']) ) {     $PHProxy->request_method = 'GET';     $PHProxy->url_segments['host'] = decode_url($_POST['server']);     $PHProxy->set_authorization($_POST['username'], $_POST['password']);     $PHProxy->start_transfer($_POST['auth_url']);     $data .= $PHProxy->return_response();     $responce = $PHProxy->return_response();     $str = $data; $encrypted = escape($str); echo $str;    exit; } $data .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'; $data .= '<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">'; $data .= '<head>'; $data .= '  <title>PHProxy</title>'; $data .= '  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />'; $data .= '  <link rel="stylesheet" type="text/css" href="style.css" media="all" />'; $data .= '  <script src="javascript.js" type="text/javascript"></script>'; $data .= '</head>'; $data .= '<body>'; $data .= '<div id="container">'; $data .= '  <div id="menu">'; $data .= '    <a href="' . $_SERVER['PHP_SELF'] . '">URL Form</a> |'; $data .= '    <a href="?action=cookies">Manage Cookies</a>'; $data .= '  </div>'; $data .= '  <div class="title">PHProxy</div>'; $data .= '  <noscript><div class="error"><big>You have Javascript disabled. Please enable it to use the proxy</big></div></noscript>'; if (isset($_GET['error'])  ) {     $data .= '<div class="error"><b>Error:</b> ' . htmlspecialchars($_GET['error']) . '</div>';     if (isset($_GET['retry']))     {         $data .= '<div class="error"><a href="'. $PHProxy->proxify_url(decode_url($_GET['retry'])) .'">Retry</a></div>';     } } if (isset($_GET['action'])  ) {     if ($_GET['action'] == 'cookies')     {         $cookies = $PHProxy->get_cookies('COOKIE', false);         if (!empty($cookies))         {             $data .= '<table style="width: 100%">';             $data .= '<tr><td class="option" colspan="5"><a href="?action=cookies&delete=all">Clear All Cookies</a></td></tr>';             $data .= '<tr><td class="head">Name</td><td class="head">Domain</td><td class="head">Path</td><td class="head">Value</td><td class="head">Action</td></tr>';             for ($i = 0; $i < count($cookies); $i++)             {                 $j = $i&1 ? ' class="shade"' : '';                 $data .= "<tr><td$j>{$cookies[$i][0]}</td><td$j>{$cookies[$i][1]}</td><td$j>{$cookies[$i][2]}</td>"                    . "<td$j>" . wordwrap($cookies[$i][3], 15, ' ') ."</td><td$j><a href=". '"?action=cookies&delete='. md5(implode('', $cookies[$i])) . '">delete</a></td></tr>';             }             $data .= '</table>';         }         else         {             $data .= '<div class="error">No cookies available.</div>';         }     }     else if ($_GET['action'] == 'auth' && isset($_GET['server'], $_GET['realm'], $_GET['auth_url']))     {         $data .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">';         $data .= '<input type="hidden" name="server" value="'. $_GET['server'] .'" />';         $data .= '<input type="hidden" name="realm" value="'. $_GET['realm'] .'" />';         $data .= '<input type="hidden" name="auth_url" value="'. $_GET['auth_url'] .'" />';         $data .= '<table style="width: 100%">';         $data .= '<tr><td colspan="2" class="option">Enter user name and password for <b>' . decode_url($_GET['realm']) . '</b> at <i>' . decode_url($_GET['server']) . '</i></td></tr>';         $data .= '<tr><td width="30%" class="option">User name</td><td class="option"><input type="text" name="username" value="" /></td></tr>';         $data .= '<tr><td width="30%" class="option">Password</td><td class="option"><input type="password" name="password" value="" /></td></tr>';         $data .= '<tr><td colspan="2" style="text-align: center"><input type="submit" value="OK" /></td></tr>';         $data .= '</table>';         $data .= '</form>';     } } else { $data .= '  <form name="' .  $PHProxy->config['proxy_url_form_name'] .'" method="get" action="' . $_SERVER['PHP_SELF'] .'">'; $data .= '  <input type="hidden" name="' . $PHProxy->config['url_var_name'] .'" value="" id="url_input" />'; $data .= '  <input type="hidden" name="' . $PHProxy->config['flags_var_name'] . '" value="" />'; $data .= '  </form>'; $data .= '  <form name="' . $PHProxy->config['proxy_settings_form_name'] . '" method="get" action="" onsubmit="return submit_form();">'; $data .= '  <table style="width: 100%">'; $data .= '  <tr><td class="option" style="width: 20%">URL</td><td class="option" style="width: 80%">&nbsp;<input type="text" name="url" size="70" value="" /></td></tr>'; $data .=    $PHProxy->options_list(true, true); $data .= '  <tr><td class="option" style="width: 20%">New Window</td><td class="option" style="width: 80%"><input type="checkbox" name="new_window" />Open URL in a new window </td></tr>'; $data .= '  </table>'; $data .= '  <div style="text-align: center"><input type="submit" name="browse" value="Browse" onclick="return submit_form();" /></div>'; $data .= '  </form>'; } $data .= '</div></body></html>'; $encrypted = escape($data); echo $encrypted; ?> [/code]
  9. kkroo

    SQL errors

    so just add `` around all occurances of $table in queries? BTW, is it manditory to have the ; at the end of a query?
  10. I created an automatic backup script, and occasionally, i will get some errors like: FAILED IN get_table_def (show keys) on line372 in/home/***/public_html/forum/includes/auto_backup.php SHOW KEYS FROM Failed in get_table_def (show fields) on line337 in/home/***/public_html/gcc/forum/includes/auto_backup.php SHOW FIELDS FROM Failed in get_table_content (select *) on line535 in/home/**/public_html/gcc/forum/includes/auto_backup.php SELECT * FROM i added a filter to see if the var is empty, and it passes, so i think it may be a syntax error this is the way the query looks like: SELECT * FROM table_name SHOW KEYS FROM table_name does it maybe have to be like this: SELECT * FROM `table_name` SHOW KEYS FROM `table_name` here is the script: [a href=\"http://phpbb-login.sourceforge.net/forum/dload.php?action=file&file_id=13\" target=\"_blank\"]http://phpbb-login.sourceforge.net/forum/d...file&file_id=13[/a] Any help will be highly appreciated
  11. Hello, does anybody know a script that will zip or gzip a directory via php? if anybody knows one please tell me where i can find it Thanks
  12. that is exatly what i did a minute ago, thanks a lot
  13. ya that is true but i would like it to work on most sites
  14. That wouldnt work for every site because one site might have more inputs than another so...
  15. thanks a lot, well, how would i find a submit button? I am trying to make this as flexible as possible because i am making my own proxy and i know that all websites code HTML a bit differently.
  16. Hello, I am a major regex noob, and i would like to know how to find an input for forms in a page ex: <input type="x" name="x" value="x"> Thanks in advance
  17. I have set up a server, ppl can access it and it works fine, but when i come to include or fetch a remote page (ex. [a href=\"http://yahoo.com)\" target=\"_blank\"]http://yahoo.com)[/a] in my scripts, it will not work because I use a proxy server to access the internet, is there a way i can insert the proxy servers setting into php so that i can fetch remote pages?
  18. I have a function that gets the names of $lang arrays from a language file, the problem that i am facing is that i would like to print_r the array name that is returned from the function. But the function returns as a string, for example, $lang['Test']. What do i do so php reconizes it as a variable that represents an array and not a variable that represents a string?
  19. i am making a script that will get the var names of arrays through file(), this is what i currently have: [code] // This function was found on http:php.net/preg_match function array_preg_match($strRegEx = "", $arrHaystack = NULL, $boolNewArray = 0, $boolMatchesOnly = 0) {    if (strlen($strRegEx) < 1) {        return "ERR: \$strRegEx argument is missing.";    }       elseif ((!is_array($arrHaystack)) || (!count($arrHaystack) > 0)) {        return "ERR: \$arrHaystack is empty, or not an array.";    }       else {        unset($arrTmp);               // search through $arrHaystack, and build new array        foreach($arrHaystack as $key => $value) {            if ($boolMatchesOnly) {                if (preg_match_all($strRegEx, $value, $tmpRes)) {                    $arrTmp[] = $tmpRes;                }            }                       else {                if (preg_match($strRegEx, $value, $tmpRes)) {                    if ($boolNewArray) { $arrTmp[] = $value; }                    else { $arrTmp[$key] = $value; }                }            }        }               return $arrTmp;    } } // My function     function get_array_names ($file)     {         $file = file($file);                  $names = array_preg_match('(\$lang\[.*\])', $file);                  return array_values($names); }     [/code] I want it to return: Array ( [0] => $lang['Test'] [1] => $lang['Test1'] [2] => $lang['Test2'] ) BUT it returns Array ( [0] => $lang['Test'] = array( [1] => $lang['Test1'] = array( [2] => $lang['Test2'] = array( ) can anyone help me out?
  20. for the past hour, i have been trying multiple things to get this to work! what it does is backs up my DB and saves it as a gzip, then it emails a gzip file to my email with a message saying Your database has been backed up successfully on (date). at the current state, it doesn't show the email message, and the file is corrupted, this is the file's contents in the view message source: [code] ‹ [/code] pretty lame huh? this is the part of the script that deals with the email and gzips: [code]                 $file_name = 'phpbb_db_backup_' . date("d-m-Y_H-i", time()) . '.sql.gz';                 $gz = gzopen(''. $phpbb_root_path . 'backups/' . $file_name . '','w9');                 gzwrite($gz, $backup);                 gzclose($gz);                                  # Compress DB for sending                 $backup_gz = gzcompress($backup);                 # Message body                 $body = "Your database has been backed up successfully on " .date("Y/m/d H:i:s") .".";                                  # Is the OS Windows or Mac or Linux                 if (strtoupper(substr(PHP_OS,0,3)=='WIN')): $eol="\r\n"; elseif (strtoupper(substr(PHP_OS,0,3)=='MAC')): $eol="\r"; else: $eol="\n"; endif;                 # To Email Address                 $emailaddress="my@mail.com";                 # Message Subject                 $emailsubject="Database Backup ".date("Y/m/d H:i:s");                 # Common Headers                 $headers .= 'From: ' . $board_config['sitename'] . ' <' . $board_config['board_email'] . '>'.$eol;                 $headers .= 'Reply-To: ' . $board_config['sitename'] . ' <' . $board_config['board_email'] . '>'.$eol;                 $headers .= 'Return-Path: ' . $board_config['sitename'] . ' <' . $board_config['board_email'] . '>'.$eol;    // these two to set reply address                 $headers .= "Message-ID: <".$now." noreply@".$_SERVER['SERVER_NAME'].">".$eol;                 $headers .= "X-Mailer: PHP v".phpversion().$eol;          // These two to help avoid spam-filters                 # Boundry for marking the split & Multitype Headers                 $mime_boundary = md5(time());                 $headers .= 'MIME-Version: 1.0'.$eol;                 $headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol;                 $msg = "";                 # Attachment                 $msg .= "--".$mime_boundary.$eol;                 $msg .= "Content-Type: application/x-gzip; name=\"".$file_name."\"".$eol;                 $msg .= "Content-Transfer-Encoding: base64".$eol;                 $msg .= "Content-Disposition: attachment; filename=\"".$file_name."\"".$eol.$eol;                 $msg .= $backup_gz.$eol.$eol;                                  $msg .= "Content-Type: multipart/alternative".$eol;                                  # Message                 $msg .= "--".$mime_boundary.$eol;                 $msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;                 $msg .= $body.$eol.$eol;                                              # Finished                 $msg .= "--".$mime_boundary."--".$eol.$eol;  // finish with two eol's for better security. see Injection.                 # SEND THE EMAIL                 mail($emailaddress, $emailsubject, $msg, $headers); [/code] The file that the script puts in the directory is fine, but not the attachment. I don't want to do fread because that will waste time. I would really apprecaite it if somebody points out the retarded mistake I am making here. Thanks in advance
  21. this is my first time to use cron jobs, so i have 3 questions: How do i set a cron job using php? How do i update a cron job using php? How do i delete a cron job using php? Thanks in advance!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.