Jump to content

PriteshP23

Members
  • Posts

    79
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Age
    24

PriteshP23's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello, I have used Single Translation Table Approach to make multilanguage site in PHP. You may see here The current index page is not working. My objective is to have one example to use these tables and display one working page. For example: It should work like this by using those tables (app_language, app_product, app_translation, app_translation_entry). What i did so far on my home page: <!DOCTYPE html> <?php session_start(); $_SESSION['current_language'] = "fr"; $con = mysql_connect("localhost","worksite",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("worksite", $con); ?> <?php // handle language selection if(in_array($_GET['lang'], $languages)) { $_SESSION['lang'] = $_GET['lang']; } // define LANG constant only if it exists in $languages array, otherwise default to EN define('LANG', in_array($_SESSION['lang'], $languages) ? $_SESSION['lang'] : 'fr'); define('LANG', in_array($_SESSION['lang'], $languages) ? $_SESSION['lang'] : 'en'); // display language options foreach($languages as $language) { echo '<a href="?lang='.$language.'">'.$language.'</a>'; } $sql = "SELECT p.*, l.name as language_name, te.field_text as title FROM `app_product` p INNER JOIN `app_translation_entry` te ON p.title = te.translation_id INNER JOIN `app_language` l ON te.language_code = l.code WHERE p.id = 1"; if($result = mysql_query($sql)){ while($row = mysql_fetch_assoc($result)){ echo "Language (".$row["language_name"]."): ".$row["title"]."<br>"; } } // Retrieve appropriate title according to the chosen language in the system $sql = "SELECT p.*, l.name as language_name, te.field_text as title FROM `app_product` p INNER JOIN `app_translation_entry` te ON p.title = te.translation_id INNER JOIN `app_language` l ON te.language_code = l.code WHERE p.id = 1 AND te.language_code = '".$_SESSION['current_language']."'"; if($result = mysql_query($sql)){ if($row = mysql_fetch_assoc($result)){ echo "Current Language: ".$row["title"]; } } ?> </body> </html> You may edit this file as you wish but it should be working as per example link (demo). I want to build static website from above approach. Thanks in advanced for your time and input.
  2. @jazzman1 Your logic is right. I agree. But in my file it is was not working and difficult to mange (in terms of variables, whitespace problems). The earlier script worked, so i keep that in my file. I am very thankful to you for your help and time.
  3. Yes, this is working fine..! Thanks a lot
  4. It will be great if anyone can give input to check the filesize and if it is too big, make 4 parts instead of 3 parts. I did so far: head -1125000 cells_20140107_154016.xml > PART1.xml echo "</details></cells>" >> PART1.xml echo "<cells><details>" >> PART2.xml sed -n '1125001,2250000p' cells_20140107_154016.xml >> PART2.xml echo "</details></cells>" >> PART2.xml echo "<cells><details>" >> PART3.xml sed -n '2250001,3480000p' cells_20140107_154016.xml >> PART4.xml The main task is to make it in general. Expected output: head -1125000 filename.xml > PART1.xml echo "</details></cells>" >> PART1.xml echo "<cells><details>" >> PART2.xml sed -n '1125001,2250000p' filename.xml >> PART2.xml echo "</details></cells>" >> PART2.xml echo "<cells><details>" >> PART3.xml sed -n '2250001,3480000p' filename.xml >> PART4.xml I hope i am clear. Thanks in advanced for your time and input.
  5. Hello, I have one big XML file (600 MB - 850 MB) in format "cells_yyyymmdd_hhmi.xml" I would like to specify that everyday i will have new file with new date. So, there should be general way to rea For exmaple, i have file of 7th January. Its, cells_20140107_154016 Goal is to split into small parts by shell script and do operation.
  6. Finally, it works cd $file/path u=$(date +%u) if [ ${u} -eq 1 ] ; then dateQ=`date --date='-3 day' +'%Y%m%d'` else dateQ=`date --date='-1 day' +'%Y%m%d'` fi zcat my_file_"$dateQ"*.tar.Z | tar xvf - Thank you all for your time and input.
  7. Good try. I like it. But there is error: Wrong parameter count for explode() It is not expected as solution because everyday it will change the filename. In addition, i have to read filename with date and later display the time from it.
  8. Yes, you are right. This is the question. How to make it general so that it take the value which is in filename? There are no more files. So, no need to find latest date or deleting other files like that. Thanks in advanced for your input.
  9. Hello, I have csv filename with date. Everyday i have same csv file with respective date. I need to read filename (everyday date changes in filename) and do operation. For example, I have file "cells_20140106_165532.csv". I did like this to read it in general: $filename = "cells_".date('Ymd_hmi').".csv"; $file_contents = file_get_contents($filename); $importcsvsql = ""; It is taking current date instead of filename's date. It is generating empty file "cells_20140114_110109.csv" Thanks in advanced.
  10. Is it possible to write like this ? u=$(date +%u) if [ ${u} -eq 1 ] ; then dateQ=`date --date='-3 day' +'%Y%m%d'` else dateQ=`date --date='-1 day' +'%Y%m%d'` fi zcat my_file_"$dateQ"*.tar.Z | tar xvf - If possible, i would like to have link which provides shell script example with output. Thanks in advanced.
  11. To unzip, zcat is working fine: zcat $file | tar xvf - i need to correct the part of date in the script. dateQ='20[0-9]{2}(0[1-9]|1[0-2])([0-2][0-9]|3[0-1])' if [ ${u} -eq 1 ] ; then dateQ=`date --date='-3 day' +'%Y%m%d'` else dateQ=`date --date='-1 day' +'%Y%m%d'` fi I believe there are more options possible. In fact, my goal is to check the date of file. There are 7 files inside the .tar.Z file. With that 7 files i need to do update operation in my database. Normally, everyday (Monday to Friday) i will receive new file with respective date. I need to check the date and display the date of file. For example, if one day i have not received file in that case, i need to use previous file. Simple example: Day 1: 09 Jan 2014 I have received the .tar.Z file --> extract --> update operation --> Mesg "File has received 09 Jan 2014" Day 2: 10 Jan 2014 I have received the .tar.Z file --> extract --> update operation --> Mesg "File has received 10 Jan 2014" Note: DELETE FILE OF 9th Jan Day 3: 13 Jan 2014 I have NO Files. So, i have to use yesterdays file and repeat the same procedure with ALERT MESG. "File has received 10 Jan 2014" (in RED) There should be one file ALWAYS available to do update operation, no matter which date. I hope i am clear.
  12. I got file from Monday to Friday. I need to verify that it should not be delay of more than 3 days. My file name is difficult to handle in shell script and check the date. Files are like this --> my_file_20140103_1540.tar.Z (For Friday) / my_file_20140106_1460.tar.Z (For Monday) / my_file_20140107_1120.tar.Z (For Tuesday) For example, if its monday than it must be the date of Friday (maximum late), not the file with date of thursday. In addition, if its Wednesday, i need to check if it is date of Tuesday --> OK, it its date of Monday --> NOK I hope i am clear. not working We need to correct the dateQ logic. It should be modified in order to print the value of filename. I think here is file of 3rd January 2014 and it need to adjust with current time. May be that's why it is not giving output. I have already written my filename in the question. Anyway, i repeat the file is in tar.Z format " my_file_20140103_1540.tar.Z " .
  13. Hello, I have one "tar.Z" file. Objective is to unzip it by shell script and check the date. File archive: filename_20140103_1540.tar.Z #!/bin/bash cd $REP_DATAS/path u=$(date +%u) if [ ${u} -eq 1 ] ; then dateQ=`date --date='-3 day' +'%Y%m%d_%H%m'` else dateQ=`date --date='-1 day' +'%Y%m%d_%H%m'` fi tar xvf filename_"dateQ".tar.Z THANKS IN ADVANCED.
  14. #!/bin/sh DB_USER="****" DB_PASS="****" DB_NAME="****" echo "##########" echo $1 echo "##########" echo date cd customer for i in *-*.php do echo $i php $i $1 echo date I need something like this. This is just REFERENCE. It is not working.
  15. Well, I have already mentioned that "Things to do:" The problem is that i am looking for a shell script which can perform expected operation.
×
×
  • 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.