That works beautifully. Thanks. smile Just tested it and it's doing exactly as it should now. smile


Thanks again,

Matt

Cheers. That has sorted that error. smile

Getting one from the second line after it, (below), now. big_smile

$db->query('UPDATE '.$db->prefix.'users, '.$db->prefix.'post_counts SET num_posts=new_num WHERE id=poster_id') or error('Could not update post counts', __FILE__, __LINE__, $db->error());

The error message is:

Line: 125

PunBB reported: Could not update post counts

Database reported: ERROR: syntax error at or near "," at character 19


Thanks.

Matt

Smartys wrote:

Try removing the if not exists, then paste any error you get

Line: 121

PunBB reported: Creating temporary table failed

Database reported: ERROR: syntax error at or near "SELECT" at character 42


Cheers,

Matt

Would anyone happen to know the pgsql version of this line?

$db->query('CREATE TEMPORARY TABLE IF NOT EXISTS '.$db->prefix.'post_counts SELECT poster_id, count(*) as new_num FROM '.$db->prefix.'posts GROUP BY poster_id') or error('Creating temporary table failed', __FILE__, __LINE__, $db->error());

It throws a wobbler on trying to synchronise the post counts. big_smile


Cheers,

Matt

1,805

(29 replies, posted in Programming)

Well, that don't do it either. big_smile Just to make sure I'm not missing something blatant, here's the first portion from register.php:

//------------------------------------------------//

        // anti-spam code variable checked here. Customise to suit your needs.
        if (isset ($_POST['spamcode']) && $_POST['spamcode'] != $_SESSION['answer']) {
//              session_unset();
//              session_destroy();
                message("$register_failed");
        }
        else if (isset ($_POST['spamcode']) && $_POST['spamcode'] == $_SESSION['answer']) {
//              session_unset();
//              session_destroy();
        }

//------------------------------------------------//

The complete contents of include/user/register.php:

<?php

if (isset($_SESSION['hint']))
{
        $hint = $_SESSION['hint'];
        $answer = $_SESSION['answer'];
        $question = $_SESSION['question'];
}
else
{

$register_failed = 'The answer you supplied was incorrect. Please try again.';
$number = rand(1, 4);

//---Questions array---//

$questions = array(

'q1' => 'Test one',
'q2' => 'Test two',
'q3' => 'Test three',
'q4' => 'Test four'

);

//-----Hints array-----//

$hints = array(

'h1' => '<b>Hint: </b>Answer: One',
'h2' => '<b>Hint: </b>Answer: Two',
'h3' => '<b>Hint: </b>Answer: Three',
'h4' => '<b>Hint: </b>Answer: Four'

);

//----Answers array----//

$answers = array(

'a1' => 'One',
'a2' => 'Two',
'a3' => 'Three',
'a4' => 'Four'

);

//--Create the session variables--//

session_start();

$_SESSION['hint'] = $hints[h.$number];
$_SESSION['answer'] = $answers[a.$number];
$_SESSION['question'] = $questions[q.$number];

//session_write_close();

}

?>

I've reached the point of no idea. big_smile

1,806

(29 replies, posted in Programming)

Smartys wrote:

Yes, because you're making two calls to the script, one when you view the form and one when you submit. That's why I suggested using sessions. It would go something like this:

session_start();
if (isset($_SESSION['hint']))
{
    $hint = $_SESSION['hint'];
    $answer = $_SESSION['answer'];
    $question = $_SESSION['question'];
}
else
{
    $number = rand(1, 2);

    $hint = $hints[$number];
    $answer = $answers[$number];
    $question = $questions[$number];

    $_SESSION['hint'] = $hint;
    $_SESSION['answer'] = $answer;
    $_SESSION['question'] = $question;
}

(Now banging head firmly on desk). big_smile That first part is the missing link. It always looks so simple when someone points out ones glaring exemption. big_smile I'll blame a slight misunderstanding of sessions on this one. big_smile I had tried a $_GET['action'] check thinking that would stop it renewing itself, but then it didn't carry over, (which is where I was losing the plot). I never even thought of trying something like the first section above. I feel such a muppet, (again), for misinterpreting something so simple in theory. big_smile (Now hurrying off to try it out). big_smile Thanks once again.

1,807

(29 replies, posted in Programming)

Cheers. smile

This thing is giving me some grief, to say the least. big_smile I've required the file just below the registration enabled check:

if ($pun_config['o_regs_allow'] == '0')
        message($lang_register['No new regs']);

require_once PUN_ROOT.'include/user/register.php';

but for some reason the script is being called twice. Once when you initially go to the forum/register.php page to register, and a second time when you click on submit, so by the time it checks the info, it's altered. If I had any sense I'd call it a day before it drives me to distraction. big_smile

1,808

(29 replies, posted in Programming)

Right, I think I've grasped the basics now, through reading and experimentation. big_smile One question on the tmpfile that's created by the session in the tmpdir. Is there a session command to remove that tmpfile when you've finished with the session?

1,809

(29 replies, posted in Programming)

Smartys wrote:

No tongue
Session data is stored in an array, but sessions and arrays aren't really related

But you can assign and read in somewhat the same manner as one would an array? The documentation is, as ever, slightly awkward to follow when one has not used that certain aspect before. big_smile

1,810

(29 replies, posted in Programming)

I can't say as I've actually any interest in using this mod personally, but for some reason it just piqued my curiosity as to how one could make a randomish choice thing work. big_smile Just been looking at the php documentation, and I am getting steadily more confused, big_smile but from what bit has sunk in so far, is a session pretty much along the same lines as an array?

1,811

(29 replies, posted in Programming)

So would creating a session be the most secure method of storing the data whilst it's needed? (I get the feeling a few hours with the php manual is what I'm going to be doing very soon). big_smile


Thanks again,

Matt

1,812

(29 replies, posted in Programming)

It always sounds so understandable in ones own head, doesn't it? big_smile Here are the relevant parts from register.php:

    197                 $language = $pun_config['o_default_lang'];
    198         }
    199
-----------------------------------------------------
    200         // anti-spam code variable checked here. Customise to suit your needs.
    201         if ($_POST['spamcode'] != $answer) {
    202                 message("$register_failed");
    203         }
------------------------------------------------------
    204
    205         $timezone = round($_POST['timezone'], 1);
    206         $save_pass = (!isset($_POST['save_pass']) || $_POST['save_pass'] != '1') ? '0' : '1';
    332 <?php if ($pun_config['o_regs_verify'] == '1'): ?>                                              <label><strong><?php echo $lang_register['Confirm e-mail'] ?></strong><br />
    333                                                 <input type="text" name="req_email2" size="50" maxlength="50" /><br/>
</label>
    334 <?php endif; ?>                                 </div>
    335                                 </fieldset>
    336                         </div>
    337
------------------------------------------------------
    338 <div class="inform">
    339         <fieldset>
    340                 <legend>Spambot prevention</legend>
    341                 <div class="infldset">
    342                         <p><?php echo ("$question"); ?></p>
    343                         <p><?php echo ("$hint"); ?></p>
    344                         <input method="post" type="text" name="spamcode" size="10" maxlength="10" /><br/>
    345                 </div>
    346         </fieldset>
    347 </div>
-------------------------------------------------------
    348
    349                         <div class="inform">
    350                                 <fieldset>
    351                                         <legend><?php echo $lang_prof_reg['Localisation legend'] ?></legend>

The sections between the dotted lines are the new code. I've left extra code above/below as markers of placement. With that bottom section of code, if I add:

<?php
require PUN_ROOT.'include/user/register.php';
?>

just before it, that require will pull the variables required from that script. However, when it gets to the $_POST check back up the top of the register.php file, (that first block of code), the variables aren't carried over to that check. If I put the require at the top of register.php, the script would appear to be being called twice, as the random(ish) variables it produces don't match. So, the question being, how do I carry the variables over to the post check? That include/user/register.php is merely arrays with a rand call to set a value for $hint, $answer and $question, i.e:

$number = rand(1, 2);
$hint = $hints[$number];
$answer = $answers[$number];
$question = $questions[$number];

Have I managed to explain it okay this time? big_smile


Thanks again,

Matt

1,813

(29 replies, posted in Programming)

Another of my useless questions. big_smile With the register.php script, I've been playing with that script that Sirena has posted: http://punbb.org/forums/viewtopic.php?id=16076

but have struck an obstacle with trying to introduce an array into it. If one includes/requires a script where the second part of the mod goes in register.php, the $_POST check, (the first part of the mod in register.php), doesn't have access to the variables pulled from the array in that script. If the include/require is done at the top of the register.php script, the results are highly erratic. (I'm assuming the external script is being included twice)? Am I missing something blindingly obvious here as to how to get this to work?


Cheers,

Matt

1,814

(4 replies, posted in Programming)

Smartys wrote:

Forum description allows HTML, nothing is stripping things out

Cheers. I feel such a muppet now. Rechecked everything and found I'd neglected to add a require for the relevant lang file in the  forums.php file. big_smile

1,815

(4 replies, posted in Programming)

Smartys wrote:

I'm not sure what you mean: what img tags?

Apologies. I should have made myself a bit clearer. big_smile I'm trying to insert an image tag through code changes in the forums.php file, (running the portal), for url redirect forums, but any img tags I insert in the forum description/header just will not appear for love nor money. big_smile For the life of me I can't find why/where they're being stripped. It's the $forum_field header that I'm trying to adapt.


Cheers,

Matt

1,816

(4 replies, posted in Programming)

Stuck again. big_smile Where does the parsing on the forums index to remove the likes of img tags and such take place?


Cheers,

Matt

quaker wrote:

Broadcast Email. Created by trel1023. The Broadcast Email plugin allows administrators to broadcast e-mail to all registered users via the administration interface.


will broadcast email handle html?
can i create a html email to all the members?



Q

Are you sure your members want html e-mails? I know I for one detest the things.

1,818

(2 replies, posted in PunBB 1.2 discussion)

Sorted. big_smile Removed the icon type setting for closed topics and inserted the image in place of in viewforum.php. big_smile

1,819

(2 replies, posted in PunBB 1.2 discussion)

Managed to do it with the stickies by putting an <img tag in the lang file and removing it from the style itself. But...., the closed topic appears to have a different setup on how that uses the lang file, so is there a sneaky way of doing that one too?


Cheers,

Matt

1,820

(2 replies, posted in PunBB 1.2 discussion)

Just out of curiosity, is there any easy way to set default icons outside of the stylesheets, so that the sticky/closed icons would have a default icon if the styles don't include/set them?


Cheers,

Matt

1,821

(17 replies, posted in Programming)

These links may be absolutely no use whatsoever to you, but here's a nice flash player for web based situations.

http://www.jeroenwijering.com/?item=Flash_Video_Player
http://www.jeroenwijering.com/?item=Flash_Media_Player


Not sure if this may be of any help on the conversion front.

http://ffmpeg.mplayerhq.hu/

1,822

(17 replies, posted in Programming)

pogenwurst wrote:

You could get into some serious flame wars calling what Wine does emulation. tongue

big_smile big_smile But it's quicker to say emulation than writing the page or two's worth of text that they use to explain it. big_smile big_smile

1,823

(17 replies, posted in Programming)

WINE is a completely different thing, though. big_smile That's merely emulation under which the programmes can run. Must admit, I'm curious about the question too. big_smile

1,824

(17 replies, posted in Programming)

To convert a M$ programme to *nix? If so, no.

1,825

(89 replies, posted in PunBB 1.2 discussion)

gil wrote:
MattF wrote:

I have to ask. What is the fuss about modding and personalising a software installation. For goodness sakes, with most *nix admins it's second nature. A pre-compiled with everything version of a programme is practically a living hell. Starting with minimal solutions and adapting has always been the best and most secure policy.

Modding and personalising a software is a good thing. But a mandatory function should not be modding. Avatar, for example, is not mandatory, and could be an extension. It is offered with the software, why not, but it was not an obligation. When a software *cannot* be used without an extension in the target context (just real world...), this package is not complete.

Just as a counter argument for that, I have looked at a lot of the other forum software, and even tried installing a lot of it, and all I would say is that I far prefer to mod PunBB with what are minor alterations than to install most of the other alternatives, which may have basics like that built in. Installing something with cartloads of crap added that then has to be removed to achieve ones purpose is far worse than having to add a few mods specific to your requirement items.