Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Post Installation Help
Author Message
andrej
Hangin' Around



Joined: Sep 10, 2005
Posts: 48

PostPosted: Thu Jun 08, 2006 2:48 pm Reply with quote

Hello !

I am using Kalender mx, however i need the same calender ( with the same events to be displayed on a non-nuke site. ) so i wrote a small simple script, which exports all the events from the .sql table to a .js file, which the other calander on the non-nuke can read.

Now i run this script to convert events as a cron job.

What i would like to do now is run this "event conversion script" everytime user submits a new event.
Through power of googe, i found out that i should put
Code:
include("myscript.php");
into the submit.php file, but whenever i do it i cannot submit events anymore, as the submite page turns blank..

So .. How can i run events whenever someone submits events.

This is the submit.php function.

Code:
<?php

// sprememba 116
/**
 * KalenderMx v1.4
 * Copyright (c) 2004 by A.Ellsel (kalender@pragmamx.org)
 * http://www.pragmamx.org & http://www.shiba-design.de
 *
 * KalenderMx was based on EventCalendar 2.0
 * Copyright (c) 2001 Originally by Rob Sutton
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * $Source: D:\\CVS/dev-Kalender/html/modules/Kalender/submit.php,v $
 * $Revision: 1.6 $
 * $Author: Andreas Ellsel $
 * $Date: 2005/11/09 00:13:33 $
 */

if (!function_exists('is_user')) die ('You can\'t access this file directly...');

if (!defined("CAL_MODULE_NAME")) define("CAL_MODULE_NAME", basename(dirname(__FILE__)));
if (!defined("CAL_MODULE_PATH")) define("CAL_MODULE_PATH", "modules/" . CAL_MODULE_NAME . "/");

if (!isset($calconf)) include(CAL_MODULE_PATH . "config/config.php");
if (!defined("CAL_TABLE_EVENTS")) include_once(CAL_MODULE_PATH . "includes/functions.php");
get_lang(CAL_MODULE_NAME);
// / Spaw-Editor in pragmaMx verwenden
$wysiwyg = 0;
if (!empty($calconf['wysiwyg']) && @is_file('spaw/spaw_control.class.php')) {
    include_once('spaw/spaw_control.class.php');
} else if (empty($calconf['wysiwyg'])) {
   define('NO_EDITOR', true);
}

// ########################################################################################
function calSubmitStart($gvs)
{
    global $dbi, $calconf;
    $user = (isset($GLOBALS['user'])) ? $GLOBALS['user'] : "";
    if (is_user($user)) {
        $cookie = cookiedecode($user);
        $event["informant"] = $cookie[1];
    } else {
        $event["informant"] = $GLOBALS["anonymous"];
    }
    if (calIsPostAllowed()) {
        $sd = Date("Y-m-d");
        if (isset($gvs["sd"])) {
            if (ereg("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $gvs["sd"], $tmp)) {
                $sd = $tmp[1] . '-' . $tmp[2] . '-' . $tmp[3];
            }
        }
        ereg("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $sd, $tmp);
        $event["aid"] = calIsAdmin();
        $event["topic"] = 0;
        $event["categorie"] = 0;
        $event["title"] = "";
        $event["hometext"] = "";
        $event["startDate"] = $sd;
        $event["startTime"] = $calconf['TimeArray'][0]; #"09:00:00";
        $event["endDate"] = $sd;
        $event["endTime"] = $calconf['TimeArray'][2]; #"10:00:00";
        $event["op"] = ($event["aid"]) ? "CalendarNewEvent" : "newEvent";
        $GLOBALS["pagetitle"] = _CALSUBMITNAME;
        if (empty($GLOBALS['header'])) include_once("header.php");
        if (calIsAdmin()) {
            calAdminMenu(_CALSUBMITNAME);
        } else {
            calBuildModusselectors('calSubmitStart', $tmp[3], $tmp[2], $tmp[1]);
            title(_CALSUBMITNAME);
        }
        calSubmitForm($event);
        include("footer.php");
    } else {
        calRedirect(CAL_MOD_USERLOGIN, _CALPLSLOGIN, 1);
    }
}
// ########################################################################################
function calNewEventPreview($event) // post
{
    global $dbi, $calconf, $user;
    $event = calStripSlashes($event);
    $GLOBALS["pagetitle"] = _CALNEWSUBPREVIEW;
    if (empty($GLOBALS['header'])) include_once("header.php");
    if (calIsAdmin()) {
        calAdminMenu(_CALNEWSUBPREVIEW);
    } else {
        calBuildModusselectors($event['op'], $event['startDay'], $event['startMonth'], $event['startYear']);
        title(_CALNEWSUBPREVIEW);
    }
    OpenTable();
    echo "<center><i>" . _CALSTORYLOOK . "</i></center>";
    CloseTable();
    echo "<br>";
    calEventView($event);
    calSubmitForm($event);
    include("footer.php");
}
// ########################################################################################
function calNewEventSubmit($event) // post
{
   
    global $dbi, $calconf, $user;
    $event = calPrepareEventForSql($event);
    $qry = calGetSqlQuery($event, "insert");
    $result = sql_query($qry, $dbi);
    if ($result) {
        if ($event["addasarticle"]) {
            calAddArticle($event);
        }
        calRedirect(CAL_MODULE_LINK . "&amp;file=submit&amp;op=calSubmitThanks&amp;sd=" . $event["startDate"], _CALTHANKSSUB, 1);
   //this is where i tried to put the include fucntion but doesn't work..    
    } else {
        calErrAdminMsg(_CALERRSQLERROR);
      
    }
   ;
   
}
// ########################################################################################
function calSubmitThanks($gvs)
{
    global $dbi, $calconf;
    $sd = Date("Y-m-d");
    if (isset($gvs["sd"])) {
        if (ereg("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $gvs["sd"], $tmp)) {
            $sd = $tmp[1] . '-' . $tmp[2] . '-' . $tmp[3];
        }
    }
    ereg("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $sd, $date);
    $qry = "select count(eid) from " . CAL_TABLE_EVENTS . " where activ=0";
    $result = sql_query($qry, $dbi);
    list($waiting) = sql_fetch_row($result, $dbi);
    $user = (isset($GLOBALS['user'])) ? $GLOBALS['user'] : "";
    if (is_user($user)) {
        $autoactive = (empty($calconf['userautoactive'])) ? 0 : 1;
    } else {
        $autoactive = (empty($calconf['anonautoactive'])) ? 0 : 1;
    }
    $msg = (calIsAdmin() || $autoactive) ? _CALSUBTEXTADMIN : _CALSUBTEXT;
    $GLOBALS["pagetitle"] = _CALNAME;
    if (empty($GLOBALS['header'])) include_once("header.php");
    if (calIsAdmin()) {
        calAdminMenu(_CALNAME);
    } else {
        title(_CALNAME);
    }
    OpenTable();
    echo "<center>" . _CALSUBSENT . "<br><br><span class=\"title\"><b>" . _CALTHANKSSUB . "</b></span><br>";
    echo "<br>$msg<br><br>" . _CALWEHAVESUB . " $waiting " . _CALWAITING . "</center>";
    CloseTable();
    echo "<br>";
    calBuildModusselectors("", $date[3], $date[2], $date[1]); # 4/23/2002
    include("footer.php");
}
// ########################################################################################
function checkpost()
{
    $pattern = '#(\<(img|i?frame|object|embed|i?layer|script|link)[^\>]+([[:space:]]{0,})(src|rel)([[:space:]]{0,})?=([^\>]+)?admin\.php\?[^\>]+\>)|(\[img\](.+)?(admin\.php\?).+?\[/img\])#si';
    if (isset($_POST['startDay'])) $_POST['startDay'] = intval($_POST['startDay']);
    if (isset($_POST['startMonth'])) $_POST['startMonth'] = intval($_POST['startMonth']);
    if (isset($_POST['startYear'])) $_POST['startYear'] = intval($_POST['startYear']);
    if (isset($_POST['startHour'])) $_POST['startHour'] = intval($_POST['startHour']);
    if (isset($_POST['startMin'])) $_POST['startMin'] = intval($_POST['startMin']);
    if (isset($_POST['endDay'])) $_POST['endDay'] = intval($_POST['endDay']);
    if (isset($_POST['endMonth'])) $_POST['endMonth'] = intval($_POST['endMonth']);
    if (isset($_POST['endYear'])) $_POST['endYear'] = intval($_POST['endYear']);
    if (isset($_POST['endHour'])) $_POST['endHour'] = intval($_POST['endHour']);
    if (isset($_POST['endMin'])) $_POST['endMin'] = intval($_POST['endMin']);
    if (isset($_POST['categorie'])) $_POST['categorie'] = intval($_POST['categorie']);
    if (isset($_POST['activ'])) $_POST['activ'] = intval($_POST['activ']);
    if (isset($_POST['eid'])) $_POST['eid'] = intval($_POST['eid']);
    if (isset($_POST['informant'])) $_POST['informant'] = substr(strip_tags($_POST['informant']), 0, 25);
    if (isset($_POST['aid'])) $_POST['aid'] = substr(strip_tags($_POST['aid']), 0, 25);
    if (isset($_POST['posteddate'])) {
        if (!ereg("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $_POST["posteddate"])) {
            $_POST["posteddate"] = sprintf ("%04d-%02d-%02d %02d:%02d:00", Date("Y"), Date("m"), Date("d"), Date("H"), Date("i"));
        }
    }
    if (isset($_POST['title'])) {
        $_POST['title'] = substr(strip_tags($_POST["title"]), 0, 150);
    }
    if (isset($_POST['hometext'])) {
        $_POST['hometext'] = strip_tags($_POST["hometext"], calGetAllowedtags());
        if (preg_match($pattern, $_POST['hometext'])) {
            $_POST['hometext'] = '';
        }
    }
    return $_POST;
}
// ########################################################################################
$op = (isset($_REQUEST["op"])) ? $_REQUEST["op"] : "";

switch ($op) {
    case "calNewEventPreview":
        calNewEventPreview(checkpost($_POST));
        break;
    case "calNewEventSubmit":
        calNewEventSubmit(checkpost($_POST));
        break;
    case "calSubmitThanks":
        calSubmitThanks($_GET);
        break;
    default:
        calSubmitStart($_GET);
        break;
}


Thanks for your help !
 
View user's profile Send private message
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Fri Jun 09, 2006 7:07 am Reply with quote

This sounds to be parse error rather than a run-time error, but you may want to check your apache error logs and ensure display_errors is turned on in your nuke config.php script just to see if you can get more information on it.

Are you still able to run this script "standalone" outside of nuke? (sorry, do not have time at the moment to review the script carefully - just trying to give a few debugging ideas) If so, then there may be some other conflict with nuke functions???

By the way, the super global variables of $_POST and $_GET are already available to any function. You do not need to pass them in and out of these functions.

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
andrej







PostPosted: Thu Jun 15, 2006 11:13 am Reply with quote

OK !

The posting page works OK by itself.
There are no problems whatsoever with it.

What i would like to do is include a link to a pseudo cron jobs, as advised here

http://www.bitfolge.de/pseudocron-en.html

It says i should put a statement like :

Code:
include("myscript.php");
, where myscript is a link to a pseudo cron job .php page.
Click the link above and you will see what i mean.
The question is : how can i insert this include statement ?
I tried putting it on different places, but in every case i got a blank page.
 
Tao_Man
Involved
Involved



Joined: Jul 15, 2004
Posts: 252
Location: OKC, OK

PostPosted: Fri Jun 16, 2006 9:42 am Reply with quote

I am sure you have a reason for using this pseudo cron tab. but I wonder have you just tried putting the code to copy the database tables in submit.php directly. It would seem more direct then using an include() or this cron tab stuff. It seems to me you are adding layers of complexity that you don't really need.

_________________
------------------------------------------
To strive, to seek, to find, but not to yield!
I don't know Kara-te but I do know cra-zy, and I WILL use it! 
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Post Installation Help

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©