vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   moderate.php (https://vborg.vbsupport.ru/showthread.php?t=65937)

sabret00the 06-07-2004 07:21 PM

moderate.php
 
just a quick question, i was just reading the script (as i need to make a moderation script) and i'm left wondering, whehter or not this could've been done so much simpler than it was done by jelsoft?

NTLDR 06-07-2004 07:27 PM

I guess it depends what your moderating. Personally I don't find moderate.php overly complex.

sabret00the 06-07-2004 07:41 PM

i just want to take some text in a database and display it, with the options to leave it in the queue, authorise it or delete, i guess my limited knowledge of php is causing problems here, i dunno i just read the script and it seemed to be doing so much more than it needed to

i expected to see;

an if //moderation is on
and a while // to show the data and give the options to moderate it

and that's it really.

NTLDR 06-07-2004 07:48 PM

You can probably get away with just adding a column to the table called visible and set it to either 1 (visible) or 0 (invisible/hidden) and add that to the where clause on the query.

eg to get all unmoderated items:

[sql]SELECT *
FROM tablename
WHERE visible = 0[/sql]

sabret00the 06-07-2004 07:51 PM

that''s how i've got the database set up, it's just a matter of getting the page in the admincp to moderate the items, i guess i'll have to stop being lazy and actually learn how to make an admincp page, to think all i need is;

Code:

text to moderate | option to approve | option to delete | option to do nothing
that has to be a pretty easy to do :D

sabret00the 07-03-2004 08:52 PM

i hate the admin cp, it baffles me completely, everything is 20 times harder than coding for vB front end :( i just don't seem to be able to comprehend the coding, well i can kinda, i can read and understand what it's saying in the moderate.php but then it comes to applying that, it's practically impossible :(

[high]* sabret00the goes for a breather before heading back in for round 3[/high]

Brad 07-03-2004 09:00 PM

Just keep at it, the only way to learn is to get your hands dirty. That admin cp will look much harder to code for at first, because their is alot of extra code for html output.

sabret00the 07-04-2004 12:44 PM

thanks for that, i'll keep at it :)

i think my main problem is how i would've gone about it and how vb went about doing it is so different, so i'm trying to think like someone else would and it's causing problems but i'll persevere(sp:?) :)

assassingod 07-04-2004 12:51 PM

Quote:

Originally Posted by sabret00the
i hate the admin cp, it baffles me completely, everything is 20 times harder than coding for vB front end :(

That's weird becaues I find coding scripts for the Admin CP so much easier than the front-end. I love coding AdminCP scripts http://www.assassingod.com/images/love.gif

sabret00the 07-04-2004 02:09 PM

well i strapped on my php hat and dove right in, and it's not proving to be all that hard, bar one line that refuses to work

PHP Code:

print_label_row('<b> Posted: By </b>'iif($confession['userid'], "<a href=\"user.php?$session[sessionurl]do=viewuser&userid=$confession[userid]\" target=\"_blank\">$confession[username]</a>""Anonymous")); 

but i think it's cos the username is stored in teh user table and the left join on the confessions table i made for the array hates me, can i do it via a left join for the array or do i need to have that as a seperate query?

sabret00the 07-04-2004 02:52 PM

one more thing :o

if
PHP Code:

    print_form_header('confessions_moderate''confessions'); 

sets the form action and name, how would i get the form to post to confessions_moderate.php?do=doconfessions ?

sabret00the 07-04-2004 08:48 PM

*bump*

Andreas 07-04-2004 09:09 PM

PHP Code:

print_form_header('confessions_moderate''doconfessions'); 


sabret00the 07-04-2004 09:15 PM

didn't work

Andreas 07-04-2004 09:30 PM

Can't be ;)

Let's take a look at adminfunctions.php:

PHP Code:

function print_form_header($phpscript ''$do ''$uploadform false$addtable true$name 'cpform'$width '90%'$target ''$echobr true$method 'post') {
...
construct_hidden_code('do'$do);
...
}

...

function 
construct_hidden_code($name$value ''$htmlise 1)
...
$GLOBALS["_HIDDENFIELDS"]["$name"] = iif($htmlisehtmlspecialchars_uni($value), $value);
...
}

...

function 
print_submit_row($submitname ''$resetname '_default_', , $colspan 2$goback ''$extra '') {
...
print_table_footer($colspan$tfoot$tooltip);
}

...

function 
print_table_footer($colspan 2$rowhtml ''$tooltip ''$echoform true) {
...
if (
$echoform)
{
        
print_hidden_fields();
...
}



assassingod 07-04-2004 09:37 PM

FWIW the second parameter in print_form_header should be the filename

sabret00the 07-04-2004 09:39 PM

PHP Code:

    print_form_header('confessions_moderate''doconfessions''confessions'); 

is giving me

HTML Code:

<!-- form started: 5 queries executed -->
<form action="confessions_moderate.php" enctype="multipart/form-data" name="cpform" method="post">
<br />


Andreas 07-04-2004 09:43 PM

@assassingod
Nope. The 1st parameter should be the filename (without .php) and the 2nd should be the action.

@sabret00the
That's just fine. So where is the problem?

sabret00the 07-04-2004 09:48 PM

because i want
HTML Code:

<form action="confessions_moderate.php?do=doconfessions">
:(

Andreas 07-04-2004 09:51 PM

That's invalid (X)HTML.

The action (script) URL cannot contain parameters.

Why in hell would you need/want that?

sabret00the 07-04-2004 09:59 PM

why would i want an admin script to be xhtml compliant?

besides surely that's the do as the second parameter in the function definition?

and the reason i would like it is because the form needs to get processed somehow and i got the main script/form as confessions_moderate.php and it has proved to work quicker if i put that part of the processing on another part of the script.

Andreas 07-04-2004 10:13 PM

> why would i want an admin script to be xhtml compliant?
You want this so that compliant browsers can display the page. If there was a 101% compliant browser it would reject the page as being invalid ;)

> besides surely that's the do as the second parameter in the function definition?
As I said, look at adminfunctions.php.

> and the reason i would like it is because the form needs to get processed somehow
Sure. And where's the problem in processing the form?

File demo.php
PHP Code:

<?php
error_reporting
(E_ALL & ~E_NOTICE);

define('NO_REGISTER_GLOBALS'1);

$phrasegroups = array();
$specialtemplates = array();

require_once(
'./global.php');

print_cp_header('AdminCP Demo');

if (!
$_REQUEST['do']) {
  
$_REQUEST['do'] = 'showform';
}

if (
$_REQUEST['do'] == 'showform') {
print_form_header('demo''processform');
print_table_header('Some foobar form');
print_input_row("Name","name","",0,50);
print_submit_row();
}

if (
$_REQUEST['do'] == 'processform') {
  
print_cp_message("Hello $_REQUEST[name]");
}

print_cp_footer();

?>


assassingod 07-05-2004 05:19 AM

Quote:

Originally Posted by KirbyDE
@assassingod
Nope. The 1st parameter should be the filename (without .php) and the 2nd should be the action.

Oops, thanks for correcting me:)

sabret00the 07-05-2004 06:49 AM

Quote:

Originally Posted by KirbyDE
> why would i want an admin script to be xhtml compliant?
You want this so that compliant browsers can display the page. If there was a 101% compliant browser it would reject the page as being invalid ;)

> besides surely that's the do as the second parameter in the function definition?
As I said, look at adminfunctions.php.

> and the reason i would like it is because the form needs to get processed somehow
Sure. And where's the problem in processing the form?

File demo.php
PHP Code:

 <?php
 error_reporting
(E_ALL & ~E_NOTICE);
 
 
define('NO_REGISTER_GLOBALS'1);
 
 
$phrasegroups = array();
 
$specialtemplates = array();
 
 require_once(
'./global.php');
 
 
print_cp_header('AdminCP Demo');
 
 if (!
$_REQUEST['do']) {
   
$_REQUEST['do'] = 'showform';
 }
 
 if (
$_REQUEST['do'] == 'showform') {
 
print_form_header('demo''processform');
 
print_table_header('Some foobar form');
 
print_input_row("Name","name","",0,50);
 
print_submit_row();
 }
 
 if (
$_REQUEST['do'] == 'processform') {
   
print_cp_message("Hello $_REQUEST[name]");
 }
 
 
print_cp_footer();
 
 
?>


sorry kirby i seem to be annoying you but unless i'm reading something wrong

PHP Code:

function print_form_header($phpscript ''$do ''$uploadform false$addtable true$name 'cpform'$width '90%'$target ''$echobr true$method 'post'

which would be the same as?
HTML Code:

<form action="moderate.php?do=WHATEVER" name="confessions" method="post">
arghh i'm confusing myself it's too early.

basically, am i being told that it's impossible?

Andreas 07-05-2004 09:05 AM

PHP Code:

function print_form_header($phpscript ''$do ''$uploadform false$addtable true$name 'cpform'$width '90%'$target ''$echobr true$method 'post'

when called as
PHP Code:

print_form_header('moderate''doconfessions'); 

generates

HTML Code:

<form action="moderate.php" name="cpform" method="post">
...
<input type="hidden" name="do" value="doconfessions" />
</form>

> basically, am i being told that it's impossible?
Yes, this is not possible with the standard functions to create CP-forms, although you could do it manually.
But as I already said earlier, this is not needed and AFAIK it's not valid at all.

sabret00the 07-05-2004 03:29 PM

thanks for your help kirby

sabret00the 07-05-2004 04:05 PM

yay it's all working fine, my only problem now is this

PHP Code:

 print_label_row('<b> Posted: By </b>'iif($confession['userid'], "<a href=\"user.php?$session[sessionurl]do=viewuser&userid=$confession[userid]\" target=\"_blank\">$confession[username]</a>""Anonymous")); 

well on that script anyway

Andreas 07-05-2004 04:13 PM

Hmm ... what's the problem with this line (except that it should be &amp; to be XHTML compliant)?

sabret00the 07-05-2004 04:23 PM

lol well basically it should do this in one line

PHP Code:

if ($confession['userid']) {
 echo(
'<a href=\"user.php?$session[sessionurl]do=viewuser&userid=$confession[userid]\" target=\"_blank\">$confession[username]</a>');
 } else {
 echo(
'Anonymous');
 } 

but all that's showing up is anonymous everytime

the query that makes the array is
PHP Code:

        $confessions=$DB_site->query("
             SELECT confessions.confessionid, confessions.text 
             FROM " 
TABLE_PREFIX "confessions
             LEFT JOIN user ON (user.userid = confessions.userid)
             WHERE visible=0
 
         while (
$confession=$DB_site->fetch_array($confessions)) { 


Andreas 07-05-2004 05:20 PM

And where do you select a userid and username in your query? I can only see confessionid and text ...

sabret00the 07-05-2004 07:15 PM

it's in the left join :ermm:

Andreas 07-05-2004 07:33 PM

Nope. You make a join, but you don't select columns from the joined table ;)
If you want username and userid you should do
PHP Code:

 $confessions=$DB_site->query("
            SELECT confessions.confessionid, confessions.text, confessions.userid, user.username
            FROM " 
TABLE_PREFIX "confessions AS confessions
            LEFT JOIN " 
TABLE_PREFIX "user AS user ON (user.userid = confessions.userid)
            WHERE visible=0

        while (
$confession=$DB_site->fetch_array($confessions)) { 


sabret00the 07-05-2004 07:42 PM

ahhhh you're right such a stupid mistake

thank you so much, i'm so grateful for the help you've given me with this.


All times are GMT. The time now is 12:57 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.01622 seconds
  • Memory Usage 1,862KB
  • 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
  • (1)bbcode_code_printable
  • (4)bbcode_html_printable
  • (14)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (33)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