News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

SMFSeo : Subject In Links Finished But

Started by SAFAD, September 21, 2009, 03:06:33 PM

Previous topic - Next topic

SAFAD

Hi All
I Really Would Like Sepcific Someone
Arnator
I Don't Know
He Just Likes Me Or Likes My Topics :)
Always Here With Me
Never Let Me Down *Not Never But Most x) *
Ok
After This Thx Card
I Know You Remeber That Topic About Subject In Urls
i find where is the log
made a very heavy fixs on
and know
the white page dispear
BUT
It Just Doesn't Work

Even If I Activate SEO URls From Admin Panel
Nothing
I Should Be Shame That *My* Code Doesn't Work Cuz Nothing  O:)

SO
QueryString.php

Rewrite URLs to include the session ID.
function 
ob_sessrewrite($buffer)
{
   global 
$scripturl$modSettings$user_info$context$mysql_prefix$boardurl;
   
   
$bufferold $buffer;
   
// If $scripturl is set to nothing, or the SID is not defined (SSI?) just quit.
   
if ($scripturl == '' || !defined('SID'))
      return 
$buffer;



   
// SMFSEO - Let's get some URL's to rewrite!
   
$boardcount preg_match_all('/"' preg_quote($scripturl'/') . '\?board=([^#";.]+).*?"/e'$bufferold$testboardsPREG_PATTERN_ORDER);

   
$topiccount preg_match_all('/"' preg_quote($scripturl'/') . '\?topic=([^#";.]+).*?"/e'$bufferold$testtopicsPREG_PATTERN_ORDER);

   if(isset(
$testboards)) { $testboards array_unique($testboards[1]); }
   if(isset(
$testtopics)) { $testtopics array_unique($testtopics[1]); }

   
// Ooops. We need to get rid of any non-numbers here.
   
foreach ($testtopics as $index => $bufferue) {
       if (!
is_numeric($bufferue)) unset($testtopics[$index]);
   }
   foreach (
$testboards as $index => $bufferue) {
       if (!
is_numeric($bufferue)) unset($testboards[$index]);
   }
      
   if (
count($testtopics) < 0) {
      
      
$temptopics implode(","$testtopics);
      
      
// Find the topic text for the temptopics.
      
$cnsql="    SELECT t.ID_TOPIC AS ID_TOPIC, t.ID_BOARD AS ID_BOARD, t.subject AS topic_text, b.name AS board_text
                FROM "
.$mysql_prefix."messages AS t, ".$mysql_prefix."boards AS b
                WHERE t.ID_BOARD = b.ID_BOARD
                AND t.ID_TOPIC
                IN ("
.$temptopics.")";
      
$request mysql_query($cnsql);
      
      if (
mysql_num_rows($request) == 0)  { return; }
      
      while (
$row mysql_fetch_assoc($request))
      {
         
$topic_id_array[] = $row['ID_TOPIC'];
         
$topic_text_array[] = $row['subject'];
         
$board_text_array[] = $row['name'];
      }
      
mysql_free_result($request);
      
      for (
$i 0$n count($topic_id_array); $i $n$i++)
      {
         
// the topic urls
         
$topicfromcache[] = '"' preg_quote($scripturl'/') . '\?topic=(' preg_quote($topic_id_array[$i], '/') . ')\.((?:from|msg|new|)[0-9]*).*?"';
         
         
            
$topictocache[] = $boardurl.'/'.$board_text_array[$i].'/'.$topic_text_array[$i].'.$2.html';
         

      }
         
      
$buffer preg_replace($topicfromcache$topictocache$buffer);
   }
   
   
$board_id_array null;
   
$board_text_array null;
   
   if (
count($testboards) < 0) {
      
      
$tempboards implode(","$testboards);
      
      
// Find the board text for the tempboards.
      
$cnsql="     SELECT ID_BOARD, name
                FROM "
.$mysql_prefix."boards
                WHERE ID_BOARD
                IN ("
.$tempboards.")";
      
$request mysql_query($cnsql__FILE____LINE__);
      
      if (
mysql_num_rows($request) == 0) { return; }
   
      while (
$row mysql_fetch_assoc($request))
      {
         
$board_id_array[] = $row['ID_BOARD'];
         
$board_text_array[] = $row['name'];
      }
      
mysql_free_result($request);
      
      for (
$i 0$n count($board_id_array); $i $n$i++)
      {
         
// the normal board URLs
         
$boardfromcache[] = '"' preg_quote($scripturl'/') . '\?board=(' preg_quote($board_id_array[$i], '/') . ')\.([0-9]*).*?"';
   
         
            
$boardtocache[] = $boardurl.'/'.$board_text_array[$i].'/index.$2.html';
         
         
         
// those pesky ;sort=([a-zA-Z]+);start=(\d)* type urls
         
$boardfromcache2[] = '"' preg_quote($scripturl'/') . '\?board=(' preg_quote($board_id_array[$i], '/') . ')(;sort=[a-zA-Z]*);start=([0-9]*).*?"';
   
         
            
$boardtocache2[] = $boardurl.'/'.$board_text_array[$i].'/index.$3.html$2';
         
         
      }
         
      
$buffer preg_replace($boardfromcache$boardtocache$buffer);
      
$buffer preg_replace($boardfromcache2$boardtocache2$buffer);
   }
   

   
   
// Return the changed buffer.
   
return $buffer;
   
// Chris Nolan - SMFSEO - End
}


News.php


// Rewrite URLs to include the session ID.
function fix_possible_url($val)
{
   global 
$scripturl$modSettings$user_info$context$mysql_prefix$boardurl;
   
 
$valold $val;
   
// If $scripturl is set to nothing, or the SID is not defined (SSI?) just quit.
   
if ($scripturl == '' || !defined('SID'))
      return 
$val;



   
// SMFSEO - Let's get some URL's to rewrite!
   
$boardcount preg_match_all('/"' preg_quote($scripturl'/') . '\?board=([^#";.]+).*?"/e'$valold$testboardsPREG_PATTERN_ORDER);

   
$topiccount preg_match_all('/"' preg_quote($scripturl'/') . '\?topic=([^#";.]+).*?"/e'$valold$testtopicsPREG_PATTERN_ORDER);

   if(isset(
$testboards)) { $testboards array_unique($testboards[1]); }
   if(isset(
$testtopics)) { $testtopics array_unique($testtopics[1]); }

   
// Ooops. We need to get rid of any non-numbers here.
   
foreach ($testtopics as $index => $value) {
       if (!
is_numeric($value)) unset($testtopics[$index]);
   }
   foreach (
$testboards as $index => $value) {
       if (!
is_numeric($value)) unset($testboards[$index]);
   }
      
   if (
count($testtopics) < 0) {
      
      
$temptopics implode(","$testtopics);
      
      
// Find the topic text for the temptopics.
      
$cnsql="    SELECT t.ID_TOPIC AS ID_TOPIC, t.ID_BOARD AS ID_BOARD, t.subject AS topic_text, b.name AS board_text
                FROM "
.$mysql_prefix."messages AS t, ".$mysql_prefix."boards AS b
                WHERE t.ID_BOARD = b.ID_BOARD
                AND t.ID_TOPIC
                IN ("
.$temptopics.")";
      
$request mysql_query($cnsql);
      
      if (
mysql_num_rows($request) == 0)  { return; }
      
      while (
$row mysql_fetch_assoc($request))
      {
         
$topic_id_array[] = $row['ID_TOPIC'];
         
$topic_text_array[] = $row['subject'];
         
$board_text_array[] = $row['name'];
      }
      
mysql_free_result($request);
      
      for (
$i 0$n count($topic_id_array); $i $n$i++)
      {
         
// the topic urls
         
$topicfromcache[] = '"' preg_quote($scripturl'/') . '\?topic=(' preg_quote($topic_id_array[$i], '/') . ')\.((?:from|msg|new|)[0-9]*).*?"';
         
         
            
$topictocache[] = $boardurl.'/'.$board_text_array[$i].'/'.$topic_text_array[$i].'.$2.html';
         

      }
         
      
$val preg_replace($topicfromcache$topictocache$val);
   }
   
   
$board_id_array null;
   
$board_text_array null;
   
   if (
count($testboards) < 0) {
      
      
$tempboards implode(","$testboards);
      
      
// Find the board text for the tempboards.
      
$cnsql="     SELECT ID_BOARD, name
                FROM "
.$mysql_prefix."boards
                WHERE ID_BOARD
                IN ("
.$tempboards.")";
      
$request mysql_query($cnsql__FILE____LINE__);
      
      if (
mysql_num_rows($request) == 0) { return; }
   
      while (
$row mysql_fetch_assoc($request))
      {
         
$board_id_array[] = $row['ID_BOARD'];
         
$board_text_array[] = $row['name'];
      }
      
mysql_free_result($request);
      
      for (
$i 0$n count($board_id_array); $i $n$i++)
      {
         
// the normal board URLs
         
$boardfromcache[] = '"' preg_quote($scripturl'/') . '\?board=(' preg_quote($board_id_array[$i], '/') . ')\.([0-9]*).*?"';
   
         
            
$boardtocache[] = $boardurl.'/'.$board_text_array[$i].'/index.$2.html';
         
         
         
// those pesky ;sort=([a-zA-Z]+);start=(\d)* type urls
         
$boardfromcache2[] = '"' preg_quote($scripturl'/') . '\?board=(' preg_quote($board_id_array[$i], '/') . ')(;sort=[a-zA-Z]*);start=([0-9]*).*?"';
   
         
            
$boardtocache2[] = $boardurl.'/'.$board_text_array[$i].'/index.$3.html$2';
         
         
      }
         
      
$val preg_replace($boardfromcache$boardtocache$val);
      
$val preg_replace($boardfromcache2$boardtocache2$val);
   }
   

   
   
// Return the changed val.
   
return $val;
   
// Chris Nolan - SMFSEO - End
}


My Best Regards
Best Regards
Sadaoui "SAFAD" Abderrahim - Lead Developer @ Electron Inc.

SAFAD

What A Dumb
Am The Dumbest

if (count($testboards) < 0) {

And

if (count($testtopics) < 0) {

Should Be Inverted

But

2: mysql_num_rows(): supplied argument is not a valid MySQL result resource
file : html/moded/Sources/QueryString.php
line : 545

Nothing Where Wrong
The Query Worx Great In PhpmyAdmin

whats wrong ??

O The Line 545 Is

if (mysql_num_rows($request) == 0) { return; }

what to do ?
Best Regards
Sadaoui "SAFAD" Abderrahim - Lead Developer @ Electron Inc.

Arantor

Don't use mysql_query.

Use db_query.

This will fix the issue where $request isn't being set correctly.

SAFAD

smcfunc you mean right ?
lets give it a try
Best Regards
Sadaoui "SAFAD" Abderrahim - Lead Developer @ Electron Inc.

Arantor

That code is suited to 1.1, so I assumed that's what you wanted. Yes, in 2.0 it should be $smcFunc['db_query'].

SAFAD

so if i do

$smcFunc['db_query']('', 'SELECT t.ID_TOPIC AS ID_TOPIC, t.ID_BOARD AS ID_BOARD, t.subject AS topic_text, b.name AS board_text
            FROM ".$mysql_prefix."messages AS t, ".$mysql_prefix."boards AS b
            WHERE t.ID_BOARD = b.ID_BOARD
            AND t.ID_TOPIC
            IN (".$temptopics.")')
will it work ??
Best Regards
Sadaoui "SAFAD" Abderrahim - Lead Developer @ Electron Inc.

Arantor

No.

1. Remove: $temptopics = implode(",", $testtopics);

Try:
$variable = $smcFunc['db_query']('', '
    SELECT t.id_topic AS ID_TOPIC, t.id_board AS ID_BOARD, t.subject AS topic_text, b.name AS board_text
    FROM {db_prefix}messages t
    INNER JOIN {db_prefix}boards b ON t.id_board = b.id_board
    WHERE t.id_topic IN ({array_int:topiclist})',
  array(
    'topiclist' => $testtopics,
  )
);

SAFAD

OK
now

I Add SmcFunc As Global
But
Undefined index: db_query
Best Regards
Sadaoui "SAFAD" Abderrahim - Lead Developer @ Electron Inc.

Arantor

So where is this code going? If you've declared $smcFunc as global, you're trying to use it before it's declared.

SAFAD

i tried
but nothing
he says smcfunc is undefind
Best Regards
Sadaoui "SAFAD" Abderrahim - Lead Developer @ Electron Inc.

Arantor

So, again, where are you using this code?

SAFAD

here
$request = $smcFunc['db_query']('', '
Best Regards
Sadaoui "SAFAD" Abderrahim - Lead Developer @ Electron Inc.

Arantor

You've misunderstood my question.

Where in the rest of SMF is that call being made? Where have you added this block of code?

If, say, you put it at the start of index.php, it'll be before $smcFunc is defined. So, thus, where is it being added?

SAFAD

ooooooooooooooooooo
mmmmmmmmmmmm
@the end

function ob_sessrewrite($buffer)
{
   global $scripturl, $modSettings, $user_info, $context, $mysql_prefix, $boardurl, $smcFunc;

Best Regards
Sadaoui "SAFAD" Abderrahim - Lead Developer @ Electron Inc.

Arantor

I don't see why you're calling it there. Are you putting your code after that function or something (in which case it'll load the moment Load.php is loaded)

SAFAD

OMG
Bro
You Saw The Code
iTs Up There
I Used SmcFunc but Didn't Work
Best Regards
Sadaoui "SAFAD" Abderrahim - Lead Developer @ Electron Inc.

Arantor

Please attach the file you've added this code into so I can see exactly where you've added it and the entire process flow around it.

SAFAD

Best Regards
Sadaoui "SAFAD" Abderrahim - Lead Developer @ Electron Inc.

Arantor

And what page did you browse to when you triggered that error?

SAFAD

Best Regards
Sadaoui "SAFAD" Abderrahim - Lead Developer @ Electron Inc.

Advertisement: