Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #21  
Old 09-25-2001, 08:10 PM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, here it is.
This might not be the best way to do this, but well, it's something.

I'm just packed with jobs lately, just can't do them all.
And since I do have some previous commitments (yes, even earlier than this one), I must complete them first.
Veyr sorry, Ruth.

1. Run this query:
Code:
CREATE TABLE tip (
  tipid SMALLINT(5) not null AUTO_INCREMENT,
  title VARCHAR(100) not null,
  tiptext MEDIUMTEXT not null,
  PRIMARY KEY (tipid)
)
2. Save this as tip.php, and upload to your main folder:
PHP Code:
<?php

error_reporting
(7);

require(
"./global.php");

$action trim($action);
if (!isset(
$action)==0) {
  
$action "showtip";
}

// ################################ start quick rate ###############################
if ($action=="showtip") {
  
$tip=$DB_site->query_first("SELECT * FROM tip ORDER BY rand()");
  echo(
"$tip[tipid]");
  eval(
"\$showtip = \"".gettemplate("tip_showtip")."\";");
}

eval(
"dooutput(\"".gettemplate("tip_main")."\");");

?>
3. Save this as tip.php and upload to your admin folder:
PHP Code:
<?php
error_reporting
(7);

require(
"./global.php");

cpheader();

if (isset(
$action)==0) {
  
$action="edit";
}

// ########################### Start Doadd ##########################
if ($action=="doadd") {

  for (
$i=1$i<=$numtips$i++) {
    if (
$tiptext[$i]!="" and $title[$i]!="") {
      
$DB_site->query("INSERT INTO tip (tipid,title,tiptext) VALUES (NULL,'".addslashes($title[$i])."','".addslashes($tiptext[$i])."')");
    }
  }
  
$action="modify";

  echo 
"<p>Record added</p>";

}

// ############################ Start Add ###########################
if ($action=="add") {

  
doformheader("tip","doadd");
  for (
$i=1$i<=$numtips$i++) {
    
maketableheader("Tip #$i");
    
makeinputcode("Title","title[$i]");
    
maketextareacode("Tip Text<br>(You may use HTML)","tiptext[$i]","","10");
  }
  
makehiddencode("numtips","$numtips");
  
doformfooter("Add");

}

// ########################## Start Preadd ##########################
if ($action=="preadd") {

  
doformheader("tip","add");
  
maketableheader("Add new tips");
  
makeinputcode("Number of tips to add","numtips","1");
  
doformfooter("Start");

}

// ########################## Start Modify ##########################
if ($action=="edit") {

  
$tips=$DB_site->query("SELECT * FROM tip");
  
$i=1;
  while (
$curtip=$DB_site->fetch_array($tips)) {
    if (
$title[$curtip[tipid]]=="" or $tiptext[$curtip[tipid]]=="") {
      
$DB_site->query("DELETE FROM tip WHERE tipid='$curtip[tipid]'");
      echo 
"Deleting tip #$i ...<br>";
    } else {
      
$DB_site->query("UPDATE tip SET title='".addslashes($title[$curtip[tipid]])."',tiptext='".addslashes($tiptext[$curtip[tipid]])."' WHERE tipid='$curtip[tipid]'");
      echo 
"Saving tip #$i ...<br>";
    }
    
$i++;
  }
  
$action="modify";

  echo 
"<p>Done</p>";

}

cpfooter();
?>
4. Save this as tip_main template:
Code:
{htmldoctype}
<html>
<head><title>Tip of the moment!</title>
$headinclude
</head>
<body>

$showtip

</body>
</html>
5. Save this as tip_showtip template:
Code:
<normalfont><b>$tip[title]:</b><br><br>

$tip[tiptext]</normalfont>
6. In index.php of the admin folder add this:
PHP Code:
<tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="2" id="navtable">
<?php maketableheader("Tips"); ?>
</table>
<a href="tip.php?s=<?php echo $session[sessionhash]; ?>&action=preadd"> Add </a> |
<a href="tip.php?s=<?php echo $session[sessionhash]; ?>&action=modify"> Modify </a>
</td></tr>
right BEFORE this:
PHP Code:
<tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="2" id="navtable">
<?php maketableheader("Avatars"); ?>
</table>
<a href="avatar.php?s=<?php echo $session[sessionhash]; ?>&action=upload"> Upload </a> |
<a href="avatar.php?s=<?php echo $session[sessionhash]; ?>&action=add"> Add </a> |
<a href="avatar.php?s=<?php echo $session[sessionhash]; ?>&action=modify"> Modify </a>
</td></tr>
That's it.
This will display a random tip on every page load.

I understand if you don't want to use this, it's far from perfect.

Sorry again.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:16 AM.


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.07359 seconds
  • Memory Usage 3,433KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (5)bbcode_code
  • (5)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (36)post_thanks_box
  • (36)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (36)post_thanks_postbit_info
  • (36)postbit
  • (1)postbit_attachment
  • (36)postbit_onlinestatus
  • (36)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete