Jump to content
php.lv forumi

Izvadot nosaukumu (!) pārāda kā ( !)


Linee

Recommended Posts

Sveiki... lieta sekojoša, 

 

ir skripts kas izvada topika nosaukumu no foruma... ja topika nosaukumā ir izsaukuma zīme... Skripts viņu pārvērš par un sākumalpā ataino kā ( ! )  

 

Kur varētu būt problēma ?

 

Paldies :)

Link to comment
Share on other sites


<html>

<meta http-equiv="content-type" content="text/html; charset=utf-8" />

<?php

 

$config->user_page = ''; ## Ievadi linku uz Profila atrašanās vietu

$config->noavatar_link = 'http://localhost/forum/public/style_images/master/profile/default_large.png'; ## ievadi linku uz no avatar atrašanās vietu

$config->forum_url = 'forum'; ## Ievadi linku uz foruma atrašanās vietu

$config->limit = '10'; ## Cik postus izvadam ?$config->tlimit = '20'; ## //cik daudz simboli driikst buut topika nosaukumaa

$config->topic_link = 'http://localhost/forum' ; ## Links uz topiku $size = 25; //cik daudz simboli driikst buut topika nosaukumaa

$config->mysql = (object)array(

'host' => 'localhost', ## Ievadi MYSQL datubāzes hostu

'user' => 'usr', ## Ievadi MYSQL datubāzes useri

'db' => 'usr', ## Ievadi MYSQL datubāzes db

'pw' => 'pw', ## Ievadi MYSQL datubāzes paroli

'prefix'=> ''

 

);

 

 

/** Beidzās skripta konfigurācija **/

 

$conn = @mysql_connect($config->mysql->host, $config->mysql->user, $config->mysql->pw) or die('<p>Neizdevās pieslēgties datubāzes lietotājam `' . $config->mysql->user . '`!</p>');

@mysql_select_db($config->mysql->db,$conn) or die('<p>Neizdevās pieslēgties datubāzei `' . $config->mysql->db . '`!</p>')

 

 

;

 

 

 

$query = mysql_query("

SELECT

LEFT(t.title,28) as ttitle,

t.tid as tid,

t.state as tstate,

t.posts as tposts ,

t.start_date as tstart_date,

t.last_poster_id as tlast_poster_id,

t.starter_name as tstarter_name,

t.last_poster_name as tlast_poster_name,

t.seo_first_name as tseo_first_name,

t.pinned as tpinned,

t.poll_state as tpoll_state,

t.title_seo as ttitle_seo,

t.seo_last_name as tseo_last_name,

t.views as tviews,

 

m.member_group_id as mmember_group_id,

m.posts as posts,

 

g.prefix AS group_ref,

g.suffix AS group_suf,

g.g_title AS gtitle,

 

a.pp_main_photo as pp_thumb_photo

 

FROM ".$config->mysql->prefix."topics t

LEFT JOIN ".$config->mysql->prefix." members m ON m.member_id = t.last_poster_id

LEFT JOIN ".$config->mysql->prefix."groups g ON g.g_id = m.member_group_id

LEFT JOIN ".$config->mysql->prefix."profile_portal a ON a.pp_member_id = m.member_id

GROUP BY t.tid

ORDER BY t.last_post DESC

 

LIMIT ".$config->limit."

") or die(mysql_error());

while($row = mysql_fetch_array($query)){

 

if(empty($row['pp_thumb_photo'])){

$avatar = $config->noavatar_link;

}else{

$avatar = $config->forum_url.'/uploads/'.$row['pp_thumb_photo'];

}

// *** ŠEIT VARI SĀKT SAVUS DIZAINBA PIELĀGOJUMS ;) ** //

?>

<!-- Izvadam pēdējā atbildētāja avataru -->

<div class="Forum">

 

<div class="Forumimg">

 

<img style="border-radius: 25%;margin-right:5px;float:left;width:30px;height:30px;padding:1px;border:1px solid #e5e5e5;" src="<?php echo $avatar;?>"width="30px;" height="30px;"></a>

</div>

<div class="ForumT">

 

 

<a style=" text-decoration: none;" href="/forum/index.php?/topic/<?php echo htmlspecialchars($row['tid']);?>-<?php echo htmlspecialchars($row['ttitle']);?>" class="tooltip" >

<span style="font-weight: bold;"><?php echo htmlspecialchars($row['ttitle']);?> ...</span><br />

<span style="font-size: 10px;">Komentāri: <?php echo htmlspecialchars($row['tposts']);?></span>

</a>

</div>

</div>

<?php

// **** ŠEIT BEIDSAS TAVI PIELAGOJUMI ****//

}

?>

</html>

Link to comment
Share on other sites

Izskatās, ka topika nosaukums tiek eskeipots divreiz. Tātad tas tiek eskeipots kaut kur, kur to nevajadzētu eskeipot, piemēram, insertojot datubāzē.

 

Edit: ok, redzot to kodu... enjoy 100 problems (bitches included).

Edited by jurchiks
Link to comment
Share on other sites

Izskatās, ka topika nosaukums tiek eskeipots divreiz. Tātad tas tiek eskeipots kaut kur, kur to nevajadzētu eskeipot, piemēram, insertojot datubāzē.

 

Edit: ok, redzot to kodu... enjoy 100 problems (bitches included).

Eniivei neko nesapratu :)

Link to comment
Share on other sites

Svarīgi kādā formā/veidā dati tiek ielikti datubāzē, ja tie jau vienreiz ir apstrādāti, tad otrreiz to darīt nevajag (rodas šādas "ķeskas").

 

 

Pagaidām (tā uz labu laimi) var ieteikt, tur kur ir:

 

<span style="font-weight: bold;"><?php echo htmlspecialchars($row['ttitle']);?> ...</span><br />

 

vienkārši izņemt to htmlspecialchars():

<span style="font-weight: bold;"><?php echo $row['ttitle'];?> ...</span><br />

 

 

 

 

 

 

 

 

Edit: ok, redzot to kodu... enjoy 100 problems (bitches included).

Sadaļa ir "Iesācējiem", ja nav ko jēdzīgu uzrakstīt, tad labāk to nedarīt vispār ..

Link to comment
Share on other sites

 

Svarīgi kādā formā/veidā dati tiek ielikti datubāzē, ja tie jau vienreiz ir apstrādāti, tad otrreiz to darīt nevajag (rodas šādas "ķeskas").

 

 

Pagaidām (tā uz labu laimi) var ieteikt, tur kur ir:

 

<span style="font-weight: bold;"><?php echo htmlspecialchars($row['ttitle']);?> ...</span><br />

 

vienkārši izņemt to htmlspecialchars():

 

<span style="font-weight: bold;"><?php echo $row['ttitle'];?> ...</span><br />

 

Liels tev paldies, viss izdevās..

 

Veram ciet sadaļu

Link to comment
Share on other sites

@Roze - tā bija piebilde, nekasies! Fakts kā tāds, tas kods ir švaks, un tas, ka dati tiek apstrādāti ar htmlspecialchars(), ievadot datubāzē, ir absolūti nepareizi.

 

 

Roze ieraksta piebildi - tā uzreiz ir kasīšanās. Tu ieraksti uzbraucienu - tā ir tikai piebilde. Nu tu cirvis! 

Link to comment
Share on other sites

dati tiek apstrādāti ar htmlspecialchars(), ievadot datubāzē, ir absolūti nepareizi

 

IPB 1 postus sakumpilēja un pie editošanas atkumpilēja. Nekad neesmu sapratis, vai tā bija "optimizācija" uz output ģenerāciju vai arī līkrocīga XSS prevencija.

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...