Jump to content

transparencia

Members
  • Posts

    54
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

transparencia's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi guys! I have a php script that works and outputs info: <?php echo exec("uptime"); ?> and another that doesn't output anything: <?php echo exec("MP4Box"); ?> Why?
  2. Basically, I have a form, and if the user inserts text in the form that is not in english, I want to translate it to english. Otherwise, just leave the text in english. This is what I have now, but it is not working: <script>/* * How to translate text. */ /* google initalize */ google.load("language", "1"); function initialize() { /* my form id is q */ var searchQuery = document.getElementById('q'); if(searchQuery.value != "") { // Detected the language google.language.detect(searchQuery, function(result) { if (!result.error) { var language = 'unknown'; for (l in google.language.Languages) { if (google.language.Languages[l] == result.language) { language = l; //if Language not english, then translate if (language != "ENGLISH") { google.language.translate(searchQuery, '', 'en', function(result) { if (result) { // if there is a result, replace the q in the form with the translated one document.getElementById('q').innerHTML = result.translation; } // else if there is no result, just leave the same query in the q form else document.getElementById('q').innerHTML = searchQuery.value; }); } break; } } } }); } } google.setOnLoadCallback(initialize); </script> This code is not working, it is not replacing the text in the form.
  3. I don't have any code yet, but you are saying that MySQL-wise there is a type of search that allows for this?
  4. Hello! I have a database like this: Product Name | Category1 | Category 2 | Category 3 Iphone | Apple | Iphone | WD HD | PC | Hard-drive | External Monitor 17" | LCD Screen| | What I want to do is to allow people to search for any categories and also the junction of the categories. For example, if the the URL is like this &category=External;PC;Hard-Drive it will show WD HD and all the other products which have any combination of these three categories. Another example, if the URL is like &category=Iphone it will show Iphone. If the URL is &category=LCD screen;Apple it will not show anything, because the ; is basically an AND. The problem is that the keywords could be in any category, so a search for a single keyword would have to be made on all the columns and a search for 3 keywords, like the first example, would have to be made 3 times on these columns for the 3 keywords, which would mean 9 searches in total!! How could I do this the fastest way?
  5. Hello guys, I have a select form that changes the website countries. My website is built like this: fr.website.com, de.website.com, etc... When the user changes the country in the form, I would like to send him to one of the subdomains. I have this code: Code: <select onchange="window.location=+this.value'.website.com'"> <option value="at">Austria</option> <option value="be">Belgium</option> etc... If the user press Austria I want to send him to at.website.com. How can I do that?
  6. My string is like this: line 1 line 2 .... line 3453 line 3454 etc... I want to split the string into chunks of 500 lines, do something with those chunks and then reassamble the main $string again. The last chunk doesn't need to be 500 lines it can be less. How can I do it?
  7. This script is supposed to run in the command line. Like the title says, I need to: [*]Import some columns (input the names with an argument) from a .CSV file [*]Split the column into blocks of 500 lines [*]Translate this pieces [*]Put them back into the original file I already have some code but it is unfinished and not working: <?php //name of the .CSV file $filename = $argv[1]; //name of the column to be translated $header_name = $argv[2]; //open file $file_handle = fopen($filename, "r"); $i=0; $j=0; $counter = 0; $translated = ''; $string = ''; while (!feof($file_handle) ) { $counter++; $line_of_text = fgetcsv($file_handle, 1024); //find the column id that contains the header name. // headers are always on the the first line if ( $counter == 1 ){ while ($line_of_text[$i] != $header_name) $i++; $header_id = $i; } //create the blocks $string .= $line_of_text[$i]; if ($counter % 500 == 0) { $gt = new GoogleTranslateWrapper(); $translated .= $gt->translate($string, "en"); } } //Write the translate column in the same .CSV file fclose($file_handle); ?> Any help in rewriting this to work?
  8. That is not working properly. It is not allowing the .css and .jpg to be shown and also it just stays in the index.php even if click on another link. Is it because of the other rewrite rules?
  9. I want to append a ?lang=$language_code on all the .php pages and directories of the website and I would like to rewrite it like this: site.com/language => site.com/index.php?lang=language site.com/language/dir/ => site.com/dir1.php?lang=language I already have this code in .htaccess: Options -MultiViews RewriteEngine On RewriteBase /pt/ RewriteRule ^product/(.*).html$ products.php?q=$1&rewrite=1&%{QUERY_STRING} [L] RewriteRule ^review/(.*).html$ reviews.php?q=$1&rewrite=1&%{QUERY_STRING} [L] RewriteRule ^merchant/$ merchants.php RewriteRule ^merchant/(.*)/$ search.php?q=merchant:$1:&rewrite=1&%{QUERY_STRING} [L] RewriteRule ^merchant/(.*)/(.*).html$ search.php?q=merchant:$1:&page=$2&rewrite=1&%{QUERY_STRING} [L] RewriteRule ^category/$ categories.php RewriteRule ^category/(.*)/$ search.php?q=category:$1:&rewrite=1&%{QUERY_STRING} [L] RewriteRule ^category/(.*)/(.*).html$ search.php?q=category:$1:&page=$2&rewrite=1&%{QUERY_STRING} [L] Is it possible to do this?
  10. My website is multi-language and using mod_rewrite for clean urls. I have a $lang variable that stores the language code. For example: website.com/index.php?lang=en, which turns to website.com/en I use a $_GET["lang"] to get the language and prepare the links to the other pages, for example a link to page1.php would be page1.php?lang=$_GET["lang"]. What I want to know is if this is the right way to do it or there is a better way.
  11. Is there any problem in opening a SWF trough a buffered transfer? This is what is happening: // Open the file and seek to starting byte $fp = fopen($file_user->full_path, 'r'); fseek($fp, $seek_start); // Start buffered download while (!feof($fp)) { // Reset time limit for large files set_time_limit(0); // Push the data to the client. print(fread($fp, UC_FILE_BYTE_SIZE)); flush(); ob_flush(); } How can I change this to make a normal transfer, an un-buffered download?
  12. I want this code to force an SWF file to open on the browser but it doesn't display it right, like parts of the SWF files are missing. Can anybody help in tracking the problem? function _uc_file_download_transfer($file_user, $ip) { // Check if any hook_file_transfer_alter calls alter the download. foreach (module_implements('file_transfer_alter') as $module) { $name = $module .'_file_transfer_alter'; $file_user->full_path = $name($file_user, $ip, $fid, $file_user->full_path); } // This could get clobbered, so make a copy. $filename = $file_user->filename; // Gather relevant info about the file. $size = filesize($file_user->full_path); $fileinfo = pathinfo($file_user->full_path); $mimetype = file_get_mimetype($filename); // Workaround for IE filename bug with multiple periods / multiple dots in filename // that adds square brackets to filename - eg. setup.abc.exe becomes setup[1].abc.exe if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { $filename = preg_replace('/\./', '%2e', $fileinfo['basename'], substr_count($fileinfo['basename'], '.') - 1); } else { $filename = $fileinfo['basename']; } // Check if HTTP_RANGE is sent by browser (or download manager) if (isset($_SERVER['HTTP_RANGE'])) { list($size_unit, $range_orig) = explode('=', $_SERVER['HTTP_RANGE'], 2); if ($size_unit == 'bytes') { // Multiple ranges could be specified at the same time, but for simplicity only serve the first range // See http://tools.ietf.org/id/draft-ietf-http-range-retrieval-00.txt list($range, $extra_ranges) = explode(',', $range_orig, 2); } else { $range = ''; } } else { $range = ''; } // Figure out download piece from range (if set) list($seek_start, $seek_end) = explode('-', $range, 2); // Set start and end based on range (if set), else set defaults and check for invalid ranges. $seek_end = intval((empty($seek_end)) ? ($size - 1) : min(abs(intval($seek_end)), ($size - 1))); $seek_start = intval((empty($seek_start) || $seek_end < abs(intval($seek_start))) ? 0 : max(abs(intval($seek_start)), 0)); ob_end_clean(); //Only send partial content header if downloading a piece of the file (IE workaround) if ($seek_start > 0 || $seek_end < ($size - 1)) { drupal_set_header('HTTP/1.1 206 Partial Content'); } // Standard headers, including content-range and length drupal_set_header('Pragma: public'); drupal_set_header('Cache-Control: cache, must-revalidate'); drupal_set_header('Accept-Ranges: bytes'); drupal_set_header('Content-Range: bytes '. $seek_start .'-'. $seek_end .'/'. $size); drupal_set_header('Content-Type: '. $mimetype); drupal_set_header('Content-Disposition: inline; filename="'. $filename .'"'); drupal_set_header('Content-Length: '. ($seek_end - $seek_start + 1)); // Last-modified is required for content served dynamically drupal_set_header('Last-modified: '. format_date(filemtime($file_user->full_path), 'large')); // Etag header is required for Firefox3 and other managers drupal_set_header('ETag: '. md5($file_user->full_path)); // Open the file and seek to starting byte $fp = fopen($file_user->full_path, 'r'); fseek($fp, $seek_start); // Start buffered download while (!feof($fp)) { // Reset time limit for large files set_time_limit(0); // Push the data to the client. print(fread($fp, UC_FILE_BYTE_SIZE)); flush(); ob_flush(); } // Finished serving the file, close the stream and log the download to the user table fclose($fp); _uc_file_log_download($file_user, $ip); }
  13. I have a PHP blog that has a comment view.php page. This page shows all the comments on the database and below each comment a button to delete. I have a delete.php page that actually deletes the comment. How can I pass the comment ID from view.php to delete.php, internally (without using URL) so that delete.php knows which comment to delete?
  14. No problem, I came up with this code: $i=0; while ($row = mysql_fetch_row($request)) { $product[$i] = $row; $i++; } $j = rand ( 0 , 10 ); print_r($product[$j]); Do you think it will slow down the website much?
×
×
  • 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.