09/10/2018, 17:51

[Q] Có ai giỏi lập trình PHP không, giúp tôi với nhé

Tôi là dân CNTT đấy, tôi rất thích ngôn ngữ lập trình web PHP. Tôi đã vào xem nhiều website viêt bằng PHP trông thật hấp dẫn. Vấn đề tôi rất băn khoăn là phần tìm kiến tên miền (Check Domain), ai có thể viết được code hoặc sưu tầm được chia xẻ giúp tôi với nhé, tôi cảm ơn rất nhiều. Mail của tôi là: Hieudtvn@vol.vnn.vn hoặc Hieudtvn@yahoo.com
bpmtri viết 20:04 ngày 09/10/2018
Vấn đề mà bạn cần tìm thường được gọi là Who Is. Bạn xem code mẫu này nhé.

PHP Code:
<?
/*
************************************************************************
* © Sloppycode.net All rights reserved.
*
* This is a standard copyright header for all source code appearing
* at sloppycode.net. This application/class/script may be redistributed,
* as long as the above copyright remains intact. 
* Comments to ***91;email***93;sloppycode@sloppycode.net***91;/email***93;
************************************************************************
*/

/*
 * Whois wrapper for most global TLDs
 * @author C.Small <chris@sloppycode.net>
 * @version 1.5 - Added PEAR style comments
 * @version 1.4 - Timeout and whois_server properties added.
 * @version 1.3 - Temporary fix for .name,.pro domains
 * @version 1.2 - Error catching for .tv domains
 * @version 1.1 - Converted to php
 * @version 1.0 - Perl version ***91;***91;url***93;http://www.sloppycode.net/sloppycode/Perl***91;/url***93;***91;CGI***93;/s29.html***93;
*/

class Whois
{
    /*
     * Optional parameter for the server to be used for the lookup.
     * If this is not set, an appropriate whois server for the domain name
     * specified is automagically found by the Whois class. 
     * @type string
     * @access public
     */
    var $whois_server;
    /*
     * The timeout, in seconds, for the lookup. Default is 30. 
     * @type integer
     * @access public
     */
    var $timeout = 30;

    /*
     * Returns a string, with new-lines (\n) converted to non-breaking spaces (<BR>),
     * with details for the domain specified by $domain. 
     * @access public
     * @param string $domain the domain to lookup, excluding ***91;url***93;http://***91;/url***93; and www
     * @return string the results of the whois
     */
    function lookup($domain)
    {
        $result = "";
        $parts  = array();
        $host   = "";
        
        // .tv don't allow access to their whois
        if (strstr($domain,".tv"))
        {
            $result = "'.tv' domain names require you to have an account to do whois searches.";
        // New domains fix (half work, half don't)
        } elseif (strstr($domain,".name") || strstr($domain,".pro") >0){
            $result = ".name,.pro require you to have an account to do whois searches.";
        } else{
            if (empty($this->whois_server))
            {
                $parts    = explode(".",$domain);
                $testhost = $parts***91;sizeof($parts)-1***93;;
                $whoisserver   = $testhost . ".whois-servers.net";
                $this->host     = gethostbyname($whoisserver);
                $this->host     = gethostbyaddr($this->host);
            
                if ($this->host == $testhost)
                {
                    $this->host = "whois.internic.net";
                }
                flush();
            }
            $whoisSocket = fsockopen($this->host,43, $errno, $errstr, $this->timeout);
            
            if ($whoisSocket)
            {
                fputs($whoisSocket, $domain."\015\012");
                while (!feof($whoisSocket))
                {
                    $result .= fgets($whoisSocket,128) . "<br>";
                }
                fclose($whoisSocket);
            }
        }
        return $result;
    }
}
?>
canhdonghoang viết 20:05 ngày 09/10/2018
Mình mới tập toẹ đọc PHP , muốn hỏi 1 tí xíu .

Làm thế nào để trên Forum có thể cài code HTML được ?
Mình có xem 2 file , 1 file cho hiển thị kết qủa dạng HTML , 1 file hiện nguyên Code , mà ko biết khác nhau ở đâu ?

Bạn nào biết mấu chốt của nó ở đâu nói cho mình nha , mình cảm ơn .
Hynohun viết 19:55 ngày 09/10/2018
"mấu chốt" là 1 file có replace cái tag > thành &gt; ( hay < thành &lt; ) nên hiển thị dưới dạng text, và cái kia thì không thay thế nên hiển thị dưới dạng HTML
canhdonghoang viết 20:03 ngày 09/10/2018
Bài viết được gửi bởi Darkbaron MX
"mấu chốt" là 1 file có replace cái tag > thành &gt; ( hay < thành &lt; ) nên hiển thị dưới dạng text, và cái kia thì không thay thế nên hiển thị dưới dạng HTML
Ừm , không có &gt; hay &lt; gì hết ấy :-(

Ý mình là : Cho phép User khi viết bài cài được Code HTML cơ , chứ ko phải người lập trình .

Hynohun viết 20:03 ngày 09/10/2018
khổ quá, thì bạn đừng replace ( hoặc bỏ chế độ replace ) thì sẽ hiển thị được HTML thôi
canhdonghoang viết 20:02 ngày 09/10/2018
Bài viết được gửi bởi Darkbaron MX
khổ quá, thì bạn đừng replace ( hoặc bỏ chế độ replace ) thì sẽ hiển thị được HTML thôi
Thì khổ quá đi chứ , cái file của mình nó ko phức tạp đến chế độ nọ kia đâu .

Cậu có thêm được gì vào đoạn thân chương trình này được ko ?
Cái chỗ Nội Dung đấy .
-------------------------------------------------------------------------

<FORM name=mainform method="POST" action="savemessage.php" enctype="multipart/form-data">
<TABLE align=center cellSpacing=0 cellPadding=0 width=782 border=0>
<TBODY>
<TR>
<TD>
<TABLE align=center cellSpacing=1 cellPadding=0 width="95%" bgColor=#668fc7 border=0>
<TBODY><TR><TD>
<TABLE align=center cellSpacing=1 cellPadding=0 width="100%" bgColor=#ffffff border=0>
<TBODY>
<TR>
<TD class=headerbar height=27>
Lời tỏ tình của Mùa Xuân </TD>
</TR>
<TR>
<TD class=cellForRecord align=left>
<TABLE align=center cellSpacing=4 cellPadding=0 width="600" border=0>
<TBODY>
<TR>
<TD class=textLabelBold align="right" width="98" valign="top"></TD>
<TD class=textlabel align=left width=380>
<INPUT name=switch onfocus=setTypingMode(0); type=radio value=OFF>Tên bài gửi <INPUT CHECKED name=switch onfocus=setTypingMode(1) type=radio value=TELEX>Ki***7875;u Telex
</TD>
</TR>
<TR>
<TD class=textLabelBold width=98>
Tên
</TD>
<TD width="484">
<input type="text" name="Author" size="28" maxLength="64" value="" onkeyup=telexingVietUC(this,event)>
<input type=hidden name=Type value=0>
</TD>
</TR>
<TR>
<TD class=textLabelBold width=98>
Mật Khẩu </TD>
<TD width="484">
<input type="password" name="Password" size="28" maxLength="64" value="">
</TD>
</TR>
<TR>
<TD class=textLabelBold width=98>
Mật Khẩu Chung:
</TD>
<TD width="484">
<input type="password" name="Security" size="28" maxLength="64" value="">
</TD>
</TR>
<TR>
<TD class=textLabelBold valign=top width=98>
<font color=red> Nội Dung :<BR>
</TD>
<TD width=484 colspan="2">
<textarea rows="12" name="Message" cols="50" onkeyup=telexingVietUC(this,event)></textarea></font>
</TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
<TR>
<TD class=footbar align="center">
<input class=footform type="button" value="G***432;***777;i" name="B1" onClick="Submit();">
<input class=footform type="button" value="Kh&ocirc;ng g***432;***777;i" name="B2" onClick="DontSubmit();">
<input class=footform type="reset" value="Reset" name="B3">
</TD>
</TR>
</TBODY>
</TABLE>
</TD></TR></TBODY>
</TABLE>
</TD>
</TR>
</TBODY>
</TABLE>
</FORM>
Hynohun viết 19:54 ngày 09/10/2018
hi`, không cần phải xem, đây chỉ là code HTML cho cái form, chẳng có việc gì phải làm với cái này đâu
bạn mở file PHP , mà có thu thập và sử lý data từ form này gửi đi, tức là savemessage.php ( theo cái code ở trên), kiếm đoạn code nào dạng dạng như vầy.
preg_replace("<","&lt;",strString);
preg_replace(">","&gt;",strString);

xóa luôn 2 cái đó đi
canhdonghoang viết 19:56 ngày 09/10/2018
Thôi, bạn giúp thì giúp cho chót đi , mình tìm ko ra .




Savemessage.php

--------------------------------------------------------------

<?
include("library.inc");
include("mysql.inc");

if (isset($HTTP_POST_VARS["Type"]))

$Type=$HTTP_POST_VARS["Type"];
if (isset($HTTP_POST_VARS["Author"]))

$Author=$HTTP_POST_VARS["Author"];
if (isset($HTTP_POST_VARS["Password"]))

$Password=$HTTP_POST_VARS["Password"];
if (isset($HTTP_POST_VARS["Security"]))

$Security=$HTTP_POST_VARS["Security"];
if (isset($HTTP_POST_VARS["Message"]))

$Message=$HTTP_POST_VARS["Message"];

if ($Security=="422")
{
$query="select Id from users where Name=\"$Author\"";
$ret=mysql_query($query);
//print($query);
if (mysql_num_rows($ret))
{
$query="select Id from users where

Name=\"$Author\" and Password=password(\"$Password\")";
$ret=mysql_query($query);
if (!($val=mysql_fetch_array($ret)))
{
Error("PasswordError");
}
$IdUser=$val["Id"];
}
else
{
$Id=0;
do
{
$Id+=1;
$query="select Id from users where

Id=$Id";
$ret=mysql_query($query);
} while (mysql_num_rows($ret));
$query="insert into users(Id,Name,Password)

values ($Id,\"$Author\",password(\"$Password\"))";
$ret=mysql_query($query);
$IdUser=$Id;
}

$datetime=date("Y-m-d H:i:s");
$query="update users set

DateTimeOfLastMessage=\"$datetime\"";
$ret=mysql_query($query);

//$Author=htmlspecialchars($Author);
//$Message=nl2br(htmlspecialchars($Message));
$Id=0;
do
{
$Id+=1;
$query="select Id from messages where Id=$Id";
$ret=mysql_query($query);
} while (mysql_num_rows($ret));

$query="insert into

messages(Id,Type,Author,DateTimeOfMessage,Message) values

($Id,$Type,\"$Author\",\"$datetime\",\"$Message\") ";
$ret=mysql_query($query);
mysql_close();
if ($ret)
{
if ($Type==0):
header("Location: forum.php");
else:
header("Location: index.php");
endif;
}
else
{
header("Location:

error.php?$errorid=SQLError");
}
}
else
{
Error("SecurityError");
}

?>
Hynohun viết 19:53 ngày 09/10/2018
nếu trong đây không có thì bạn xem trong các file mà hiển thị nội dung lên đó, ví dụ file showmessage.php, trong đó vẫn có thể dùng preg_replace.
Mình cũng chưa đọc cái code trên, buồn ngủ quá rồi, aooo,
mai xử lý nhé
Bài liên quan
0