Welcome to Geeklog, Anonymous Thursday, November 28 2024 @ 01:38 pm EST

Geeklog Forums

Removing backslashes after apostrophes (in Geekbook)


Status: offline

jadiepoo

Forum User
Chatty
Registered: 01/11/03
Posts: 43
How do you remove backslashes which are entered in a comment form? I'm using the GeekBook plugin.

I tried including COM_stripslashes() in the index.php but it spat out errors and I know that lib-common is referred to by the plugin(I'm not a PHP coder).

Here's the GeekBook in action and here's my PHPInfo in case it might help.

I don't have problems with backslashes (since most of them have been addressed and fixed already in the upgrades) in any other part of geeklog so I think this is just a GeekBook bug.

Any help will be appreciated, thanks!

 Quote

Anonymous

Anonymous
You want to use addslashes() not srtipslashes() when inserting data.

Here's a nifty program Blaine wrote to test for magic_quotes and the use of addslashes().

Text Formatted Code

<?php

/* Program to test SQL inserts and handling of magic_quotes_gpc
*  Blaine Lang
*  Feb 26,2002

The SQL to create the test table is:
CREATE TABLE magictest (
  id mediumint(8) NOT NULL auto_increment,
  text varchar(254) NOT NULL default '',
  PRIMARY KEY  (id)
) TYPE=MyISAM;

*/


require_once('lib-common.php');
$_TABLES['magictest']          = 'magictest';

echo "This is a program for testing magic_quotes and database inserts of quotes";
if(get_magic_quotes_gpc() ) {
    echo "<br>Currently magic_quotes_gpc is set to be on";
} else {
    echo "<br>Currently magic_quotes_gpc is set to be off";
}

if ($HTTP_POST_VARS['test'] == "") {
echo '<form action="' .$_PHP_SELF. '" method="post">';
echo '<table border="0" cellspacing="0" cellpadding="3">';
echo '<tr><td>Enter test content:</td>';
echo '<td><input type="text" size="32" maxlength="128" name="test"></td>';
echo '</tr></table></form>';

} else {
echo "<p>Saving <b>{$HTTP_POST_VARS['test']}</b> as a new record ...";
if(!get_magic_quotes_gpc() ) {
    echo "<br>magic_quotes_gpc is off - using addslashes()";
    $test = addslashes($HTTP_POST_VARS['test']);
} else {
    $test = $HTTP_POST_VARS['test'];
}
DB_query("INSERT INTO {$_TABLES['magictest']} (text) VALUES ('$test')");
echo '<br><b>Record saved ok.</b>';
}
?>
 
 Quote

Status: offline

squatty

Forum User
Full Member
Registered: 01/21/02
Posts: 269
Opps..I mis-read your post. Can you site an example of how you are calling COM_stripslashes? ---Danny @ squatty.com
In a world without walls and fences, who needs Windows and Gates?
 Quote

Status: offline

jadiepoo

Forum User
Chatty
Registered: 01/11/03
Posts: 43
I know magic_quotes is set to on from my phpinfo (and the function refers to it, so I checked). I tried including stripslashes as my last pathetic attempt to try to fix this myself since I'm not a coder.

THis is the beginning of my index.php:

Text Formatted Code
include('gbfunctions.php');
$sitename = $_CONF['site_name'];

$result=mysql_query("SELECT name, date, email, comment, yahoo, aolim, icq, msn FROM geekbook");
$entriesperpage = 10;
$results = mysql_query("SELECT * FROM geekbook");
$endresult = mysql_num_rows($results);
//To protect entry number validation
$checkendresult = $endresult+1;

if ( $from == "" && $limit == "") {
  $from = 0;
  $limit = $entriesperpage;
  $page = 1;
}

$result = mysql_query("SELECT * FROM geekbook order by id DESC limit $from, $limit",$db);


$display .= COM_siteHeader();
 
I added:
Text Formatted Code

$display .= COM_stripslashes();
 
just below siteHeader inclusion.

The first line in the function in lib-common is

Text Formatted Code
function COM_stripslashes( $text )
. I'm sure something goes in between the parenthesis in the stripslashes function I included, but don't know what Frown

Again, I'm not a coder and just tried a logical fix. I removed the line once I saw it didn't work.
Just to clarify, if I type "I can't and won't" in the geekbook, it displays "I can't and won't"

Thanks for replying btw Big Grin

 Quote

Status: offline

jadiepoo

Forum User
Chatty
Registered: 01/11/03
Posts: 43
Ack, I reread my story and my bad, my problem isn't very clear. The backslashes appear after typing in apostrophes.

My above post had an example of what error I'm getting but it didn't display how it should've had.

It should've been:
If I typed out "I couldn't and shouldn't and wouldn't" it'll echo out

Text Formatted Code
"I couldn't and shouldn't and wouldn't"
 Quote

Status: offline

jadiepoo

Forum User
Chatty
Registered: 01/11/03
Posts: 43
great, it didn't include the backslashes again Frown "It\'s like it wouldn\'t cooperate" Hope this shows it like it is
 Quote

Status: offline

squatty

Forum User
Full Member
Registered: 01/21/02
Posts: 269
You need to feed the ouput to the COM_stripslashes() function. For example: $display .= COM_stripslashes($results); I can't tell from the snip that you provided what the correct output variable is? ---Danny @ squatty.com
In a world without walls and fences, who needs Windows and Gates?
 Quote

Status: offline

jadiepoo

Forum User
Chatty
Registered: 01/11/03
Posts: 43
thanks a gazillion for trying to help Big Grin

Unfortunately, that didn't work Frown I tried $result as well but no cigar

Here's the index. Here are some other files that I think might need the stripslashes:
gbfunctions - it refers to the lib-common, geekbadd and gkaddentry.

Is there a documentation on how a static page has stripslashes implemented? I think geekbook is derived/used static pages.

Again, thanks a bunch!

 Quote

All times are EST. The time is now 01:38 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content