...

View Full Version : PHP script installation



artistique_girl
06-16-2005, 07:11 PM
Hello all,

The problem is, I am a dittsy newbie (for the time being, at least) when it comes to PHP!

I have this script on my webserver, but I dont understand all of the instructions that are located on the install directory.

In step three it says . . . .


3) Install cron jobs
Edit files:
periodic/cmd.php
periodic/notifies.php

periodic/imcron.php
to set correct path to the "inc/header.inc.php" file at the begining of each file.
Add following cron jobs:

0 0 * * * php -q /path/to/periodic/cmd.php
*/15 * * * * php -q /path/to/periodic/notifies.php



OK- so I know that I have to open the three files in the directory "periodic," I have to edit them, and then FTP them back to my server. But, I am not sure how to set the correct path to the "inc/header.inc.php" file . . .also (*blushing)I don't even know what "cron jobs" are, nor do I know how to add them.

PLEASE. . .any help would be GREATLY appreciated!
Thanks!

http://www.profilebase.net/artistique_girl1.gif
Artistique

Just in case . . .here is the actual code from the file periodic/cmd.php



<?
/*

*/

require_once( "/path_to/inc/header.inc.php" );
require_once( "$dir[inc]db.inc.php" );
require_once( "$dir[inc]profiles.inc.php" );
require_once( "$dir[inc]admin.inc.php" );
require_once( "$dir[inc]modules.inc.php" );


// - Functions -
function finish()
{
global $site;
global $MODE;

if ( $MODE != "_LIVE_" )
{
$output = ob_get_contents();
ob_end_clean();
if ( $MODE == "_MAIL_" )
{
mail( $site[email], "{$site['title']}: Periodic Report", $output, "From: Periodic <$site[email]>", "-f$site[email]" );
}
}
exit;
}

function clean_database()
{
$db_clean_vkiss = getParam("db_clean_vkiss");
$db_clean_profiles = getParam("db_clean_profiles");
$db_clean_msg = getParam("db_clean_msg");
$db_clean_views = getParam("db_clean_views");
$db_clean_priv_msg = getParam("db_clean_priv_msg");

// profile_delete
if ( $db_clean_profiles > 0)
{
$res = db_res("SELECT ID FROM Profiles WHERE (TO_DAYS(NOW()) - TO_DAYS(LastLoggedIn)) > $db_clean_profiles");
if ( $res )
{
$db_clean_profiles_num = mysql_num_rows($res);
while ( $arr = mysql_fetch_array($res) )
{
profile_delete($arr[ID]);
}
}
}


if ( $db_clean_vkiss > 0 )
{
$res = db_res("DELETE FROM VKisses WHERE (TO_DAYS(NOW()) - TO_DAYS(Arrived)) > $db_clean_vkiss");
if ( $res )
$db_clean_vkiss_num = mysql_affected_rows();
}

if ( $db_clean_msg > 0 )
{
$res = db_res("DELETE FROM Messages WHERE (TO_DAYS(NOW()) - TO_DAYS(`Date`)) > $db_clean_msg");
if ( $res )
$db_clean_msg_num = mysql_affected_rows();
}

if ( $db_clean_views > 0 )
{
$res = db_res("DELETE FROM ProfilesTrack WHERE (TO_DAYS(NOW())-TO_DAYS(`Arrived`)) > $db_clean_views");
if ( $res )
$db_clean_views_num = mysql_affected_rows();
}

if ( $db_clean_priv_msg > 0 )
{
$res = db_res("DELETE FROM IMessages WHERE (TO_DAYS(NOW()) - TO_DAYS(`When`)) > $db_clean_priv_msg");
if ( $res )
$db_clean_priv_msg_num = mysql_affected_rows();
}


echo "\n- Database cleaning -\n";

echo "Deleted profiles: $db_clean_profiles_num\n";
echo "Deleted virtual kisses: $db_clean_vkiss_num\n";
echo "Deleted messages: $db_clean_msg_num\n";
echo "Deleted private messages: $db_clean_priv_msg_num\n";
echo "Deleted profile views: $db_clean_views_num\n";
}

function del_old_wav_files()
{
global $TMP_SOUND_DIR;

$num_tmp = 0;
$num_del = 0;

$file_life = 172800; // two days
$wdir = $TMP_SOUND_DIR;

if ( !( $lang_dir = opendir( $wdir ) ) )
return false;
for ( $i = 0; $lang_file = readdir( $lang_dir ); )
{
$arr = explode( ".", $lang_file);

if ( $arr[1] == "wav" )
{
//echo $lang_file." <br>\n";

$diff = time() - filectime ( "$wdir$lang_file");

if ( $diff > $file_life )
{
unlink ( "$wdir$lang_file" );
++$num_del;
}
++$num_tmp;
}
}
closedir( $lang_dir );

echo "\n- Temporary files check -\n";

echo "Total temp wav files: $num_tmp\n";
echo "Deleted temp wav files: $num_del\n";
}

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


function del_old_avi_files()
{
global $TMP_VIDEO_DIR;
global $video_ext;

$num_tmp = 0;
$num_del = 0;

$file_life = 172800; // two days
$wdir = $TMP_VIDEO_DIR;

if ( !( $lang_dir = opendir( $wdir ) ) )
return false;
for ( $i = 0; $lang_file = readdir( $lang_dir ); )
{
$arr = explode( ".", $lang_file);

if ( $arr[1] == $video_ext )
{
//echo $lang_file." <br>\n";

$diff = time() - filectime ( "$wdir$lang_file");

if ( $diff > $file_life )
{
unlink ( "$wdir$lang_file" );
++$num_del;
}
++$num_tmp;
}
}
closedir( $lang_dir );

echo "\n- Temporary files check -\n";

echo "Total temp $video_ext files: $num_tmp\n";
echo "Deleted temp $video_ext files: $num_del\n";
}



function modules_proceed()
{
// update modules
$n = 0;

$p_res = db_res("SELECT ID, NickName, Email FROM Profiles WHERE Status = 'Active' AND ( ExtraAddons = '' OR ExtraAddons IS NULL OR ExtraAddons = 0)");
while ( $p_arr = mysql_fetch_array($p_res) )
{
modules_del ( $p_arr['ID'], $p_arr['NickName'], $p_arr['Email'], "gold" );
++$n;
}

echo "\n- Modules check -\n";
echo "Processed profiles: $n\n";
}

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



// - Defaults -
$MODE = "_MAIL_";
$DAY = "_OBEY_";



// - Always finish
set_time_limit( 36000 );
ignore_user_abort();




// - Parameters check -
for ( $i = 0; strlen( $argv[$i] ); $i++ )
{
switch( $argv[$i] )
{
case "--live": $MODE = "_LIVE_"; break;
case "--mail": $MODE = "_MAIL_"; break;
case "--force-day": $DAY = "_FORCE_"; break;
case "--obey-day": $DAY = "_OBEY_"; break;
}
}



if ( $MODE != "_LIVE_" )
ob_start();


$day = date( "d" );
if ( getParam( "cmdDay" ) == $day && $DAY == "_OBEY_" )
{
echo "Already done today, bailing out\n";
finish();
}
else
setParam( "cmdDay", $day );




// - Membership check -
echo "\n- Membership check -\n";

$exp_res = db_res( "SELECT ID FROM `Mem_Avff` WHERE amount = 0", 0 );
$rows = mysql_num_rows( $exp_res );
echo "Expired membership records: $rows\n";

if ( $rows )
{
while( $row = mysql_fetch_array( $exp_res ) )
{
db_res( "UPDATE `Profiles` SET ExtraAddons = (ExtraAddons & ~1) WHERE ID = $row[ID]", 0 );
gold_mem_expiration_letter( $row[ID] );
}

db_res( "DELETE FROM `Mem_Avff` WHERE amount = 0", 0 );
$rows = mysql_affected_rows();
if ( $rows == -1 )
echo "Failed deleting expired membership records\n" . mysql_error() . "\n";
else
echo "Deleted expired membership records: $rows\n";
}

if ( !((int)getParam("days_forall_avff")) )
{
db_res( "UPDATE `Mem_Avff` SET amount = amount - 1 WHERE Type = '0'", 0 );
$rows = mysql_affected_rows();
if ( $rows == -1 )
echo "Failed updating membership records\n" . mysql_error() . "\n";
else
echo "Processed membership records: $rows\n";
}







// - CAff Membership check -
echo "\n- Caff Membership check -\n";

$exp_res = db_res( "SELECT ID FROM `Mem_caff` WHERE amount = 0", 0 );
$rows = mysql_num_rows( $exp_res );
echo "Expired caff membership records: $rows\n";

if ( $rows )
{
while( $row = mysql_fetch_array( $exp_res ) )
{
db_res( "UPDATE `Profiles` SET ExtraAddons = (ExtraAddons & ~2) WHERE ID = $row[ID]", 0 );
gold_mem_expiration_letter( $row[ID], 1 );
}

db_res( "DELETE FROM `Mem_caff` WHERE amount = 0", 0 );
$rows = mysql_affected_rows();
if ( $rows == -1 )
echo "Failed deleting expired caff membership records\n" . mysql_error() . "\n";
else
echo "Deleted expired caff membership records: $rows\n";
}

if ( !((int)getParam("days_forall_caff")) )
{
db_res( "UPDATE `Mem_caff` SET amount = amount - 1 ", 0 );
$rows = mysql_affected_rows();
if ( $rows == -1 )
echo "Failed updating caff membership records\n" . mysql_error() . "\n";
else
echo "Processed caff membership records: $rows\n";
}


if ( ((int)getParam("days_forall_caff")) > 0 )
{
setParam("days_forall_caff", "".(getParam("days_forall_caff") - 1) );
}

if ( ((int)getParam("days_forall_avff")) > 0 )
{
setParam("days_forall_avff", "".(getParam("days_forall_avff") - 1) );
}

del_old_wav_files();
del_old_avi_files();

clean_database();

modules_proceed();

finish();

?>

Thanks again!

marek_mar
06-16-2005, 09:15 PM
Cron jobs are are the "scheduled Tasks" on unix systems. You must be allowed to start cron jobs on your server.

delinear
06-16-2005, 11:21 PM
To find the correct path to "inc/header.inc.php", create the following little script:

<?php echo realpath('.');
Drop that into the same folder as the file called "header.inc.php" and then browse to it in your browser. It will return the exact server path to the directory where header.inc.php is stored in the correct format. It will probably look something like this:

"/usr/home/client_name/public_html/inc/"
You then just take that, stick header.inc.php on the end and put it in the three files indicated, so using that as an example, you would edit the require_once to look like this:

require_once("/usr/home/client_name/public_html/inc/header.inc.php");
As Marek said, cron jobs are scheduled tasks which have to be set up on the *nix server itself so you have to have permission to do this. You may have an option to set these up in your hosting cpanel if you have one. Either way your web host will probably be able to tell you if this is allowed or if they have some facility in place to create them, or even if they will create it for you.

artistique_girl
06-21-2005, 04:09 AM
Thanks guys, both of you. I found out that I can not access cron jobs on my webhost, so I am changing hosting companies.

;)
http://www.profilebase.net/artistique_girl1.gif
Artistique



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum