vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   misc bits-o-code y'all might enjoy... (https://vborg.vbsupport.ru/showthread.php?t=6200)

01-01-2001 10:42 PM

first of all my 'beginning' code might be a bit different, my board is really hacked up. anyways,...

to get a 'Next Page >' button in your multi-page threads, so people dont need to remember what page they're on:
in showthread.php replace
Code:

  while ($curpage++<$totalpages) {

    if (($curpage<$pagenumber-$pagenavpages or $curpage>$pagenumber+$pagenavpages) and $pagenavpages!=0) {
      if ($curpage==1) {
        $pagenav.=" <a href=\"showthread.php?threadid=$threadid&pagenumber=$curpage".iif($perpage==$maxposts,"","&perpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>&lt;&lt; First Page</font></a>&nbsp;&nbsp; ...&nbsp;&nbsp;";
      }
      if ($curpage==$totalpages) {
        $pagenav.=" ...&nbsp;&nbsp;<a href=\"showthread.php?threadid=$threadid&pagenumber=$curpage".iif($perpage==$maxposts,"","&perpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>Last Page &gt;&gt;</font></a>&nbsp;&nbsp;";
      }
    } else {
      if ($curpage==$pagenumber) {
        $pagenav.=" <font color=\"#afa3c5\" class=thtcolor>$curpage</font>&nbsp;&nbsp;";
      } else {
        $pagenav.=" <a href=\"showthread.php?threadid=$threadid&pagenumber=$curpage".iif($perpage==$maxposts,"","&perpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>$curpage</font></a>&nbsp;&nbsp;";
      }
    }
  }
} else {

with
Code:

  while ($curpage++<$totalpages) {

    if (($curpage<$pagenumber-$pagenavpages or $curpage>$pagenumber+$pagenavpages) and $pagenavpages!=0) {
      if ($curpage==1) {
        $pagenav.=" <a href=\"showthread.php?threadid=$threadid&pagenumber=$curpage".iif($perpage==$maxposts,"","&perpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>&lt;&lt; First Page</font></a>&nbsp;&nbsp; ...&nbsp;&nbsp;";
      }
      if ($curpage==$totalpages) {
                $twrat_nextpage = ($pagenumber)+1;
        $pagenav.=" ...&nbsp;&nbsp; <a href=\"showthread.php?threadid=$threadid&pagenumber=$twrat_nextpage".iif($perpage==$maxposts,"","&perpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>Next Page &gt;</font></a>&nbsp;&nbsp;<a href=\"showthread.php?threadid=$threadid&pagenumber=$curpage".iif($perpage==$maxposts,"","&perpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>Last Page &gt;&gt;</font></a>&nbsp;&nbsp;";
      }
    } else {
      if ($curpage==$pagenumber) {
        $pagenav.=" <font color=\"#afa3c5\" class=thtcolor>$curpage</font>&nbsp;&nbsp;";
      } else {
        $pagenav.=" <a href=\"showthread.php?threadid=$threadid&pagenumber=$curpage".iif($perpage==$maxposts,"","&perpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>$curpage</font></a>&nbsp;&nbsp;";
      }
    }
  }
$twrat_nextpage = ($pagenumber)+1;
$pagenav.="&nbsp;&nbsp; <a href=\"showthread.php?threadid=$threadid&pagenumber=$twrat_nextpage".iif($perpage==$maxposts,"","&perpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>Next Page &gt;</font></a>&nbsp;&nbsp;";

} else {

excuse the weird var names, i prefix my stuff generally w/ tw_ or twrat_ so i can find it easier before i go back and comment it :D

to make your template.php create instantly useable templates from the form (instead of having to go into global.php and register them) open /admin/template.php and find

Code:

  $DB_site->query("INSERT INTO template (templateid,title,template) VALUES (NULL,'".addslashes("$title")."','".addslashes("$template")."')");
under it add

Code:

# added template code
# echo "title is $title <br>"; # debugging
$filename = "rattemp.php";
$str = '<?php eval("\$';
$str .= $title;
$str .= ' = \"".gettemplate("';
$str .= $title;
$str .= '")."\";"); ?>';
$fp=fopen($filename, 'a+');
fwrite($fp,"$str \n");
fclose($fp);

# end

then open up global.php and find
Code:

eval("\$fivelinks = \"".gettemplate("fivelinks")."\";");
and under it add
Code:

require ("admin/rattemp.php");
now create an empty file called /admin/rattemp.php and upload it, make sure its CHMOD-ed to 666, and you're set. also note if you delete custom templates, this wont remove the reference from the rattemp.php file, you'll have to do that manually, but i did this for my design guy who isnt really one to go trekking through code when he wants to make a template :)

anyways, thats all stuff ive been meaning to do for 3 months and never got around to it, so i figured maybe i'd share it :o

also im not really a mega-php programmer, my bag is perl, so if you find my code is weird (or just plain bad) thats why :)

[Edited by Ratorasniki on 01-01-2001 at 07:45 PM]

01-01-2001 10:53 PM

my bad, old ver. to get the next button replace it with

Code:

  while ($curpage++<$totalpages) {

    if (($curpage<$pagenumber-$pagenavpages or $curpage>$pagenumber+$pagenavpages) and $pagenavpages!=0) {
      if ($curpage==1) {
        $pagenav.=" <a href=\"showthread.php?threadid=$threadid&pagenumber=$curpage".iif($perpage==$maxposts,"","&perpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>&lt;&lt; First Page</font></a>&nbsp;&nbsp; ...&nbsp;&nbsp;";
      }
      if ($curpage==$totalpages) {
        $pagenav.=" ...&nbsp;&nbsp;<a href=\"showthread.php?threadid=$threadid&pagenumber=$curpage".iif($perpage==$maxposts,"","&perpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>Last Page &gt;&gt;</font></a>&nbsp;&nbsp;";
      }
    } else {
      if ($curpage==$pagenumber) {
        $pagenav.=" <font color=\"#afa3c5\" class=thtcolor>$curpage</font>&nbsp;&nbsp;";
      } else {
        $pagenav.=" <a href=\"showthread.php?threadid=$threadid&pagenumber=$curpage".iif($perpage==$maxposts,"","&perpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>$curpage</font></a>&nbsp;&nbsp;";
      }
    }
  }
$twrat_nextpage = ($pagenumber)+1;
      if ($pagenumber != $totalpages) {
        $pagenav.="&nbsp;&nbsp; <a href=\"showthread.php?threadid=$threadid&pagenumber=$twrat_nextpage".iif($perpage==$maxposts,"","&perpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>Next Page &gt;</font></a>&nbsp;&nbsp;"; }

} else {

sorry if anyone stuck that in already, it'd actually let you keep going to say, page 4 of a 3 page thread. it looks kinda dorky :)

01-02-2001 11:02 AM

thanks for the code, it workes perfectly, but can you add previous page to the hack?

01-02-2001 12:46 PM

Quote:

Originally posted by Scaramanga_gold
thanks for the code, it workes perfectly, but can you add previous page to the hack?
Changing the above code to:
Code:

$twrat_prevpage = ($pagenumber)-1;
$twrat_nextpage = ($pagenumber)+1;
if ($pagenumber != $totalpages) {
  $pagenav="<a href=\"showthread.php?threadid=$threadid&pagenumber=$twrat_prevpage".iif($perpage==$maxposts,"","&perpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>Next Page &gt;</font></a>&nbsp;&nbsp;".$pagenav;
  $pagenav.="&nbsp;&nbsp;<a href=\"showthread.php?threadid=$threadid&pagenumber=$twrat_nextpage".iif($perpage==$maxposts,"","&perpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>Next Page &gt;</font></a>&nbsp;&nbsp;";
  }

Should work.

01-02-2001 03:32 PM

not exactly,
first of all you didnt change it to perivous page (so both of them are "next page",
and second,
the previos text shows before "This thread is X pages long:".
please fix that.

01-02-2001 03:40 PM

Code:

$twrat_prevpage = ($pagenumber)-1;
$twrat_nextpage = ($pagenumber)+1;
if ($pagenumber != 1) {
  $pagenav.="<a href=\"showthread.php?threadid=$threadid&pagenumber=$twrat_prevpage".iif($perpage==$maxposts,"","&perpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>Previous Page &gt;</font></a>&nbsp;&nbsp;";
}
if ($pagenumber != $totalpages) {
  $pagenav.="&nbsp;&nbsp;<a href=\"showthread.php?threadid=$threadid&pagenumber=$twrat_nextpage".iif($perpage==$maxposts,"","&perpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>Next Page &gt;</font></a>&nbsp;&nbsp;";
  }


01-02-2001 03:52 PM

that is not what i wanted, what I want is something like this:
< Previous Page 1 2 3 Next Page >

now it is:

1 2 3 Previous Page > Next Page >

01-02-2001 05:39 PM

Why don't you look at the code a little and fix it.

Sorry but while I try to help, I am not at your beck and call and my time is precious. The next time you need help, why don't you ask a little more kindly and without the demanding tone?

01-02-2001 05:53 PM

sorry if i didnt ask kindly, I really aprreciate your work.
I know nothing about php but ill try.
thanks anyway.
well maybe just one more thing,
can you tell me how to use this "<" char?

[Edited by Scaramanga_gold on 01-02-2001 at 02:57 PM]

01-02-2001 06:10 PM

If you look at the source of this page you will see that you need to use "&lt;"

01-02-2001 06:18 PM

thanks freddie!

01-02-2001 08:09 PM

Code:

$twrat_prevpage = ($pagenumber)-1;
$twrat_nextpage = ($pagenumber)+1;
if ($pagenumber != 1) {
  $pagenav.="<a href=\"showthread.php?threadid=$threadid&pagenumber=$twrat_prevpage".iif($perpage==$maxposts,"","&perpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>&lt; Previous Page &gt;</font></a>&nbsp;&nbsp;";
}
if ($pagenumber != $totalpages) {
  $pagenav.="&nbsp;&nbsp;<a href=\"showthread.php?threadid=$threadid&pagenumber=$twrat_nextpage".iif($perpage==$maxposts,"","&perpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>Next Page &gt; &gt;</font></a>&nbsp;&nbsp;";
}

put that between:

eval("\$pagenav = \"".gettemplate("showthread_numpages")."\";");

and

$curpage=0;
while ($curpage++<$totalpages) {

01-03-2001 03:43 AM

you were close but I already find it out..
the full code should be:
Quote:

eval("\$pagenav = \"".gettemplate("showthread_numpages")."\";");
$twrat_prevpage = ($pagenumber)-1;
$twrat_nextpage = ($pagenumber)+1;
if ($pagenumber != 1) {
$pagenav.="<a href=\"showthread.php?threadid=$threadid&pagenumbe r=$twrat_prevpage".iif($perpage==$maxposts,"","&pe rpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>&lt; Previous Page</font></a>&nbsp;&nbsp;";
}
$curpage=0;
while ($curpage++<$totalpages) {

if (($curpage<$pagenumber-$pagenavpages or $curpage>$pagenumber+$pagenavpages) and $pagenavpages!=0) {
if ($curpage==1) {
$pagenav.=" <a href=\"showthread.php?threadid=$threadid&pagenumbe r=$curpage".iif($perpage==$maxposts,"","&perpage=$ perpage")."\"><font color=\"#afa3c5\" class=thtcolor>&lt;&lt; First Page</font></a>&nbsp;&nbsp; ...&nbsp;&nbsp;";
}
if ($curpage==$totalpages) {
$pagenav.=" ...&nbsp;&nbsp;<a href=\"showthread.php?threadid=$threadid&pagenumbe r=$curpage".iif($perpage==$maxposts,"","&perpage=$ perpage")."\"><font color=\"#afa3c5\" class=thtcolor>Last Page &gt;&gt;</font></a>&nbsp;&nbsp;";
}
} else {
if ($curpage==$pagenumber) {
$pagenav.=" <font color=\"#afa3c5\" class=thtcolor>$curpage</font>&nbsp;&nbsp;";
} else {
$pagenav.=" <a href=\"showthread.php?threadid=$threadid&pagenumbe r=$curpage".iif($perpage==$maxposts,"","&perpage=$ perpage")."\"><font color=\"#afa3c5\" class=thtcolor>$curpage</font></a>&nbsp;&nbsp;";
}
}
}
if ($pagenumber != $totalpages) {
$pagenav.="&nbsp;&nbsp;<a href=\"showthread.php?threadid=$threadid&pagenumbe r=$twrat_nextpage".iif($perpage==$maxposts,"","&pe rpage=$perpage")."\"><font color=\"#afa3c5\" class=thtcolor>Next Page &gt;</font></a>&nbsp;&nbsp;";
}
} else {
that works great.


[Edited by Scaramanga_gold on 01-03-2001 at 07:12 AM]

01-03-2001 01:09 PM

Glad you figured it out. Now you are on your way to becoming a successful vBulletin Hacker and have a sense of accomplishment far greater than a mere copying and pasting could have given you.

Congratulations.

01-03-2001 03:01 PM

Well, I dont think Ill become the greatest vb hacker of all times but I might fix some problems with other ppl work, that because I know just NOTHING about PHP but i have a good logic and I know C++.

thanks, and have a happy new year.

01-03-2001 03:04 PM

All it takes is knowing C/C++ and you are 75% there.

01-03-2001 08:17 PM

hey, i came from Perl :P

i still like it better then c/c++, although to be fair i only know enough c/c++ to do what needs to be done, so to speak. im starting to like php but i need to work with it a lot more, i think before i can really pass judgement. still, i find myself using perl for most anything besides the vb on my site.

to be honest im surprised that worked for anyone else, like i said im a php newbie, and my version of vb is so hacked up its barely recognizable from the code standpoint. we ran a bunch of optimizations, added 'real' private forums (w/ passwords, etc), and all sorts of neato stuff. anyways, im glad it worked for anyone who tried it.

01-03-2001 09:59 PM

My forums are really private. :) Those without access can't even see them and I control all access to them. :)

01-03-2001 10:06 PM

sure they cant see them, but by default (in the version i have installed, which is like 1.1.3 i think - im scared to upgrade w/ all my hacked up shiznit) you can change the forumid and get in w/ no checks.

01-03-2001 10:15 PM

Quote:

Originally posted by Ratorasniki
you can change the forumid and get in w/ no checks.
Are you sure you weren't actually logged in? :D

[Edited by Ed Sullivan on 01-03-2001 at 07:22 PM]

01-04-2001 05:26 PM

i didnt test or fix that particular problem, so no im not sure exactly what the circumstances were, sorry.

01-04-2001 05:57 PM

Quote:

Originally posted by Ratorasniki
sure they cant see them, but by default (in the version i have installed, which is like 1.1.3 i think - im scared to upgrade w/ all my hacked up shiznit) you can change the forumid and get in w/ no checks.
I logged out of the system and went to the following URL (a private forum):
http://sitepointforums.com/forumdisplay.php?forumid=14

I got:
Quote:

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:
You are not logged in. Fill in the form at the bottom of this page and try again.
You do not have permission to access the page that you were trying to. Are you trying to edit someone else's post or trying to access administrative features? Check that you are allowed to perform this action in the Forum Rules.
If you are trying to post, the administrators may have disabled your account, or it may be awaiting activation.
If you continue to have problems please contact us.
I signed in as a normal user (a test account I made with my Fiance's info). Type in the same URL and got:
Quote:

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:
You are not logged in. Fill in the form at the bottom of this page and try again.
You do not have permission to access the page that you were trying to. Are you trying to edit someone else's post or trying to access administrative features? Check that you are allowed to perform this action in the Forum Rules.
If you are trying to post, the administrators may have disabled your account, or it may be awaiting activation.
If you continue to have problems please contact us.
My other two accounts have access to that forum so it wouldn't do any good to try them.


All times are GMT. The time now is 08:51 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01282 seconds
  • Memory Usage 1,813KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (10)bbcode_code_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (22)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete