function phpAds_performAutoMaintenance()
{
    global $phpAds_config;
    // Make sure that the output is sent to the browser before
    // loading libraries and connecting to the db
    flush();
    // Include required files
    if (!defined('LIBLOCKS_INCLUDED')) {
        require phpAds_path . '/libraries/lib-locks.inc.php';
    }
    // Load config from the db
    phpAds_LoadDbConfig();
    $last_run = $phpAds_config['maintenance_timestamp'];
    // Make sure that negative values don't break the script
    if ($last_run > 0) {
        $last_run = strtotime(date('Y-m-d H:00:05', $last_run));
    }
    if (time() >= $last_run + 3600) {
        if ($lock = phpAds_maintenanceGetLock()) {
            require phpAds_path . "/libraries/lib-userlog.inc.php";
            require phpAds_path . "/maintenance/lib-maintenance.inc.php";
            // Got the advisory lock, we can proceed running maintenance
            phpAds_userlogSetUser(phpAds_userAutoMaintenance);
            // Finally run maintenance
            phpAds_performMaintenance();
            // Release lock
            phpAds_maintenanceReleaseLock($lock);
        }
    }
}
Esempio n. 2
0
}
// Include required files
include "../libraries/lib-io.inc.php";
include "../libraries/lib-db.inc.php";
include "../libraries/lib-dbconfig.inc.php";
include "lib-gui.inc.php";
include "lib-permissions.inc.php";
include "../libraries/lib-userlog.inc.php";
// Open the database connection
$link = phpAds_dbConnect();
if (!$link) {
    // This text isn't translated, because if it is shown the language files are not yet loaded
    phpAds_Die("A fatal error occurred", $phpAds_productname . " can't connect to the database.\n\t\t\t\tBecause of this it isn't possible to use the administrator interface. The delivery\n\t\t\t\tof banners might also be affected. Possible reasons for the problem are:\n\t\t\t\t<ul><li>The database server isn't functioning at the moment</li>\n\t\t\t\t<li>The location of the database server has changed</li>\n\t\t\t\t<li>The username or password used to contact the database server are not correct</li>\n\t\t\t\t</ul>");
}
// Load settings from the database
phpAds_LoadDbConfig();
if (!isset($phpAds_config['config_version']) || $phpAds_version > $phpAds_config['config_version']) {
    // Post configmanager, but not up to date -> update
    header("Location: upgrade.php");
    exit;
}
// Check for SLL requirements
if ($phpAds_config['ui_forcessl'] && $_SERVER['SERVER_PORT'] != 443) {
    header('Location: https://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF']);
    exit;
}
// Adjust url_prefix if SLL is used
if ($_SERVER['SERVER_PORT'] == 443) {
    $phpAds_config['url_prefix'] = str_replace('http://', 'https://', $phpAds_config['url_prefix']);
}
// First thing to do is clear the $Session variable to
Esempio n. 3
0
require "lib-install-db.inc.php";
require "lib-statistics.inc.php";
require "lib-storage.inc.php";
require "lib-banner.inc.php";
require "lib-zones.inc.php";
// Turn off database compatibility mode
$phpAds_config['compatibility_mode'] = false;
// Open the database connection
$link = phpAds_dbConnect();
if (!$link) {
    phpAds_PageHeader('');
    phpAds_Die("A fatal error occurred", "phpAdsNew can't connect to the database, \n\t\t\t\t\t\t\t\t\t\t   please make sure the database is working \n\t\t\t\t\t\t\t\t\t\t   and phpAdsNew is configured correctly");
} else {
    // Load settings from the database
    // in case settings are stored in the database
    phpAds_LoadDbConfig(phpAds_getAgencyID());
}
// Disable GZIP compression
$phpAds_config['content_gzip_compression'] = false;
// First thing to do is clear the $Session variable to
// prevent users from pretending to be logged in.
unset($Session);
// Authorize the user
phpAds_Start();
// Load language strings
@(include phpAds_path . '/language/english/default.lang.php');
if ($phpAds_config['language'] != 'english' && file_exists(phpAds_path . '/language/' . $phpAds_config['language'] . '/default.lang.php')) {
    @(include phpAds_path . '/language/' . $phpAds_config['language'] . '/default.lang.php');
} else {
    $phpAds_config['language'] = 'english';
}
Esempio n. 4
0
    header('Location: ' . $phpAds_config['ssl_url_prefix'] . $HTTP_SERVER_VARS['PHP_SELF']);
    exit;
}
// Adjust url_prefix if SLL is used
if ($HTTP_SERVER_VARS['SERVER_PORT'] == 443) {
    $phpAds_config['url_prefix'] = $phpAds_config['ssl_url_prefix'];
}
// First thing to do is clear the $Session variable to
// prevent users from pretending to be logged in.
unset($Session);
// Authorize the user
phpAds_Start();
// Reload settings from the database because we are using agency settings.
$agencyid = phpAds_getAgencyID();
if ($agencyid > 0) {
    phpAds_LoadDbConfig($agencyid);
}
// Load language strings
@(include phpAds_path . '/language/english/default.lang.php');
if ($phpAds_config['language'] != 'english' && file_exists(phpAds_path . '/language/' . $phpAds_config['language'] . '/default.lang.php')) {
    @(include phpAds_path . '/language/' . $phpAds_config['language'] . '/default.lang.php');
}
// Register variables
phpAds_registerGlobal('affiliateid', 'agencyid', 'bannerid', 'campaignid', 'clientid', 'day', 'trackerid', 'userlogid', 'zoneid');
if (!isset($affiliateid)) {
    $affiliateid = '';
}
if (!isset($agencyid)) {
    $agencyid = '';
}
if (!isset($bannerid)) {
function phpAds_deactivateMail($campaign)
{
    global $phpAds_config;
    global $strMailSubjectDeleted, $strMailHeader, $strMailClientDeactivated;
    global $strNoMoreClicks, $strNoMoreViews, $strBeforeActivate, $strAfterExpire;
    global $strBanner, $strMailNothingLeft, $strMailFooter, $strUntitled;
    $clientresult = phpAds_dbQuery("SELECT *" . " FROM " . $phpAds_config['tbl_clients'] . " WHERE clientid=" . $campaign['clientid']);
    if ($client = phpAds_dbFetchArray($clientresult)) {
        if ($client["email"] != '' && $client["reportdeactivate"] == 't') {
            // Load config from the database
            if (!defined('LIBDBCONFIG_INCLUDED')) {
                include phpAds_path . '/libraries/lib-dbconfig.inc.php';
                phpAds_LoadDbConfig();
            }
            // Load client language strings
            @(include phpAds_path . '/language/english/default.lang.php');
            if ($client['language'] != '') {
                $phpAds_config['language'] = $client['language'];
            }
            if ($phpAds_config['language'] != 'english' && file_exists(phpAds_path . '/language/' . $phpAds_config['language'] . '/default.lang.php')) {
                @(include phpAds_path . '/language/' . $phpAds_config['language'] . '/default.lang.php');
            }
            // Build email
            $Subject = $strMailSubjectDeleted . ": " . $campaign['campaignname'];
            $Body = $strMailHeader . "\n";
            $Body .= $strMailClientDeactivated;
            if ($campaign['clicks'] == 0) {
                $Body .= ", {$strNoMoreClicks}";
            }
            if ($campaign['views'] == 0) {
                $Body .= ", {$strNoMoreViews}";
            }
            if (time() < $campaign["activate_st"]) {
                $Body .= ", {$strBeforeActivate}";
            }
            if (time() > $campaign["expire_st"] && $campaign["expire_st"] != 0) {
                $Body .= ", {$strAfterExpire}";
            }
            $Body .= ".\n\n";
            $res_banners = phpAds_dbQuery("SELECT" . " bannerid" . ",url" . ",description" . ",alt" . " FROM " . $phpAds_config['tbl_banners'] . " WHERE campaignid=" . $campaign['campaignid']);
            if (phpAds_dbNumRows($res_banners) > 0) {
                $Body .= "-------------------------------------------------------\n";
                while ($row_banners = phpAds_dbFetchArray($res_banners)) {
                    $name = "[id" . $row_banners['bannerid'] . "] ";
                    if ($row_banners['description'] != "") {
                        $name .= $row_banners['description'];
                    } elseif ($row_banners['alt'] != "") {
                        $name .= $row_banners['alt'];
                    } else {
                        $name .= $strUntitled;
                    }
                    $Body .= $strBanner . "  " . $name . "\n";
                    $Body .= "linked to: " . $row_banners['url'] . "\n";
                    $Body .= "-------------------------------------------------------\n";
                }
            }
            $Body .= "\n";
            $Body .= "{$strMailNothingLeft}\n\n";
            $Body .= "{$strMailFooter}";
            $Body = str_replace("{clientname}", $client["clientname"], $Body);
            $Body = str_replace("{contact}", $client["contact"], $Body);
            $Body = str_replace("{adminfullname}", $phpAds_config['admin_fullname'], $Body);
            // Send email
            phpAds_sendMail($client['email'], $client['contact'], $Subject, $Body);
            if ($phpAds_config['userlog_email']) {
                phpAds_userlogAdd(phpAds_actionDeactivationMailed, $campaign['campaignid'], $Subject . "\n\n" . $Body);
            }
        }
    }
}