276

Re: Calendar 2.0

Hi Mystic...
My initial thought is to wonder if you have been doing any .htaccess editing for your site, or other files management on the site, that would have altered the way your server is told to respond to file requests.

We are going to need more information...
Did you recently edit/re-mod your calendar installation, or has nothing changed?
Does it do this only for editing an event, or for what links exactly?
Does it do this for any other php files at the site or only calendar? 
When was it (they) last working that you know of?
What sort of work has been performed on your site since then (not just punbb)?
Has anyone else tested this for you?   (give us the relevant link(s) to your site)

...to start with.

TwoHawks
Love is the Function
No Form is the Tool

277

Re: Calendar 2.0

twohawks wrote:

Hi Mystic...
My initial thought is to wonder if you have been doing any .htaccess editing for your site, or other files management on the site, that would have altered the way your server is told to respond to file requests.

We are going to need more information...
Did you recently edit/re-mod your calendar installation, or has nothing changed?
Does it do this only for editing an event, or for what links exactly?
Does it do this for any other php files at the site or only calendar? 
When was it (they) last working that you know of?
What sort of work has been performed on your site since then (not just punbb)?
Has anyone else tested this for you?   (give us the relevant link(s) to your site)

...to start with.

Hi there;

I didnt change anything..few days ago i still can access to add new events but now i couldnt... And furthermore I didnt perform my site any new scripts yet...

Also I didnt edit/re-mod the calendar files as well as punbb because it worked fine. All other functions of my site (including Punbb Forum) still working great except the calendar...

I've tested on different pc, with different OS as well as browsers but all the same results...

Here is the link : https://os.fastueux.com/Forum/calendar.php

I love sky - i love flowers - and i love myself :D

278 (edited by twohawks 2007-02-19 21:47)

Re: Calendar 2.0

Wow, Mystic, that's weird!

I went to your link and I get a blank page (completely).
When I view the source I see the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title></title></head><body></body></html>

I think you still have my email address?  Can you send me the file 'calendar.php' that the link you provided above points to? (or post it within code tags here)... I would like to take a look at it directly.

I will be able to offer some help on this problem a little bit today, and tomorrow evening.
Hope you are watching the posts!

PS: Is it possible for you to allow 'form email' to you setting in your profile here so its easy to send you an email when not at my computer?  If you do not generally like to, is it possible for only a couple days?

TwoHawks
Love is the Function
No Form is the Tool

279

Re: Calendar 2.0

In header.php you include the stylesheet image_upload.css
Wouldn't it be better when that would be under "imports", since it doesn't really work out fine as forum design big_smile

FluxBB - v1.4.8

280

Re: Calendar 2.0

Hi lie2815...  I cannot find what/where it is you are addressing, would you please be more specific, i.e., whom are you addressing and which header.php (in what directory)?

TwoHawks
Love is the Function
No Form is the Tool

281

Re: Calendar 2.0

<?php
define('PUN_ROOT', './');
require PUN_ROOT.'calendar/header.php';
require PUN_ROOT.'include/parser.php';



?>
<!--Calendar Version:2.0.6a -->
<div class="blocktable">
<?php
//
//do the stuff like viewing topics posts birthdays or events
//
if(isset($view))
{
    if($view == 'topics')
    {
        ###########################################################
        ###//===============//=================//===============//#
        ##//===============// Show Topic List //===============//##
        #//===============//=================//===============//###
        ###########################################################

        //Number of posts to display
        $disp_topics = $pun_user['disp_topics'];

        $result = $db->query('SELECT id FROM '.$db->prefix.'topics WHERE posted > '.$datestart.' AND posted < '.$dateend);
        $num_replies = $db->num_rows($result);


        // Determine the post offset (based on $_GET['p'])
        $num_pages = ceil(($num_replies) / $disp_topics);

        $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
        $start_from = $disp_topics * ($p - 1);

        $pages = paginate($num_pages, $p, 'calendar.php?view=topics&date='.$year.'.'.$month.'.'.$day);

        // Pulls list of topics for the day
        $result = $db->query('
            SELECT
             t.id, t.poster, t.subject, t.posted, t.last_post, t.last_post_id, t.last_poster, t.moved_to, t.num_replies, t.closed, t.forum_id
            FROM '.$db->prefix.'topics AS t
            LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].')

            WHERE
                t.posted > '.$datestart.'  AND
                t.posted < '.$dateend.' AND
                (fp.read_forum IS NULL OR fp.read_forum=1)

            ORDER BY posted LIMIT '.$start_from.','.$disp_topics
        ) or error('Unable to fetch topic list for forum', __FILE__, __LINE__, $db->error());

?>
        <h2 style="text-align:center"><span><?php echo $lang_calendar['Viewing_Topics']." ".$datestring ?></span></h2>

        <div class="box">

        <table cellspacing="0">
        <thead>
        <tr>
            <th style="white-space: nowrap"><?php echo $lang_common['Topic']?></th>
            <th style="width: 13%; white-space: nowrap"><?php echo $lang_common['Author']?></th>
            <th style="width: 7%; white-space: nowrap"><?php echo $lang_common['Replies']?></th>
            <th style="width: 25%; white-space: nowrap"><?php echo $lang_common['Last post']?></th>
        </tr>
        </thead>
        <tbody>
<?php
        if($db->num_rows($result))
        {
            while ($cur_topic = $db->fetch_assoc($result))
            {
                if ($cur_topic['moved_to'] == null)
                    $last_post = '<a href="viewtopic.php?pid='.$cur_topic['last_post_id'].'#'.$cur_topic['last_post_id'].'">'.format_time($cur_topic['last_post']).'</a><br /> '.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['last_poster']);
                else
                    $last_post = ' ';

                if ($pun_config['o_censoring'] == '1')
                    $cur_topic['subject'] = censor_words($cur_topic['subject']);

                if ($cur_topic['closed'] == '0')
                    $subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a>';
                else
                    $subject = '<a class="punclosed" href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a>';

?>
            <tr class="puntopic">
                <td><?php echo $subject ?></td>
                <td><?php echo pun_htmlspecialchars($cur_topic['poster']) ?></td>
                <td><?php echo ($cur_topic['moved_to'] == null) ? $cur_topic['num_replies'] : ' ' ?></td>
                <td style="white-space: nowrap"><?php echo $last_post ?></td>
            </tr>
<?php
            }
        }else
            echo"\t\t\t<tr>\n\t\t\t\t<td colspan='4'>".$lang_calendar['No_Topics']."</td>\n\t\t\t</tr>";
?>
            <tr>
                <th colspan='4'> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a>       <a href="calendar.php"><?php echo"Xem các s? ki?n khác"; ?></a> </th>
            </tr>
        </tbody>
        </table>
    </div>

<?php
        navigation('topics');
    }
    elseif($view == 'posts')
    {
        ##########################################################
        ###//===============//================//===============//#
        ##//===============// Show Post list //===============//##
        #//===============//================//================ ###
        ##########################################################

        //Number of posts to display
        $disp_posts = $pun_user['disp_posts'];

        $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE posted > '.$datestart.' AND posted < '.$dateend);
        $num_replies = $db->num_rows($result);


        // Determine the post offset (based on $_GET['p'])
        $num_pages = ceil(($num_replies) / $disp_posts);

        $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
        $start_from = $disp_posts * ($p - 1);

        $pages = paginate($num_pages, $p, 'calendar.php?view=posts&date='.$year.'.'.$month.'.'.$day);

        $result = $db->query('
            SELECT
             p.id, p.poster, p.poster_id, p.message, p.posted, p.topic_id,
             t.id as tid, t.subject as tsub, t.forum_id,
             f.id as fid, f.forum_name as fname

            FROM '.$db->prefix.'posts AS p
            INNER JOIN '.$db->prefix.'topics AS t ON p.topic_id=t.id
            INNER JOIN '.$db->prefix.'forums AS f ON t.forum_id=f.id
            LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')


            WHERE
                p.posted > '.$datestart.' AND
                p.posted < '.$dateend.' AND
                (fp.read_forum IS NULL OR fp.read_forum=1)

            ORDER BY p.posted LIMIT '.$start_from.','.$disp_posts
        )or error('Unable to fetch topic list for forum', __FILE__, __LINE__, $db->error());

?>
        <h2 style="text-align:center"><span><?php echo $lang_calendar['Viewing_Posts']." ".$datestring ?></span></h2>

        <div class="box">
        <table cellspacing="0">
        <thead>
            <tr>
                <th style="white-space: nowrap"> <?php echo $lang_common['Message']?></th>
                <th style="width: 12%"><?php echo $lang_common['Posted']?></th>
                <th style="width: 12%"><?php echo $lang_common['Forum']?></th>
            </tr>
        </thead>
        <tbody>
<?php
        if($db->num_rows($result))
        {
            while ($cur_posts = $db->fetch_assoc($result))
            {
                if (pun_strlen($cur_posts['message']) >= 80)
                {
                    $cur_posts['message'] = substr($cur_posts['message'], 0, 79);
                    $cur_posts['message'] .= '…';
                }

?>
            <tr>
                <td>
                <?php echo $lang_common['Topic']?>: <a href="viewtopic.php?id=<?php echo$cur_posts['tid']?>"><?php echo $cur_posts['tsub']?></a><br />
                <?php echo $lang_calendar['Posted_by']?> <a href="profile.php?id=<?php echo$cur_posts['poster_id']?>"><?php echo $cur_posts['poster']?></a><br />

                <div class="box" style="padding:5px; margin:4px;">
                    <?php echo $cur_posts['message']?>
                    <div style="text-align: right">
                        <a href="viewtopic.php?pid=<?php echo$cur_posts['id'].'#p'.$cur_posts['id']?>"><?php echo $lang_calendar['go_to_post']?></a>
                    </div>
                </div>
                </td>
                <td class="puncon2cent"><?php echo date($pun_config['o_time_format'], $cur_posts['posted'])?></td>
                <td class="puncon1cent"><a href="viewforum.php?id=<?php echo$cur_posts['fid']?>"><?php echo $cur_posts['fname']?></a></td>

            </tr>

<?php            }
        }else
            echo"\t\t\t<tr>\n\t\t\t\t<td colspan='3'>".$lang_calendar['No_Posts']."</td>\n\t\t\t</tr>";
?>
                <tr>
                    <th colspan='3'> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a>       <a href="calendar.php"><?php echo"Tr? v? l?ch"; ?></a> </th>
                </tr>
            </tbody>
            </table>
        </div>
<?php
        navigation('posts');
    }
    elseif($view == 'bday')
    {
        ###########################################################
        ###//===============//===============//=================//#
        ##//===============// Birthday list //=================//##
        #//==================================================// ###
        ###########################################################
        require PUN_ROOT.'lang/'.$pun_user['language'].'/profile.php';

        $result = $db->query('SELECT id, username, use_avatar, last_post, registered, birthday, DAYOFMONTH(birthday) as day    FROM '.$db->prefix.'users WHERE DAYOFMONTH(birthday) = '.$day.' AND MONTH(birthday) = '.$month.' ORDER BY username') or error('Unable to fetch birtday list', __FILE__, __LINE__, $db->error());


?>
        <h2 style="text-align:center"><span><?php echo $lang_calendar['Viewing_Bday']." ".$datestring ?></span></h2>

        <div class="box">

        <table cellspacing="0">
        <thead>
            <tr>
                <th style="width: 80px"><?php echo $lang_profile['Avatar']?></th>
                <th style="width: 25%; text-align: center"><?php echo $lang_common['Username']?></th>
                <th style="width: 15%; text-align: center"><?php echo $lang_calendar['Age']?></th>
                <th style="text-align: center"><?php echo $lang_common['Registered']?></th>
            </tr>
        </thead>
        <tbody>

<?php
        if($db->num_rows($result))
        {
            while($bday_list = $db->fetch_assoc($result))
            {
                if ($bday_list['use_avatar'] == '1')
                {
                    if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$bday_list['id'].'.gif'))
                        $avatar = '<img class="punavatar" src="'.$pun_config['o_avatars_dir'].'/'.$bday_list['id'].'.gif" alt="" />';
                    else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$bday_list['id'].'.jpg'))
                        $avatar = '<img class="punavatar" src="'.$pun_config['o_avatars_dir'].'/'.$bday_list['id'].'.jpg" alt="" />';
                    else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$bday_list['id'].'.png'))
                        $avatar = '<img class="punavatar" src="'.$pun_config['o_avatars_dir'].'/'.$bday_list['id'].'.png" alt="" />';
                    else
                        $avatar = $lang_profile['No avatar'];
                }
                else
                    $avatar = $lang_profile['No avatar'];

                list($bday_year,$bday_month,$bday_day) = explode('-', $bday_list['birthday']);
                $age = (strlen($bday_year)!='4')? $lang_profile['Unknown']: $year-$bday_year;
?>
            <tr>
                <td><?php echo $avatar?></td>
                <td style="text-align: center; font-size: 120%"><a href="profile.php?id=<?php echo$bday_list['id']?>"><?php echo $bday_list['username']?></a></td>
                <td style="text-align: center; font-size: 120%"><?php echo $age?></td>
                <td style="text-align: center; font-size: 120%"><?php echo format_time($bday_list['registered'])?></td>
            </tr>
<?php
            }
        }else
            echo"\t\t\t<tr>\n\t\t\t\t<td colspan='4'>".$lang_calendar['No_Bday']>"</td>\n\t\t\t</tr>\n";
?>
            <tr>
                <th colspan='4'> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a>       <a href="calendar.php"><?php echo"Tr? v? l?ch"; ?></a> </th>
            </tr>
        </tbody>
        </table>
    </div>
<?php
        navigation('bday');
    }
    elseif($view == 'event')
    {
        ######################################################
        ###//===============//=============//==============//#
        ##//===============// Events List //==============//##
        #//===============//=============//==============//###
        ######################################################

        $stype = (isset($_GET['id']))? 'e.id = '.intval($_GET['id']) : 'dayofmonth(e.date) = '.$day.' AND month(e.date) = '.$month ;
        $result = $db->query('SELECT e.id, e.date, e.title, e.user_id, e.body, u.username as username, u.num_posts as posts, u.registered as reg, g.g_title as group_id FROM '.$db->prefix.'calendar AS e INNER JOIN '.$db->prefix.'users AS u ON e.user_id=u.id LEFT JOIN '.$db->prefix.'groups AS g ON u.group_id=g.g_id WHERE '.$stype) or error('Unable to fetch event list', __FILE__, __LINE__, $db->error());
?>
    <h2 style="text-align:center"><span><?php echo $lang_calendar['Viewing_Event']?></span></h2>
    <div class="box">

        <table cellspacing="0">
<?php
        if($db->num_rows($result))
        {
            while($event_info = $db->fetch_assoc($result))
            {

                //setting up the date info
                $date_part = explode('-',$event_info['date']);
                           //     $date = date("F jS", mktime(0,0,0,$date_part['1'],$date_part['2'], $date_part['0']));

                                  // could have used $datestring but choose do it this way, in case someone wants to use it to
                                  // view all the events in a week or month.
                                  $date = date_str(mktime(0,0,0,$date_part['1'],$date_part['2'], $date_part['0']));

                           //     This is currently not functional
                           //     if($date_part[0]=="0000")
                           //             $date .= ' (Recuring Event)';
                           //     else
                           //       $date .= ' '.$date_part[0].' (Single Day Event)';

                                  $event_info['body'] = parse_message($event_info['body'], 0);
?>
            <tr>
                <th style="width:18em;" align="left"><a href="profile.php?id=<?php echo $event_info['user_id']?>"><?php echo $event_info['username']?></a></th>
                          <th align="left"><b><?php echo $event_info['title']?></b></th>
            </tr>
            <tr>
                <td>
                                <?php echo $lang_calendar['Event_Date'].' '.$date ?>
                          </td>
                          <td valign="top">
                                <?php echo $event_info['body']?>
                          </td>
            </tr>
<?php
            }
        }else
            echo"\t\t\t<tr>\n\t\t\t\t<td colspan='2'>".$lang_calendar['No_Events']>"</td>\n\t\t\t</tr>\n";

?>
            <tr>
                <th colspan='2'> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a>       <a href="calendar.php"><?php echo"Tr? v? l?ch"; ?></a> </th>
            </tr>
        </table>

    </div>



<?php
        navigation('event');

    }

}




//
// Do the actions like adding and editing events
//
elseif(isset($action))
{
    if(
        ($pun_user['group_id'] == PUN_MOD && $CFG_mod_add=='no')
        or ($pun_user['group_id'] == PUN_MEMBER && $CFG_user_add=='no')
        or ($pun_user['group_id'] == PUN_GUEST))
        message($lang_calendar['warning']);

    elseif($action == 'add')
    {
        #######################################################
        ###//===============//==============//==============//#
        ##//===============// Add an event //==============//##
        #//===============//==============//==============//###
        #######################################################
        if(isset($_POST['form_sent']))
        {
            // Check to see if the Title, Body, Month, and Day were sent
            if(empty($_POST['title']))
                message($lang_calendar['need_title']);
            elseif(empty($_POST['body']))
                message($lang_calendar['need_body']);
            elseif($_POST['month']=="0" || $_POST['day']=="0")
                message($lang_calendar['need_date']);

            // Clean up body and title from POST
            $title = pun_trim($_POST['title']);
            $body = pun_linebreaks(pun_trim($_POST['body']));
                         $body = preparse_bbcode($body, $errors);

            // Setup the corretct date layout for the database
                        if($_POST['year'] == $lang_calendar['Year'])
                $_POST['year'] = date('Y');

            // Check to see of the month and day were set

            // Check to see if the day seleced for the month is an actual day
            $year=($_POST['year']=='0000')? date('Y'): $_POST['year'];
            if(date('t', mktime(0,0,0,$_POST['month'],1,$year))< $_POST['day'])
                message($lang_calendar['date_error']);

            $date = $_POST['year'].'-'.$_POST['month'].'-'.$_POST['day'];

            // Add the Event to the database
            $db->query('INSERT INTO '.$db->prefix.'calendar (date, title, body, user_id) VALUES("'.$date.'", "'.$title.'", "'.$body.'", "'.$_POST['user_id'].'")') or error('Unable to create new event', __FILE__, __LINE__, $db->error());

            redirect('calendar.php', $lang_calendar['event_added']);
        }
        else
        {
?>
    <div class="blockform">
    <h2><?php echo $lang_calendar['add_event']?></h2>
    <div class="box">
        <form method="post" action="https://os.fastueux.com/Forum/calendar.php?action=add" onsubmit="return process_form(this)">
            <div class="inform">
                <fieldset>
                    <legend><?php echo $lang_calendar['add_info']?></legend>
                    <div class="infldset">
                        <input type="hidden" name="form_sent" value="1" />
                        <input type="hidden" name="user_id" value="<?php echo $pun_user['id']?>" />

                        <label class="conl" style="width: 152px;">
                            <strong><?php echo $lang_calendar['Title']?></strong><br />
                            <input type="text"  name="title" maxlength="50" /><br />
                        </label>

                        <label class="conl">
                            <strong><?php echo $lang_calendar['Date']?></strong><br />

                            <select name="month">
                                <option value='0'><?php echo $lang_calendar['Month']?></option>
<?php
    $month_name = array('',$lang_calendar['January'],$lang_calendar['February'],$lang_calendar['March'],$lang_calendar['April'],$lang_calendar['May'],$lang_calendar['June'],$lang_calendar['July'],$lang_calendar['August'],$lang_calendar['September'],$lang_calendar['October'],$lang_calendar['November'],$lang_calendar['December']);
    for($x=1;$x<13;$x++)
        echo"\t\t\t\t\t\t\t\t<option value='".$x."'>".$month_name[$x]."</option>\n";

?>
                            </select>
                        </label>
                        <label class="conl"><br />
                            <select name="day">
                                <option value='0'><?php echo $lang_calendar['Day']?></option>
<?php
    for($x=01;$x<=31;$x++)
        echo"\t\t\t\t\t\t\t\t<option value='".$x."'>".$x."</option>\n";

?>
                            </select>
                        </label>
                        <label class="conl"><br />
                            <input name="year" size="5" value="<?php echo $lang_calendar['Year']?>" onselect="document.post.year.value=''" /> 

                        </label>
                        <br />

                        <div class="txtarea">
                            <label class="conl">
                                <strong><?php echo $lang_calendar['Body']?></strong><br />
                                <textarea name="body"  rows="7" cols="65"></textarea><br />
                            </label><br />
                        </div>
                        <br class="clearer">
                    </div>

                </fieldset>
            </div>
            <p><input type="submit" value="<?php echo $lang_common['Submit'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a>       <a href="calendar.php"><?php echo"Tr? v? l?ch"; ?></a></p>
        </form>
    </div>
    </div>
        <?php
        }
    }
    elseif($action =='edit')
    {
        ########################################################
        ###//===============//===============//==============//#
        ##//===============// Edit an event //==============//##
        #//===============//===============//==============//###
        ########################################################
        if(isset($_POST['form_sent']))
        {
            // Check to see if the Title, Body, Month, and Day were sent
            if(empty($_POST['title']))
                message($lang_calendar['need_title']);
            elseif(empty($_POST['body']))
                message($lang_calendar['need_body']);
            elseif($_POST['month']=="0" || $_POST['day']=="0")
                message($lang_calendar['need_date']);

            // Clean up body and title from POST
            $title = pun_trim($_POST['title']);
            $body = pun_linebreaks(pun_trim($_POST['body']));
                         $body = preparse_bbcode($body, $errors);

            // Setup the corretct date layout for the database
                        if($_POST['year'] == $lang_calendar['Year'])
                $_POST['year'] = date('Y');

            // Check to see of the month and day were set

            // Check to see if the day seleced for the month is an actual day
            $year=($_POST['year']=='0000')? date('Y'): $_POST['year'];
            if(date('t', mktime(0,0,0,$_POST['month'],1,$year))< $_POST['day'])
                message($lang_calendar['date_error']);

            $date = $_POST['year'].'-'.$_POST['month'].'-'.$_POST['day'];

            // Add the Event to the database
            $db->query('UPDATE '.$db->prefix.'calendar SET date="'.$date.'", title="'.$title.'", body="'.$body.'" WHERE id='.$_POST['event_id']) or error('Unable to Update event', __FILE__, __LINE__, $db->error());

            redirect('calendar.php?action=edit', $lang_calendar['event_edited']);
        }
        elseif(isset($_POST['delete_event']))
        {
            if(isset($_POST['delete_confirmed'])){
                $db->query('DELETE FROM '.$db->prefix.'calendar WHERE id ="'.$_POST['delete_event'].'"') or error('Unable to Delete event', __FILE__, __LINE__, $db->error());

                redirect('calendar.php?action=edit', $lang_calendar['event_deleted']);
            }
            else
            {
                if(empty($_POST['event']))
                    message($lang_calendar['no_event']);

                $result = $db->query('SELECT date, title, body FROM '.$db->prefix.'calendar WHERE id = "'.$_POST['event'].'"') or error('Unable to fetch Event info', __FILE__, __LINE__, $db->error());
                $cur_event = $db->fetch_assoc($result);


?>
</div>
<div class="blockform">
    <h2><span><?php echo $lang_common['Info'] ?></span></h2>
    <div class="box">
        <form method="post" action="calendar.php?action=edit">
            <input type="hidden" name="delete_event" value="<?php echo $_POST['event']?>" />
            <div class="inform">
                <fieldset>
                    <legend class=warntext><?php echo $lang_calendar['delete_confirm'];?></legend>
                    <div class="infldset">
                        <div class="postmsg">
                            <p><b><?php echo $cur_event['title']?></b></p>
                            <p><?php echo $cur_event['body']?></p>
                        </div>
                    </div>
                </fieldset>
            </div>
            <p><input type="Submit" name="delete_confirmed" value="<?php echo $lang_calendar['delete_yes']?>" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a>       <a href="calendar.php"><?php echo"Tr? v? l?ch"; ?></a></p>
        </form>
    </div>
<?php
            }
        }
        else if(isset($_POST['edit_event']))
        {
            if(empty($_POST['event']))
                message($lang_calendar['no_event']);

            // Get all the info for the event your trying to edit
            $result = $db->query('SELECT * FROM '.$db->prefix.'calendar WHERE id ="'.$_POST['event'].'"') or error('Unable to fetch event information', __FILE__, __LINE__, $db->error());
            $event_list = $db->fetch_assoc($result);

            // Get the date info and put it into parts
            $date = explode('-', $event_list['date']);
?>
    <div class="blockform">
    <h2><?php echo $lang_calendar['edit_event']?></h2>
    <div class="box">
        <form method="post" action="calendar.php?action=edit" onsubmit="return process_form(this)">
            <div class="inform">
                <fieldset>
                    <legend><?php echo $lang_calendar['edit_info']?></legend>
                    <div class="infldset">
                        <input type="hidden" name="form_sent" value="1" />
                        <input type="hidden" name="event_id" value="<?php echo $_POST['event']?>" />
                        <label style="float:left; width: 152px;">
                            <strong><?php echo $lang_calendar['Title']?></strong><br />
                            <input type="text"  value="<?php echo $event_list['title']?>" name="title" maxlength="50" tabindex="1" /><br />
                        </label>

                        <label class="conl">
                            <strong><?php echo $lang_calendar['Date']?></strong><br />

                            <select name="month" tabindex="2">
                                <option value='0'><?php echo $lang_calendar['Month']?></option>
<?php
    $month_name = array('',$lang_calendar['January'],$lang_calendar['February'],$lang_calendar['March'],$lang_calendar['April'],$lang_calendar['May'],$lang_calendar['June'],$lang_calendar['July'],$lang_calendar['August'],$lang_calendar['September'],$lang_calendar['October'],$lang_calendar['November'],$lang_calendar['December']);
    for($x=1;$x<13;$x++)
    {
        $s = ($x == $date[1])? " selected='selected'" : NULL ;
        echo"\t\t\t\t\t\t\t\t<option value='".$x."'".$s.">".$month_name[$x]."</option>\n";
    }
?>
                            </select>
                        </label>
                        <label class="conl"><br />
                            <select name="day" tabindex="3">
                                <option value='0'><?php echo $lang_calendar['Day']?></option>
<?php
    for($x=01;$x<=31;$x++)
    {
        $s = ($x == $date[2])? " selected='selected'" : NULL ;
        echo"\t\t\t\t\t\t\t\t<option value='".$x."'".$s.">".$x."</option>\n";
    }
?>
                            </select>
                        </label>
                        <label class="conl"><br />
                            <input name="year" value="<?php echo $date[0]?>" size="5" tabindex="4" /> 

                        </label>
                        <br />

                        <div class="txtarea">
                            <label class="conl">
                                <strong><?php echo $lang_calendar['Body']?></strong><br />
                                <textarea name="body" rows="7"  cols="65"><?php echo str_replace('<br />',"\n",$event_list['body'])?></textarea><br />
                            </label><br />
                        </div>
                        <br class="clearer">
                    </div>

                </fieldset>
            </div>
            <p><input type="submit" value="<?php echo $lang_common['Submit'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a>       <a href="calendar.php"><?php echo"Tr? v? l?ch"; ?></a></p>
        </form>
    </div>
    </div>

<?php
        }
        else
        {

            if(($pun_user['g_id'] == PUN_MOD && $CFG_mod_add=='yes') or ($pun_user['g_id'] == PUN_MOD && $CFG_mod_edit=='no') or ($pun_user['g_id'] == PUN_MEMBER && $CFG_user_add=='yes'))
                $can_edit = "WHERE user_id = ".$pun_user['id'];
            else
                $can_edit = "";

            //Number of posts to display
            $disp_posts = $pun_user['disp_posts'];

            $result = $db->query('SELECT id FROM '.$db->prefix.'calendar');
            $num_replies = $db->num_rows($result);

            // Determine the post offset (based on $_GET['p'])
            $num_pages = ceil(($num_replies) / $disp_posts);
            $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
            $start_from = $disp_posts * ($p - 1);

            $pages = paginate($num_pages, $p, 'calendar.php?action=edit');

            $result = $db->query('SELECT * FROM '.$db->prefix.'calendar '.$can_edit.' ORDER BY date LIMIT '.$start_from.','.$disp_posts) or error('Unable to fetch event information', __FILE__, __LINE__, $db->error());

            if(!$db->num_rows($result)){
                message($lang_calendar['no_events_edit']);
            }

?>
    <form method="post" action="calendar.php?action=edit" onsubmit="return process_form(this)">
    <div class="blockform">
        <h2><?php echo $lang_calendar['edit_event']?></h2>
        <div class="box">
            <table cellspacing='0'>
            <thead>
                <tr>
                    <th> </th>
                    <th><?php echo $lang_calendar['Title']?></th>
                    <th><?php echo $lang_calendar['Date']?></th>
                    <th><?php echo $lang_calendar['Body']?></th>


                </tr>
            </thead>
            <tbody>
<?php

            while($event_list = $db->fetch_assoc($result))
            {
                $date_part = explode('-',$event_list['date']);
                $date_year = ($date_part['0']=='0000')?  date('y') : $date_part['0'];
                $date = date_str( mktime(0,0,0,$date_part['1'],$date_part['2'],$date_year));
?>
                <tr>
                    <td style="width:10px">
                        <input type="radio" name="event" value="<?php echo $event_list['id']?>" />
                    </td>
                    <td style="width:145px"><?php echo $event_list['title']?></td>
                    <td style="width:85px"><?php echo $date ?></td>
                    <td><?php echo str_replace('\n','<br />',$event_list['body'])?></td>

                </tr>
<?php
            }
?>
                <tr>
                    <td colspan="4">
                        <input type="submit" value="<?php echo $lang_calendar['edit_event']?>" name="edit_event" /> <input type="submit" value="<?php echo $lang_calendar['delete_event']?>" name="delete_event" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a>       <a href="calendar.php"><?php echo"Tr? v? l?ch"; ?></a>
                    </td>
                </tr>
            </tbody>
            </table>
        </div>
    </div>
    </form>
</div>
<div class="linksb">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $lang_common['Pages'].': '.$pages?></p>
        <div class="clearer"></div>
    </div>
<?php
        }


    }
}
//
// Show the weekly calendar
//
elseif(isset($week))
{
    ########################################################
    ###//===============//===============//==============//#
    ##//===============// Week Calendar //==============//##
    #//===============//===============//==============//###
    ########################################################
    list($year,$week) = explode('.',$week);
    $day_one = (date('w',mktime(0,0,0,1,1,$year))==0)? 7 : date('w',mktime(0,0,0,1,1,$year));

    $first_day = strtotime("-".$day_one." days", mktime(0,0,0,1,1,$year));
    $date = strtotime ("+$week weeks", $first_day);
    $month = date('n',$date);
    $week_start = mktime(0,0,0,date('n',$date),date('j',$date),$year);
    $week_end = $week_start+(60*60*24*7);

        $strdate = date(Y, $date)."-".$month."-".date('d',$date);
        $strdate2 = date(Y, $week_end)."-".date('m',$week_end)."-".date('d',$week_end);


    //change querys if $type is set to posts
    if($type == "posts")
    {

        $result = $db->query('SELECT t.posted FROM '.
                          $db->prefix.'topics as t LEFT JOIN '.
                          $db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].
                          ') WHERE t.posted > '.$week_start.' AND t.posted < '.$week_end.
                          ' AND    (fp.read_forum IS NULL OR fp.read_forum=1)') or
                          error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
        $topic = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
        while($topic_list = $db->fetch_row($result)){
            $time = date("j",$topic_list[0]);
            $topic[$time]++;
        };

        //Find the posts made for "said" day (one month only)
        $result = $db->query('SELECT p.posted FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON p.topic_id=t.id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].') WHERE p.posted > '.$week_start.' AND p.posted < '.$week_end.' AND (fp.read_forum IS NULL OR fp.read_forum=1)') or error('Unable to fetch posts list', __FILE__, __LINE__, $db->error());
        $posts = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
        while($post_list = $db->fetch_assoc($result)){
            $time = date('j',$post_list['posted']);
            $posts[$time]++;
        };
    }
    //change querys if $type is set to events
    elseif($type == "events")
    {
        //Find the birthdays for "said" day (selected week)
        $strWhere = 'WHERE MONTH(birthday) = '.$month.' or (MONTH(birthday) = '.date('n',$week_end).' and DAYOFMONTH(birthday) < 7) ';
        $strQuery = 'SELECT DAYOFMONTH(birthday) as day, username FROM '.$db->prefix.'users '.$strWhere;

        $result = $db->query($strQuery) or error('Unable to fetch birtday list', __FILE__, __LINE__, $db->error());
        $bdays = array('','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','');
        while($bday_list = $db->fetch_assoc($result)){
            if(count($bday_list)>6)
                $bdays[$bday_list['day']]++;
            else
                $bdays[$bday_list['day']] .="*<a href='calendar.php?view=bday&date=".$year.".".$month.".".$bday_list['day']."'>".$lang_calendar['Birthday'].$bday_list['username']."</a>  ";
        };

        //Find the events for "said" day (selected week)
        $strWhere = 'WHERE date >= "'.$strdate .'" AND date <= DATE_ADD("'.$strdate.'", INTERVAL 8 DAY ) ';
        $strQuery = 'SELECT id, title, DAYOFMONTH(date) as day FROM '.$db->prefix.'calendar '.$strWhere;
              $result = $db->query($strQuery) or
                          error('Unable to fetch calendar dates', __FILE__, __LINE__, $db->error());
        $dates = array('','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','');
        while($dates_list = $db->fetch_assoc($result)){
            $dates[$dates_list['day']] .= "*<a href='calendar.php?view=event&id=".$dates_list['id']."'>".$dates_list['title']."</a>  ";
        };
    }
?>
    <div style="width:100%;float:left;margin-right:-225px">
    <div style="display:inline;float:left;margin-right:225px">

<?php
    //list dates in this week
    if($CFG_start_day == "S"){$a='0';$b='7';}
    elseif($CFG_start_day == "M"){$a='1';$b='8';}

    for ($x=$a; $x<$b; $x++) {
            $datestamp = strtotime("+$x days", $date);
        $wk_name = $lang_calendar[date ('l', $datestamp)];
        $date_no      =date('j', $datestamp);
        $mth_name =date('F', $datestamp);
        $year_name =date("Y", $datestamp);
                $month_no   =date("n", $datestamp);

        if ($x == "0" | ($x == "1" & $b =="8")){
            echo "\t<h2><a href='calendar.php?".$ltype."date=".$year_name.".".$month_no."'>".$lang_calendar[$mth_name]." ".$year_name."</a></h2>\n\t<div class='box'>\n\t<table cellspacing='0'>\n";
        } elseif(date('d', $datestamp)=="1" ){
            echo "\t\t</table>\n\t</div>\n";
            echo "\t<h2><a href='calendar.php?".$ltype."date=".$year_name.".".$month_no."'>".$lang_calendar[$mth_name]." ".$year_name."</a></h2>\n\t<div class='box'>\n\t<table cellspacing='0'>\n";
        }
        $class = ($date_no == date('j') && $mth_name == date('F') && $year_name == date('Y'))? "class='calendar_day'" : "";
                        if (!empty($bdays[$date_no])) $class =" class='calendar_bday'";
                        if (!empty($dates[$date_no])) $class =" class='calendar_event'";

        echo "\t\t\t\t<tr><td valign='top' colspan='2' ".$class."><strong>".$wk_name."</strong></td></tr>\n";
        echo "\t\t\t\t<tr>\n\t\t\t\t\t<td valign='top' style='width:2%' ".$class.">".$date_no."</td>\n";
        echo "\t\t\t\t\t<td style='width:97%' ".$class.">";

        if(!empty($topic[$date_no]))echo"<a href='calendar.php?view=topics&date=".$year.".".$month.".".$date_no."'>".$lang_calendar['Topics']." ".$topic[$date_no]."</a>  ";
        if(!empty($posts[$date_no]))echo"<a href='calendar.php?view=posts&date=".$year.".".$month.".".$date_no."'>".$lang_calendar['Posts']." ".$posts[$date_no]."</a>  ";

        if(!empty($bdays[$date_no]) && !is_int($bdays[$date_no]))
            echo "<a href='calendar.php?view=bday&date=".$year.".".$month.".".$date_no."'>".$lang_calendar['Birthdays']." ".$bdays[$date_no]."</a><br /><img src='./img/icon_party.gif' width='38' height='18' alt='' />";
        elseif(!empty($bdays[$date_no]) && is_int($bdays[$date_no]))
                echo $bdays[$date_no];

            if(!empty($dates[$date_no]))
                echo $dates[$date_no];
        
        echo " </td>\n\t\t\t\t</tr>\n\n";
    }
?>
                <tr>
                    <td colspan="2"><div style="float:left">
<?php                    echo "<a href='calendar.php?week=".$year.".".($week-1)."'>".$lang_calendar['Last Week']."</a> | ";
                    echo "<a href='calendar.php?week=".$year.".".($week+1)."'>".$lang_calendar['Next Week']."</a></div>"; ?>
<?php if($CFG_show_typelist=="yes") { ?>
                    <div style="float:right">
                                                <form id="date" method="post" action="calendar.php?week=<?php echo $_GET['week']?>">
                                                        <div style="float:left">
                                                                <select name="type" onChange="document.forms['date'].submit()">
                                                                        <option value="posts"<?php if($type=="posts")echo" selected='selected'"?>><?php echo $lang_calendar['posts/topics']?></option>
                                                                        <option value="events"<?php if($type=="events")echo" selected='selected'"?>><?php echo $lang_calendar['events']?></option>
                                                                </select>

                                                        </div>
                                                </form>
                                 </div>
<?php } ?>
                                       </td>
                </tr>

            </table>
        </div>


<?php    if(
        ($pun_user['g_id'] == PUN_MOD && $CFG_mod_add=='yes')
        or ($pun_user['g_id'] == PUN_MEMBER && $CFG_user_add=='yes')
        or ($pun_user['g_id'] == PUN_ADMIN)
    )
        echo "\t<br />\n\t<div class='box'><p> <a href='https://os.fastueux.com/Forum/calendar.php?action=add'>".$lang_calendar['Add_event']."</a> | <a href='calendar.php?action=edit'>".$lang_calendar['Edit_event']."</a></p></div>\n";
?>
</div>
    </div>

<?php    if($CFG_show_cal == "yes"){
    echo "<div style='float:right;width:215px'>";
        mini_cal($month_no, $year, "week");
        echo "</div>";
        }
?>

    <br class="clearer" />


<?php

}
//
//
//if $actions, $view or $week isnt set
//
else
{
    #########################################################
    ###//===============//===============//===============//#
    ##//===============// Main Calendar //===============//##
    #//===============//===============//===============//###
    #########################################################

    //change querys if $type is set to posts
    if($type == "posts")
    {

        $result = $db->query('SELECT t.posted FROM '.$db->prefix.'topics as t LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].') WHERE t.posted > '.$month_start.' AND t.posted < '.$month_end.' AND    (fp.read_forum IS NULL OR fp.read_forum=1)') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
        $topic = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
        while($topic_list = $db->fetch_row($result)){
            $time = date("j",$topic_list[0]);
            $topic[$time]++;
        };

        //Find the posts made for "said" day
        $result = $db->query('SELECT p.posted FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON p.topic_id=t.id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].') WHERE p.posted > '.$month_start.' AND p.posted < '.$month_end.' AND (fp.read_forum IS NULL OR fp.read_forum=1)') or error('Unable to fetch posts list', __FILE__, __LINE__, $db->error());
        $posts = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
        while($post_list = $db->fetch_assoc($result)){
            $time = date('j',$post_list['posted']);
            $posts[$time]++;
        };
    }
    //change querys if $type is set to events
    elseif($type == "events")
    {

        //Find the birthdays for "said" day
        $result = $db->query('SELECT DAYOFMONTH(birthday) as day, username FROM '.$db->prefix.'users WHERE MONTH(birthday) = '.$month) or error('Unable to fetch birtday list', __FILE__, __LINE__, $db->error());
        $bdays = array('','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','');
        while($bday_list = $db->fetch_assoc($result)){
            if(count($bday_list)>3)
                $bdays[$bday_list['day']]++;
            else
                                $bdays[$bday_list['day']] .="<a href='calendar.php?view=bday&date=".$year.".".$month.".".$bday_list['day']."'>".$bday_list['username'].$lang_calendar['Birthday']."</a><br />";
        };

        //Find the events for "said" day
        $result = $db->query('SELECT id, title, DAYOFMONTH(date) as day FROM '.$db->prefix.'calendar WHERE MONTH(date) = '.$month.' AND (YEAR(date) = '.$year.' OR YEAR(date) = "0000")') or error('Unable to fetch calendar dates', __FILE__, __LINE__, $db->error());
        $dates = array('','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','');
        while($dates_list = $db->fetch_assoc($result)){
            $dates[$dates_list['day']] .= "<a href='calendar.php?view=event&date=".$year.".".$month.".".$dates_list['day']."'>".$dates_list['title']."</a><br />";
        };


    }
?>
    <h2 style="text-align:center">
        <span>
                     <!--   <a href="calendar.php?<?php echo $ltype?>date=<?php echo ($year-1).'.'.$month;?>"><–</a> -->
                        <a href="calendar.php?<?php echo $ltype?>date=<?php if($month == 1){echo $year-1;}else{echo$year;}?>.<?php if($month == 1){echo '12';}else{echo $month-1;}?>"><<—</a>
            <?php echo $lang_calendar[$monthtext]." ".$year."\n" ?>
                        <a href="calendar.php?<?php echo $ltype?>date=<?php if($month == 12){echo $year+1;}else{echo$year;}?>.<?php if($month == 12){echo '1';}else{echo $month+1;}?>">—>></a>
                     <!--   <a href="calendar.php?<?php echo $ltype?>date=<?php echo ($year+1).'.'.$month;?>">–></a> -->
        </span>
    </h2>
    <div class="box">
        <table cellspacing="0">
        <thead>
            <tr>
<?php if($CFG_start_day == "S"):?>                <th><?php echo $lang_calendar['Sunday']?></th>
<?php endif;?>                <th><?php echo $lang_calendar['Monday']?></th>
                <th><?php echo $lang_calendar['Tuesday']?></th>
                                <th><?php echo $lang_calendar['Wednesday']?></th>
                <th><?php echo $lang_calendar['Thursday']?></th>
                <th><?php echo $lang_calendar['Friday']?></th>
                <th><?php echo $lang_calendar['Saturday']?></th>
<?php if($CFG_start_day == "M"):?>                <th><?php echo $lang_calendar['Sunday']?></th>
<?php endif;?>
                <th class='calendar_wk'> </th>
            </tr>
        </thead>
        <tbody>
            <tr>
<?php

        if ($day_of_wk <> 0){
            for ($i=0; $i<$day_of_wk; $i++)
            { echo "\t\t\t\t<td valign='top' style='width:14%; height:75px' class='calendar_no' > </td>\n"; }
        }

        for ($date_of_mth = 1; $date_of_mth <= $days_in_mth; $date_of_mth++) {

            $date_no = date("j", mktime(0, 0, 0, $month, $date_of_mth, $year));
            $day_of_wk = start_date(date('w', mktime(0, 0, 0, $month, $date_of_mth, $year)));
            $class = ($date_no ==  date("j") &&  $month == date("n") && $year == date("Y"))? " class='calendar_day'" : NULL ;
                        if (!empty($bdays[$date_no])) $class =" class='calendar_bday'";
                        if (!empty($dates[$date_no])) $class =" class='calendar_event'";

            echo "\t\t\t\t<td valign='top' style='width:14%; height:75px'".$class."><span>".$date_no."</span><br />";

            if(!empty($topic[$date_no]))echo"<a href='calendar.php?view=topics&date=".$year.".".$month.".".$date_no."'>".$lang_calendar['Topics']." ".$topic[$date_no]."</a><br />";
            if(!empty($posts[$date_no]))echo"<a href='calendar.php?view=posts&date=".$year.".".$month.".".$date_no."'>".$lang_calendar['Posts']." ".$posts[$date_no]."</a><br />";

            if(!empty($bdays[$date_no]) && !is_int($bdays[$date_no]))
                echo"<a href='calendar.php?view=bday&date=".$year.".".$month.".".$date_no."'>".$lang_calendar['Birthdays']."<br /> ".$bdays[$date_no]."</a><br />";
            elseif(!empty($bdays[$date_no]) && is_int($bdays[$date_no]))
                echo $bdays[$date_no]."<br />";

            if(!empty($dates[$date_no]))echo $dates[$date_no]."<br />";

            echo "</td>\n";

            if ( $day_of_wk == 6 )
            {

                //if $date_no minus 5 days is greater than 0 AKA 1 or biger
                if($date_no-5 > 0)
                {
                    $date_link = date('W', mktime(0,0,0,$month,($date_no-5),$year));
                    $year_link = $year;
                }
                //if its less than 1 aka 0 or negitive
                else
                {
                    //if $month minus 1 month is less than 1 AKA 0 or negitive
                    if($month-1 < 1)
                    {
                        $pre_year = $year-1;
                        $pre_month = '12';
                        $pre_day = date('t', mktime(0,0,0,$pre_month,1,$pre_year))+($date_no-5)-1;

                    }
                    else
                    {
                        $pre_year = $year;
                        $pre_month = $month-1;
                        $pre_day = date('t', mktime(0,0,0,$pre_month,1,$pre_year))+($date_no-5);

                    }

                    $date_link = date('W', mktime(0,0,0,$pre_month,$pre_day,$pre_year));
                    $year_link = $pre_year;
                }

        //        if($year_link == date('Y')-1)        $date_link = $date_link-1;
        //        elseif($year_link == date('Y')+1)    $date_Link = $date_link+1;
                echo "\t\t\t\t<td class='calendar_wk'><a href='calendar.php?".$ltype."week=".$year_link.".".$date_link."'>«</a></td>\n";

                echo "\t\t\t</tr>\n\t\t\t<tr>\n";
            }
            if ( $day_of_wk < 6 && $date_of_mth == $days_in_mth ) {

                for ( $i = $day_of_wk ; $i < 6; $i++ )
                { echo "\t\t\t\t<td valign='top' style='width:14%; height:75px' class='calendar_no' > </td>\n"; }

                echo "\t\t\t\t<td class='calendar_wk'><a href='calendar.php?week=".$year_link.".".($date_link+1)."'>«</a></td>\n";
                echo "\t\t\t</tr>\n";
            }
            if( $date_of_mth == $days_in_mth)
                break;
        }
?>
                <td colspan="8">
                    <div style="float:left; padding-top:5px; padding-right:3px"><?php echo $lang_calendar['go_to']?></div>
                    <form id="date" method="post" action="calendar.php">
                        <div style="float:left">
                            <select name="month">
<?php
                $month_name = array($lang_calendar['January'],$lang_calendar['February'],$lang_calendar['March'],$lang_calendar['April'],$lang_calendar['May'],$lang_calendar['June'],$lang_calendar['July'],$lang_calendar['August'],$lang_calendar['September'],$lang_calendar['October'],$lang_calendar['November'],$lang_calendar['December']);
                for($x=00;$x<12;$x++)
                {
                    $z = $x+1;
                    echo"\t\t\t\t\t\t\t\t<option value='".$z."'";
                    if($month == $z)echo" selected='selected'";
                    echo">".$month_name[$x]."</option>\n";
                }
?>
                            </select>
                            <select name="year">
<?php
                for($x=-5; $x<=5; $x++)
                {
                    $said_year = $year+$x;
                    echo"\t\t\t\t\t\t\t\t<option value='".$said_year."'";
                    if($said_year == $year)echo" selected='selected'";
                    echo ">".$said_year."</option>\n";
                }
?>
                            </select>
                                                        <input type="submit" value="<?php echo $lang_calendar['go'] ?>" />
                        </div>
                        <div style="float:left; padding-top:5px; padding-left:3px">
                            <a href="calendar.php?date=<?php echo date('Y.m')?>"><?php echo $lang_calendar['current_month'];?></a>
                            <a href="calendar.php?week=<?php echo date('Y.W')?>"><?php echo $lang_calendar['current_week'];?></a>
                        </div>
<?php if($CFG_show_typelist=="yes") { ?>
                                              <div style="float:right">
                                                        <select name="type" onChange="document.forms['date'].submit()" >
                                                                <option value="posts"<?php if($type=="posts")echo" selected='selected'"?>><?php echo $lang_calendar['posts/topics']?></option>
                                                                <option value="events"<?php if($type=="events")echo" selected='selected'"?>><?php echo $lang_calendar['events']?></option>
                                                        </select>
                                                </div>
<?php } ?>
                    </form>
                </td>
            </tr>
        </tbody>
        </table>
    </div>
<?php
    if($CFG_show_cal == "yes"){
        echo"\t<br />\n\t<table cellspacing='0'>\n\t<tr>\n\t\t<td valign='top' style='border:none;padding:0 5px 0 0; margin:0'>\n";
        mini_cal($month, $year, 'main');
        echo "\t\t</td>\n\t</tr>\n\t</table>\n";
    }

    if(
        ($pun_user['g_id'] == PUN_MOD && $CFG_mod_add=='yes')
        or ($pun_user['g_id'] == PUN_MEMBER && $CFG_user_add=='yes')
        or ($pun_user['g_id'] == PUN_ADMIN)
    )
        echo "\t<br />\n\t<div class='box'><p> <a href='calendar.php?action=add'>".$lang_calendar['Add_event']."</a> | <a href='calendar.php?action=edit'>".$lang_calendar['Edit_event']."</a></p></div>\n";
}
?>
</div>
<?php require PUN_ROOT.'footer.php';?>
<script language="javascript1.2" type="text/javascript" src="https://os.fastueux.com/Forum/js/him.js"></script>

here it is. I dont think i have changed anything though...Thanks

I love sky - i love flowers - and i love myself :D

282

Re: Calendar 2.0

@Mystic..
There's nothing I can see wrong with your file.
I did, however, have to edit the first couple lines because in my installation I use the upgrade from
"2.Readme Calendar 2.0.7 to 2.0.7b UPDATE Instructions.txt"
Instruction #8, as follows

#-----------[ 8. OPEN ]------------------------------
# This includes several fixes and some minor additions
#

      calendar.php

#
#-----------[ 9a.  Find ~line 3 ]-------------------
#

require PUN_ROOT.'calendar/header.php';
require PUN_ROOT.'include/parser.php';

#
#-----------[ 9b.  Replace with  ]-----------------------
# 

// require PUN_ROOT.'calendar/header.php';
require PUN_ROOT.'include/common.php';
require PUN_ROOT.'include/parser.php';

..
If you use this method but fail to implement that change you should receive a "failed to open stream" error code message (not a blank page) from /calendar/header.php, which I did not observe on your website.

I am a bit stumped  |^\

I have two thoughts/suggestions:
1) Check your database tables
2) Copy all your calendar files to a local directory and run some diffs to the installation files so you can observe any other potential changes that may indicate file code corruption in any of those files, or anything else weird.

3)I hate to say it, but if the database is okay (and I think it probably is or you would most likely get a different error than a blanmk page) ...I think the way for you to troubleshoot this may be to...
1) backup the whole site
2) Remove the calendar Mod
3) Reinstall the calendar mod fresh
...taking things a step at a time and testing to see where/if it fails.

---------------------
I hope someone else can jump in here and  offer you better suggestions. 
If I think of anything else I will post back here.

Good luck.

TwoHawks
Love is the Function
No Form is the Tool

283

Re: Calendar 2.0

Sorry, that is another plugin. I added three mods to my forum yesterday and what I asked was about the image_upload mod. Sorry again wink

FluxBB - v1.4.8

284

Re: Calendar 2.0

Where would I have to "plug in" a self-made stylesheet for my calendar? (I just wanted to change the link colors for the colors, and I saw no other way)...

FluxBB - v1.4.8

285

Re: Calendar 2.0

o0O..does anyone ever actually read the readme's?? 0Oo

lie... look in the place in the readme where it says you can customize your own colors.
Cheers,

TwoHawks
Love is the Function
No Form is the Tool

286

Re: Calendar 2.0

roll OOps, I really missed something there. The dumm thing is though, that would change the link colors everywhere, wouldn't it?

FluxBB - v1.4.8

287

Re: Calendar 2.0

lie2815 wrote:

roll OOps, I really missed something there. The dumm thing is though, that would change the link colors everywhere, wouldn't it?

Yes and no...
In "1.Readme..."  #14 clearly states some installations may not require the ".pun" adjustment... that's because i havven't spent time on it to sort it out better.

However, if you continue reading you will see that #15 assigns css codes for only the calendar.

I think this should be readily clear.
If anyone thinks it could be explained better in the readme, please share your thoughts.
I hope this helps ;^)

TwoHawks
Love is the Function
No Form is the Tool

288

Re: Calendar 2.0

A lot. Thanks. I just didnt know where to put it in the other file. Now I know. Thanks again.

FluxBB - v1.4.8

289

Re: Calendar 2.0

hmm it still cant...weird...

I've checked the database; nothing seems wrong. Furthermore; i tried to delete/add event inside phpmyadmin, it still does highlight on the small calendar but cant access...blank page still..

I love sky - i love flowers - and i love myself :D

290

Re: Calendar 2.0

mystic wrote:

hmm it still cant...weird...

I've checked the database; nothing seems wrong. Furthermore; i tried to delete/add event inside phpmyadmin, it still does highlight on the small calendar but cant access...blank page still..

It would be more helpful if you post more precisely of what you actually did or didn't do, especially with regard to all suggestions beign posted here, as "it still cant" and the only mentioning checking the database... doesn't really give us enough to go off of (maybe you tried out one or two suggestions, or all of them ???). 
   And did you confirm with your host regarding any upgrades to your services they may have performed (like php upgrade they may have implemented)?

If you tried the other suggestions unsuccessfully, and your host has not implemented updates, then I think what I would do is install another fresh copy of punbb (using a prefix) into a new folder (say, 'testforum' or something), and then begin installing my mods one at a time, starting with the problem one, in this case the calendar mod, being sure to configure each one fully the why I wanted it before moving on to the next.

If I was successful in rebuilding the forum structure including installing all my mods in good working  order, then I would begin copying the original database tables into the new ones, essentially populating my new tables with the original information, one at a time and testing along the way. 

The idea is that while you rebuild the forum you should eventually run into where a problem arises, OR, in the off chance you don't, you will have succeeded in rebuilding a good working version of your forum and then be able to migrate it into place of the original.

I am sorry,  I simply cannot right now think of some other way to troubleshoot this (without hands -on access).

I hope this helps. Good luck.
HTH

TwoHawks
Love is the Function
No Form is the Tool

291

Re: Calendar 2.0

thank you for your reply. I did uninstall the calendar mod..i will try to fresh install it again...

Thanks

I love sky - i love flowers - and i love myself :D

292

Re: Calendar 2.0

twohawks wrote:

I would be happy to take a look at your file and check your code, Vanslyde, if you wish to post the code (or a temporary link to where I can download your calendar.php file).  I can then test it for you here.  Be sure to use the !code tag! if you post the code here!

here's my calendar.php
I tried the modifications you posted here on feb 12th. It didn't work (apart form the "No_Event message display corrections" - thanks!) and I rolled back to the previous version. I removed the Birthday stuff.

I'm stll looking for a way to a hide the Edit Event link for a guest if he/she didn't posted any in the first place, 'cause otherwiise that would bring them to this kind of screen

<?php
define('PUN_ROOT', './');
require PUN_ROOT.'calendar/header.php';
require PUN_ROOT.'include/parser.php';


?>
<!--Calendar Version:2.0.6a -->
<div class="blocktable">
<?php
//
//do the stuff like viewing topics posts birthdays or events
//
if(isset($view))
{
    if($view == 'topics')
    {
        ###########################################################
        ###//===============//=================//===============//#
        ##//===============// Show Topic List //===============//##
        #//===============//=================//===============//###
        ###########################################################

        //Number of posts to display
        $disp_topics = $pun_user['disp_topics'];

        $result = $db->query('SELECT id FROM '.$db->prefix.'topics WHERE posted > '.$datestart.' AND posted < '.$dateend);
        $num_replies = $db->num_rows($result);


        // Determine the post offset (based on $_GET['p'])
        $num_pages = ceil(($num_replies) / $disp_topics);

        $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
        $start_from = $disp_topics * ($p - 1);

        $pages = paginate($num_pages, $p, 'calendar.php?view=topics&date='.$year.'.'.$month.'.'.$day);

        // Pulls list of topics for the day
        $result = $db->query('
            SELECT
             t.id, t.poster, t.subject, t.posted, t.last_post, t.last_post_id, t.last_poster, t.moved_to, t.num_replies, t.closed, t.forum_id
            FROM '.$db->prefix.'topics AS t
            LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].')

            WHERE
                t.posted > '.$datestart.'  AND
                t.posted < '.$dateend.' AND
                (fp.read_forum IS NULL OR fp.read_forum=1)

            ORDER BY posted LIMIT '.$start_from.','.$disp_topics
        ) or error('Unable to fetch topic list for forum', __FILE__, __LINE__, $db->error());

?>
        <h2 style="text-align:center"><span><?php echo $lang_calendar['Viewing_Topics']." ".$datestring ?></span></h2>

        <div class="box">

        <table cellspacing="0">
        <thead>
        <tr>
            <th style="white-space: nowrap"><?php echo $lang_common['Topic']?></th>
            <th style="width: 13%; white-space: nowrap"><?php echo $lang_common['Author']?></th>
            <th style="width: 7%; white-space: nowrap"><?php echo $lang_common['Replies']?></th>
            <th style="width: 25%; white-space: nowrap"><?php echo $lang_common['Last post']?></th>
        </tr>
        </thead>
        <tbody>
<?php
        if($db->num_rows($result))
        {
            while ($cur_topic = $db->fetch_assoc($result))
            {
                if ($cur_topic['moved_to'] == null)
                    $last_post = '<a href="viewtopic.php?pid='.$cur_topic['last_post_id'].'#'.$cur_topic['last_post_id'].'">'.format_time($cur_topic['last_post']).'</a><br /> '.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['last_poster']);
                else
                    $last_post = ' ';

                if ($pun_config['o_censoring'] == '1')
                    $cur_topic['subject'] = censor_words($cur_topic['subject']);

                if ($cur_topic['closed'] == '0')
                    $subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a>';
                else
                    $subject = '<a class="punclosed" href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a>';

?>
            <tr class="puntopic">
                <td><?php echo $subject ?></td>
                <td><?php echo pun_htmlspecialchars($cur_topic['poster']) ?></td>
                <td><?php echo ($cur_topic['moved_to'] == null) ? $cur_topic['num_replies'] : ' ' ?></td>
                <td style="white-space: nowrap"><?php echo $last_post ?></td>
            </tr>
<?php
            }
        }else
            echo"\t\t\t<tr>\n\t\t\t\t<td colspan='4'>".$lang_calendar['No_Topics']."</td>\n\t\t\t</tr>";
?>
            <tr>
                <th colspan='4'> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a>       <a href="calendar.php"><?php echo"Return to Calendar"; ?></a> </th>
            </tr>
        </tbody>
        </table>
    </div>

<?php
        navigation('topics');
    }
    elseif($view == 'posts')
    {
        ##########################################################
        ###//===============//================//===============//#
        ##//===============// Show Post list //===============//##
        #//===============//================//================ ###
        ##########################################################

        //Number of posts to display
        $disp_posts = $pun_user['disp_posts'];

        $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE posted > '.$datestart.' AND posted < '.$dateend);
        $num_replies = $db->num_rows($result);


        // Determine the post offset (based on $_GET['p'])
        $num_pages = ceil(($num_replies) / $disp_posts);

        $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
        $start_from = $disp_posts * ($p - 1);

        $pages = paginate($num_pages, $p, 'calendar.php?view=posts&date='.$year.'.'.$month.'.'.$day);

        $result = $db->query('
            SELECT
             p.id, p.poster, p.poster_id, p.message, p.posted, p.topic_id,
             t.id as tid, t.subject as tsub, t.forum_id,
             f.id as fid, f.forum_name as fname

            FROM '.$db->prefix.'posts AS p
            INNER JOIN '.$db->prefix.'topics AS t ON p.topic_id=t.id
            INNER JOIN '.$db->prefix.'forums AS f ON t.forum_id=f.id
            LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')


            WHERE
                p.posted > '.$datestart.' AND
                p.posted < '.$dateend.' AND
                (fp.read_forum IS NULL OR fp.read_forum=1)

            ORDER BY p.posted LIMIT '.$start_from.','.$disp_posts
        )or error('Unable to fetch topic list for forum', __FILE__, __LINE__, $db->error());

?>
        <h2 style="text-align:center"><span><?php echo $lang_calendar['Viewing_Posts']." ".$datestring ?></span></h2>

        <div class="box">
        <table cellspacing="0">
        <thead>
            <tr>
                <th style="white-space: nowrap"> <?php echo $lang_common['Message']?></th>
                <th style="width: 12%"><?php echo $lang_common['Posted']?></th>
                <th style="width: 12%"><?php echo $lang_common['Forum']?></th>
            </tr>
        </thead>
        <tbody>
<?php
        if($db->num_rows($result))
        {
            while ($cur_posts = $db->fetch_assoc($result))
            {
                if (pun_strlen($cur_posts['message']) >= 80)
                {
                    $cur_posts['message'] = substr($cur_posts['message'], 0, 79);
                    $cur_posts['message'] .= '…';
                }

?>
            <tr>
                <td>
                <?php echo $lang_common['Topic']?>: <a href="viewtopic.php?id=<?php echo$cur_posts['tid']?>"><?php echo $cur_posts['tsub']?></a><br />
                <?php echo $lang_calendar['Posted_by']?> <a href="profile.php?id=<?php echo$cur_posts['poster_id']?>"><?php echo $cur_posts['poster']?></a><br />

                <div class="box" style="padding:5px; margin:4px;">
                    <?php echo $cur_posts['message']?>
                    <div style="text-align: right">
                        <a href="viewtopic.php?pid=<?php echo$cur_posts['id'].'#p'.$cur_posts['id']?>"><?php echo $lang_calendar['go_to_post']?></a>
                    </div>
                </div>
                </td>
                <td class="puncon2cent"><?php echo date($pun_config['o_time_format'], $cur_posts['posted'])?></td>
                <td class="puncon1cent"><a href="viewforum.php?id=<?php echo$cur_posts['fid']?>"><?php echo $cur_posts['fname']?></a></td>

            </tr>

<?php            }
        }else
            echo"\t\t\t<tr>\n\t\t\t\t<td colspan='3'>".$lang_calendar['No_Posts']."</td>\n\t\t\t</tr>";
?>
                <tr>
                    <th colspan='3'> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a>       <a href="calendar.php"><?php echo"Return to Calendar"; ?></a> </th>
                </tr>
            </tbody>
            </table>
        </div>
<?php
        navigation('posts');
    }
    elseif($view == 'bday')
    {
        ###########################################################
        ###//===============//===============//=================//#
        ##//===============// Birthday list //=================//##
        #//==================================================// ###
        ###########################################################
        require PUN_ROOT.'lang/'.$pun_user['language'].'/profile.php';

        $result = $db->query('SELECT id, username, use_avatar, last_post, registered, birthday, DAYOFMONTH(birthday) as day    FROM '.$db->prefix.'users WHERE DAYOFMONTH(birthday) = '.$day.' AND MONTH(birthday) = '.$month.' ORDER BY username') or error('Unable to fetch birtday list', __FILE__, __LINE__, $db->error());


?>
        <h2 style="text-align:center"><span><?php echo $lang_calendar['Viewing_Bday']." ".$datestring ?></span></h2>

        <div class="box">

        <table cellspacing="0">
        <thead>
            <tr>
                <th style="width: 80px"><?php echo $lang_profile['Avatar']?></th>
                <th style="width: 25%; text-align: center"><?php echo $lang_common['Username']?></th>
                <th style="width: 15%; text-align: center"><?php echo $lang_calendar['Age']?></th>
                <th style="text-align: center"><?php echo $lang_common['Registered']?></th>
            </tr>
        </thead>
        <tbody>

<?php
        if($db->num_rows($result))
        {
            while($bday_list = $db->fetch_assoc($result))
            {
                if ($bday_list['use_avatar'] == '1')
                {
                    if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$bday_list['id'].'.gif'))
                        $avatar = '<img class="punavatar" src="'.$pun_config['o_avatars_dir'].'/'.$bday_list['id'].'.gif" alt="" />';
                    else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$bday_list['id'].'.jpg'))
                        $avatar = '<img class="punavatar" src="'.$pun_config['o_avatars_dir'].'/'.$bday_list['id'].'.jpg" alt="" />';
                    else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$bday_list['id'].'.png'))
                        $avatar = '<img class="punavatar" src="'.$pun_config['o_avatars_dir'].'/'.$bday_list['id'].'.png" alt="" />';
                    else
                        $avatar = $lang_profile['No avatar'];
                }
                else
                    $avatar = $lang_profile['No avatar'];

                list($bday_year,$bday_month,$bday_day) = explode('-', $bday_list['birthday']);
                $age = (strlen($bday_year)!='4')? $lang_profile['Unknown']: $year-$bday_year;
?>
            <tr>
                <td><?php echo $avatar?></td>
                <td style="text-align: center; font-size: 120%"><a href="profile.php?id=<?php echo$bday_list['id']?>"><?php echo $bday_list['username']?></a></td>
                <td style="text-align: center; font-size: 120%"><?php echo $age?></td>
                <td style="text-align: center; font-size: 120%"><?php echo format_time($bday_list['registered'])?></td>
            </tr>
<?php
            }
        }else
            echo"\t\t\t<tr>\n\t\t\t\t<td colspan='4'>".$lang_calendar['No_Bday']>"</td>\n\t\t\t</tr>\n";
?>
            <tr>
                <th colspan='4'> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a>       <a href="calendar.php"><?php echo"Return to Calendar"; ?></a> </th>
            </tr>
        </tbody>
        </table>
    </div>
<?php
        navigation('bday');
    }
    elseif($view == 'event')
    {
        ######################################################
        ###//===============//=============//==============//#
        ##//===============// Events List //==============//##
        #//===============//=============//==============//###
        ######################################################

        $stype = (isset($_GET['id']))? 'e.id = '.intval($_GET['id']) : 'dayofmonth(e.date) = '.$day.' AND month(e.date) = '.$month ;
        $result = $db->query('SELECT e.id, e.date, e.title, e.user_id, e.body, u.username as username, u.num_posts as posts, u.registered as reg, g.g_title as group_id FROM '.$db->prefix.'calendar AS e INNER JOIN '.$db->prefix.'users AS u ON e.user_id=u.id LEFT JOIN '.$db->prefix.'groups AS g ON u.group_id=g.g_id WHERE '.$stype) or error('Unable to fetch event list', __FILE__, __LINE__, $db->error());
?>
    <h2 style="text-align:center"><span><?php echo $lang_calendar['Viewing_Event']?></span></h2>
    <div class="box">

        <table cellspacing="0">
<?php
        if($db->num_rows($result))
        {
            while($event_info = $db->fetch_assoc($result))
            {

                //setting up the date info
                $date_part = explode('-',$event_info['date']);
                           //     $date = date("F jS", mktime(0,0,0,$date_part['1'],$date_part['2'], $date_part['0']));

                                  // could have used $datestring but choose do it this way, in case someone wants to use it to
                                  // view all the events in a week or month.
                                  $date = date_str(mktime(0,0,0,$date_part['1'],$date_part['2'], $date_part['0']));

                           //     This is currently not functional
                           //     if($date_part[0]=="0000")
                           //             $date .= ' (Recuring Event)';
                           //     else
                           //       $date .= ' '.$date_part[0].' (Single Day Event)';

                                  $event_info['body'] = parse_message($event_info['body'], 0);
?>
            <tr>
                <th style="width:18em;" align="left"><a href="profile.php?id=<?php echo $event_info['user_id']?>"><?php echo $event_info['username']?></a></th>
                          <th align="left"><b><?php echo $event_info['title']?></b></th>
            </tr>
            <tr>
                <td>
                                <?php echo $lang_calendar['Event_Date'].' '.$date ?>
                          </td>
                          <td valign="top">
                                <?php echo $event_info['body']?>
                          </td>
            </tr>
<?php
            }
        }else
            echo"\t\t\t<tr>\n\t\t\t\t<td colspan='2'>".$lang_calendar['No_Events']>"</td>\n\t\t\t</tr>\n";

?>
            <tr>
                <th colspan='2'> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a>       <a href="calendar.php"><?php echo"Return to Calendar"; ?></a> </th>
            </tr>
        </table>

    </div>



<?php
        navigation('event');

    }

}




//
// Do the actions like adding and editing events
//
elseif(isset($action))
{
    if(
        ($pun_user['group_id'] == PUN_MOD && $CFG_mod_add=='no')
        or ($pun_user['group_id'] == PUN_MEMBER && $CFG_user_add=='no')
        or ($pun_user['group_id'] == PUN_GUEST))
        message($lang_calendar['warning']);

    elseif($action == 'add')
    {
        #######################################################
        ###//===============//==============//==============//#
        ##//===============// Add an event //==============//##
        #//===============//==============//==============//###
        #######################################################
        if(isset($_POST['form_sent']))
        {
            // Check to see if the Title, Body, Month, and Day were sent
            if(empty($_POST['title']))
                message($lang_calendar['need_title']);
            elseif(empty($_POST['body']))
                message($lang_calendar['need_body']);
            elseif($_POST['month']=="0" || $_POST['day']=="0")
                message($lang_calendar['need_date']);

            // Clean up body and title from POST
            $title = pun_trim($_POST['title']);
            $body = pun_linebreaks(pun_trim($_POST['body']));
                         $body = preparse_bbcode($body, $errors);

            // Setup the corretct date layout for the database
                        if($_POST['year'] == $lang_calendar['Year'])
                $_POST['year'] = date('Y');

            // Check to see of the month and day were set

            // Check to see if the day seleced for the month is an actual day
            $year=($_POST['year']=='0000')? date('Y'): $_POST['year'];
            if(date('t', mktime(0,0,0,$_POST['month'],1,$year))< $_POST['day'])
                message($lang_calendar['date_error']);

            $date = $_POST['year'].'-'.$_POST['month'].'-'.$_POST['day'];

            // Add the Event to the database
            $db->query('INSERT INTO '.$db->prefix.'calendar (date, title, body, user_id) VALUES("'.$date.'", "'.$title.'", "'.$body.'", "'.$_POST['user_id'].'")') or error('Unable to create new event', __FILE__, __LINE__, $db->error());

            redirect('calendar.php', $lang_calendar['event_added']);
        }
        else
        {
?>
    <div class="blockform">
    <h2><?php echo $lang_calendar['add_event']?></h2>
    <div class="box">
        <form method="post" action="calendar.php?action=add" onsubmit="return process_form(this)">
            <div class="inform">
                <fieldset>
                    <legend><?php echo $lang_calendar['add_info']?></legend>
                    <div class="infldset">
                        <input type="hidden" name="form_sent" value="1" />
                        <input type="hidden" name="user_id" value="<?php echo $pun_user['id']?>" />

                        <label class="conl" style="width: 152px;">
                            <strong><?php echo $lang_calendar['Title']?></strong><br />
                            <input type="text" name="title" maxlength="50" /><br />
                        </label>

                        <label class="conl">
                            <strong><?php echo $lang_calendar['Date']?></strong><br />

                            <select name="month">
                                <option value='0'><?php echo $lang_calendar['Month']?></option>
<?php
    $month_name = array('',$lang_calendar['January'],$lang_calendar['February'],$lang_calendar['March'],$lang_calendar['April'],$lang_calendar['May'],$lang_calendar['June'],$lang_calendar['July'],$lang_calendar['August'],$lang_calendar['September'],$lang_calendar['October'],$lang_calendar['November'],$lang_calendar['December']);
    for($x=1;$x<13;$x++)
        echo"\t\t\t\t\t\t\t\t<option value='".$x."'>".$month_name[$x]."</option>\n";

?>
                            </select>
                        </label>
                        <label class="conl"><br />
                            <select name="day">
                                <option value='0'><?php echo $lang_calendar['Day']?></option>
<?php
    for($x=01;$x<=31;$x++)
        echo"\t\t\t\t\t\t\t\t<option value='".$x."'>".$x."</option>\n";

?>
                            </select>
                        </label>
                        <label class="conl"><br />
                            <input name="year" size="5" value="<?php echo $lang_calendar['Year']?>" onselect="document.post.year.value=''" /> 

                        </label>
                        <br />

                        <div class="txtarea">
                            <label class="conl">
                                <strong><?php echo $lang_calendar['Body']?></strong><br />
                                <textarea name="body" rows="7" cols="65"></textarea><br />
                            </label><br />
                        </div>
                        <br class="clearer">
                    </div>

                </fieldset>
            </div>
            <p><input type="submit" value="<?php echo $lang_common['Submit'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a>       <a href="calendar.php"><?php echo"Return to Calendar"; ?></a></p>
        </form>
    </div>
    </div>
        <?php
        }
    }
    elseif($action =='edit')
    {
        ########################################################
        ###//===============//===============//==============//#
        ##//===============// Edit an event //==============//##
        #//===============//===============//==============//###
        ########################################################
        if(isset($_POST['form_sent']))
        {
            // Check to see if the Title, Body, Month, and Day were sent
            if(empty($_POST['title']))
                message($lang_calendar['need_title']);
            elseif(empty($_POST['body']))
                message($lang_calendar['need_body']);
            elseif($_POST['month']=="0" || $_POST['day']=="0")
                message($lang_calendar['need_date']);

            // Clean up body and title from POST
            $title = pun_trim($_POST['title']);
            $body = pun_linebreaks(pun_trim($_POST['body']));
                         $body = preparse_bbcode($body, $errors);

            // Setup the corretct date layout for the database
                        if($_POST['year'] == $lang_calendar['Year'])
                $_POST['year'] = date('Y');

            // Check to see of the month and day were set

            // Check to see if the day seleced for the month is an actual day
            $year=($_POST['year']=='0000')? date('Y'): $_POST['year'];
            if(date('t', mktime(0,0,0,$_POST['month'],1,$year))< $_POST['day'])
                message($lang_calendar['date_error']);

            $date = $_POST['year'].'-'.$_POST['month'].'-'.$_POST['day'];

            // Add the Event to the database
            $db->query('UPDATE '.$db->prefix.'calendar SET date="'.$date.'", title="'.$title.'", body="'.$body.'" WHERE id='.$_POST['event_id']) or error('Unable to Update event', __FILE__, __LINE__, $db->error());

            redirect('calendar.php?action=edit', $lang_calendar['event_edited']);
        }
        elseif(isset($_POST['delete_event']))
        {
            if(isset($_POST['delete_confirmed'])){
                $db->query('DELETE FROM '.$db->prefix.'calendar WHERE id ="'.$_POST['delete_event'].'"') or error('Unable to Delete event', __FILE__, __LINE__, $db->error());

                redirect('calendar.php?action=edit', $lang_calendar['event_deleted']);
            }
            else
            {
                if(empty($_POST['event']))
                    message($lang_calendar['no_event']);

                $result = $db->query('SELECT date, title, body FROM '.$db->prefix.'calendar WHERE id = "'.$_POST['event'].'"') or error('Unable to fetch Event info', __FILE__, __LINE__, $db->error());
                $cur_event = $db->fetch_assoc($result);


?>
</div>
<div class="blockform">
    <h2><span><?php echo $lang_common['Info'] ?></span></h2>
    <div class="box">
        <form method="post" action="calendar.php?action=edit">
            <input type="hidden" name="delete_event" value="<?php echo $_POST['event']?>" />
            <div class="inform">
                <fieldset>
                    <legend class=warntext><?php echo $lang_calendar['delete_confirm'];?></legend>
                    <div class="infldset">
                        <div class="postmsg">
                            <p><b><?php echo $cur_event['title']?></b></p>
                            <p><?php echo $cur_event['body']?></p>
                        </div>
                    </div>
                </fieldset>
            </div>
            <p><input type="Submit" name="delete_confirmed" value="<?php echo $lang_calendar['delete_yes']?>" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a>       <a href="calendar.php"><?php echo"Return to Calendar"; ?></a></p>
        </form>
    </div>
<?php
            }
        }
        else if(isset($_POST['edit_event']))
        {
            if(empty($_POST['event']))
                message($lang_calendar['no_event']);

            // Get all the info for the event your trying to edit
            $result = $db->query('SELECT * FROM '.$db->prefix.'calendar WHERE id ="'.$_POST['event'].'"') or error('Unable to fetch event information', __FILE__, __LINE__, $db->error());
            $event_list = $db->fetch_assoc($result);

            // Get the date info and put it into parts
            $date = explode('-', $event_list['date']);
?>
    <div class="blockform">
    <h2><?php echo $lang_calendar['edit_event']?></h2>
    <div class="box">
        <form method="post" action="calendar.php?action=edit" onsubmit="return process_form(this)">
            <div class="inform">
                <fieldset>
                    <legend><?php echo $lang_calendar['edit_info']?></legend>
                    <div class="infldset">
                        <input type="hidden" name="form_sent" value="1" />
                        <input type="hidden" name="event_id" value="<?php echo $_POST['event']?>" />

                        <label style="float:left; width: 152px;">
                            <strong><?php echo $lang_calendar['Title']?></strong><br />
                            <input type="text" value="<?php echo $event_list['title']?>" name="title" maxlength="50" tabindex="1" /><br />
                        </label>

                        <label class="conl">
                            <strong><?php echo $lang_calendar['Date']?></strong><br />

                            <select name="month" tabindex="2">
                                <option value='0'><?php echo $lang_calendar['Month']?></option>
<?php
    $month_name = array('',$lang_calendar['January'],$lang_calendar['February'],$lang_calendar['March'],$lang_calendar['April'],$lang_calendar['May'],$lang_calendar['June'],$lang_calendar['July'],$lang_calendar['August'],$lang_calendar['September'],$lang_calendar['October'],$lang_calendar['November'],$lang_calendar['December']);
    for($x=1;$x<13;$x++)
    {
        $s = ($x == $date[1])? " selected='selected'" : NULL ;
        echo"\t\t\t\t\t\t\t\t<option value='".$x."'".$s.">".$month_name[$x]."</option>\n";
    }
?>
                            </select>
                        </label>
                        <label class="conl"><br />
                            <select name="day" tabindex="3">
                                <option value='0'><?php echo $lang_calendar['Day']?></option>
<?php
    for($x=01;$x<=31;$x++)
    {
        $s = ($x == $date[2])? " selected='selected'" : NULL ;
        echo"\t\t\t\t\t\t\t\t<option value='".$x."'".$s.">".$x."</option>\n";
    }
?>
                            </select>
                        </label>
                        <label class="conl"><br />
                            <input name="year" value="<?php echo $date[0]?>" size="5" tabindex="4" /> 

                        </label>
                        <br />

                        <div class="txtarea">
                            <label class="conl">
                                <strong><?php echo $lang_calendar['Body']?></strong><br />
                                <textarea name="body" rows="7" cols="65"><?php echo str_replace('<br />',"\n",$event_list['body'])?></textarea><br />
                            </label><br />
                        </div>
                        <br class="clearer">
                    </div>

                </fieldset>
            </div>
            <p><input type="submit" value="<?php echo $lang_common['Submit'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a>       <a href="calendar.php"><?php echo"Return to Calendar"; ?></a></p>
        </form>
    </div>
    </div>

<?php

        }
        else
        {

            if(($pun_user['g_id'] == PUN_MOD && $CFG_mod_add=='yes') or ($pun_user['g_id'] == PUN_MOD && $CFG_mod_edit=='no') or ($pun_user['g_id'] == PUN_MEMBER && $CFG_user_add=='yes'))
                $can_edit = "WHERE user_id = ".$pun_user['id'];
            else
                $can_edit = "";

            //Number of posts to display
            $disp_posts = $pun_user['disp_posts'];

            $result = $db->query('SELECT id FROM '.$db->prefix.'calendar');
            $num_replies = $db->num_rows($result);

            // Determine the post offset (based on $_GET['p'])
            $num_pages = ceil(($num_replies) / $disp_posts);
            $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
            $start_from = $disp_posts * ($p - 1);

            $pages = paginate($num_pages, $p, 'calendar.php?action=edit');

            $result = $db->query('SELECT * FROM '.$db->prefix.'calendar '.$can_edit.' ORDER BY date LIMIT '.$start_from.','.$disp_posts) or error('Unable to fetch event information', __FILE__, __LINE__, $db->error());

            if(!$db->num_rows($result)){
                message($lang_calendar['no_events']);
            }

?>


    
    <form method="post" action="calendar.php?action=edit" onsubmit="return process_form(this)">
    <div class="blockform">
        <h2><?php echo $lang_calendar['edit_event']?></h2>
        <div class="box">
            <table cellspacing='0'>
            <thead>
                <tr>
                    <th> </th>
                    <th><?php echo $lang_calendar['Title']?></th>
                    <th><?php echo $lang_calendar['Date']?></th>
                    <th><?php echo $lang_calendar['Body']?></th>


                </tr>
            </thead>
            <tbody>
<?php

            while($event_list = $db->fetch_assoc($result))
            {
                $date_part = explode('-',$event_list['date']);
                $date_year = ($date_part['0']=='0000')?  date('y') : $date_part['0'];
                $date = date_str( mktime(0,0,0,$date_part['1'],$date_part['2'],$date_year));
?>
                <tr>
                    <td style="width:10px">
                        <input type="radio" name="event" value="<?php echo $event_list['id']?>" />
                    </td>
                    <td style="width:145px"><?php echo $event_list['title']?></td>
                    <td style="width:85px"><?php echo $date ?></td>
                    <td><?php echo str_replace('\n','<br />',$event_list['body'])?></td>

                </tr>
<?php
            }
?>
                <tr>
                    <td colspan="4">
                        <input type="submit" value="<?php echo $lang_calendar['edit_event']?>" name="edit_event" /> <input type="submit" value="<?php echo $lang_calendar['delete_event']?>" name="delete_event" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a>       <a href="calendar.php"><?php echo"Return to Calendar"; ?></a>
                    </td>
                </tr>
            </tbody>
            </table>
        </div>
    </div>
    </form>
</div>
<div class="linksb">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $lang_common['Pages'].': '.$pages?></p>
        <div class="clearer"></div>
    </div>
<?php
        }


    }
}
//
// Show the weekly calendar
//
elseif(isset($week))
{
    ########################################################
    ###//===============//===============//==============//#
    ##//===============// Week Calendar //==============//##
    #//===============//===============//==============//###
    ########################################################
    list($year,$week) = explode('.',$week);
    $day_one = (date('w',mktime(0,0,0,1,1,$year))==0)? 7 : date('w',mktime(0,0,0,1,1,$year));

    $first_day = strtotime("-".$day_one." days", mktime(0,0,0,1,1,$year));
    $date = strtotime ("+$week weeks", $first_day);
    $month = date('n',$date);
    $week_start = mktime(0,0,0,date('n',$date),date('j',$date),$year);
    $week_end = $week_start+(60*60*24*7);

        $strdate = date(Y, $date)."-".$month."-".date('d',$date);
        $strdate2 = date(Y, $week_end)."-".date('m',$week_end)."-".date('d',$week_end);


    //change querys if $type is set to posts
    if($type == "posts")
    {

        $result = $db->query('SELECT t.posted FROM '.
                          $db->prefix.'topics as t LEFT JOIN '.
                          $db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].
                          ') WHERE t.posted > '.$week_start.' AND t.posted < '.$week_end.
                          ' AND    (fp.read_forum IS NULL OR fp.read_forum=1)') or
                          error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
        $topic = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
        while($topic_list = $db->fetch_row($result)){
            $time = date("j",$topic_list[0]);
            $topic[$time]++;
        };

        //Find the posts made for "said" day (one month only)
        $result = $db->query('SELECT p.posted FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON p.topic_id=t.id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].') WHERE p.posted > '.$week_start.' AND p.posted < '.$week_end.' AND (fp.read_forum IS NULL OR fp.read_forum=1)') or error('Unable to fetch posts list', __FILE__, __LINE__, $db->error());
        $posts = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
        while($post_list = $db->fetch_assoc($result)){
            $time = date('j',$post_list['posted']);
            $posts[$time]++;
        };
    }
    //change querys if $type is set to events
    elseif($type == "events")
    {
        //Find the birthdays for "said" day (selected week)
        $strWhere = 'WHERE MONTH(birthday) = '.$month.' or (MONTH(birthday) = '.date('n',$week_end).' and DAYOFMONTH(birthday) < 7) ';
        $strQuery = 'SELECT DAYOFMONTH(birthday) as day, username FROM '.$db->prefix.'users '.$strWhere;

        $result = $db->query($strQuery) or error('Unable to fetch birtday list', __FILE__, __LINE__, $db->error());
        $bdays = array('','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','');
        while($bday_list = $db->fetch_assoc($result)){
            if(count($bday_list)>6)
                $bdays[$bday_list['day']]++;
            else
                $bdays[$bday_list['day']] .="*<a href='calendar.php?view=bday&date=".$year.".".$month.".".$bday_list['day']."'>".$bday_list['username'].$lang_calendar['Birthday']."</a>  ";
        };

        //Find the events for "said" day (selected week)
        $strWhere = 'WHERE date >= "'.$strdate .'" AND date <= DATE_ADD("'.$strdate.'", INTERVAL 8 DAY ) ';
        $strQuery = 'SELECT id, title, DAYOFMONTH(date) as day FROM '.$db->prefix.'calendar '.$strWhere;
              $result = $db->query($strQuery) or
                          error('Unable to fetch calendar dates', __FILE__, __LINE__, $db->error());
        $dates = array('','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','');
        while($dates_list = $db->fetch_assoc($result)){
            $dates[$dates_list['day']] .= "*<a href='calendar.php?view=event&id=".$dates_list['id']."'>".$dates_list['title']."</a>  ";
        };
    }
?>
    <div style="width:100%;float:left;margin-right:-225px">
    <div style="display:inline;float:left;margin-right:225px">

<?php
    //list dates in this week
    if($CFG_start_day == "S"){$a='0';$b='7';}
    elseif($CFG_start_day == "M"){$a='1';$b='8';}

    for ($x=$a; $x<$b; $x++) {
            $datestamp = strtotime("+$x days", $date);
        $wk_name = $lang_calendar[date ('l', $datestamp)];
        $date_no      =date('j', $datestamp);
        $mth_name =date('F', $datestamp);
        $year_name =date("Y", $datestamp);
                $month_no   =date("n", $datestamp);

        if ($x == "0" | ($x == "1" & $b =="8")){
            echo "\t<h2><a href='calendar.php?".$ltype."date=".$year_name.".".$month_no."'>".$lang_calendar[$mth_name]." ".$year_name."</a></h2>\n\t<div class='box'>\n\t<table cellspacing='0'>\n";
        } elseif(date('d', $datestamp)=="1" ){
            echo "\t\t</table>\n\t</div>\n";
            echo "\t<h2><a href='calendar.php?".$ltype."date=".$year_name.".".$month_no."'>".$lang_calendar[$mth_name]." ".$year_name."</a></h2>\n\t<div class='box'>\n\t<table cellspacing='0'>\n";
        }
        $class = ($date_no == date('j') && $mth_name == date('F') && $year_name == date('Y'))? "class='calendar_day'" : "";
                        if (!empty($bdays[$date_no])) $class =" class='calendar_bday'";
                        if (!empty($dates[$date_no])) $class =" class='calendar_event'";

        echo "\t\t\t\t<tr><td valign='top' colspan='2' ".$class."><strong>".$wk_name."</strong></td></tr>\n";
        echo "\t\t\t\t<tr>\n\t\t\t\t\t<td valign='top' style='width:2%' ".$class.">".$date_no."</td>\n";
        echo "\t\t\t\t\t<td style='width:97%' ".$class.">";

        if(!empty($topic[$date_no]))echo"<a href='calendar.php?view=topics&date=".$year.".".$month.".".$date_no."'>".$lang_calendar['Topics']." ".$topic[$date_no]."</a>  ";
        if(!empty($posts[$date_no]))echo"<a href='calendar.php?view=posts&date=".$year.".".$month.".".$date_no."'>".$lang_calendar['Posts']." ".$posts[$date_no]."</a>  ";

        if(!empty($bdays[$date_no]) && !is_int($bdays[$date_no]))
            echo "<a href='calendar.php?view=bday&date=".$year.".".$month.".".$date_no."'>".$lang_calendar['Birthdays']." ".$bdays[$date_no]."</a><br /><img src='./img/icon_party.gif' width='38' height='18' alt='' />";
        elseif(!empty($bdays[$date_no]) && is_int($bdays[$date_no]))
                echo $bdays[$date_no];

            if(!empty($dates[$date_no]))
                echo $dates[$date_no];
        
        echo " </td>\n\t\t\t\t</tr>\n\n";
    }
?>
                <tr>
                    <td colspan="2"><div style="float:left">
<?php                    echo "<a href='calendar.php?week=".$year.".".($week-1)."'>".$lang_calendar['Last Week']."</a> | ";
                    echo "<a href='calendar.php?week=".$year.".".($week+1)."'>".$lang_calendar['Next Week']."</a></div>"; ?>
<?php if($CFG_show_typelist=="yes") { ?>
                    <div style="float:right">
                                                <form id="date" method="post" action="calendar.php?week=<?php echo $_GET['week']?>">
                                                        <div style="float:left">
                                                                <select name="type" onChange="document.forms['date'].submit()">
                                                                        <option value="posts"<?php if($type=="posts")echo" selected='selected'"?>><?php echo $lang_calendar['posts/topics']?></option>
                                                                        <option value="events"<?php if($type=="events")echo" selected='selected'"?>><?php echo $lang_calendar['events']?></option>
                                                                </select>

                                                        </div>
                                                </form>
                                 </div>
<?php } ?>
                                       </td>
                </tr>

            </table>
        </div>


<?php    if(
        ($pun_user['g_id'] == PUN_MOD && $CFG_mod_add=='yes')
        or ($pun_user['g_id'] == PUN_MEMBER && $CFG_user_add=='yes')
        or ($pun_user['g_id'] == PUN_ADMIN)
    )
        echo "\t<br />\n\t<div class='box'><p> <a href='calendar.php?action=add'>".$lang_calendar['Add_event']."</a> | <a href='calendar.php?action=edit'>".$lang_calendar['Edit_event']."</a></p></div>\n";
?>
</div>
    </div>

<?php    if($CFG_show_cal == "yes"){
    echo "<div style='float:right;width:215px'>";
        mini_cal($month_no, $year, "week");
        echo "</div>";
        }
?>

    <br class="clearer" />


<?php

}
//
//
//if $actions, $view or $week isnt set
//
else
{
    #########################################################
    ###//===============//===============//===============//#
    ##//===============// Main Calendar //===============//##
    #//===============//===============//===============//###
    #########################################################

    //change querys if $type is set to posts
    if($type == "posts")
    {

        $result = $db->query('SELECT t.posted FROM '.$db->prefix.'topics as t LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].') WHERE t.posted > '.$month_start.' AND t.posted < '.$month_end.' AND    (fp.read_forum IS NULL OR fp.read_forum=1)') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
        $topic = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
        while($topic_list = $db->fetch_row($result)){
            $time = date("j",$topic_list[0]);
            $topic[$time]++;
        };

        //Find the posts made for "said" day
        $result = $db->query('SELECT p.posted FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON p.topic_id=t.id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].') WHERE p.posted > '.$month_start.' AND p.posted < '.$month_end.' AND (fp.read_forum IS NULL OR fp.read_forum=1)') or error('Unable to fetch posts list', __FILE__, __LINE__, $db->error());
        $posts = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
        while($post_list = $db->fetch_assoc($result)){
            $time = date('j',$post_list['posted']);
            $posts[$time]++;
        };
    }
    //change querys if $type is set to events
    elseif($type == "events")
    {

        //Find the birthdays for "said" day
        $result = $db->query('SELECT DAYOFMONTH(birthday) as day, username FROM '.$db->prefix.'users WHERE MONTH(birthday) = '.$month) or error('Unable to fetch birtday list', __FILE__, __LINE__, $db->error());
        $bdays = array('','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','');
        while($bday_list = $db->fetch_assoc($result)){
            if(count($bday_list)>3)
                $bdays[$bday_list['day']]++;
            else
                                $bdays[$bday_list['day']] .="<a href='calendar.php?view=bday&date=".$year.".".$month.".".$bday_list['day']."'>".$bday_list['username'].$lang_calendar['Birthday']."</a><br />";
        };

        //Find the events for "said" day
        $result = $db->query('SELECT id, title, DAYOFMONTH(date) as day FROM '.$db->prefix.'calendar WHERE MONTH(date) = '.$month.' AND (YEAR(date) = '.$year.' OR YEAR(date) = "0000")') or error('Unable to fetch calendar dates', __FILE__, __LINE__, $db->error());
        $dates = array('','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','');
        while($dates_list = $db->fetch_assoc($result)){
            $dates[$dates_list['day']] .= "<a href='calendar.php?view=event&date=".$year.".".$month.".".$dates_list['day']."'>".$dates_list['title']."</a><br />";
        };


    }
?>
    <h2 style="text-align:center">
        <span>
                     <!--   <a href="calendar.php?<?php echo $ltype?>date=<?php echo ($year-1).'.'.$month;?>"><–</a> -->
                        <a href="calendar.php?<?php echo $ltype?>date=<?php if($month == 1){echo $year-1;}else{echo$year;}?>.<?php if($month == 1){echo '12';}else{echo $month-1;}?>"><<—</a>
            <?php echo $lang_calendar[$monthtext]." ".$year."\n" ?>
                        <a href="calendar.php?<?php echo $ltype?>date=<?php if($month == 12){echo $year+1;}else{echo$year;}?>.<?php if($month == 12){echo '1';}else{echo $month+1;}?>">—>></a>
                     <!--   <a href="calendar.php?<?php echo $ltype?>date=<?php echo ($year+1).'.'.$month;?>">–></a> -->
        </span>
    </h2>
    <div class="box">
        <table cellspacing="0">
        <thead>
            <tr>
<?php if($CFG_start_day == "S"):?>                <th><?php echo $lang_calendar['Sunday']?></th>
<?php endif;?>                <th><?php echo $lang_calendar['Monday']?></th>
                <th><?php echo $lang_calendar['Tuesday']?></th>
                                <th><?php echo $lang_calendar['Wednesday']?></th>
                <th><?php echo $lang_calendar['Thursday']?></th>
                <th><?php echo $lang_calendar['Friday']?></th>
                <th><?php echo $lang_calendar['Saturday']?></th>
<?php if($CFG_start_day == "M"):?>                <th><?php echo $lang_calendar['Sunday']?></th>
<?php endif;?>
                <th class='calendar_wk'> </th>
            </tr>
        </thead>
        <tbody>
            <tr>
<?php

        if ($day_of_wk <> 0){
            for ($i=0; $i<$day_of_wk; $i++)
            { echo "\t\t\t\t<td valign='top' style='width:14%; height:75px' class='calendar_no' > </td>\n"; }
        }

        for ($date_of_mth = 1; $date_of_mth <= $days_in_mth; $date_of_mth++) {

            $date_no = date("j", mktime(0, 0, 0, $month, $date_of_mth, $year));
            $day_of_wk = start_date(date('w', mktime(0, 0, 0, $month, $date_of_mth, $year)));
            $class = ($date_no ==  date("j") &&  $month == date("n") && $year == date("Y"))? " class='calendar_day'" : NULL ;
                        if (!empty($bdays[$date_no])) $class =" class='calendar_bday'";
                        if (!empty($dates[$date_no])) $class =" class='calendar_event'";

            echo "\t\t\t\t<td valign='top' style='width:14%; height:75px'".$class."><span>".$date_no."</span><br />";

            if(!empty($topic[$date_no]))echo"<a href='calendar.php?view=topics&date=".$year.".".$month.".".$date_no."'>".$lang_calendar['Topics']." ".$topic[$date_no]."</a><br />";
            if(!empty($posts[$date_no]))echo"<a href='calendar.php?view=posts&date=".$year.".".$month.".".$date_no."'>".$lang_calendar['Posts']." ".$posts[$date_no]."</a><br />";

            if(!empty($bdays[$date_no]) && !is_int($bdays[$date_no]))
                echo"<a href='calendar.php?view=bday&date=".$year.".".$month.".".$date_no."'>".$lang_calendar['Birthdays']."<br /> ".$bdays[$date_no]."</a><br />";
            elseif(!empty($bdays[$date_no]) && is_int($bdays[$date_no]))
                echo $bdays[$date_no]."<br />";

            if(!empty($dates[$date_no]))echo $dates[$date_no]."<br />";

            echo "</td>\n";

            if ( $day_of_wk == 6 )
            {

                //if $date_no minus 5 days is greater than 0 AKA 1 or biger
                if($date_no-5 > 0)
                {
                    $date_link = date('W', mktime(0,0,0,$month,($date_no-5),$year));
                    $year_link = $year;
                }
                //if its less than 1 aka 0 or negitive
                else
                {
                    //if $month minus 1 month is less than 1 AKA 0 or negitive
                    if($month-1 < 1)
                    {
                        $pre_year = $year-1;
                        $pre_month = '12';
                        $pre_day = date('t', mktime(0,0,0,$pre_month,1,$pre_year))+($date_no-5)-1;

                    }
                    else
                    {
                        $pre_year = $year;
                        $pre_month = $month-1;
                        $pre_day = date('t', mktime(0,0,0,$pre_month,1,$pre_year))+($date_no-5);

                    }

                    $date_link = date('W', mktime(0,0,0,$pre_month,$pre_day,$pre_year));
                    $year_link = $pre_year;
                }

        //        if($year_link == date('Y')-1)        $date_link = $date_link-1;
        //        elseif($year_link == date('Y')+1)    $date_Link = $date_link+1;
                echo "\t\t\t\t<td class='calendar_wk'><a href='calendar.php?".$ltype."week=".$year_link.".".$date_link."'>«</a></td>\n";

                echo "\t\t\t</tr>\n\t\t\t<tr>\n";
            }
            if ( $day_of_wk < 6 && $date_of_mth == $days_in_mth ) {

                for ( $i = $day_of_wk ; $i < 6; $i++ )
                { echo "\t\t\t\t<td valign='top' style='width:14%; height:75px' class='calendar_no' > </td>\n"; }

                echo "\t\t\t\t<td class='calendar_wk'><a href='calendar.php?week=".$year_link.".".($date_link+1)."'>«</a></td>\n";
                echo "\t\t\t</tr>\n";
            }
            if( $date_of_mth == $days_in_mth)
                break;
        }
?>
                <td colspan="8">
                    <div style="float:left; padding-top:5px; padding-right:3px"><?php echo $lang_calendar['go_to']?></div>
                    <form id="date" method="post" action="calendar.php">
                        <div style="float:left">
                            <select name="month">
<?php
                $month_name = array($lang_calendar['January'],$lang_calendar['February'],$lang_calendar['March'],$lang_calendar['April'],$lang_calendar['May'],$lang_calendar['June'],$lang_calendar['July'],$lang_calendar['August'],$lang_calendar['September'],$lang_calendar['October'],$lang_calendar['November'],$lang_calendar['December']);
                for($x=00;$x<12;$x++)
                {
                    $z = $x+1;
                    echo"\t\t\t\t\t\t\t\t<option value='".$z."'";
                    if($month == $z)echo" selected='selected'";
                    echo">".$month_name[$x]."</option>\n";
                }
?>
                            </select>
                            <select name="year">
<?php
                for($x=-5; $x<=5; $x++)
                {
                    $said_year = $year+$x;
                    echo"\t\t\t\t\t\t\t\t<option value='".$said_year."'";
                    if($said_year == $year)echo" selected='selected'";
                    echo ">".$said_year."</option>\n";
                }
?>
                            </select>
                                                        <input type="submit" value="<?php echo $lang_calendar['go'] ?>" />
                        </div>
                        <div style="float:left; padding-top:5px; padding-left:3px">
                            <a href="calendar.php?date=<?php echo date('Y.m')?>"><?php echo $lang_calendar['current_month'];?></a>
                            <a href="calendar.php?week=<?php echo date('Y.W')?>"><?php echo $lang_calendar['current_week'];?></a>
                        </div>
<?php if($CFG_show_typelist=="yes") { ?>
                                              <div style="float:right">
                                                        <select name="type" onChange="document.forms['date'].submit()" >
                                                                <option value="posts"<?php if($type=="posts")echo" selected='selected'"?>><?php echo $lang_calendar['posts/topics']?></option>
                                                                <option value="events"<?php if($type=="events")echo" selected='selected'"?>><?php echo $lang_calendar['events']?></option>
                                                        </select>
                                                </div>
<?php } ?>
                    </form>
                </td>
            </tr>
        </tbody>
        </table>
    </div>
<?php
    if($CFG_show_cal == "yes"){
        echo"\t<br />\n\t<table cellspacing='0'>\n\t<tr>\n\t\t<td valign='top' style='border:none;padding:0 5px 0 0; margin:0'>\n";
        mini_cal($month, $year, 'main');
        echo "\t\t</td>\n\t</tr>\n\t</table>\n";
    }

    if(
        ($pun_user['g_id'] == PUN_MOD && $CFG_mod_add=='yes')
        or ($pun_user['g_id'] == PUN_MEMBER && $CFG_user_add=='yes')
        or ($pun_user['g_id'] == PUN_ADMIN)
    )
        echo "\t<br />\n\t<div class='box'><p> <a href='calendar.php?action=add'>".$lang_calendar['Add_event']."</a> | <a href='calendar.php?action=edit'>".$lang_calendar['Edit_event']."</a></p></div>\n";
}
?>
</div>
<?php require PUN_ROOT.'footer.php';?>

293

Re: Calendar 2.0

@Vanslyde:   
I looked at your file today.
I only found one error in the file, ....comparing to the original 2.07b1 full dated 2/13/2007
and this would not affect any of the problems you describe. 

Of course, that revision has patches posted for it, and I observe Patch 1, which directly addresses your issue of the edit button,  is not applied (either at all or correctly).
Go here: http://www.punres.org/viewtopic.php?pid=13826#p13826
That should fix it.

I suggest you focus your attention at the punres forum discussion pertaining to this mod, and not here.  None of the fixes or progress on the Calendar are being posted or sorted out here.  I think if you carefully check out and apply the patches posted thus far, and search that thread for issues pertaining to dealing with guests, you will have all your answers.

I hope this helps.
Cheers,
TwoHawks

TwoHawks
Love is the Function
No Form is the Tool

294

Re: Calendar 2.0

This might have been asked before, but I couldn't find it through search...

Would it be possible to add an event signup feature? So, lets say I post an event for tomorrow, and want to know who can make the event. People could sign up to that event. If I am just speaking jibberish, lemme know and I will refine the post big_smile

295 (edited by badbussenab 2007-04-29 22:14)

Re: Calendar 2.0

How do I print out say the titles of some upcoming events on my front page?
And to be shown as links to the event info. Something like this:


Upcoming Events

> (date) - event1
> (date) - event2
> (date) - event3
> (date) - event4
> (date) - event5



If someone could help me on this I would be really greatful. Thanks.
It would be great if it was just a file that I could include on the front page. I just don't know how to do it.

296

Re: Calendar 2.0

I have got exactly the same question. Is it possible to get an RSS-feed from the Calendar 2.0?

badbussenab wrote:

How do I print out say the titles of some upcoming events on my front page?
And to be shown as links to the event info. Something like this:


Upcoming Events

> (date) - event1
> (date) - event2
> (date) - event3
> (date) - event4
> (date) - event5

If someone could help me on this I would be really greatful. Thanks.
It would be great if it was just a file that I could include on the front page. I just don't know how to do it.

Re: Calendar 2.0

cherry1499 wrote:

@Gizzmo,
it'spossible or easy to make an option "from/till".. Excample: I'm from  December - 24 - 05 till December - 29 - 05 at vacaion. So that i dont need to insert all single days.

It's an important option, i think.

Thanks
Michaela

P.S It is a general bug, that User could edit all events or is that bug only in my script?

Dont forget this funktion ....   smile