Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-09-2012, 08:03 AM   PM User | #1
ricolding
New Coder

 
Join Date: Jul 2012
Posts: 22
Thanks: 6
Thanked 0 Times in 0 Posts
ricolding is an unknown quantity at this point
php issue

Hi
i have a question

in the login page of a chat script there is channel and list of channels

the channels files is located in a folder called database

example

channel name main
in the database folder there is a file called
main.db.php

and it have that code
|main|public|<?die?>

and in the login page
have that code

$cur_channel = $chatdir."database/".trim($_SESSION['chant_channel']);
if(!file_exists($cur_channel)) die();

i mean when u change the name like that
from |main|public|<?die?>
To |any name|public|<?die?>
the name changes in the login page

now when u write any other lang like arabic
in the login page the channel name isn`t the same but it is only a space
i mean it doesn`t appear

now what should i edit
the main.db.php file

or the login file
and how to solve it
ricolding is offline   Reply With Quote
Old 07-09-2012, 09:42 AM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Quote:
and it have that code
|main|public|<?die?>

and in the login page
have that code

$cur_channel = $chatdir."database/".trim($_SESSION['chant_channel']);
if(!file_exists($cur_channel)) die();

i mean when u change the name like that
from |main|public|<?die?>
To |any name|public|<?die?>
the name changes in the login page

now when u write any other lang like arabic
in the login page the channel name isn`t the same but it is only a space
i mean it doesn`t appear

now what should i edit
the main.db.php file
Sorry, that doesn't make any sense to me.
I'd request you to read your above post like a person who doesn't have the access to the code and see what you can grasp from that. If you post all the code involved, may be we may get an idea.

PS: Please use [PHP][/PHP] tags to wrap the code while posting here.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 07-09-2012, 11:59 AM   PM User | #3
ricolding
New Coder

 
Join Date: Jul 2012
Posts: 22
Thanks: 6
Thanked 0 Times in 0 Posts
ricolding is an unknown quantity at this point
Quote:
Originally Posted by abduraooft View Post
Sorry, that doesn't make any sense to me.
I'd request you to read your above post like a person who doesn't have the access to the code and see what you can grasp from that. If you post all the code involved, may be we may get an idea.

PS: Please use [PHP][/PHP] tags to wrap the code while posting here.
ok here is the script

chantlive.com
ricolding is offline   Reply With Quote
Old 07-09-2012, 03:22 PM   PM User | #4
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
That doesn't help us, we need to see your PHP code, and only the relevant sections.
Keleth is offline   Reply With Quote
Old 07-09-2012, 04:35 PM   PM User | #5
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,513
Thanks: 45
Thanked 439 Times in 428 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
If it helps, all I understand from this topic is that you're using a script that uses files instead of a database, you want to do something in arabic, it's not working and you've provided a link to the script.

__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 07-09-2012, 10:36 PM   PM User | #6
ricolding
New Coder

 
Join Date: Jul 2012
Posts: 22
Thanks: 6
Thanked 0 Times in 0 Posts
ricolding is an unknown quantity at this point
Quote:
Originally Posted by tangoforce View Post
If it helps, all I understand from this topic is that you're using a script that uses files instead of a database, you want to do something in arabic, it's not working and you've provided a link to the script.

i`m srry what i meant is that i want to import the arabic name instead of the english but it doesn`t appear

here is the codes

PHP Code:
$cur_channel $chatdir."database/".trim($_SESSION['chant_channel']);
if(!
file_exists($cur_channel)) die(); 
and here is the files that have the code

login.php

PHP Code:
<?php
/*
@ CHANT - AJAX/PHP Based Chat System Framework 
@ Copyright (C) 2006-07 Alexander Movsisyan. All rights reserved
@ Site: http://www.ChaNTLIVE.com
@ Released under GNU/GPL License: Free for noncommercial purposes
@ version $Revision: 1.0.1 $
*/
    
if (!defined('CHANT_KEY')) {
    
Header("Location: ../index.php");
    die();
}

ChaNT_widgets::run_widgets('OnGetDataStart');

if(!
session_is_registered('chant_username')) {
die(
"Session has expired");
}    

if(
$_GLOBAL['username'] != $_SESSION['chant_username']) {
die(
"Access denied");
}

if(
$_SESSION['chant_locked'] == "yes") die(); 
$_SESSION['chant_locked'] = "yes";        
$cur_channel $chatdir."database/".trim($_SESSION['chant_channel']);
if(!
file_exists($cur_channel)) die();
$ignore_array = array();
if(!empty(
$_GLOBAL['ignore'])) $ignore_array explode("|"$_GLOBAL['ignore']);

header("Expires: Mon, 9 Apr 1999 09:09:09 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Last-Modified: ".gmdate("D, d M Y H:is")." GMT");
define("hashprint",  md5_file($cur_channel));
//define("microtime",  ChaNT::getmicrotime(1));
   
ChaNT_widgets::run_widgets('OnGetData');
if(
$_GLOBAL['do'] == "history" || empty($_SESSION['chant_hashprint']) || empty($_SESSION['chant_timestamp'])) {
$file_db file($cur_channel);
array_shift($file_db);
if(
$_GLOBAL['do'] != "history"$file_db array_slice($file_db, -30);    
foreach(
$file_db as $val) {
list(
$time$nick$private$str) = explode("|"trim($val), 4);
if(
in_array($nick$ignore_array)) continue;
$ciphertext = ($des == "enable")?ChaNT::des_crypt($str"enc"):$str;
if(
$private == "no"){ 
echo 
trim("no|".$ciphertext)."\n";    
} elseif(
$private == "on") {  
echo 
trim("on|".$ciphertext)."\n";    
} elseif(
$private == "ex") {  
echo 
trim("ex|".$ciphertext)."\n";    
} elseif(
$private == "xe") {  
echo 
trim("xe|".$ciphertext)."\n";    
} elseif(
$nick == $_SESSION['chant_username']) {  
echo 
trim($nick."|".$ciphertext)."\n";    
} elseif(
$private == $_SESSION['chant_username']) {  
echo 
trim($private."|".$ciphertext)."\n";    
}
}   
$_SESSION['chant_timestamp'] = $time;
} elseif(
hashprint != $_SESSION['chant_hashprint']) {
$file_db file($cur_channel);
foreach(
$file_db as $val$endtime ChaNT::parser($val);  
$_SESSION['chant_timestamp'] = $endtime;
}
$_SESSION['chant_hashprint'] = hashprint;
$_SESSION['chant_locked'] = "no";        
ChaNT_widgets::run_widgets('OnGetDataEnd');
?>
and that is getdata.php

PHP Code:
<?php
/*
@ CHANT - AJAX/PHP Based Chat System Framework 
@ Copyright (C) 2006-07 Alexander Movsisyan. All rights reserved
@ Site: http://www.ChaNTLIVE.com
@ Released under GNU/GPL License: Free for noncommercial purposes
@ version $Revision: 1.0.1 $
*/
    
if (!defined('CHANT_KEY')) {
    
Header("Location: ../index.php");
    die();
}

ChaNT_widgets::run_widgets('OnGetDataStart');

if(!
session_is_registered('chant_username')) {
die(
"Session has expired");
}    

if(
$_GLOBAL['username'] != $_SESSION['chant_username']) {
die(
"Access denied");
}

if(
$_SESSION['chant_locked'] == "yes") die(); 
$_SESSION['chant_locked'] = "yes";        
$cur_channel $chatdir."database/".trim($_SESSION['chant_channel']);
if(!
file_exists($cur_channel)) die();
$ignore_array = array();
if(!empty(
$_GLOBAL['ignore'])) $ignore_array explode("|"$_GLOBAL['ignore']);

header("Expires: Mon, 9 Apr 1999 09:09:09 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Last-Modified: ".gmdate("D, d M Y H:is")." GMT");
define("hashprint",  md5_file($cur_channel));
//define("microtime",  ChaNT::getmicrotime(1));
   
ChaNT_widgets::run_widgets('OnGetData');
if(
$_GLOBAL['do'] == "history" || empty($_SESSION['chant_hashprint']) || empty($_SESSION['chant_timestamp'])) {
$file_db file($cur_channel);
array_shift($file_db);
if(
$_GLOBAL['do'] != "history"$file_db array_slice($file_db, -30);    
foreach(
$file_db as $val) {
list(
$time$nick$private$str) = explode("|"trim($val), 4);
if(
in_array($nick$ignore_array)) continue;
$ciphertext = ($des == "enable")?ChaNT::des_crypt($str"enc"):$str;
if(
$private == "no"){ 
echo 
trim("no|".$ciphertext)."\n";    
} elseif(
$private == "on") {  
echo 
trim("on|".$ciphertext)."\n";    
} elseif(
$private == "ex") {  
echo 
trim("ex|".$ciphertext)."\n";    
} elseif(
$private == "xe") {  
echo 
trim("xe|".$ciphertext)."\n";    
} elseif(
$nick == $_SESSION['chant_username']) {  
echo 
trim($nick."|".$ciphertext)."\n";    
} elseif(
$private == $_SESSION['chant_username']) {  
echo 
trim($private."|".$ciphertext)."\n";    
}
}   
$_SESSION['chant_timestamp'] = $time;
} elseif(
hashprint != $_SESSION['chant_hashprint']) {
$file_db file($cur_channel);
foreach(
$file_db as $val$endtime ChaNT::parser($val);  
$_SESSION['chant_timestamp'] = $endtime;
}
$_SESSION['chant_hashprint'] = hashprint;
$_SESSION['chant_locked'] = "no";        
ChaNT_widgets::run_widgets('OnGetDataEnd');
?>
and the last is senddata.php

PHP Code:
<?php
/*
@ CHANT - AJAX/PHP Based Chat System Framework 
@ Copyright (C) 2006-07 Alexander Movsisyan. All rights reserved
@ Site: http://www.ChaNTLIVE.com
@ Released under GNU/GPL License: Free for noncommercial purposes
@ version $Revision: 1.0.1 $
*/
    
if (!defined('CHANT_KEY')) {
    
Header("Location: ../index.php");
    die();
}

ChaNT_widgets::run_widgets('OnSendDataStart');

if(!
session_is_registered('chant_username')) {
die(
"Session has expired");
}   
$_SESSION['chant_locked'] = "yes";        
if(
$_SESSION['chant_login'] != "OK" || !file_exists($chatdir."database/".trim($_SESSION['chant_channel']))) die("Access denied");

if(empty(
$_GLOBAL['text']) || !isset($_GLOBAL['user']) || ($_GLOBAL['user'] != $_SESSION['chant_username'])) die("Access denied");

header("Expires: Mon, 9 Apr 1999 09:09:09 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Last-Modified: ".gmdate("D, d M Y H:is")." GMT");
define("microtime"ChaNT::getmicrotime(1));

$private = (isset($_GLOBAL['private']) && ctype_alnum($_GLOBAL['private']) && strlen($_GLOBAL['private'])>2)?$_GLOBAL['private']:"no";
$color = (isset($_SESSION['chant_color']) && ctype_alnum($_SESSION['chant_color']))?$_SESSION['chant_color']:"green"
$cur_channel $chatdir."database/".trim($_SESSION['chant_channel']);
if(!
file_exists($cur_channel)) { $_SESSION['chant_locked'] = "no"; die(); }
$ignore_array = array();
if(!empty(
$_GLOBAL['ignore'])) $ignore_array explode("|"$_GLOBAL['ignore']);
require_once(
$chatdir."core/include/sanitizer.class.php");
$vanish = new HTML_Sanitizer;
    
//Fix big proglem, thanks xmaddy
//$text = str_replace("*", "+", $_GLOBAL['text']);  
$text = ($des == "enable")?ChaNT::des_crypt($_GLOBAL['text'], "dec"):trim($_GLOBAL['text']);  
$text base64_decode(str_replace("*""+"$text));
$text htmlspecialchars(strip_tags($vanish->sanitize($text)));
$text trim(urldecode(addslashes($text)));
//$text = chunk_split($text, 110, "<br />");
$text substr($text0350);
$pattern = array(                  
"/\:01\)/",
"/\:02\)/",  
"/\:03\)/",  
"/\:04\)/",  
"/\:05\)/",  
"/\:06\)/",  
"/\:07\)/",  
"/\:08\)/",  
"/\:09\)/",  
"/\:10\)/",  
"/\:01\]/",
"/\:02\]/",
"/\:03\]/",
"/\:04\]/",
"/\:05\]/",
"/\:06\]/",
"/\:07\]/",
"/\:08\]/",
"/\:09\]/",
"/\:10\]/",
"/((?:[a-z0-9_-]{2,20})(?:@)(?:[a-z0-9-]{2,20}\.[a-z]{2,4}))/i",           
"/\[color=([a-z]{1,10})\](.*)\[\/color\]/",
"/\[size=([1-7]{1})\](.*)\[\/size\]/"
"/\[QUOTE\](.*)\[\/QUOTE\]/"
"/\[B\](.*)\[\/B\]/"
"/\[I\](.*)\[\/I\]/",
"/\[U\](.*)\[\/U\]/"
);
$replace = array(           
"<img src=\"".$chaturl."skins/".$skin."/emo/01.gif\" onclick=\"ChaNT.setThis(':01)')\" alt=\":01)\" />",
"<img src=\"".$chaturl."skins/".$skin."/emo/02.gif\" onclick=\"ChaNT.setThis(':02)')\" alt=\":02)\" />",
"<img src=\"".$chaturl."skins/".$skin."/emo/03.gif\" onclick=\"ChaNT.setThis(':03)')\" alt=\":03)\" />",
"<img src=\"".$chaturl."skins/".$skin."/emo/04.gif\" onclick=\"ChaNT.setThis(':04)')\" alt=\":04)\" />",
"<img src=\"".$chaturl."skins/".$skin."/emo/05.gif\" onclick=\"ChaNT.setThis(':05)')\" alt=\":05)\" />",
"<img src=\"".$chaturl."skins/".$skin."/emo/06.gif\" onclick=\"ChaNT.setThis(':06)')\" alt=\":06)\" />",
"<img src=\"".$chaturl."skins/".$skin."/emo/07.gif\" onclick=\"ChaNT.setThis(':07)')\" alt=\":07)\" />",
"<img src=\"".$chaturl."skins/".$skin."/emo/08.gif\" onclick=\"ChaNT.setThis(':08)')\" alt=\":08)\" />",
"<img src=\"".$chaturl."skins/".$skin."/emo/09.gif\" onclick=\"ChaNT.setThis(':09)')\" alt=\":09)\" />",
"<img src=\"".$chaturl."skins/".$skin."/emo/10.gif\" onclick=\"ChaNT.setThis(':10)')\" alt=\":10)\" />",
"<img src=\"".$chaturl."images/xsmiles/36_1_01.gif\" onclick=\"ChaNT.setThis(':01]')\" alt=\":01]\" />",
"<img src=\"".$chaturl."images/xsmiles/36_1_02.gif\" onclick=\"ChaNT.setThis(':02]')\" alt=\":02]\" />",
"<img src=\"".$chaturl."images/xsmiles/36_1_03.gif\" onclick=\"ChaNT.setThis(':03]')\" alt=\":03]\" />",
"<img src=\"".$chaturl."images/xsmiles/36_1_04.gif\" onclick=\"ChaNT.setThis(':04]')\" alt=\":04]\" />",
"<img src=\"".$chaturl."images/xsmiles/36_1_05.gif\" onclick=\"ChaNT.setThis(':05]')\" alt=\":05]\" />",
"<img src=\"".$chaturl."images/xsmiles/36_1_06.gif\" onclick=\"ChaNT.setThis(':06]')\" alt=\":06]\" />",
"<img src=\"".$chaturl."images/xsmiles/36_1_07.gif\" onclick=\"ChaNT.setThis(':07]')\" alt=\":07]\" />",
"<img src=\"".$chaturl."images/xsmiles/36_1_08.gif\" onclick=\"ChaNT.setThis(':08]')\" alt=\":08]\" />",
"<img src=\"".$chaturl."images/xsmiles/36_1_09.gif\" onclick=\"ChaNT.setThis(':09]')\" alt=\":09]\" />",
"<img src=\"".$chaturl."images/xsmiles/36_1_10.gif\" onclick=\"ChaNT.setThis(':10]')\" alt=\":10]\" />",
"<i><a href=\"mailto:$1\">$1</a></i>",            
"<font color=\"$1\">$2</font>",
"<font size=\"$1\">$2</font>",
"<span class=\"quote\">$1</span>",
"<b>$1</b>",
"<i>$1</i>",
"<u>$1</u>"
);
if(
$irc == "enable") {
require_once(
$chatdir."core/libs/irc.lib.php");
$pattern[] = "/\/[\w]{2,10}/ie";
$replace[] = "irc_comm('\\0')";
}
ChaNT_widgets::run_widgets('OnSendData');
$text preg_replace($pattern$replace$text);
$text = (empty($irc_text))?$text:$irc_text;
if(
strlen($text) == 0) { $_SESSION['chant_locked'] = "no"; die(); }
$text "<span onclick=\"ChaNT.setThis('".$_GLOBAL['user'].":')\" style=\"color: ".trim($color)."; line-height: 190%\">".$_GLOBAL['user']."[".gmdate("h:ia"time() + (int) $timezone 3600)."]</span> : ".$text;
$text trim(microtime."|".$_SESSION['chant_username']."|".trim($private)."|".base64_encode(trim($text)."\n")); 
ChaNT::save_to_file($cur_channel$text."\n""a+");  
//
$file_db file($cur_channel);
foreach(
$file_db as $val$endtime ChaNT::parser($val);  
if(
count($file_db) > 100) {
if(
$archive == "enable") {  
include_once(
$chatdir."core/pclzip.lib.php");  
$archive = new PclZip($chatdir."logs/".gmdate("H-i_d-M-y_"time()+ (int) $timezone 3600).trim($_SESSION['chant_channel']).".zip");
$archive->add($cur_channelPCLZIP_OPT_REMOVE_ALL_PATH);
}  
ChaNT::save_to_file($cur_channeltrim($file_db[0])."\n""w+"); 
}
$_SESSION['chant_timestamp'] = $endtime;
$_SESSION['chant_locked'] = "no";        
ChaNT_widgets::run_widgets('OnSendDataEnd');
?>

and that is the database file

main.db.php

PHP Code:
|Main|public|<?die?>
i want to change (main) to any arabic word but it doesn`t appear

i think i gave u what u need if u want more go to the script site
ricolding is offline   Reply With Quote
Old 07-09-2012, 11:27 PM   PM User | #7
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,513
Thanks: 45
Thanked 439 Times in 428 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
It might be a charset problem - arabic may not be supported so you may need to look at using unicode / utf8.

I can't say much more than that really - the whole area is a minefield. I had to do a conversion to UTF8 on a website once.. it was a horrible task that took over a week to get right.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 07-09-2012, 11:29 PM   PM User | #8
ricolding
New Coder

 
Join Date: Jul 2012
Posts: 22
Thanks: 6
Thanked 0 Times in 0 Posts
ricolding is an unknown quantity at this point
Quote:
Originally Posted by tangoforce View Post
It might be a charset problem - arabic may not be supported so you may need to look at using unicode / utf8.

I can't say much more than that really - the whole area is a minefield. I had to do a conversion to UTF8 on a website once.. it was a horrible task that took over a week to get right.
u mean i convert the database file to utf-8

tried but fail

i want only to know when the login page import the name how could we set the charset !!
ricolding is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:46 AM.


Advertisement
Log in to turn off these ads.