hi
all i need to learn what does this mean (this style of writing)
may be is there another variant to write the code

<?
exit;}
if($_GET['step'] == "2"){
$name_db=$_POST['name_db']; 
$host_db=$_POST['host_db'];
$user_db=$_POST['user_db']; 
$password_db=$_POST['password_db']; 
$connect=mysql_connect($host_db,$user_db,$password_db);
mysql_query("create database $name_db");
$connect=mysql_pconnect($host_db,$user_db,$password_db);
mysql_select_db($name_db,$connect);
$sql1 = "create table `config` (
  `id` int(1) NOT NULL default '0',
  `admin` varchar(25) NOT NULL default '',
  `password` varchar(100) NOT NULL default '',
  `script_dir` varchar(10) NOT NULL default '',
  `am_news` int(2) NOT NULL default '0',
  `PreLengthC` int(5) NOT NULL default '0',
  `tab_width` varchar(5) NOT NULL default '',
  `p_time` int(1) NOT NULL default '0',
  `p_date` int(1) NOT NULL default '0',
  `img_dir` varchar(10) NOT NULL default '',
  `img_height` int(5) NOT NULL default '0',
  `c_top` int(1) NOT NULL default '0',
  `c_bottom` int(1) NOT NULL default '0',
  PRIMARY KEY  (`id`)
)";
mysql_query("$sql1");
$sql2 = "create table `news` (
  `news_id` int(11) NOT NULL auto_increment,
  `news_stamp` int(11) NOT NULL default '0',
  `news_time` varchar(5) NOT NULL default '00:00',
  `news_date` date NOT NULL default '0000-00-00',
  `news_title` text NOT NULL,
  `news_content` text NOT NULL,
  `news_img` char(1) default 'n',
  `news_exp` varchar(5) NOT NULL default '.jpg',
  PRIMARY KEY  (`news_id`)
)";
mysql_query("$sql2");
$config="<?\r\n".
"$"."name_db = \"".$name_db."\"; // name of Database \r\n". [B]here i dont understand of writing why ?[/B]
"$"."host_db = \"".$host_db."\"; // host r\n".here i dont understand of writing why ?
"$"."user_db = \"".$user_db."\"; // login \r\n".here i dont understand of writing why ?

"$"."password_db = \"".$password_db."\"; // password db \r\n".[COLOR]="Red"][B]here i dont understand of writing why ?[/B]
"$"."table_news = \"news\";\r\n\r\n".[B]here i dont understand of writing why ?[/B]
"$"."connect = mysql_connect (\$host_db, \$user_db, \$password_db);\r\n".[B]here i dont understand of writing why ?[/B]
"mysql_select_db (\$name_db, \$connect);\r\n".[B]here i dont understand of writing why ?[/B]

"$"."result = mysql_query(\"select * from `config` where (id = '-1')\","."$"."connect);\r\n".
"$"."row=mysql_fetch_array("."$"."result);\r\n".
"$"."admin = \$row['admin'];\r\n".here i dont understand of writing why ?

"$"."password = \$row['password'];\r\n". and so on
"$"."script_dir = \$row['script_dir'];\r\n".
"$"."am_news = \$row['am_news'];\r\n".
"$"."PreLengthC = \$row['PreLengthC'];\r\n".
"$"."tab_width = \$row['tab_width'];\r\n".
"$"."p_time = \$row['p_time'];\r\n".
"$"."p_date = \$row['p_date'];\r\n".
"$"."img_dir = \$row['img_dir'];\r\n".
"$"."img_height = \$row['img_height'];\r\n".
"$"."c_top = \$row['c_top'];\r\n".
"$"."c_bottom = \$row['c_bottom'];\r\n?>";
$fp=fopen("cpanel/lib.php","w");
flock ($fp,LOCK_EX);
fputs($fp,$config);
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
@chmod("cpanel/lib.php", 0755);
?>

Thanks beforehands

Recommended Answers

All 5 Replies

hi
all i need to learn what does this mean (this style of writing)
may be is there another variant to write the code

<?
exit;}
if($_GET['step'] == "2"){
$name_db=$_POST['name_db']; 
$host_db=$_POST['host_db'];
$user_db=$_POST['user_db']; 
$password_db=$_POST['password_db']; 
$connect=mysql_connect($host_db,$user_db,$password_db);
mysql_query("create database $name_db");
$connect=mysql_pconnect($host_db,$user_db,$password_db);
mysql_select_db($name_db,$connect);
$sql1 = "create table `config` (
  `id` int(1) NOT NULL default '0',
  `admin` varchar(25) NOT NULL default '',
  `password` varchar(100) NOT NULL default '',
  `script_dir` varchar(10) NOT NULL default '',
  `am_news` int(2) NOT NULL default '0',
  `PreLengthC` int(5) NOT NULL default '0',
  `tab_width` varchar(5) NOT NULL default '',
  `p_time` int(1) NOT NULL default '0',
  `p_date` int(1) NOT NULL default '0',
  `img_dir` varchar(10) NOT NULL default '',
  `img_height` int(5) NOT NULL default '0',
  `c_top` int(1) NOT NULL default '0',
  `c_bottom` int(1) NOT NULL default '0',
  PRIMARY KEY  (`id`)
)";
mysql_query("$sql1");
$sql2 = "create table `news` (
  `news_id` int(11) NOT NULL auto_increment,
  `news_stamp` int(11) NOT NULL default '0',
  `news_time` varchar(5) NOT NULL default '00:00',
  `news_date` date NOT NULL default '0000-00-00',
  `news_title` text NOT NULL,
  `news_content` text NOT NULL,
  `news_img` char(1) default 'n',
  `news_exp` varchar(5) NOT NULL default '.jpg',
  PRIMARY KEY  (`news_id`)
)";
mysql_query("$sql2");
$config="<?\r\n".
"$"."name_db = \"".$name_db."\"; // name of Database \r\n". [B]here i dont understand of writing why ?[/B]
"$"."host_db = \"".$host_db."\"; // host r\n".here i dont understand of writing why ?
"$"."user_db = \"".$user_db."\"; // login \r\n".here i dont understand of writing why ?

"$"."password_db = \"".$password_db."\"; // password db \r\n".[COLOR]="Red"][B]here i dont understand of writing why ?[/B]
"$"."table_news = \"news\";\r\n\r\n".[B]here i dont understand of writing why ?[/B]
"$"."connect = mysql_connect (\$host_db, \$user_db, \$password_db);\r\n".[B]here i dont understand of writing why ?[/B]
"mysql_select_db (\$name_db, \$connect);\r\n".[B]here i dont understand of writing why ?[/B]

"$"."result = mysql_query(\"select * from `config` where (id = '-1')\","."$"."connect);\r\n".
"$"."row=mysql_fetch_array("."$"."result);\r\n".
"$"."admin = \$row['admin'];\r\n".here i dont understand of writing why ?

"$"."password = \$row['password'];\r\n". and so on
"$"."script_dir = \$row['script_dir'];\r\n".
"$"."am_news = \$row['am_news'];\r\n".
"$"."PreLengthC = \$row['PreLengthC'];\r\n".
"$"."tab_width = \$row['tab_width'];\r\n".
"$"."p_time = \$row['p_time'];\r\n".
"$"."p_date = \$row['p_date'];\r\n".
"$"."img_dir = \$row['img_dir'];\r\n".
"$"."img_height = \$row['img_height'];\r\n".
"$"."c_top = \$row['c_top'];\r\n".
"$"."c_bottom = \$row['c_bottom'];\r\n?>";
$fp=fopen("cpanel/lib.php","w");
flock ($fp,LOCK_EX);
fputs($fp,$config);
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
@chmod("cpanel/lib.php", 0755);
?>

Thanks beforehands

You are going to have to be a little more specific about what you are thinking if you want a helpful answer. "here i dont understand of writing why ?" doesn't help me much.

thank you for attention
simply here the code what does mean i dont know

"$"."password = \$row['password'];\r\n".

it is not possible to write in that format

"$password = $row['password']\r\n".;

thank you for attention
simply here the code what does mean i dont know

"$"."password = \$row['password'];\r\n".

it is not possible to write in that format

"$password = $row['password']\r\n".;

no it's not... because you are printing between "". If you write the code the way you propose, what php will print is:

value_of_password = value_of_row\r\n

and what was really meant to write is:

$password = $row['password']\r\n

thank you for attention
simply here the code what does mean i dont know

"$"."password = \$row['password'];\r\n".

it is not possible to write in that format

"$password = $row['password']\r\n".;

OK, if I understand you correctly, you have a question about escaping characters. Here is some information in the manual about strings and if you look you will see a segment entitled "Escaping Characters". 90% of your escaped characters are going to fall in strings surrounded by double quotes because singled quoted strings don't recognize most escaped characters.

You escape characters like:
\" to show a double quote on the page
\$ to show a dollar sign on the page
\n is a new line in a text document
\' escape a single quote in a string surrounded by single quotes
etc... There are more on the page that I linked to if you follow the link. I didn't run the script and didn't spend much time studying it but it looks like this coder is planning to create a configuration file that he can parse at a later time which includes some variables and what not.

thanky you very much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.