Jump to content

Need help..


xam

Recommended Posts

Hello,

I use below code to change my language files.

[code]<?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>[/code]

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):
[code]<?php
$lang['category'] = 'You have been redirected to main page \'.$MAIN[\'mainpage\'].\' ';
?>[/code]

I want:

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

without slashes..
Link to comment
Share on other sites

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

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

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

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

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

$settings[xxxx] values should be write as text content..
I use htmlspecialchars but It wont help ...
Link to comment
Share on other sites

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
Link to comment
Share on other sites

[quote author=Barand link=topic=99045.msg390167#msg390167 date=1151765522]
Do you mean this
[code=php:0]
$lang['Copyright'] = 'Copyright  All Rights Reserved.';

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

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..
Link to comment
Share on other sites

[quote author=Barand link=topic=99045.msg390167#msg390167 date=1151765522]
Do you mean this
[code=php:0]
$lang['Copyright'] = 'Copyright  All Rights Reserved.';

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

I already have
Link to comment
Share on other sites

[quote author=Barand link=topic=99045.msg390437#msg390437 date=1151836056]
[quote author=Barand link=topic=99045.msg390167#msg390167 date=1151765522]
Do you mean this
[code=php:0]
$lang['Copyright'] = 'Copyright  All Rights Reserved.';

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

I already have
[/quote]

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

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

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.">
Link to comment
Share on other sites

[quote author=Barand link=topic=99045.msg391003#msg391003 date=1151940373]
http://uk.php.net/manual/en/language.types.string.php
[/quote]

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

???
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.