Jump to content


Photo

Need help..


  • Please log in to reply
12 replies to this topic

#1 xam

xam
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 30 June 2006 - 08:39 PM

Hello,

I use below code to change my language files.

<?php
session_start();
function addslashes2 ($string) {
if (!get_magic_quotes_gpc())
   return str_replace('\'','\\\'',$string);
else
   return str_replace('\'','\\\'',stripslashes($string));

}
if (isset($_POST['new_lang'])):
    $current_lang = $_SESSION['lang'];
    $new_lang_file_content = array();
    foreach ($_POST['new_lang'] as $key => $value):
          $new_lang_file_content[] = '$lang[\''.$key.'\'] = \''. addslashes2($value) .'\';';
    endforeach;
    $handler = fopen('lang.inc','w');
    fwrite($handler,"<?php\n".implode("\n",$new_lang_file_content)."\n?>");
    fclose($handler);
    Die ('Language file has been updated. Click <a href=javascript:history.go(-1)> here</a> to go back.');
endif;
include_once 'lang.inc';
echo $lang['category'];
?> 
<form method="post">
<input name="new_lang[category]" type="text" value="<?=$lang['category'];?>">
<input type="submit"></form>

It works fine but I need some help about; When I insert a text with php string into input area, e.g. following text: You have been redirected to main page '.$MAIN['mainpage'].'
It save it as a text I want to save it as php string, take a look at below example thats what I want..

e.g.:
I wrote: You have been redirected to main page '.$MAIN['mainpage'].'
It has been saved as (lang.inc):
<?php
$lang['category'] = 'You have been redirected to main page \'.$MAIN[\'mainpage\'].\' ';
?>

I want:

<?php
$lang['category'] = 'You have been redirected to main page '.$MAIN['mainpage'].' ';
?>

without slashes..

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 30 June 2006 - 09:00 PM

stripslashes()

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 xam

xam
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 30 June 2006 - 09:16 PM

stripslashes()

Orio.


ok done, thx

#4 xam

xam
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 01 July 2006 - 11:05 AM

well, I have another question / I need another help..

An example language file content:
language.php
$lang['Copyright'] = 'Copyright '.$Settings['url'].' All Rights Reserved.';

An example modify script for language file:
include_once ('language.php');
echo '<input onClick="highlight(this);" size="200" type="text" name="new_lang[Copyright]" value=" '.$lang['Copyright'].' ">'

It shows:
<input onClick="highlight(this);" size="200" type="text" name="new_lang[Copyright]" value="Copyright  All Rights Reserved.">

I want:
<input onClick="highlight(this);" size="200" type="text" name="new_lang[Copyright]" value="Copyright '.$lang['Copyright'].'  All Rights Reserved.">

$settings[xxxx] values should be write as text content..
I use htmlspecialchars but It wont help ...

#5 xam

xam
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 01 July 2006 - 02:07 PM

I need urgent help  ???

#6 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 01 July 2006 - 02:52 PM

Do you mean this
$lang['Copyright'] = 'Copyright  All Rights Reserved.';

echo  $lang['Copyright']; //-->   Copyright  All Rights Reserved.
echo '<br>';
    // text in single quotes
echo  '$lang[\'Copyright\']'; //-->   $lang['Copyright'];

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#7 eunicewt

eunicewt
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 01 July 2006 - 03:20 PM

Hi,
  I have this error and I know it is an empty string but I cannot find where is my mistake. Anyone can tell me where is my mistake.

My coding
  // update asset
                        $sql = "UPDATE Assets SET financetag='" . $assettype_id  . $assettag . "',assettype='" . $assettype . "',assetsupplier='" . $assetsupplier . "',assetmodel='" . $assetmodel . "',assetserial='" . $assetserial . "',assetprice='" . $assetprice .  "',description='" . $assetdescription . "',make='" . $assetmake . "',year='" . $assetyear . "',rego='" . $assetrego . "',notes='" .  $notes . "' WHERE id=" . $key . ";";
                        if ($result = doSql($sql)) {

An error occurred while attempting to update the database. Please contact the webmaster. This is action attempted:: INSERT INTO Assets (financetag,assettype,assetsupplier,assetmodel,assetserial,assetprice,description,make,year,rego,status,notes,added_by, date_added) VALUES ('1691751','sdsd','16','','','0','','','2006','','','', '1', '2006-07-01 15:09:11');
Duplicate entry '' for key 2

Eunice

#8 xam

xam
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 01 July 2006 - 03:22 PM

Do you mean this

$lang['Copyright'] = 'Copyright  All Rights Reserved.';

echo  $lang['Copyright']; //-->   Copyright  All Rights Reserved.
echo '<br>';
    // text in single quotes
echo  '$lang[\'Copyright\']'; //-->   $lang['Copyright'];


no, I mean:
$lang['leecher'] = 'This page is only avaliable from the '.$MAIN['url'].' site.';

The code:
<input onClick="highlight(this);" size="200" type="text" name="new_lang[leecher]" value="'.$lang['leecher'].'">

It shows:
<input onClick="highlight(this);" size="200" type="text" name="new_lang[leecher]" value="This page is only avaliable from the  site.">

It should be:
<input onClick="highlight(this);" size="200" type="text" name="new_lang[leecher]" value="This page is only avaliable from the '.$MAIN['url'].' site.">

It must show '.$MAIN['url'].' string as text not a php value/string..

#9 xam

xam
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 02 July 2006 - 10:24 AM

Does anyone help me about that my problem ????

???

#10 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 02 July 2006 - 10:27 AM

Do you mean this

$lang['Copyright'] = 'Copyright  All Rights Reserved.';

echo  $lang['Copyright']; //-->   Copyright  All Rights Reserved.
echo '<br>';
    // text in single quotes
echo  '$lang[\'Copyright\']'; //-->   $lang['Copyright'];


I already have
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#11 xam

xam
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 03 July 2006 - 02:51 PM

Do you mean this

$lang['Copyright'] = 'Copyright  All Rights Reserved.';

echo  $lang['Copyright']; //-->   Copyright  All Rights Reserved.
echo '<br>';
    // text in single quotes
echo  '$lang[\'Copyright\']'; //-->   $lang['Copyright'];


I already have


I mean:
lang-en.php
$lang['protected2'] = 'Copyright '.$MAIN['url'].' All Rights Reserved.';

Form (to change/edit language text in adminpanel):
echo '<input onClick="highlight(this);" size="200" type="text" name="new_lang[protected2]" value="'.$lang['protected2'].'"><br>';

Output (to input value):
<input onClick="highlight(this);" size="200" type="text" name="new_lang[protected2]" value="Copyright All Rights Reserved.">

I want:
Output (to input value):
<input onClick="highlight(this);" size="200" type="text" name="new_lang[protected2]" value="Copyright '.$MAIN['url'].'  All Rights Reserved.">

#12 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 03 July 2006 - 03:26 PM

http://uk.php.net/ma...ypes.string.php
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#13 xam

xam
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 03 July 2006 - 03:37 PM

http://uk.php.net/ma...ypes.string.php


Its hard for me ;( my english not enought for this tutorial thats why I wrote here....

???




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users