Ejemplo n.º 1
0
function postcalendar_user_submit($args)
{
    // We need at least ADD permission to submit an event
    if (!(bool) PC_ACCESS_ADD) {
        return _POSTCALENDARNOAUTH;
    }
    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    // get the theme globals :: is there a better way to do this?
    pnThemeLoad(pnUserGetTheme());
    global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5, $textcolor1, $textcolor2;
    // $category = pnVarCleanFromInput('event_category');
    $category = pnVarCleanFromInput('category');
    if (!empty($category)) {
        $category = unserialize(base64_decode($category));
        //print_r($category);
    } else {
        //print_r($_POST);
        $cat = $_POST['category'];
        $category = unserialize(base64_decode($cat));
        //print_r($category);
    }
    //print_r($category);
    // echo("<!-- Here is the argument array: -->\n");
    // foreach ($args as $tmpkey => $tmpval) { // debugging
    //  echo("<!-- $tmpkey => '$tmpval' -->\n");
    // }
    extract($args);
    $Date =& postcalendar_getDate();
    $year = substr($Date, 0, 4);
    $month = substr($Date, 4, 2);
    $day = substr($Date, 6, 2);
    // basic event information
    $event_desc = pnVarCleanFromInput('event_desc');
    $event_category = pnVarCleanFromInput('event_category');
    $event_subject = pnVarCleanFromInput('event_subject');
    $event_sharing = pnVarCleanFromInput('event_sharing');
    $event_topic = pnVarCleanFromInput('event_topic');
    //id of the user the event is for
    $event_userid = pnVarCleanFromInput('event_userid');
    if (!is_numeric($event_userid)) {
        $event_userid = 0;
    }
    $event_pid = pnVarCleanFromInput('event_pid');
    if (!is_numeric($event_pid)) {
        $event_pid = "";
    }
    // event start information
    $event_startmonth = pnVarCleanFromInput('event_startmonth');
    $event_startday = pnVarCleanFromInput('event_startday');
    $event_startyear = pnVarCleanFromInput('event_startyear');
    $event_starttimeh = pnVarCleanFromInput('event_starttimeh');
    $event_starttimem = pnVarCleanFromInput('event_starttimem');
    $event_startampm = pnVarCleanFromInput('event_startampm');
    // location data
    $event_location = pnVarCleanFromInput('event_location');
    $event_street1 = pnVarCleanFromInput('event_street1');
    $event_street2 = pnVarCleanFromInput('event_street2');
    $event_city = pnVarCleanFromInput('event_city');
    $event_state = pnVarCleanFromInput('event_state');
    $event_postal = pnVarCleanFromInput('event_postal');
    $event_location_info = serialize(compact('event_location', 'event_street1', 'event_street2', 'event_city', 'event_state', 'event_postal'));
    // contact data
    $event_contname = pnVarCleanFromInput('event_contname');
    $event_conttel = pnVarCleanFromInput('event_conttel');
    $event_contemail = pnVarCleanFromInput('event_contemail');
    $event_website = pnVarCleanFromInput('event_website');
    $event_fee = pnVarCleanFromInput('event_fee');
    $event_patient_name = pnVarCleanFromInput('patient_name');
    // event repeating data
    if (is_array($category)) {
        //$event_subject        =
        $event_desc = $category['desc'];
        $event_category = $category['id'];
        $event_duration = $category['event_duration'];
        //seconds of the event
        $event_dur_hours = $event_duration / (60 * 60);
        //seconds divided by 60 seconds * 60 minutes
        $event_dur_minutes = $event_duration % (60 * 60) / 60;
        $event_repeat = $category['event_repeat'];
        $event_repeat_freq = $category['event_repeat_freq'];
        $event_repeat_freq_type = $category['event_repeat_freq_type'];
        $event_repeat_on_num = $category['event_repeat_on_num'];
        $event_repeat_on_day = $category['event_repeat_on_day'];
        $event_repeat_on_freq = $category['event_repeat_on_freq'];
        $event_recurrspec = serialize(compact('event_repeat_freq', 'event_repeat_freq_type', 'event_repeat_on_num', 'event_repeat_on_day', 'event_repeat_on_freq'));
        // event end information
        $multiple = $category['end_date_freq'] . " ";
        switch ($category['end_date_type']) {
            case REPEAT_EVERY_DAY:
            case REPEAT_EVERY_WORK_DAY:
                //end date is in days
                $multiple .= "days";
                break;
            case REPEAT_EVERY_WEEK:
                //end date is in weeks
                $multiple .= "weeks";
                break;
            case REPEAT_EVERY_MONTH:
                //end date is in months
                $multiple .= "months";
                break;
            case REPEAT_EVERY_YEAR:
                //end date is in years
                $multiple .= "years";
                break;
        }
        $edate = strtotime(pnVarCleanFromInput('Date'));
        $event_startmonth = date("m", $edate);
        $event_startday = date("d", $edate);
        $event_startyear = date("Y", $edate);
        $event_enddate = strtotime(pnVarCleanFromInput('Date') . " + " . $multiple);
        $event_endmonth = date("m", $event_enddate);
        $event_endday = date("d", $event_enddate);
        $event_endyear = date("Y", $event_enddate);
        $event_endtype = $category['end_date_flag'];
        // I'm pretty sure this was a bug since 'event_all_day' appears nowhere
        // else in the code, but it's hard to tell WTF is going on.
        //    $event_allday         = $category['event_all_day'];
        $event_allday = $category['all_day'];
    } else {
        $event_dur_hours = pnVarCleanFromInput('event_dur_hours');
        $event_dur_minutes = pnVarCleanFromInput('event_dur_minutes');
        $event_duration = 60 * 60 * $event_dur_hours + 60 * $event_dur_minutes;
        $event_repeat = pnVarCleanFromInput('event_repeat');
        $event_repeat_freq = pnVarCleanFromInput('event_repeat_freq');
        $event_repeat_freq_type = pnVarCleanFromInput('event_repeat_freq_type');
        $event_repeat_on_num = pnVarCleanFromInput('event_repeat_on_num');
        $event_repeat_on_day = pnVarCleanFromInput('event_repeat_on_day');
        $event_repeat_on_freq = pnVarCleanFromInput('event_repeat_on_freq');
        $event_recurrspec = serialize(compact('event_repeat_freq', 'event_repeat_freq_type', 'event_repeat_on_num', 'event_repeat_on_day', 'event_repeat_on_freq'));
        // event end information
        $event_endmonth = pnVarCleanFromInput('event_endmonth');
        $event_endday = pnVarCleanFromInput('event_endday');
        $event_endyear = pnVarCleanFromInput('event_endyear');
        $event_endtype = pnVarCleanFromInput('event_endtype');
        $event_allday = pnVarCleanFromInput('event_allday');
    }
    // Added by Rod:
    if ($event_allday) {
        $event_starttimeh = 0;
        $event_starttimem = 0;
        $event_startampm = 1;
        $event_dur_hours = 24;
        $event_dur_minutes = 0;
        $event_duration = 60 * 60 * $event_dur_hours;
    }
    $form_action = pnVarCleanFromInput('form_action');
    $pc_html_or_text = pnVarCleanFromInput('pc_html_or_text');
    $pc_event_id = pnVarCleanFromInput('pc_event_id');
    $data_loaded = pnVarCleanFromInput('data_loaded');
    $is_update = pnVarCleanFromInput('is_update');
    $authid = pnVarCleanFromInput('authid');
    //pennfirm uname matchup future fix
    //if(pnUserLoggedIn()) { $uname = pnUserGetVar('uname'); }
    //else { $uname = pnConfigGetVar('anonymous'); }
    $uname = $_SESSION['authUser'];
    if (!isset($event_repeat)) {
        $event_repeat = 0;
    }
    if (!isset($pc_event_id) || empty($pc_event_id) || $data_loaded) {
        // lets wrap all the data into array for passing to submit and preview functions
        $eventdata = compact('event_subject', 'event_desc', 'event_sharing', 'event_category', 'event_topic', 'event_startmonth', 'event_startday', 'event_startyear', 'event_starttimeh', 'event_starttimem', 'event_startampm', 'event_endmonth', 'event_endday', 'event_endyear', 'event_endtype', 'event_dur_hours', 'event_dur_minutes', 'event_duration', 'event_allday', 'event_location', 'event_street1', 'event_street2', 'event_city', 'event_state', 'event_postal', 'event_location_info', 'event_contname', 'event_conttel', 'event_contemail', 'event_website', 'event_fee', 'event_repeat', 'event_repeat_freq', 'event_repeat_freq_type', 'event_repeat_on_num', 'event_repeat_on_day', 'event_repeat_on_freq', 'event_recurrspec', 'uname', "event_userid", "event_pid", 'Date', 'year', 'month', 'day', 'pc_html_or_text', 'event_patient_name', 'event_pid');
        $eventdata['is_update'] = $is_update;
        $eventdata['pc_event_id'] = $pc_event_id;
        $eventdata['data_loaded'] = true;
        $eventdata['category'] = base64_encode(serialize($category));
    } else {
        $event =& postcalendar_userapi_pcGetEventDetails($pc_event_id);
        //echo "uname is:$uname  other name is: ".$event['uname'] . "<br />";
        if ($uname != $event['uname']) {
            if (!validateGroupStatus($uname, getUsername($event['uname']))) {
                return _PC_CAN_NOT_EDIT;
            }
        }
        $eventdata['event_subject'] = $event['title'];
        $eventdata['event_desc'] = $event['hometext'];
        $eventdata['event_sharing'] = $event['sharing'];
        $eventdata['event_category'] = $event['catid'];
        $eventdata['event_topic'] = $event['topic'];
        $eventdata['event_startmonth'] = substr($event['eventDate'], 5, 2);
        $eventdata['event_startday'] = substr($event['eventDate'], 8, 2);
        $eventdata['event_startyear'] = substr($event['eventDate'], 0, 4);
        $eventdata['event_starttimeh'] = substr($event['startTime'], 0, 2);
        $eventdata['event_starttimem'] = substr($event['startTime'], 3, 2);
        $eventdata['event_startampm'] = $eventdata['event_starttimeh'] < 12 ? 1 : 2;
        //1 is am , 2 is pm
        $eventdata['event_endmonth'] = substr($event['endDate'], 5, 2);
        $eventdata['event_endday'] = substr($event['endDate'], 8, 2);
        $eventdata['event_endyear'] = substr($event['endDate'], 0, 4);
        $eventdata['event_endtype'] = $event['endDate'] == '0000-00-00' ? '0' : '1';
        $eventdata['event_dur_hours'] = $event['duration_hours'];
        $eventdata['event_dur_minutes'] = $event['duration_minutes'];
        $eventdata['event_duration'] = $event['duration'];
        $eventdata['event_allday'] = $event['alldayevent'];
        $loc_data = unserialize($event['location']);
        $eventdata['event_location'] = $loc_data['event_location'];
        $eventdata['event_street1'] = $loc_data['event_street1'];
        $eventdata['event_street2'] = $loc_data['event_street2'];
        $eventdata['event_city'] = $loc_data['event_city'];
        $eventdata['event_state'] = $loc_data['event_state'];
        $eventdata['event_postal'] = $loc_data['event_postal'];
        $eventdata['event_location_info'] = $loc_data;
        $eventdata['event_contname'] = $event['contname'];
        $eventdata['event_conttel'] = $event['conttel'];
        $eventdata['event_contemail'] = $event['contemail'];
        $eventdata['event_website'] = $event['website'];
        $eventdata['event_fee'] = $event['fee'];
        $eventdata['event_repeat'] = $event['recurrtype'];
        $rspecs = unserialize($event['recurrspec']);
        $eventdata['event_repeat_freq'] = $rspecs['event_repeat_freq'];
        $eventdata['event_repeat_freq_type'] = $rspecs['event_repeat_freq_type'];
        $eventdata['event_repeat_on_num'] = $rspecs['event_repeat_on_num'];
        $eventdata['event_repeat_on_day'] = $rspecs['event_repeat_on_day'];
        $eventdata['event_repeat_on_freq'] = $rspecs['event_repeat_on_freq'];
        $eventdata['event_recurrspec'] = $rspecs;
        $eventdata['uname'] = $uname;
        $eventdata['event_userid'] = $event['event_userid'];
        $eventdata['event_pid'] = $event['pid'];
        $eventdata['event_aid'] = $event['aid'];
        $eventdata['Date'] = $Date;
        $eventdata['year'] = $year;
        $eventdata['month'] = $month;
        $eventdata['day'] = $day;
        $eventdata['is_update'] = true;
        $eventdata['pc_event_id'] = $pc_event_id;
        $event_data['patient_name'] = $event_patient_name;
        $eventdata['data_loaded'] = true;
        $eventdata['pc_html_or_text'] = $pc_html_or_text;
        $eventdata['category'] = base64_encode(serialize($category));
    }
    // lets get the module's information
    $modinfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__));
    $categories = pnModAPIFunc(__POSTCALENDAR__, 'user', 'getCategories');
    $output->tabindex = 1;
    //================================================================
    //    ERROR CHECKING
    //================================================================
    // removed event_desc as a required_var
    $required_vars = array('event_subject');
    $required_name = array(_PC_EVENT_TITLE, _PC_EVENT_DESC);
    $error_msg = '';
    $output->SetOutputMode(_PNH_RETURNOUTPUT);
    $reqCount = count($required_vars);
    //print_r($eventdata);
    for ($r = 0; $r < $reqCount; $r++) {
        if (empty(${$required_vars}[$r]) || !preg_match('/\\S/i', ${$required_vars}[$r])) {
            $error_msg .= $output->Text('<b>' . $required_name[$r] . '</b> ' . _PC_SUBMIT_ERROR4);
            $error_msg .= $output->Linebreak();
        }
    }
    unset($reqCount);
    // check repeating frequencies
    if ($event_repeat == REPEAT) {
        //can't have a repeating event that doesnt have an end date
        if ($event_endtype == 0) {
            $error_msg .= $output->Text("Repeating events must have an end date set.");
            $error_msg .= $output->Linebreak();
        }
        if (!isset($event_repeat_freq) || $event_repeat_freq < 1 || empty($event_repeat_freq)) {
            $error_msg .= $output->Text(_PC_SUBMIT_ERROR5);
            $error_msg .= $output->Linebreak();
        } elseif (!is_numeric($event_repeat_freq)) {
            $error_msg .= $output->Text(_PC_SUBMIT_ERROR6);
            $error_msg .= $output->Linebreak();
        }
    } elseif ($event_repeat == REPEAT_ON) {
        //can't have a repeating event that doesnt have an end date
        if ($event_endtype == 0) {
            $error_msg .= $output->Text("Repeating events must have an end date set.");
            $error_msg .= $output->Linebreak();
        }
        if (!isset($event_repeat_on_freq) || $event_repeat_on_freq < 1 || empty($event_repeat_on_freq)) {
            $error_msg .= $output->Text(_PC_SUBMIT_ERROR5);
            $error_msg .= $output->Linebreak();
        } elseif (!is_numeric($event_repeat_on_freq)) {
            $error_msg .= $output->Text(_PC_SUBMIT_ERROR6);
            $error_msg .= $output->Linebreak();
        }
    }
    // check date validity
    if (_SETTING_TIME_24HOUR) {
        $startTime = $event_starttimeh . ':' . $event_starttimem;
        $endTime = $event_endtimeh . ':' . $event_endtimem;
    } else {
        if ($event_startampm == _AM_VAL) {
            $event_starttimeh = $event_starttimeh == 12 ? '00' : $event_starttimeh;
        } else {
            $event_starttimeh = $event_starttimeh != 12 ? $event_starttimeh += 12 : $event_starttimeh;
        }
        $startTime = $event_starttimeh . ':' . $event_starttimem;
    }
    $sdate = strtotime($event_startyear . '-' . $event_startmonth . '-' . $event_startday);
    $edate = strtotime($event_endyear . '-' . $event_endmonth . '-' . $event_endday);
    $tdate = strtotime(date('Y-m-d'));
    if ($edate < $sdate && $event_endtype == 1) {
        $error_msg .= $output->Text(_PC_SUBMIT_ERROR1);
        $error_msg .= $output->Linebreak();
    }
    if (!checkdate($event_startmonth, $event_startday, $event_startyear)) {
        $error_msg .= $output->Text(_PC_SUBMIT_ERROR2 . " '{$event_startyear}-{$event_startmonth}-{$event_startday}'");
        $error_msg .= $output->Linebreak();
    }
    if (!checkdate($event_endmonth, $event_endday, $event_endyear)) {
        $error_msg .= $output->Text(_PC_SUBMIT_ERROR3 . " '{$event_endyear}-{$event_endmonth}-{$event_endday}'");
        $error_msg .= $output->Linebreak();
    }
    //check limit on category
    if (($ret = checkCategoryLimits($eventdata)) != null) {
        $error_msg .= $output->Text("This category has a limit of {$ret['limit']} between {$ret['start']} and {$ret['end']} which you have exceeded.");
        $error_msg .= $output->Linebreak();
        //$output->Text(pnModAPIFunc('PostCalendar','user','buildSubmitForm',$eventdata));
        //return $output->GetOutput();
    }
    //echo "fa: " . $form_action . " double_book: " . pnVarCleanFromInput("double_book") . " update: " . $eventdata['is_update'] . " em: " . $error_msg;
    //event collision check
    if ($form_action == "commit" && pnVarCleanFromInput("double_book") != 1 && !$eventdata['is_update'] && empty($error_msg)) {
        //check on new shceduling events(in or out of office) to make sure that
        //you don't have more than one set per day
        //event category 1 is in office, event category 2 is out of office
        if ($eventdata['event_category'] == 2 || $eventdata['event_category'] == 3) {
            $searchargs = array();
            $searchargs['start'] = $eventdata['event_startmonth'] . "/" . $eventdata['event_startday'] . "/" . $eventdata['event_startyear'];
            $searchargs['end'] = $eventdata['event_endmonth'] . "/" . $eventdata['event_endday'] . "/" . $eventdata['event_endyear'];
            $searchargs['provider_id'] = $eventdata['event_userid'];
            //faFLag uses pcgeteventsfa, which can search on provider
            $searchargs['faFlag'] = true;
            $searchargs['s_keywords'] = " (a.pc_catid = 2 OR a.pc_catid = 3) ";
            //print_r($searchargs);
            $eventsByDate =& postcalendar_userapi_pcGetEvents($searchargs);
            $ekey = md5($event_data['subject'] . date("U") . rand(0, 1000));
            $oldstatus = $eventdata['event_status'];
            $oldtitle = $eventdata['event_subject'];
            $old_patient_name = $eventdata['patient_name'];
            $old_dur_hours = $eventdata['event_dur_hours'];
            $old_dur_min = $eventdata['event_dur_minutes'];
            $old_duration = $eventdata['event_duration'];
            $eventdata['event_subject'] = mysql_real_escape_string($ekey);
            $eventdata['event_status'] = _EVENT_TEMPORARY;
            if (!pnModAPIFunc(__POSTCALENDAR__, 'user', 'submitEvent', $eventdata)) {
                $error_msg .= $output->Text('<center><div style="padding:5px; border:1px solid red; background-color: pink;">');
                $error_msg .= $output->Text("<b>The system was unable to check you event for conflicts with other events because there was a problem with your database.</b><br />");
                $error_msg .= $output->Text('</div></center>');
                $error_msg .= $output->Linebreak();
                $error_msg .= $output->Text($dbconn->ErrorMsg());
            }
            $searchargs['s_keywords'] = " (a.pc_catid = 2 OR a.pc_catid = 3) AND a.pc_title = '" . $eventdata['event_subject'] . "' ";
            $searchargs['event_status'] = _EVENT_TEMPORARY;
            $submitEventByDate =& postcalendar_userapi_pcGetEvents($searchargs);
            if (!delete_event($ekey)) {
                $error_msg .= $output->Text('<center><div style="padding:5px; border:1px solid red; background-color: pink;">');
                $error_msg .= $output->Text("<b>The system was unable to delete a temporary record it created, this may have left the database in an inconsistent state.</b><br />");
                $error_msg .= $output->Text('</div></center>');
                $error_msg .= $output->Linebreak();
                $error_msg .= $output->Text($dbconn->ErrorMsg());
            }
            $eventdata['event_status'] = $oldstatus;
            $eventdata['event_subject'] = $oldtitle;
            $eventdata['patient_name '] = $old_patient_name;
            $eventdata['event_dur_hours'] = $old_dur_hour;
            $eventdata['event_dur_minutes'] = $old_dur_min;
            foreach ($submitEventByDate as $date => $newevent) {
                if (count($eventsByDate[$date]) > 0 && count($newevent) > 0) {
                    foreach ($eventsByDate[$date] as $con_event) {
                        if ($con_event['catid'] == $newevent[0]['catid']) {
                            $error_msg .= $output->Text('There is a conflict on ' . $date . ' with event ' . $con_event['title']);
                            $error_msg .= $output->Linebreak();
                        }
                    }
                }
            }
            /*echo "<br /><br />";
              print_r($eventsByDate);
              echo "<br /><br />";
              print_r($submitEventByDate);*/
        }
        $colls = checkEventCollision($eventdata);
        if (count($colls) > 0) {
            foreach ($colls as $coll) {
                $error_msg .= $output->Text("Event Collides with: " . $coll['title'] . " at " . date("g:i a", strtotime($coll['startTime'])) . "<br />");
                $error_msg .= $output->Linebreak();
            }
            $error_msg .= $output->Text("Submit again to \"Double Book\" <br />To change values click back in your browser.");
            $error_msg .= $output->Linebreak();
            // the following line will display "DOUBLE BOOKED" if when adding an event there is a collistion with anothe appointment
            //$eventdata['event_subject'] = "DOUBLE BOOKED " . $eventdata['event_subject'];
            $eventdata['double_book'] = 1;
        }
    }
    $output->SetOutputMode(_PNH_KEEPOUTPUT);
    if ($form_action == 'preview') {
        //================================================================
        //  Preview the event
        //================================================================
        // check authid
        if (!pnSecConfirmAuthKey()) {
            return _NO_DIRECT_ACCESS;
        }
        if (!empty($error_msg)) {
            $preview = false;
            $output->Text('<table border="0" width="100%" cellpadding="1" cellspacing="0"><tr><td bgcolor="red">');
            $output->Text('<table border="0" width="100%" cellpadding="1" cellspacing="0"><tr><td bgcolor="pink">');
            $output->Text('<center><b>' . _PC_SUBMIT_ERROR . '</b></center>');
            $output->Linebreak();
            $output->Text($error_msg);
            $output->Text('</td></td></table>');
            $output->Text('</td></td></table>');
            $output->Linebreak(2);
        } else {
            $output->Text(pnModAPIFunc(__POSTCALENDAR__, 'user', 'eventPreview', $eventdata));
            $output->Linebreak();
        }
    } elseif ($form_action == 'commit') {
        //================================================================
        //  Enter the event into the DB
        //================================================================
        if (!empty($error_msg)) {
            if (!pnSecConfirmAuthKey(true)) {
                return _NO_DIRECT_ACCESS;
            }
        } else {
            if (!pnSecConfirmAuthKey()) {
                return _NO_DIRECT_ACCESS;
            }
        }
        if (!empty($error_msg)) {
            $preview = false;
            $output->Text('<table border="0" width="100%" cellpadding="1" cellspacing="0"><tr><td bgcolor="red">');
            $output->Text('<table border="0" width="100%" cellpadding="1" cellspacing="0"><tr><td bgcolor="pink">');
            $output->Text('<center><b>' . _PC_SUBMIT_ERROR . '</b></center>');
            $output->Linebreak();
            $output->Text($error_msg);
            $output->Text('</td></td></table>');
            $output->Text('</td></td></table>');
            $output->Linebreak(2);
        } else {
            if (!pnModAPIFunc(__POSTCALENDAR__, 'user', 'submitEvent', $eventdata)) {
                $output->Text('<center><div style="padding:5px; border:1px solid red; background-color: pink;">');
                $output->Text("<b>" . _PC_EVENT_SUBMISSION_FAILED . "</b>");
                $output->Text('</div></center>');
                $output->Linebreak();
                $output->Text($dbconn->ErrorMsg());
            } else {
                // clear the Smarty cache
                $tpl = new pcSmarty();
                $tpl->clear_all_cache();
                $output->Text('<center><div style="padding:5px; border:1px solid green; background-color: lightgreen;">');
                if ($is_update) {
                    $output->Text("<b>" . _PC_EVENT_EDIT_SUCCESS . "</b>");
                } else {
                    $output->Text("<b>" . _PC_EVENT_SUBMISSION_SUCCESS . "</b>");
                }
                $output->Text('</div></center>');
                $output->Linebreak();
                // clear the form vars
                $event_subject = $event_desc = $event_sharing = $event_category = $event_topic = $event_startmonth = $event_startday = $event_startyear = $event_starttimeh = $event_starttimem = $event_startampm = $event_endmonth = $event_endday = $event_endyear = $event_endtype = $event_dur_hours = $event_dur_minutes = $event_duration = $event_allday = $event_location = $event_street1 = $event_street2 = $event_city = $event_state = $event_postal = $event_location_info = $event_contname = $event_conttel = $event_contemail = $event_website = $event_fee = $event_repeat = $event_repeat_freq = $event_repeat_freq_type = $event_repeat_on_num = $event_repeat_on_day = $event_repeat_on_freq = $event_recurrspec = $uname = $Date = $year = $month = $day = $pc_html_or_text = $event_patient_name = $evnet_pid = null;
                $is_update = false;
                $pc_event_id = 0;
                //$_SESSION['category'] = "";
                // lets wrap all the data into array for passing to submit and preview functions
                $eventdata = compact('event_subject', 'event_desc', 'event_sharing', 'event_category', 'event_topic', 'event_startmonth', 'event_startday', 'event_startyear', 'event_starttimeh', 'event_starttimem', 'event_startampm', 'event_endmonth', 'event_endday', 'event_endyear', 'event_endtype', 'event_dur_hours', 'event_dur_minutes', 'event_duration', 'event_allday', 'event_location', 'event_street1', 'event_street2', 'event_city', 'event_state', 'event_postal', 'event_location_info', 'event_contname', 'event_conttel', 'event_contemail', 'event_website', 'event_fee', 'event_repeat', 'event_repeat_freq', 'event_repeat_freq_type', 'event_repeat_on_num', 'event_repeat_on_day', 'event_repeat_on_freq', 'event_recurrspec', 'uname', 'Date', 'year', 'month', 'day', 'pc_html_or_text', 'is_update', 'pc_event_id', 'event_patient_name');
                //if no using the no_nav format then show form again after submit
                if (pnVarCleanFromInput("no_nav") == 1) {
                    return $output->GetOutput();
                }
            }
        }
    }
    $output->Text(pnModAPIFunc('PostCalendar', 'user', 'buildSubmitForm', $eventdata));
    return $output->GetOutput();
}
Ejemplo n.º 2
0
/**
 * Main administration menu
 */
function postcalendar_adminmenu($upgraded = false)
{
    if (!PC_ACCESS_ADMIN) {
        return _POSTCALENDAR_NOAUTH;
    }
    pnThemeLoad(pnUserGetTheme());
    // get the theme globals :: is there a better way to do this?
    global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5, $bgcolor6;
    global $textcolor1, $textcolor2;
    $pcModInfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__));
    $pcDir = pnVarPrepForOS($pcModInfo['directory']);
    @define('_AM_VAL', 1);
    @define('_PM_VAL', 2);
    @define('_EVENT_APPROVED', 1);
    @define('_EVENT_QUEUED', 0);
    @define('_EVENT_HIDDEN', -1);
    $adminURL = pnModURL(__POSTCALENDAR__, 'admin', '');
    $settingsURL = pnModURL(__POSTCALENDAR__, 'admin', 'modifyconfig');
    $categoryURL = pnModURL(__POSTCALENDAR__, 'admin', 'categories');
    $submitURL = pnModURL(__POSTCALENDAR__, 'admin', 'submit');
    $approvedURL = pnModURL(__POSTCALENDAR__, 'admin', 'listapproved');
    $hiddenURL = pnModURL(__POSTCALENDAR__, 'admin', 'listhidden');
    $queuedURL = pnModURL(__POSTCALENDAR__, 'admin', 'listqueued');
    $cacheURL = pnModURL(__POSTCALENDAR__, 'admin', 'clearCache');
    $systemURL = pnModURL(__POSTCALENDAR__, 'admin', 'testSystem');
    $limitsURL = pnModURL(__POSTCALENDAR__, 'admin', 'categoryLimits');
    $adminText = _POSTCALENDAR;
    $settingsText = _EDIT_PC_CONFIG_GLOBAL;
    $categoryText = _EDIT_PC_CONFIG_CATEGORIES;
    $submitText = _PC_CREATE_EVENT;
    $approvedText = "Event List";
    $hiddenText = _PC_VIEW_HIDDEN;
    $queuedText = "Marked for Deletion";
    $cacheText = _PC_CLEAR_CACHE;
    $cacheText = _PC_CLEAR_CACHE;
    $systemText = _PC_TEST_SYSTEM;
    $limitsText = _PC_CAT_LIMITS;
    // check for upgrade
    $upgrade = '';
    if ($upgraded === false) {
        $upgrade = pc_isNewVersion();
    }
    $output = <<<EOF
<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="{$bgcolor2}"><tr><td>
<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="{$bgcolor1}">
\t<tr>
\t\t<td align="left" valign="middle"><a href="{$adminURL}"><img
\t\t\tborder="0" src="modules/{$pcDir}/pnimages/admin.gif"></a></td>
        <td width="100%" align="left" valign="middle">
\t\t\t<table border="0" cellpadding="1" cellspacing="0"><tr><td bgcolor="{$bgcolor2}">
\t\t\t<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="{$bgcolor1}">
\t\t\t\t<tr>
\t\t\t\t\t<td nowrap>
\t\t\t\t\t\t<!--<a href="{$settingsURL}">{$settingsText}</a> |-->
\t\t\t\t\t\t<!--<a href="{$submitURL}">{$submitText}</a> |-->
\t\t\t\t\t\t<a href="{$cacheURL}">{$cacheText}</a> |
\t\t\t\t\t\t<a href="{$systemURL}">{$systemText}</a> |
\t\t\t\t\t\t<a href="{$categoryURL}">{$categoryText}</a> |
\t\t\t\t\t\t<a href="{$limitsURL}">{$limitsText}</a><!-- |
\t\t\t\t\t\t<a href="{$queuedURL}">{$queuedText}</a> |
\t\t\t\t\t\t<a href="{$approvedURL}">{$approvedText}</a> |
\t\t\t\t\t\t<a href="{$hiddenURL}">{$hiddenText}</a>-->
\t\t\t\t\t\t{$upgrade}
\t\t\t\t</tr>
\t\t\t</table>
\t\t\t</td></tr></table>
\t\t</td>
    </tr>
</table>
</td></tr></table>
<br />
EOF;
    // Return the output that has been generated by this function
    return $output;
}
Ejemplo n.º 3
0
function postcalendar_userapi_eventDetail($args, $admin = false)
{
    if (!(bool) PC_ACCESS_READ) {
        return _POSTCALENDARNOAUTH;
    }
    // get the theme globals :: is there a better way to do this?
    pnThemeLoad(pnUserGetTheme());
    global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5;
    global $textcolor1, $textcolor2;
    $popup = pnVarCleanFromInput('popup');
    extract($args);
    unset($args);
    if (!isset($cacheid)) {
        $cacheid = null;
    }
    if (!isset($eid)) {
        return false;
    }
    if (!isset($nopop)) {
        $nopop = false;
    }
    $uid = pnUserGetVar('uid');
    //=================================================================
    //  Find out what Template we're using
    //=================================================================
    $template_name = _SETTING_TEMPLATE;
    if (!isset($template_name)) {
        $template_name = 'default';
    }
    //=================================================================
    //  Setup Smarty Template Engine
    //=================================================================
    $tpl = new pcSmarty();
    if ($admin) {
        $template = $template_name . '/admin/details.html';
        $args['cacheid'] = '';
        $print = 0;
        $Date =& postcalendar_getDate();
        $tpl->caching = false;
    } else {
        $template = $template_name . '/user/details.html';
    }
    if (!$tpl->is_cached($template, $cacheid)) {
        // let's get the DB information
        list($dbconn) = pnDBGetConn();
        $pntable = pnDBGetTables();
        // get the event's information
        $event =& postcalendar_userapi_pcGetEventDetails($eid);
        // if the above is false, it's a private event for another user
        // we should not diplay this - so we just exit gracefully
        if ($event === false) {
            return false;
        }
        //=================================================================
        //  get event's topic information
        //=================================================================
        $topics_table = $pntable['topics'];
        $topics_column = $pntable['topics_column'];
        $topicsql = "SELECT {$topics_column['topictext']},{$topics_column['topicimage']}\n                     FROM {$topics_table}\n                     WHERE {$topics_column['topicid']} = {$event['topic']}\n                     LIMIT 1";
        $topic_result = $dbconn->Execute($topicsql);
        list($event['topictext'], $event['topicimg']) = $topic_result->fields;
        $location = unserialize($event['location']);
        $event['location'] = $location['event_location'];
        $event['street1'] = $location['event_street1'];
        $event['street2'] = $location['event_street2'];
        $event['city'] = $location['event_city'];
        $event['state'] = $location['event_state'];
        $event['postal'] = $location['event_postal'];
        $event['date'] = str_replace('-', '', $Date);
        //=================================================================
        //  populate the template
        //=================================================================
        if (!empty($event['location']) || !empty($event['street1']) || !empty($event['street2']) || !empty($event['city']) || !empty($event['state']) || !empty($event['postal'])) {
            $tpl->assign('LOCATION_INFO', true);
        } else {
            $tpl->assign('LOCATION_INFO', false);
        }
        if (!empty($event['contname']) || !empty($event['contemail']) || !empty($event['conttel']) || !empty($event['website'])) {
            $tpl->assign('CONTACT_INFO', true);
        } else {
            $tpl->assign('CONTACT_INFO', false);
        }
        $display_type = substr($event['hometext'], 0, 6);
        if ($display_type == ':text:') {
            $prepFunction = 'pcVarPrepForDisplay';
            $event['hometext'] = substr($event['hometext'], 6);
        } elseif ($display_type == ':html:') {
            $prepFunction = 'pcVarPrepHTMLDisplay';
            $event['hometext'] = substr($event['hometext'], 6);
        } else {
            $prepFunction = 'pcVarPrepHTMLDisplay';
        }
        unset($display_type);
        // prep the vars for output
        $event['title'] =& $prepFunction($event['title']);
        $event['hometext'] =& $prepFunction($event['hometext']);
        $event['desc'] =& $event['hometext'];
        $event['conttel'] =& $prepFunction($event['conttel']);
        $event['contname'] =& $prepFunction($event['contname']);
        $event['contemail'] =& $prepFunction($event['contemail']);
        $event['website'] =& $prepFunction(postcalendar_makeValidURL($event['website']));
        $event['fee'] =& $prepFunction($event['fee']);
        $event['location'] =& $prepFunction($event['location']);
        $event['street1'] =& $prepFunction($event['street1']);
        $event['street2'] =& $prepFunction($event['street2']);
        $event['city'] =& $prepFunction($event['city']);
        $event['state'] =& $prepFunction($event['state']);
        $event['postal'] =& $prepFunction($event['postal']);
        $tpl->assign_by_ref('A_EVENT', $event);
        //=================================================================
        //  populate the template $ADMIN_OPTIONS
        //=================================================================
        $target = '';
        if (_SETTING_OPEN_NEW_WINDOW) {
            $target = 'target="csCalendar"';
        }
        $admin_edit_url = $admin_delete_url = '';
        if (pnSecAuthAction(0, 'PostCalendar::', '::', ACCESS_ADMIN)) {
            $admin_edit_url = pnModURL(__POSTCALENDAR__, 'admin', 'submit', array('pc_event_id' => $eid));
            $admin_delete_url = pnModURL(__POSTCALENDAR__, 'admin', 'adminevents', array('action' => _ACTION_DELETE, 'pc_event_id' => $eid));
        }
        $user_edit_url = $user_delete_url = '';
        if (pnUserLoggedIn()) {
            $logged_in_uname = $_SESSION['authUser'];
        } else {
            $logged_in_uname = '';
        }
        $can_edit = false;
        if (pnSecAuthAction(0, 'PostCalendar::', '::', ACCESS_ADD) && validateGroupStatus($logged_in_uname, getUsername($event['uname']))) {
            $user_edit_url = pnModURL(__POSTCALENDAR__, 'user', 'submit', array('pc_event_id' => $eid));
            $user_delete_url = pnModURL(__POSTCALENDAR__, 'user', 'delete', array('pc_event_id' => $eid));
            $can_edit = true;
        }
        $tpl->assign('STYLE', $GLOBALS['style']);
        $tpl->assign_by_ref('ADMIN_TARGET', $target);
        $tpl->assign_by_ref('ADMIN_EDIT', $admin_edit_url);
        $tpl->assign_by_ref('ADMIN_DELETE', $admin_delete_url);
        $tpl->assign_by_ref('USER_TARGET', $target);
        $tpl->assign_by_ref('USER_EDIT', $user_edit_url);
        $tpl->assign_by_ref('USER_DELETE', $user_delete_url);
        $tpl->assign_by_ref('USER_CAN_EDIT', $can_edit);
    }
    //=================================================================
    //  Parse the template
    //=================================================================
    if ($popup != 1 && $print != 1) {
        $output = "\n\n<!-- START POSTCALENDAR OUTPUT [-: HTTP://POSTCALENDAR.TV :-] -->\n\n";
        $output .= $tpl->fetch($template, $cacheid);
        $output .= "\n\n<!-- END POSTCALENDAR OUTPUT [-: HTTP://POSTCALENDAR.TV :-] -->\n\n";
    } else {
        $theme = pnUserGetTheme();
        echo "<html><head>";
        echo "<LINK REL=\"StyleSheet\" HREF=\"themes/{$theme}/style/styleNN.css\" TYPE=\"text/css\">\n\n\n";
        echo "<style type=\"text/css\">\n";
        echo "@import url(\"themes/{$theme}/style/style.css\"); ";
        echo "</style>\n";
        echo "</head><body>\n";
        $tpl->display($template, $cacheid);
        echo postcalendar_footer();
        echo "\n</body></html>";
        session_write_close();
        exit;
    }
    return $output;
}
Ejemplo n.º 4
0
 function __construct()
 {
     $theme = pnUserGetTheme();
     $osTheme = pnVarPrepForOS($theme);
     pnThemeLoad($theme);
     global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5, $bgcolor6, $textcolor1, $textcolor2;
     // call constructor
     parent::__construct();
     // gather module information
     $pcModInfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__));
     $pcDir = pnVarPrepForOS($pcModInfo['directory']);
     $pcDisplayName = $pcModInfo['displayname'];
     unset($pcModInfo);
     // setup up pcSmarty configs
     $this->compile_check = true;
     $this->force_compile = false;
     $this->debugging = false;
     $this->template_dir = "modules/{$pcDir}/pntemplates";
     array_push($this->plugins_dir, "modules/{$pcDir}/pnincludes/Smarty/plugins");
     array_push($this->plugins_dir, "modules/{$pcDir}/plugins");
     $this->compile_dir = "modules/{$pcDir}/pntemplates/compiled";
     $this->cache_dir = "modules/{$pcDir}/pntemplates/cache";
     $this->caching = _SETTING_USE_CACHE;
     $this->cache_lifetime = _SETTING_CACHE_LIFETIME;
     $this->left_delimiter = '[-';
     $this->right_delimiter = '-]';
     //============================================================
     //	checks for safe mode
     //	i think it's safe to say we can do this automagically now
     //============================================================
     $safe_mode = ini_get('safe_mode');
     $safe_mode_gid = ini_get('safe_mode_gid');
     $open_basedir = ini_get('open_basedir');
     $use_safe_mode = (bool) $safe_mode || (bool) $safe_mode_gid || !empty($open_basedir);
     if ($use_safe_mode) {
         $this->use_sub_dirs = false;
     } else {
         $this->use_sub_dirs = true;
     }
     unset($use_safe_mode, $safe_mode, $safe_mode_gid, $open_basedir);
     $this->autoload_filters = array('output' => array('trimwhitespace'));
     $lang = pnUserGetLang();
     $func = pnVarCleanFromInput('func');
     $print = pnVarCleanFromInput('print');
     // assign theme globals
     $this->assign_by_ref('BGCOLOR1', $bgcolor1);
     $this->assign_by_ref('BGCOLOR2', $bgcolor2);
     $this->assign_by_ref('BGCOLOR3', $bgcolor3);
     $this->assign_by_ref('BGCOLOR4', $bgcolor4);
     $this->assign_by_ref('BGCOLOR5', $bgcolor5);
     $this->assign_by_ref('BGCOLOR6', $bgcolor6);
     $this->assign_by_ref('TEXTCOLOR1', $textcolor1);
     $this->assign_by_ref('TEXTCOLOR2', $textcolor2);
     $this->assign_by_ref('USER_LANG', $lang);
     $this->assign_by_ref('FUNCTION', $func);
     $this->assign('PRINT_VIEW', $print);
     $this->assign('USE_POPUPS', _SETTING_USE_POPUPS);
     $this->assign('USE_TOPICS', _SETTING_DISPLAY_TOPICS);
     $this->assign('USE_INT_DATES', _SETTING_USE_INT_DATES);
     $this->assign('OPEN_NEW_WINDOW', _SETTING_OPEN_NEW_WINDOW);
     $this->assign('EVENT_DATE_FORMAT', _SETTING_DATE_FORMAT);
     $this->assign('HIGHLIGHT_COLOR', _SETTING_DAY_HICOLOR);
     $this->assign('24HOUR_TIME', _SETTING_TIME_24HOUR);
     $this->assign_by_ref('MODULE_NAME', $pcDisplayName);
     $this->assign_by_ref('MODULE_DIR', $pcDir);
     $this->assign('ACCESS_NONE', PC_ACCESS_NONE);
     $this->assign('ACCESS_OVERVIEW', PC_ACCESS_OVERVIEW);
     $this->assign('ACCESS_READ', PC_ACCESS_READ);
     $this->assign('ACCESS_COMMENT', PC_ACCESS_COMMENT);
     $this->assign('ACCESS_MODERATE', PC_ACCESS_MODERATE);
     $this->assign('ACCESS_EDIT', PC_ACCESS_EDIT);
     $this->assign('ACCESS_ADD', PC_ACCESS_ADD);
     $this->assign('ACCESS_DELETE', PC_ACCESS_DELETE);
     $this->assign('ACCESS_ADMIN', PC_ACCESS_ADMIN);
     //=================================================================
     //  Find out what Template we're using
     //=================================================================
     $template_name = _SETTING_TEMPLATE;
     if (!isset($template_name)) {
         $template_name = 'default';
     }
     //=================================================================
     //  Find out what Template View to use
     //=================================================================
     $template_view = pnVarCleanFromInput('tplview');
     if (!isset($template_view)) {
         $template_view = 'default';
     }
     $this->config_dir = "modules/{$pcDir}/pntemplates/{$template_name}/config/";
     $this->assign_by_ref('TPL_NAME', $template_name);
     $this->assign_by_ref('TPL_VIEW', $template_view);
     $this->assign('TPL_IMAGE_PATH', $GLOBALS['rootdir'] . "/main/calendar/modules/{$pcDir}/pntemplates/{$template_name}/images");
     $this->assign('TPL_ROOTDIR', $GLOBALS['rootdir']);
     $this->assign('TPL_STYLE_PATH', "modules/{$pcDir}/pntemplates/{$template_name}/style");
     $this->assign('THEME_PATH', "themes/{$osTheme}");
 }
Ejemplo n.º 5
0
 */
// grab the form variables
$tplview = pnVarCleanFromInput('tplview');
$viewtype = pnVarCleanFromInput('viewtype');
$eid = pnVarCleanFromInput('eid');
$Date = pnVarCleanFromInput('Date');
$print = pnVarCleanFromInput('print');
$uid = pnUserGetVar('uid');
$pc_username = pnVarCleanFromInput('pc_username');
$output =& new pnHTML();
$output->SetInputMode(_PNH_VERBATIMINPUT);
if (!pnModAPILoad('postcalendar', 'user')) {
    die('Could not load PostCalendar user API');
}
$theme = pnUserGetTheme();
if (!pnThemeLoad($theme)) {
    die('Could not load theme');
}
$output->Text('<html><head>');
$output->Text("<title>" . pnConfigGetVar('sitename') . ' :: ' . pnConfigGetVar('slogan') . "</title>\n");
$output->Text('<link rel="StyleSheet" href="themes/' . $theme . '/style/styleNN.css" type="text/css" />');
$output->Text('<style type="text/css">@import url("themes/' . $theme . '/style/style.css"); </style>');
$output->Text('</head>');
$output->Text('<body bgcolor="#ffffff">');
// setup our cache id
$cacheid = md5($Date . $viewtype . $tplview . _SETTING_TEMPLATE . $eid . $print . $uid . $pc_username . $theme);
// display the correct view
switch ($viewtype) {
    case 'details':
        $output->Text(pnModAPIFunc('PostCalendar', 'user', 'eventDetail', array('eid' => $eid, 'Date' => $Date, 'print' => $print, 'cacheid' => $cacheid)));
        break;
Ejemplo n.º 6
0
/**
 *  postcalendar_userapi_eventPreview
 *  Creates the detailed event display and outputs html.
 *  Accepts an array of key/value pairs
 *  @param array $event array of event details from the form
 *  @return string html output
 *  @access public
 */
function postcalendar_userapi_eventPreview($args)
{
    // get the theme globals :: is there a better way to do this?
    pnThemeLoad(pnUserGetTheme());
    global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5;
    global $textcolor1, $textcolor2;
    extract($args);
    unset($args);
    $uid = pnUserGetVar('uid');
    //=================================================================
    //  Setup Smarty Template Engine
    //=================================================================
    $tpl = new pcSmarty();
    $tpl->caching = false;
    // add preceding zeros
    $event_starttimeh = sprintf('%02d', $event_starttimeh);
    $event_starttimem = sprintf('%02d', $event_starttimem);
    $event_startday = sprintf('%02d', $event_startday);
    $event_startmonth = sprintf('%02d', $event_startmonth);
    $event_endday = sprintf('%02d', $event_endday);
    $event_endmonth = sprintf('%02d', $event_endmonth);
    if (!(bool) _SETTING_TIME_24HOUR) {
        if ($event_startampm == _PM_VAL) {
            if ($event_starttimeh != 12) {
                $event_starttimeh += 12;
            }
        } elseif ($event_startampm == _AM_VAL) {
            if ($event_starttimeh == 12) {
                $event_starttimeh = 00;
            }
        }
    }
    $event_startampm . " - ";
    $startTime = $event_starttimeh . ':' . $event_starttimem . ' ';
    $event = array();
    $event['eid'] = '';
    $event['uname'] = $uname;
    $event['catid'] = $event_category;
    if ($pc_html_or_text == 'html') {
        $prepFunction = 'pcVarPrepHTMLDisplay';
    } else {
        $prepFunction = 'pcVarPrepForDisplay';
    }
    $event['title'] = $prepFunction($event_subject);
    $event['hometext'] = $prepFunction($event_desc);
    $event['desc'] = $event['hometext'];
    $event['date'] = $event_startyear . $event_startmonth . $event_startday;
    $event['duration'] = $event_duration;
    $event['duration_hours'] = $event_dur_hours;
    $event['duration_minutes'] = $event_dur_minutes;
    $event['endDate'] = $event_endyear . '-' . $event_endmonth . '-' . $event_endday;
    $event['startTime'] = $startTime;
    $event['recurrtype'] = '';
    $event['recurrfreq'] = '';
    $event['recurrspec'] = $event_recurrspec;
    $event['topic'] = $event_topic;
    $event['alldayevent'] = $event_allday;
    $event['conttel'] = $prepFunction($event_conttel);
    $event['contname'] = $prepFunction($event_contname);
    $event['contemail'] = $prepFunction($event_contemail);
    $event['website'] = $prepFunction(postcalendar_makeValidURL($event_website));
    $event['fee'] = $prepFunction($event_fee);
    $event['location'] = $prepFunction($event_location);
    $event['street1'] = $prepFunction($event_street1);
    $event['street2'] = $prepFunction($event_street2);
    $event['city'] = $prepFunction($event_city);
    $event['state'] = $prepFunction($event_state);
    $event['postal'] = $prepFunction($event_postal);
    //=================================================================
    //  get event's topic information
    //=================================================================
    if (_SETTING_DISPLAY_TOPICS) {
        list($dbconn) = pnDBGetConn();
        $pntable = pnDBGetTables();
        $topics_table = $pntable['topics'];
        $topics_column = $pntable['topics_column'];
        $topicsql = "SELECT {$topics_column['topictext']},{$topics_column['topicimage']}\n            \t \t FROM {$topics_table}\n            \t \t WHERE {$topics_column['topicid']} = {$event['topic']}\n            \t \t LIMIT 1";
        $topic_result = $dbconn->Execute($topicsql);
        list($event['topictext'], $event['topicimg']) = $topic_result->fields;
        $topic_result->Close();
    } else {
        $event['topictext'] = $event['topicimg'] = '';
    }
    //=================================================================
    //  Find out what Template we're using
    //=================================================================
    $template_name = _SETTING_TEMPLATE;
    if (!isset($template_name)) {
        $template_name = 'default';
    }
    //=================================================================
    //  populate the template
    //=================================================================
    if (!empty($event['location']) || !empty($event['street1']) || !empty($event['street2']) || !empty($event['city']) || !empty($event['state']) || !empty($event['postal'])) {
        $tpl->assign('LOCATION_INFO', true);
    } else {
        $tpl->assign('LOCATION_INFO', false);
    }
    if (!empty($event['contname']) || !empty($event['contemail']) || !empty($event['conttel']) || !empty($event['website'])) {
        $tpl->assign('CONTACT_INFO', true);
    } else {
        $tpl->assign('CONTACT_INFO', false);
    }
    $tpl->assign_by_ref('A_EVENT', $event);
    $tpl->assign('STYLE', $GLOBALS['style']);
    //=================================================================
    //  Parse the template
    //=================================================================
    $output = "\n\n<!-- POSTCALENDAR HTTP://WWW.BAHRAINI.TV -->\n\n";
    $output .= "\n\n<!-- POSTCALENDAR TEMPLATE START -->\n\n";
    $output .= $tpl->fetch($template_name . '/user/preview.html');
    $output .= "\n\n<!-- POSTCALENDAR TEMPLATE END -->\n\n";
    return $output;
}
Ejemplo n.º 7
0
/**
 * display block
 */
function postcalendar_calendarblock_display($blockinfo)
{
    // You supposed to be here?
    if (!pnSecAuthAction(0, 'PostCalendar:calendarblock:', "{$blockinfo['title']}::", ACCESS_OVERVIEW)) {
        return false;
    }
    // find out what view we're using
    $template_view = pnVarCleanFromInput('tplview');
    if (!isset($template_view)) {
        $template_view = 'default';
    }
    // find out what template we're using
    $template_name = _SETTING_TEMPLATE;
    if (!isset($template_name) || empty($template_name)) {
        $template_name = 'default';
    }
    // What is today's correct date
    $Date =& postcalendar_getDate();
    // Get variables from content block
    $vars = unserialize($blockinfo['content']);
    $showcalendar = $vars['pcbshowcalendar'];
    $showevents = $vars['pcbeventoverview'];
    $eventslimit = $vars['pcbeventslimit'];
    $nextevents = $vars['pcbnextevents'];
    $pcbshowsslinks = $vars['pcbshowsslinks'];
    $pcbeventsrange = $vars['pcbeventsrange'];
    // Let's setup the info to build this sucka!
    $the_year = substr($Date, 0, 4);
    $the_month = substr($Date, 4, 2);
    $the_day = substr($Date, 6, 2);
    $uid = pnUserGetVar('uid');
    $cacheid1 = $cacheid2 = $cacheid3 = '';
    $theme = pnUserGetTheme();
    pnThemeLoad($theme);
    global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5;
    global $textcolor1, $textcolor2;
    // 20021125 - rraymond :: we have to do this to make it work with envolution
    $pcModInfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__));
    $pcDir = pnVarPrepForOS($pcModInfo['directory']);
    require_once "modules/{$pcDir}/pnincludes/Smarty/Config_File.class.php";
    unset($pcModInfo);
    // set up Smarty
    $tpl =& new pcSmarty();
    // setup the Smarty cache id
    $templates_cached = true;
    if ($showcalendar) {
        $cacheid1 = md5($Date . 'M' . $template_view . $template_name . $showcalendar . $showevents . $nextevents . $uid . $theme);
        if (!$tpl->is_cached($template_name . '/views/calendarblock/month_view.html', $cacheid1)) {
            $templates_cached = false;
        }
    }
    if ($showevents) {
        $cacheid2 = md5($Date . 'T' . $template_view . $template_name . $showcalendar . $showevents . $nextevents . $uid . $theme);
        if (!$tpl->is_cached($template_name . '/views/calendarblock/todays_events.html', $cacheid2)) {
            $templates_cached = false;
        }
    }
    if ($nextevents) {
        $cacheid3 = md5($Date . 'U' . $template_view . $template_name . $showcalendar . $showevents . $nextevents . $uid . $theme);
        if (!$tpl->is_cached($template_name . '/views/calendarblock/upcoming_events.html', $cacheid3)) {
            $templates_cached = false;
        }
    }
    // start the output container
    $output = pnModAPIFunc(__POSTCALENDAR__, 'user', 'pageSetup');
    // if one of the templates is not cached, we need to run the following
    if (!$templates_cached) {
        // set up the next and previous months to move to
        $prev_month = Date_Calc::beginOfPrevMonth(1, $the_month, $the_year, '%Y%m%d');
        $next_month = Date_Calc::beginOfNextMonth(1, $the_month, $the_year, '%Y%m%d');
        $last_day = Date_Calc::daysInMonth($the_month, $the_year);
        $pc_prev = pnModURL(__POSTCALENDAR__, 'user', 'view', array('tplview' => $template_view, 'viewtype' => 'month', 'Date' => $prev_month));
        $pc_next = pnModURL(__POSTCALENDAR__, 'user', 'view', array('tplview' => $template_view, 'viewtype' => 'month', 'Date' => $next_month));
        $pc_month_name = pnModAPIFunc(__POSTCALENDAR__, 'user', 'getmonthname', array('Date' => mktime(0, 0, 0, $the_month, $the_day, $the_year)));
        $month_link_url = pnModURL(__POSTCALENDAR__, 'user', 'view', array('tplview' => $template_view, 'viewtype' => 'month', 'Date' => date('Ymd', mktime(0, 0, 0, $the_month, 1, $the_year))));
        $month_link_text = $pc_month_name . ' ' . $the_year;
        //*******************************************************************
        //  Here we get the events for the current month view
        //*******************************************************************
        $day_of_week = 1;
        $pc_month_names = array(_CALJAN, _CALFEB, _CALMAR, _CALAPR, _CALMAY, _CALJUN, _CALJUL, _CALAUG, _CALSEP, _CALOCT, _CALNOV, _CALDEC);
        $pc_short_day_names = array(_CALSUNDAYSHORT, _CALMONDAYSHORT, _CALTUESDAYSHORT, _CALWEDNESDAYSHORT, _CALTHURSDAYSHORT, _CALFRIDAYSHORT, _CALSATURDAYSHORT);
        $pc_long_day_names = array(_CALSUNDAY, _CALMONDAY, _CALTUESDAY, _CALWEDNESDAY, _CALTHURSDAY, _CALFRIDAY, _CALSATURDAY);
        switch (_SETTING_FIRST_DAY_WEEK) {
            case _IS_MONDAY:
                $pc_array_pos = 1;
                $first_day = date('w', mktime(0, 0, 0, $the_month, 0, $the_year));
                $end_dow = date('w', mktime(0, 0, 0, $the_month, $last_day, $the_year));
                if ($end_dow != 0) {
                    $the_last_day = $last_day + (7 - $end_dow);
                } else {
                    $the_last_day = $last_day;
                }
                break;
            case _IS_SATURDAY:
                $pc_array_pos = 6;
                $first_day = date('w', mktime(0, 0, 0, $the_month, 2, $the_year));
                $end_dow = date('w', mktime(0, 0, 0, $the_month, $last_day, $the_year));
                if ($end_dow == 6) {
                    $the_last_day = $last_day + 6;
                } elseif ($end_dow != 5) {
                    $the_last_day = $last_day + (5 - $end_dow);
                } else {
                    $the_last_day = $last_day;
                }
                break;
            case _IS_SUNDAY:
            default:
                $pc_array_pos = 0;
                $first_day = date('w', mktime(0, 0, 0, $the_month, 1, $the_year));
                $end_dow = date('w', mktime(0, 0, 0, $the_month, $last_day, $the_year));
                if ($end_dow != 6) {
                    $the_last_day = $last_day + (6 - $end_dow);
                } else {
                    $the_last_day = $last_day;
                }
                break;
        }
        $month_view_start = date('Y-m-d', mktime(0, 0, 0, $the_month, 1, $the_year));
        $month_view_end = date('Y-m-t', mktime(0, 0, 0, $the_month, 1, $the_year));
        $today_date = postcalendar_today('%Y-%m-%d');
        $starting_date = date('m/d/Y', mktime(0, 0, 0, $the_month, 1 - $first_day, $the_year));
        $ending_date = date('m/t/Y', mktime(0, 0, 0, $the_month + $pcbeventsrange, 1, $the_year));
        $eventsByDate =& pnModAPIFunc(__POSTCALENDAR__, 'user', 'pcGetEvents', array('start' => $starting_date, 'end' => $ending_date));
        $calendarView = Date_Calc::getCalendarMonth($the_month, $the_year, '%Y-%m-%d');
        $sdaynames = array();
        $numDays = count($pc_short_day_names);
        for ($i = 0; $i < $numDays; $i++) {
            if ($pc_array_pos >= $numDays) {
                $pc_array_pos = 0;
            }
            array_push($sdaynames, $pc_short_day_names[$pc_array_pos]);
            $pc_array_pos++;
        }
        $daynames = array();
        $numDays = count($pc_long_day_names);
        for ($i = 0; $i < $numDays; $i++) {
            if ($pc_array_pos >= $numDays) {
                $pc_array_pos = 0;
            }
            array_push($daynames, $pc_long_day_names[$pc_array_pos]);
            $pc_array_pos++;
        }
        $dates = array();
        while ($starting_date <= $ending_date) {
            array_push($dates, $starting_date);
            list($m, $d, $y) = explode('/', $starting_date);
            $starting_date = Date_Calc::nextDay($d, $m, $y, '%m/%d/%Y');
        }
        $categories =& pnModAPIFunc(__POSTCALENDAR__, 'user', 'getCategories');
        if (isset($calendarView)) {
            $tpl->assign_by_ref('CAL_FORMAT', $calendarView);
        }
        $tpl->assign_by_ref('A_MONTH_NAMES', $pc_month_names);
        $tpl->assign_by_ref('A_LONG_DAY_NAMES', $pc_long_day_names);
        $tpl->assign_by_ref('A_SHORT_DAY_NAMES', $pc_short_day_names);
        $tpl->assign_by_ref('S_LONG_DAY_NAMES', $daynames);
        $tpl->assign_by_ref('S_SHORT_DAY_NAMES', $sdaynames);
        $tpl->assign_by_ref('A_EVENTS', $eventsByDate);
        $tpl->assign_by_ref('A_CATEGORY', $categories);
        $tpl->assign_by_ref('PREV_MONTH_URL', $pc_prev);
        $tpl->assign_by_ref('NEXT_MONTH_URL', $pc_next);
        $tpl->assign_by_ref('MONTH_START_DATE', $month_view_start);
        $tpl->assign_by_ref('MONTH_END_DATE', $month_view_end);
        $tpl->assign_by_ref('TODAY_DATE', $today_date);
        $tpl->assign_by_ref('DATE', $Date);
        $tpl->assign_by_ref('DISPLAY_LIMIT', $eventslimit);
        $tpl->assign('TODAYS_EVENTS_TITLE', _PC_TODAYS_EVENTS);
        $tpl->assign('UPCOMING_EVENTS_TITLE', _PC_UPCOMING_EVENTS);
        $tpl->assign('NO_EVENTS', _PC_BLOCK_NO_EVENTS);
    }
    if ($showcalendar) {
        // we need to create a unique ID for caching purposes
        $output .= $tpl->fetch($template_name . '/views/calendarblock/month_view.html', $cacheid1);
    }
    if ($showevents) {
        if ($showcalendar) {
            $tpl->assign('SHOW_TITLE', 1);
        } else {
            $tpl->assign('SHOW_TITLE', 0);
        }
        // we need to create a unique ID for caching purposes
        $output .= $tpl->fetch($template_name . '/views/calendarblock/todays_events.html', $cacheid2);
    }
    if ($nextevents) {
        if ($showcalendar || $showevents) {
            $tpl->assign('SHOW_TITLE', 1);
        } else {
            $tpl->assign('SHOW_TITLE', 0);
        }
        // we need to create a unique ID for caching purposes
        $output .= $tpl->fetch($template_name . '/views/calendarblock/upcoming_events.html', $cacheid3);
    }
    if ($pcbshowsslinks) {
        $output .= '<br /><br />';
        $submit_event_url = pnModURL(__POSTCALENDAR__, 'user', 'submit');
        $search_event_url = pnModURL(__POSTCALENDAR__, 'user', 'search');
        $output .= '<center>';
        if (PC_ACCESS_ADD) {
            $output .= '[ <a href="' . $submit_event_url . '">' . _PC_SUBMIT_EVENT . '</a> ] ';
        }
        $output .= '[ <a href="' . $search_event_url . '">' . _PC_SEARCH_EVENT . '</a> ]';
        $output .= '</center>';
    }
    // Populate block info and pass to theme
    $blockinfo['content'] = $output;
    return themesideblock($blockinfo);
}
Ejemplo n.º 8
0
function head()
{
    global $index, $artpage, $topic, $hlpfile, $hr, $theme, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5, $textcolor1, $textcolor2, $textcolor3, $textcolor4, $forumpage, $thename, $postnuke_theme, $pntheme, $themename, $themeimages, $additional_header, $themeOverrideCategory, $themeOverrideStory;
    // modification mouzaia .71
    $cWhereIsPerso = WHERE_IS_PERSO;
    if (!empty($cWhereIsPerso)) {
        include "modules/NS-Multisites/head.inc.php";
    } else {
        global $themesarein;
        if (pnUserLoggedIn() && pnConfigGetVar('theme_change') != 1) {
            $thistheme = pnUserGetTheme();
            if (isset($theme)) {
                $thistheme = pnVarPrepForOs($theme);
            }
        } else {
            $thistheme = pnConfigGetVar('Default_Theme');
            if (isset($theme)) {
                $thistheme = pnVarPrepForOs($theme);
            }
        }
        // eugenio themeover 20020413
        // override the theme per category or story
        // precedence is story over category override
        if ($themeOverrideCategory != '' && file_exists("themes/{$themeOverrideCategory}")) {
            $thistheme = $themeOverrideCategory;
        }
        if ($themeOverrideStory != '' && file_exists("themes/{$themeOverrideStory}")) {
            $thistheme = $themeOverrideStory;
        }
        if (@file(WHERE_IS_PERSO . "themes/" . $thistheme . "/theme.php")) {
            $themesarein = WHERE_IS_PERSO;
        } else {
            $themesarein = "";
        }
    }
    // eugenio themeover 20020413
    pnThemeLoad($thistheme);
    /**
     * Simple XHTML Beginnings
     */
    if (pnConfigGetVar('supportxhtml')) {
        //include("includes/xhtml.php");
        xhtml_head_start(0);
        /* Transitional Support for now */
    } else {
        echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
        echo "<html>\n<head>\n";
        if (defined("_CHARSET") && _CHARSET != "") {
            echo "<meta http-equiv=\"Content-Type\" " . "content=\"text/html; charset=" . _CHARSET . "\">\n";
        }
    }
    if ($artpage == 1) {
        /**
         * article page output
         */
        global $info, $hometext;
        echo "<title>{$info['title']} :: " . pnConfigGetVar('sitename') . ' :: ' . pnConfigGetVar('slogan') . "</title>\n";
        if (pnConfigGetVar('dyn_keywords') == 1) {
            $htmlless = check_html($info['maintext'], $strip = 'nohtml');
            $symbolLess = trim(ereg_replace('("|\\?|!|:|\\.|\\(|\\)|;|\\\\)+', ' ', $htmlless));
            $keywords = ereg_replace('( |' . CHR(10) . '|' . CHR(13) . ')+', ',', $symbolLess);
            $metatags = ereg_replace(",+", ",", $keywords);
            echo "<meta http-equiv=\"Keywords\" content=\"{$metatags}\">\n";
        } else {
            echo "<meta name=\"KEYWORDS\" content=\"" . pnConfigGetVar('metakeywords') . "\">\n";
        }
    } else {
        /**
         * all other page output
         */
        echo '<title>' . pnConfigGetVar('sitename') . ' :: ' . pnConfigGetVar('slogan') . "</title>\n";
        echo '<meta name="KEYWORDS" content="' . pnConfigGetVar('metakeywords') . "\">\n";
    }
    echo '<meta name="DESCRIPTION" content="' . pnConfigGetVar('slogan') . "\">\n";
    echo "<meta name=\"ROBOTS\" content=\"INDEX,FOLLOW\">\n";
    echo "<meta name=\"resource-type\" content=\"document\">\n";
    echo "<meta http-equiv=\"expires\" content=\"0\">\n";
    echo '<meta name="author" content="' . pnConfigGetVar('sitename') . "\">\n";
    echo '<meta name="copyright" content="Copyright (c) 2003 by ' . pnConfigGetVar('sitename') . "\">\n";
    echo "<meta name=\"revisit-after\" content=\"1 days\">\n";
    echo "<meta name=\"distribution\" content=\"Global\">\n";
    echo '<meta name="generator" content="PostNuke ' . _PN_VERSION_NUM . " - http://postnuke.com\">\n";
    echo "<meta name=\"rating\" content=\"General\">\n";
    global $themesarein;
    echo "<link rel=\"StyleSheet\" href=\"" . $themesarein . "themes/" . $thistheme . "/style/styleNN.css\" type=\"text/css\">\n";
    echo "<style type=\"text/css\">";
    echo "@import url(\"" . $themesarein . "themes/" . $thistheme . "/style/style.css\"); ";
    echo "</style>\n";
    echo "<script type=\"text/javascript\" src=\"javascript/showimages.php\"></script>\n\n";
    /* Enable Wysiwyg editor configuration at seeting Added by bharvey42 edited by Neo */
    $pnWysiwygEditor = pnConfigGetVar('WYSIWYGEditor');
    if (is_numeric($pnWysiwygEditor) && $pnWysiwygEditor == 1) {
        $pnWSEditorPath = pnGetBaseURI();
        echo "<!--Visual Editor Plug-in-->" . "<script type=\"text/javascript\">QBPATH='" . $pnWSEditorPath . "/javascript'; VISUAL=0; SECURE=1;</script>" . "<script type=\"text/javascript\" src='" . $pnWSEditorPath . "/javascript/quickbuild.js'></script>" . "<script type=\"text/javascript\" src='" . $pnWSEditorPath . "/javascript/tabedit.js'></script>";
    } else {
    }
    echo "<script type=\"text/javascript\" src=\"javascript/openwindow.php?hlpfile={$hlpfile}\"></script>\n\n";
    if (isset($additional_header)) {
        echo @implode("\n", $additional_header);
    }
    themeheader();
}
Ejemplo n.º 9
0
function postcalendar_adminapi_buildAdminList($args)
{
    extract($args);
    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    pnThemeLoad(pnUserGetTheme());
    // get the theme globals :: is there a better way to do this?
    global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5;
    global $textcolor1, $textcolor2;
    $formUrl = pnModUrl(__POSTCALENDAR__, 'admin', 'adminevents');
    $output->FormStart($formUrl);
    $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="' . $bgcolor2 . '"><tr><td>');
    $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="' . $bgcolor1 . '"><tr><td>');
    $output->Text('<center><font size="4"><b>' . $title . '</b></font></center>');
    $output->Text('</td></tr></table>');
    $output->Text('</td></tr></table>');
    $output->Linebreak();
    $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="' . $bgcolor2 . '"><tr><td>');
    $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="' . $bgcolor1 . '">');
    if (!$result || $result->EOF) {
        $output->Text('<tr><td width="100%" bgcolor="' . $bgcolor1 . '" align="center"><b>' . _PC_NO_EVENTS . '</b></td></tr>');
    } else {
        $output->Text('<tr><td bgcolor="' . $bgcolor1 . '" align="center"><b>' . _PC_EVENTS . '</b></td></tr>');
        $output->Text('<table border="0" cellpadding="2" cellspacing="0" width="100%" bgcolor="' . $bgcolor1 . '">');
        // build sorting urls
        if (!isset($sdir)) {
            $sdir = 1;
        } else {
            $sdir = $sdir ? 0 : 1;
        }
        $title_sort_url = pnModUrl(__POSTCALENDAR__, 'admin', $function, array('offset' => $offset, 'sort' => 'title', 'sdir' => $sdir));
        $time_sort_url = pnModUrl(__POSTCALENDAR__, 'admin', $function, array('offset' => $offset, 'sort' => 'time', 'sdir' => $sdir));
        $output->Text('<tr><td>select</td><td><a href="' . $title_sort_url . '">title</a></td><td><a href="' . $time_sort_url . '">timestamp</a><td></tr>');
        // output the queued events
        $count = 0;
        for (; !$result->EOF; $result->MoveNext()) {
            list($eid, $title, $timestamp) = $result->fields;
            $output->Text('<tr>');
            $output->Text('<td align="center" valign="top">');
            $output->FormCheckbox('pc_event_id[]', false, $eid);
            $output->Text('</td>');
            $output->Text('<td  align="left" valign="top" width="100%">');
            $output->URL(pnModURL(__POSTCALENDAR__, 'admin', 'edit', array('pc_event_id' => $eid)), pnVarPrepHTMLDisplay(postcalendar_removeScriptTags($title)));
            $output->Text('</td>');
            $output->Text('<td  align="left" valign="top" nowrap>');
            $output->Text($timestamp);
            $output->Text('</td>');
            $output->Text('</tr>');
            $count++;
        }
        $output->Text('</table>');
    }
    $output->Text('</td></tr></table>');
    if ($result->NumRows()) {
        $output->Linebreak();
        // action to take?
        $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="' . $bgcolor2 . '"><tr><td>');
        $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="' . $bgcolor1 . '"><tr>');
        $output->Text('<td align="left" valign="middle">');
        $seldata[0]['id'] = _ADMIN_ACTION_VIEW;
        $seldata[0]['selected'] = 1;
        $seldata[0]['name'] = _PC_ADMIN_ACTION_VIEW;
        $seldata[1]['id'] = _ADMIN_ACTION_APPROVE;
        $seldata[1]['selected'] = 0;
        $seldata[1]['name'] = _PC_ADMIN_ACTION_APPROVE;
        $seldata[2]['id'] = _ADMIN_ACTION_HIDE;
        $seldata[2]['selected'] = 0;
        $seldata[2]['name'] = _PC_ADMIN_ACTION_HIDE;
        $seldata[3]['id'] = _ADMIN_ACTION_DELETE;
        $seldata[3]['selected'] = 0;
        $seldata[3]['name'] = _PC_ADMIN_ACTION_DELETE;
        $output->FormSelectMultiple('action', $seldata);
        $output->FormHidden('thelist', $function);
        $output->FormSubmit(_PC_PERFORM_ACTION);
        $output->Text('</td>');
        $output->Text('</tr></table>');
        $output->Text('</td></tr></table>');
        $output->Linebreak();
        // start previous next links
        $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="' . $bgcolor2 . '"><tr><td>');
        $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="' . $bgcolor1 . '"><tr>');
        if ($offset > 1) {
            $output->Text('<td align="left">');
            $next_link = pnModUrl(__POSTCALENDAR__, 'admin', $function, array('offset' => $offset - $offset_increment, 'sort' => $sort, 'sdir' => $sdir));
            $output->Text('<a href="' . $next_link . '"><< ' . _PC_PREV . ' ' . $offset_increment . '</a>');
            $output->Text('</td>');
        } else {
            $output->Text('<td align="left"><< ' . _PC_PREV . '</td>');
        }
        if ($result->NumRows() >= $offset_increment) {
            $output->Text('<td align="right">');
            $next_link = pnModUrl(__POSTCALENDAR__, 'admin', $function, array('offset' => $offset + $offset_increment, 'sort' => $sort, 'sdir' => $sdir));
            $output->Text('<a href="' . $next_link . '">' . _PC_NEXT . ' ' . $offset_increment . ' >></a>');
            $output->Text('</td>');
        } else {
            $output->Text('<td align="right">' . _PC_NEXT . ' >></td>');
        }
        $output->Text('</tr></table>');
    }
    $output->Text('</td></tr></table>');
    // end previous next links
    $output->FormEnd();
    return $output->GetOutput();
}
Ejemplo n.º 10
0
function dplink_adminmenu()
{
    $theme = pnUserGetTheme();
    pnThemeLoad($theme);
    // Create output object
    $output = new pnHTML();
    // Security check
    if (!pnSecAuthAction(0, 'dplink::', '::', ACCESS_ADMIN)) {
        $output->Text(pnVarPrepHTMLDisplay(_SHIMLINKNOAUTH));
        return $output->GetOutput();
    }
    //Title
    ob_start();
    OpenTable();
    $oTable = ob_get_contents();
    ob_end_clean();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->Text($oTable);
    $output->Title(pnVarPrepHTMLDisplay('<b>' . _SHIMLINK . '</b>'));
    $output->Text(pnVarPrepHTMLDisplay(_SHIMLINKMODIFYCONFIG));
    ob_start();
    CloseTable();
    $cTable = ob_get_contents();
    ob_end_clean();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->Text($cTable);
    // Start form
    $output->FormStart(pnModURL('dplink', 'admin', 'updateconfig'));
    // Add an authorisation ID
    $output->FormHidden('authid', pnSecGenAuthKey());
    // Start the table that holds the information to be modified.
    ob_start();
    OpenTable();
    $oTable = ob_get_contents();
    ob_end_clean();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->Text($oTable);
    $output->TableStart();
    // dplink location
    $row = array();
    $output->SetOutputMode(_PNH_RETURNOUTPUT);
    $row[] = $output->Text(pnVarPrepHTMLDisplay(_MODSUBJECT));
    $row[] = $output->FormText('url', pnModGetVar('dplink', 'url'), 50, 50);
    $output->SetOutputMode(_PNH_KEEPOUTPUT);
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->TableAddrow($row, 'left');
    // Warning
    $row = array();
    $output->SetOutputMode(_PNH_RETURNOUTPUT);
    $row[] = $output->Text(pnVarPrepHTMLDisplay(_MODWARNING));
    $output->SetOutputMode(_PNH_KEEPOUTPUT);
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->TableAddrow($row, 'left');
    // Use I-frame
    $row = array();
    $output->SetOutputMode(_PNH_RETURNOUTPUT);
    $row[] = $output->Text(pnVarPrepHTMLDisplay(_MODWRAP));
    $row[] = $output->FormCheckbox('use_wrap', pnModGetVar('dplink', 'use_wrap'));
    $output->SetOutputMode(_PNH_KEEPOUTPUT);
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->TableAddrow($row, 'left');
    // Open in New >Window
    $row = array();
    $output->SetOutputMode(_PNH_RETURNOUTPUT);
    $row[] = $output->Text(pnVarPrepHTMLDisplay(_MODWINDOW));
    $row[] = $output->FormCheckbox('use_window', pnModGetVar('dplink', 'use_window'));
    $output->SetOutputMode(_PNH_KEEPOUTPUT);
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->TableAddrow($row, 'left');
    $output->TableEnd();
    ob_start();
    CloseTable();
    $cTable = ob_get_contents();
    ob_end_clean();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->Text($cTable);
    // End form
    //$output->Linebreak(1);
    ob_start();
    OpenTable();
    $oTable = ob_get_contents();
    ob_end_clean();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->Text($oTable);
    $output->Text('<div align="center"><br>');
    $output->FormSubmit(pnVarPrepHTMLDisplay(_SHIMLINKUPDATE));
    $output->Text('<br><br></div>');
    ob_start();
    CloseTable();
    $cTable = ob_get_contents();
    ob_end_clean();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->Text($cTable);
    $output->FormEnd();
    // Return the output that has been generated by this function
    $output->SetOutputMode(_PNH_KEEPOUTPUT);
    return $output->GetOutput();
}
Ejemplo n.º 11
0
/**
* Initialise PostNuke
* <br />
* Carries out a number of initialisation tasks to get PostNuke up and
* running.
*
* @returns void
*/
function pnInit()
{
    // force register_globals=off
    // force register_globals = off
    if (!defined('_PNINSTALLVER') && ini_get('register_globals')) {
        foreach ($GLOBALS as $s_variable_name => $m_variable_value) {
            if (!in_array($s_variable_name, array('GLOBALS', 'argv', 'argc', '_FILES', '_COOKIE', '_POST', '_GET', '_SERVER', '_ENV', '_SESSION', '_REQUEST', 's_variable_name', 'm_variable_value'))) {
                unset($GLOBALS[$s_variable_name]);
            }
        }
        unset($GLOBALS['s_variable_name']);
        unset($GLOBALS['m_variable_value']);
    }
    // proper error_repoting
    // E_ALL for development
    // error_reporting(E_ALL);
    // without warnings and notices for release
    error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
    // Hack for some weird PHP systems that should have the
    // LC_* constants defined, but don't
    if (!defined('LC_TIME')) {
        define('LC_TIME', 'LC_TIME');
    }
    // Initialise and load configuration
    $pnconfig = array();
    $pndebug = array();
    include 'config.php';
    $GLOBALS['pnconfig'] = $pnconfig;
    $GLOBALS['pndebug'] = $pndebug;
    // Initialize the (ugly) additional header array
    $GLOBALS['additional_header'] = array();
    // load ADODB
    pnADODBInit();
    // Connect to database
    if (!pnDBInit()) {
        die('Database initialisation failed');
    }
    // Set up multisites
    // added this @define for .71, ugly ?
    // i guess the E_ALL stuff.
    @define('WHERE_IS_PERSO', '');
    // Initialise and load pntables
    pnDBSetTables();
    // user and modules system includes
    include 'includes/pnUser.php';
    include 'includes/pnMod.php';
    // Set compression on if desired
    if (pnConfigGetVar('UseCompression') == 1) {
        ob_start("ob_gzhandler");
    }
    if (isset($_REQUEST['_SESSION'])) {
        die('Attempted pollution of SESSION space via GPC request');
    }
    // Other includes
    include 'includes/pnSession.php';
    if (pnConfigGetVar('anonymoussessions') || !empty($_REQUEST['POSTNUKESID'])) {
        // Start session
        if (!pnSessionSetup()) {
            die('Session setup failed');
        }
        if (!pnSessionInit()) {
            die('Session initialisation failed');
        }
    }
    // load security functions.
    include 'includes/pnSecurity.php';
    include 'includes/pnBlocks.php';
    // Load our language files
    include 'includes/pnLang.php';
    pnLangLoad();
    // inclusion of pnrender class -- jn
    include 'includes/pnRender.class.php';
    include 'includes/pnTheme.php';
    include 'includes/pnHTML.php';
    // Legacy includes
    if (pnConfigGetVar('loadlegacy') == '1') {
        include 'includes/legacy/legacy.php';
        include 'includes/legacy/queryutil.php';
        include 'includes/legacy/xhtml.php';
        include 'includes/legacy/oldfuncs.php';
    }
    // Check for site closed
    if (pnConfigGetVar('siteoff') && !pnSecAuthAction(0, 'Settings::', 'SiteOff::', ACCESS_ADMIN)) {
        include 'includes/templates/siteoff.htm';
        die;
    }
    // Cross-Site Scripting attack defense - Sent by larsneo
    // some syntax checking against injected javascript
    if (pnConfigGetVar('pnAntiCracker') == '1') {
        include 'includes/pnAntiCracker.php';
        pnSecureInput();
    }
    // load safehtml class for xss filtering
    // the XML_HTMLSAX3 define is also needed inside the class so we
    // cannot use the path directly in the include.
    if (pnConfigGetVar('safehtml') == '1') {
        define('XML_HTMLSAX3', 'includes/classes/safehtml/');
        include XML_HTMLSAX3 . 'safehtml.php';
    }
    // Banner system
    // TODO - move to banners module
    if (pnModAvailable('Banners')) {
        include 'includes/pnBanners.php';
    }
    // Call Stats module counter code if installed
    if (pnModAvailable('Stats') && !pnSecAuthAction(0, '.*', '.*', ACCESS_ADMIN)) {
        include 'includes/legacy/counter.php';
    }
    // Handle referer
    if (pnModAvailable('Referers') && pnConfigGetVar('httpref') == 1) {
        include 'includes/legacy/referer.php';
        httpreferer();
    }
    // Load the theme
    pnThemeLoad(pnUserGetTheme());
    return true;
}
 /**
 * add core data to the template
 *
 * This function adds some basic data to the template depending on the
 * current user and the PN settings.
 *
 * @param   list of module names. all mod vars of these modules will be included too
            The mod vars of the current module will always be included
 * @return  boolean true if ok, otherwise false
 * @access  public
 */
 function add_core_data()
 {
     $pncore = array();
     $pncore['version_num'] = _PN_VERSION_NUM;
     $pncore['version_id'] = _PN_VERSION_ID;
     $pncore['version_sub'] = _PN_VERSION_SUB;
     $pncore['logged_in'] = pnUserLoggedIn();
     $pncore['language'] = pnUserGetLang();
     $pncore['themeinfo'] = pnThemeInfo(pnUserGetTheme());
     pnThemeLoad($pncore['themeinfo']['name']);
     $colors = array();
     $colors['bgcolor1'] = pnThemeGetVar('bgcolor1');
     $colors['bgcolor2'] = pnThemeGetVar('bgcolor2');
     $colors['bgcolor3'] = pnThemeGetVar('bgcolor3');
     $colors['bgcolor4'] = pnThemeGetVar('bgcolor4');
     $colors['bgcolor5'] = pnThemeGetVar('bgcolor5');
     $colors['sepcolor'] = pnThemeGetVar('sepcolor');
     $colors['textcolor1'] = pnThemeGetVar('textcolor1');
     $colors['textcolor2'] = pnThemeGetVar('textcolor2');
     // add userdata
     $pncore['user'] = pnUserGetVars(pnSessionGetVar('uid'));
     // add modvars of current module
     $pncore[$this->module] = pnModGetVar($this->module);
     // add mod vars of all modules supplied as parameter
     foreach (func_get_args() as $modulename) {
         // if the modulename is empty do nothing
         if (!empty($modulename) && !is_array($modulename) && $modulename != $this->module) {
             // check if user wants to have /PNConfig
             if ($modulename == _PN_CONFIG_MODULE) {
                 $pnconfig = pnModGetVar(_PN_CONFIG_MODULE);
                 foreach ($pnconfig as $key => $value) {
                     // unserialize all config vars
                     $pncore['pnconfig'][$key] = @unserialize($value);
                 }
             } else {
                 $pncore[$modulename] = pnModGetVar($modulename);
             }
         }
     }
     $this->assign('pncore', $pncore);
     $this->assign($colors);
     return true;
 }