예제 #1
0
파일: user.php 프로젝트: raj47i/PHP.Fx
 public function Load(int $userId, $loadRoles = true)
 {
     $db = GetDatabase();
     if ($loadRoles) {
         return $this->LoadRoles();
     }
     return true;
 }
예제 #2
0
function getConnection()
{
    $host = GetHost();
    $db_user = GetUsername();
    $db_pw = GetPassword();
    $database = GetDatabase();
    $mysqli = new mysqli($host, $db_user, $db_pw, $database);
    $mysqli->set_charset('utf8');
    return $mysqli;
}
예제 #3
0
 /**
  * _open
  * Checks the database connection is valid, if it's not it tries to open it up.
  *
  * @see GetDatabase
  * @see DbConnection
  *
  * @return boolean Returns false if it can't connect to the database, otherwise true.
  */
 function _open()
 {
     if (!$this->DbConnection) {
         $db =& GetDatabase();
         if (!$db) {
             return false;
         }
         $this->DbConnection =& $db;
     }
     return true;
 }
예제 #4
0
 /**
  * GetDb
  * Sets up the database object for this and the child objects to use.
  * If the Db var is null it will fetch it and store it for easy reference.
  * If it's unable to setup the database (or it's null or false) it will trigger an error.
  *
  * @see Db
  * @see GetDatabase
  *
  * @return boolean True if it works or false if it fails. Failing also triggers a fatal error.
  */
 function GetDb()
 {
     if (is_null($this->Db)) {
         $Db =& GetDatabase();
         $this->Db =& $Db;
     }
     if (!$this->Db) {
         trigger_error('Unable to connect to database', ERROR_FATAL);
         return false;
     }
     return true;
 }
예제 #5
0
 /**
  * Constructor
  * Does nothing.
  *
  * @return void
  */
 function ViewAll_Search()
 {
     $db =& GetDatabase();
     $this->Db =& $db;
 }
예제 #6
0
* @version     $Id: move.php,v 1.2 2005/04/29 02:56:40 chris Exp $
* @author Chris <*****@*****.**>
*
* @package TrackPoint
* @filesource
*/
/**
* Include our base file.
*/
require 'functions/init.php';
/**
* Include the utility file, this lets us quickly grab keywords etc so we can update properly.
*/
require 'functions/api/tputil.php';
$TPUtil =& new TPUtil();
$Db =& GetDatabase();
$SearchEngines = parse_ini_file(TRACKPOINT_INCLUDES_DIRECTORY . '/se.ini', true);
$qry = "SELECT domain FROM " . TRACKPOINT_TABLEPREFIX . "referrers GROUP BY domain ORDER BY domain";
$result = $Db->Query($qry);
while ($row = $Db->Fetch($result)) {
    $FoundSearchEngine = false;
    foreach ($SearchEngines as $key => $detail) {
        // if the search engine url is the same as the referrer domain, we have a match!
        if ($row['domain'] == 'http://' . $detail['url'] || $row['domain'] == 'https://' . $detail['url']) {
            $FoundSearchEngine = $key;
            break;
        }
        // if the search engine url doesn't have "www" - see whether the referrer matches if we put it in.
        // that way we can check for something like:
        // overture.com/.... and www.overture.com/....
        if (strpos($detail['url'], 'www') !== false) {
예제 #7
0
 /**
  * Constructor
  * Sets up the database connection.
  *
  * @see GetDatabase
  *
  * @return void
  */
 function Index()
 {
     $db =& GetDatabase();
     $this->Db =& $db;
 }
예제 #8
0
 /**
  * Constructor
  * Sets up the database connection.
  *
  * @see GetDatabase
  *
  * @return void
  */
 function View_Conversions()
 {
     $db =& GetDatabase();
     $this->Db =& $db;
 }
 /**
  * Constructor
  * Sets up the database connection.
  *
  * @see GetDatabase
  *
  * @return void
  */
 function LandingPages_Engines()
 {
     $db =& GetDatabase();
     $this->Db =& $db;
 }
 /**
  * Constructor
  * Sets up the database connection.
  *
  * @see GetDatabase
  *
  * @return void
  */
 function LandingPages_Referrers()
 {
     $db =& GetDatabase();
     $this->Db =& $db;
 }
예제 #11
0
 /**
  * Constructor
  * Sets up the database connection.
  *
  * @see GetDatabase
  *
  * @return void
  */
 function ViewAll_Engines()
 {
     $db =& GetDatabase();
     $this->Db =& $db;
 }
예제 #12
0
 /**
  * Process
  * Lets a user manage their own account - to a certain extent.
  * The API itself manages saving and updating, this just works out displaying of forms etc.
  *
  * @see PrintHeader
  * @see ParseTemplate
  * @see GetSession
  * @see Session::Get
  * @see GetDatabase
  * @see GetUser
  * @see User::Set
  * @see GetLang
  * @see PrintEditForm
  * @see PrintFooter
  *
  * @return void
  */
 function Process()
 {
     $this->PrintHeader();
     $this->ParseTemplate('Menu');
     $session =& GetSession();
     $thisuser = $session->Get('UserDetails');
     $db =& GetDatabase();
     $action = isset($_GET['Action']) ? $_GET['Action'] : '';
     switch ($action) {
         case 'Save':
             $userid = isset($_GET['UserID']) ? $_GET['UserID'] : 0;
             $user =& GetUser($userid);
             foreach (array('fullname', 'emailaddress', 'status', 'admin', 'ignoreips', 'ignorekeywords', 'usertimezone') as $p => $area) {
                 $val = isset($_POST[$area]) ? $_POST[$area] : '';
                 if (in_array($area, array('status', 'admin'))) {
                     if ($userid == $thisuser->userid) {
                         $val = $thisuser->{$area};
                     }
                 }
                 $user->Set($area, stripslashes($val));
             }
             $ignoresites = isset($_POST['ignoresites']) ? $_POST['ignoresites'] : '';
             $ignoresites = str_replace(array('http://', 'https://'), '', $ignoresites);
             $user->Set('ignoresites', $ignoresites);
             $error = false;
             $template = false;
             if (!$error) {
                 if ($_POST['tp_password'] != '') {
                     if ($_POST['tp_password_confirm'] != '' && $_POST['tp_password_confirm'] == $_POST['tp_password']) {
                         $user->Set('password', stripslashes($_POST['tp_password']));
                     } else {
                         $error = GetLang('PasswordsDontMatch');
                     }
                 }
             }
             if (!$error) {
                 $result = $user->Save();
                 if ($result) {
                     // update the session if we save everything ok. This is important for "ignoresites" and "ignoreips".
                     if ($userid == $thisuser->userid) {
                         $session->Set('UserDetails', $user);
                     }
                     // In case we change ip's or domains we're going to ignore, we need to recalculate the first hit and ignore criteria.
                     $session->Remove('FirstHit');
                     $session->Remove('IgnoreDetails');
                     $GLOBALS['Success'] = GetLang('UserUpdated');
                     $GLOBALS['Message'] = $this->ParseTemplate('SuccessMsg', true, false);
                 } else {
                     $GLOBALS['Error'] = GetLang('UserNotUpdated');
                     $GLOBALS['Message'] = $this->ParseTemplate('ErrorMsg', true, false);
                 }
             } else {
                 $GLOBALS['Error'] = $error;
                 $GLOBALS['Message'] = $this->ParseTemplate('ErrorMsg', true, false);
             }
             $this->PrintEditForm($userid);
             break;
         default:
             $userid = $thisuser->userid;
             $this->PrintEditForm($userid);
             break;
     }
     $this->PrintFooter();
 }
예제 #13
0
/**
* LogMessage
* Logs a message in the database if the option is turned on. It will allow us to see what actions took place based on the user & ip - the logentry will contain text describing the action taken.
*
* @param string The IP address of the client's browser.
* @param string The log message to keep.
* @param logtype The type of log message this is (referrer or conversion).
* @param int UserID the action is for.
*
* @see TRACKPOINT_LOGHISTORY_TIME
* @see TRACKPOINT_TRACKINGLOGS
* @see GetDatabase
* @see Trackpoint_Functions::DeleteOldCookies
*
* @return void
*/
function LogMessage($file = __FILE__, $line = __LINE__, $ip = '', $sessionid = '', $message = '', $userid = 0, $logtype = 'referrer', $loglevel = 'info')
{
    if (!$ip || !$message) {
        return;
    }
    if (!defined('TRACKPOINT_TRACKINGLOGS') || (int) TRACKPOINT_TRACKINGLOGS == 0) {
        return;
    }
    $db =& GetDatabase();
    $id = $db->NextId(TRACKPOINT_TABLEPREFIX . 'loghistory_sequence');
    $query = "INSERT INTO " . TRACKPOINT_TABLEPREFIX . "loghistory (logid, logtime, file, line, sessionid, userid, ip, logtype, logentry, loglevel) VALUES (" . (int) $id . ", '" . time() . "', '" . addslashes($file) . "', '" . addslashes($line) . "', '" . addslashes($sessionid) . "', '" . (int) $userid . "', '" . addslashes($ip) . "', '" . addslashes($logtype) . "', '" . addslashes($message) . "', '" . addslashes(strtoupper($loglevel)) . "')";
    $db->Query($query);
}
예제 #14
0
 /**
  * Constructor
  * Sets up the database connection.
  *
  * @see GetDatabase
  *
  * @return void
  */
 function TPChart()
 {
     $db =& GetDatabase();
     $this->Db =& $db;
 }
예제 #15
0
/**
* Track conversions.
* This file does all of the conversion tracking. It works out where a conversion came from originally so it can mark it back to the original tracking point.
*
* @version     $Id: tp.php,v 1.20 2005/11/03 02:15:18 chris Exp $
* @author Chris <*****@*****.**>
*
* @package TrackPoint
* @filesource
*/
/**
* Include our base file.
*/
require 'functions/init.php';
$trackpoint_sessionid = session_id();
$db =& GetDatabase();
if (!$db) {
    error_log("Unable to get database, date: " . date('d M Y H:i:s') . "\n", 3, TEMP_DIRECTORY . '/tracking_errors.log');
    exit;
}
/**
* Include the utility file, this lets us quickly grab keywords etc so we can update properly.
* This also handles processing of cookies etc.
*
* @see TPUtil
*/
require TRACKPOINT_API_DIRECTORY . '/tputil.php';
$TPUtil =& new TPUtil();
$ip = $TPUtil->GetRealIp();
/**
* Work everything out before we do anything else.
예제 #16
0
 /**
  * Constructor
  * Sets up the database connection.
  *
  * @see GetDatabase
  *
  * @return void
  */
 function Engines()
 {
     $db =& GetDatabase();
     $this->Db =& $db;
 }
예제 #17
0
 /**
  * Constructor
  * Sets up the database object, loads the user if the ID passed in is not 0.
  * @param userid int The userid of the user to load. If it is 0 then you get a base class only. Passing in a userid > 0 will load that user.
  *
  * @return true
  */
 function User($userid = 0)
 {
     if (is_null($this->Db)) {
         $Db =& GetDatabase();
         if ($Db) {
             $this->Db = $Db;
         }
     }
     if ($userid >= 0) {
         return $this->Load($userid);
     }
     return true;
 }
예제 #18
0
 /**
  * Constructor
  * Sets up the database connection.
  *
  * @see GetDatabase
  *
  * @return void
  */
 function LandingPages_Search()
 {
     $db =& GetDatabase();
     $this->Db =& $db;
 }
 /**
  * DeleteOldCookies
  *
  * This will delete the cookies that have expired from the database. It checks their time compared to the setting of the cookie time (in the config file).
  * It also cleans up old sessions from the database that have expired or not been used.
  * It also cleans up old logs bsaed on TRACKPOING_LOGHISTORY_TIME. It does this whether the option is on or off, if the option is off it's not going to take any time to delete 0 records.
  *
  * @see TRACKPOINT_ISSETUP
  * @see TRACKPOINT_DATABASE_TYPE
  * @see GetDatabase
  * @see Db::Query
  * @see TRACKPOINT_LOGHISTORY_TIME
  * @see TRACKPOINT_COOKIE_TIME
  *
  * @return void
  */
 function DeleteOldCookies()
 {
     if (!TRACKPOINT_ISSETUP) {
         return;
     }
     $limit = 50;
     $time = time() - TRACKPOINT_COOKIE_TIME * 60 * 60;
     $logtime = time() - TRACKPOINT_LOGHISTORY_TIME * 30 * 24 * 60 * 60;
     if (strtolower(TRACKPOINT_DATABASE_TYPE) == 'pgsql') {
         $cookie_query = "DELETE FROM " . TRACKPOINT_TABLEPREFIX . "cookies WHERE EXISTS (SELECT cookietime FROM " . TRACKPOINT_TABLEPREFIX . "cookies WHERE cookietime < " . $time . " LIMIT " . $limit . ")";
         $session_query = "DELETE FROM " . TRACKPOINT_TABLEPREFIX . "sessions WHERE EXISTS (SELECT sessiontime FROM " . TRACKPOINT_TABLEPREFIX . "sessions WHERE sessiontime < " . $time . " LIMIT " . $limit . ")";
         $log_query = "DELETE FROM " . TRACKPOINT_TABLEPREFIX . "loghistory WHERE EXISTS (SELECT logid FROM " . TRACKPOINT_TABLEPREFIX . "loghistory WHERE logtime < " . $logtime . " LIMIT " . $limit . ")";
     } else {
         $cookie_query = "DELETE FROM " . TRACKPOINT_TABLEPREFIX . "cookies WHERE cookietime < " . $time . " LIMIT " . $limit;
         $session_query = "DELETE FROM " . TRACKPOINT_TABLEPREFIX . "sessions WHERE sessiontime < " . $time . " LIMIT " . $limit;
         $log_query = "DELETE FROM " . TRACKPOINT_TABLEPREFIX . "loghistory WHERE logtime < " . $logtime . " LIMIT " . $limit;
     }
     $db =& GetDatabase();
     $db->Query($cookie_query);
     $db->Query($session_query);
     $db->Query($log_query);
 }
예제 #20
0
 /**
  * Constructor
  * Sets up the database connection.
  *
  * @see GetDatabase
  *
  * @return void
  */
 function Search()
 {
     $db =& GetDatabase();
     $this->Db =& $db;
 }
예제 #21
0
 /**
  * Constructor
  * Sets up the database connection.
  *
  * @see GetDatabase
  *
  * @return void
  */
 function ViewAll_PPCs()
 {
     $db =& GetDatabase();
     $this->Db =& $db;
 }
예제 #22
0
 /**
  * Constructor
  * Sets up the database connection.
  * Adds 'domain' to the list of sort types.
  *
  * @see GetDatabase
  *
  * @return void
  */
 function Referrers()
 {
     $this->_SortTypes[] = 'domain';
     $db =& GetDatabase();
     $this->Db =& $db;
 }
예제 #23
0
function SportChoice($Userid, $sport1, $sport2, $sport3, $sport4)
{
    try {
        GetDatabase()->beginTransaction();
        $req1 = GetDatabase()->prepare('INSERT INTO choix (IDSport, ID, OrdrePref) VALUES(:sport1, :ID, 1)');
        $req1->bindParam(':sport1', $sport1, PDO::PARAM_STR);
        $req1->bindParam(':ID', $Userid, PDO::PARAM_STR);
        $req1->execute();
        $req2 = GetDatabase()->prepare('INSERT INTO choix (IDSport, ID, OrdrePref) VALUES(:sport2, :ID, 2)');
        $req2->bindParam(':sport2', $sport2, PDO::PARAM_STR);
        $req2->bindParam(':ID', $Userid, PDO::PARAM_STR);
        $req2->execute();
        $req3 = GetDatabase()->prepare('INSERT INTO choix (IDSport, ID, OrdrePref) VALUES(:sport3, :ID, 3)');
        $req3->bindParam(':sport3', $sport3, PDO::PARAM_STR);
        $req3->bindParam(':ID', $Userid, PDO::PARAM_STR);
        $req3->execute();
        $req4 = GetDatabase()->prepare('INSERT INTO choix (IDSport, ID, OrdrePref) VALUES(:sport4, :ID, 4)');
        $req4->bindParam(':sport4', $sport4, PDO::PARAM_STR);
        $req4->bindParam(':ID', $Userid, PDO::PARAM_STR);
        $req4->execute();
        GetDatabase()->commit();
        return TRUE;
    } catch (PDOException $e) {
        throw $e;
        GetDatabase()->rollback();
        return FALSE;
    }
}
예제 #24
0
 /**
  * Constructor
  * Sets up the database connection.
  *
  * @see GetDatabase
  *
  * @return void
  */
 function Campaigns()
 {
     $db =& GetDatabase();
     $this->Db =& $db;
 }
예제 #25
0
 /**
  * PrintManageUsers
  * Prints a list of users in the system.
  * If you are not an admin, then it will only print your user in the list.
  * If you are an admin, it will also check your license to make sure you're not exceeding your allowed limit.
  *
  * @see GetSession
  * @see Session::Get
  * @see GetDatabase
  *
  * @return void
  */
 function PrintManageUsers()
 {
     $session =& GetSession();
     $thisuser = $session->Get('UserDetails');
     $db =& GetDatabase();
     if ($thisuser->Admin()) {
         $licensecheck = tpk23twgezm2();
         $GLOBALS['UserReport'] = $licensecheck;
         $qry = "SELECT * FROM " . TRACKPOINT_TABLEPREFIX . "users ORDER BY username";
     } else {
         $qry = "SELECT * FROM " . TRACKPOINT_TABLEPREFIX . "users WHERE userid='" . $thisuser->userid . "'";
     }
     $result = $db->Query($qry);
     if (!$result) {
         list($error, $level) = $db->GetError();
         trigger_error($error, $level);
         return false;
     }
     $switched_userid = $thisuser->userid;
     $switch_user = $session->Get('SwitchUser');
     if ($switch_user && $thisuser->Admin()) {
         $switched_userid = $switch_user;
     }
     $display = '';
     while ($row = $db->Fetch($result)) {
         $GLOBALS['UserName'] = $row['username'];
         $GLOBALS['FullName'] = $row['fullname'];
         $GLOBALS['Status'] = $row['status'] == 1 ? 'Active' : 'Inactive';
         $GLOBALS['Admin'] = $row['admin'] == 1 ? 'Administrator' : 'Regular User';
         $action = '<a href="index.php?Page=Users&Action=Edit&UserID=' . $row['userid'] . '">' . GetLang('Edit') . '</a>';
         if ($thisuser->Admin()) {
             $action .= '&nbsp;&nbsp;<a href="javascript: ConfirmDelete(' . $row['userid'] . ');">' . GetLang('Delete') . '</a>';
             if ($row['userid'] == $switched_userid) {
                 $action .= '&nbsp;&nbsp;<a class="Disabled" title="' . GetLang('SwitchTo_Disabled_Title') . '">' . GetLang('SwitchTo') . '</a>';
             } else {
                 $action .= '&nbsp;&nbsp;<a href="index.php?Page=Users&Action=SwitchTo&UserID=' . $row['userid'] . '" title="' . GetLang('SwitchTo_Title') . '">' . GetLang('SwitchTo') . '</a>';
             }
         }
         $GLOBALS['UserAction'] = $action;
         $template = $this->ParseTemplate('Users_List_Row', true, false);
         $display .= $template;
     }
     if ($thisuser->Admin()) {
         $GLOBALS['Users_AddButton'] = '<form name="" method="" action=""><input id="createAccountButton" type="button" class="smallbutton" value="' . GetLang('UserAdd') . '" onclick=\'document.location="index.php?Page=Users&Action=Add"\';></form>';
     }
     $user_list = $this->ParseTemplate('Users', true, false);
     $user_list = str_replace('%%TPL_Users_List_Row%%', $display, $user_list);
     echo $user_list;
 }
예제 #26
0
 /**
  * UpdatePPC
  * Updates the ppc (based on id) to the new cookieid in the database.
  *
  * @param int PPC to update.
  * @param string New cookie id
  *
  * @see EncodeCookie
  * @see TrackPPC
  *
  * @return boolean Returns false if the database connection isn't present. Otherwise runs the update and returns true.
  */
 function UpdatePPC($ppcid = 0, $cookieid = '')
 {
     $db =& GetDatabase();
     if (!$db) {
         return false;
     }
     $query = "UPDATE " . TRACKPOINT_TABLEPREFIX . "payperclicks SET cookieid='" . addslashes($cookieid) . "' WHERE ppcid='" . (int) $ppcid . "'";
     $db->Query($query);
     return true;
 }
예제 #27
0
 /**
  * Constructor
  * Sets up the database connection.
  *
  * @see GetDatabase
  * Does nothing.
  *
  * @return void
  */
 function PPC()
 {
     $db =& GetDatabase();
     $this->Db =& $db;
 }
예제 #28
0
 /**
  * Constructor
  * Sets up the database connection.
  *
  * @see GetDatabase
  *
  * @return void
  */
 function PrintReport()
 {
     $db =& GetDatabase();
     $this->Db =& $db;
 }
예제 #29
0
    function UpgradeDb()
    {
        $queries_todo = array();
        $queries_todo[] = 'ALTER TABLE ' . TRACKPOINT_TABLEPREFIX . 'search CHANGE COLUMN cookieid cookieid varchar(255)';
        $queries_todo[] = 'ALTER TABLE ' . TRACKPOINT_TABLEPREFIX . 'referrers CHANGE COLUMN cookieid cookieid varchar(255)';
        $queries_todo[] = 'ALTER TABLE ' . TRACKPOINT_TABLEPREFIX . 'campaigns CHANGE COLUMN cookieid cookieid varchar(255)';
        $queries_todo[] = 'ALTER TABLE ' . TRACKPOINT_TABLEPREFIX . 'payperclicks CHANGE COLUMN cookieid cookieid varchar(255)';
        $queries_todo[] = 'ALTER TABLE ' . TRACKPOINT_TABLEPREFIX . 'conversions CHANGE COLUMN cookieid cookieid varchar(255)';
        $queries_todo[] = 'ALTER TABLE ' . TRACKPOINT_TABLEPREFIX . 'cookies CHANGE COLUMN cookieid cookieid varchar(255)';
        $queries_todo[] = 'ALTER TABLE ' . TRACKPOINT_TABLEPREFIX . 'payperclicks ADD COLUMN ip varchar(20)';
        $queries_todo[] = 'ALTER TABLE ' . TRACKPOINT_TABLEPREFIX . 'campaigns ADD COLUMN ip varchar(20)';
        $queries_todo[] = 'ALTER TABLE ' . TRACKPOINT_TABLEPREFIX . 'users ADD COLUMN usertimezone varchar(255)';
        $queries_todo[] = 'ALTER TABLE ' . TRACKPOINT_TABLEPREFIX . 'users ADD COLUMN ignoreips text';
        $queries_todo[] = 'ALTER TABLE ' . TRACKPOINT_TABLEPREFIX . 'users ADD COLUMN ignoresites text';
        $queries_todo[] = 'ALTER TABLE ' . TRACKPOINT_TABLEPREFIX . 'users ADD COLUMN ignorekeywords text';
        $queries_todo[] = 'UPDATE ' . TRACKPOINT_TABLEPREFIX . 'users SET usertimezone=\'GMT\'';
        $queries_todo[] = 'CREATE INDEX conversion_cookie on ' . TRACKPOINT_TABLEPREFIX . 'conversions (cookieid)';
        $queries_todo[] = 'CREATE INDEX conversion_session on ' . TRACKPOINT_TABLEPREFIX . 'conversions (sessionid)';
        $queries_todo[] = 'CREATE TABLE ' . TRACKPOINT_TABLEPREFIX . 'loghistory_sequence (id int not null auto_increment primary key)';
        $queries_todo[] = 'CREATE TABLE ' . TRACKPOINT_TABLEPREFIX . 'loghistory (logid int, file varchar(255), line int,   userid int, logtime int, logtype varchar(255), loglevel varchar(255), ip varchar(20), logentry text, sessionid varchar(255))';
        $queries_todo[] = 'INSERT INTO ' . TRACKPOINT_TABLEPREFIX . 'loghistory_sequence VALUES(1)';
        $queries_todo[] = 'CREATE INDEX loghistory_time ON ' . TRACKPOINT_TABLEPREFIX . 'loghistory(logtime)';
        $session =& GetSession();
        $this->PrintHeader(true);
        ?>
			<script language="javascript">
				window.focus();
			</script>
		<?php 
        $updates_done = $session->Get('UpdatesDone');
        if (!$updates_done) {
            $updates_done = array();
        }
        if ($updates_done == $queries_todo) {
            ?>
			<script language="javascript">
				document.location='index.php?Page=Upgrade&Action=Upgrade_Finished';
			</script>
			<?php 
            return;
        }
        $db =& GetDatabase();
        echo '<span class="MessageWhite"><b>Upgrading your database, please wait...</b><br/><br/>';
        foreach ($queries_todo as $p => $query) {
            if (in_array($query, $updates_done)) {
                echo 'Query ' . $query . ' has been done.<br/>';
                continue;
            }
            echo '<br/>Running query ' . $query . '. Please wait...';
            echo '</span>';
            $this->PrintFooter(true);
            $result = $db->Query($query);
            if ($result) {
                $updates_done[] = $query;
            } else {
                list($reason, $errorlevel) = $db->GetError();
                $error = urlencode('Unable to run database query ' . $query . ': ' . $reason);
                ?>
				<script language="javascript">
					window.opener.document.location = 'index.php?Page=Upgrade&Action=Step2&Error=<?php 
                echo $error;
                ?>
';
					window.opener.focus();
					window.close();
				</script>
				<?php 
            }
            break;
        }
        $session->Set('UpdatesDone', $updates_done);
        ?>
		<script language="javascript">
			setTimeout("document.location='index.php?Page=Upgrade&Action=Upgrade'", 1);
		</script>
		<?php 
    }
예제 #30
0
 /**
  * Process
  * Processes the creation of the campaign.
  * Uses an iframe to post the results when a particular action is set.
  * Makes it nice and easy to keep creating campaigns and not worrying about retyping any of the information.
  *
  * @see Trackpoint_Functions::Process()
  *
  * @return void
  */
 function Process()
 {
     $session =& GetSession();
     $thisuser = $session->Get('UserDetails');
     $userid = $thisuser->userid;
     $switched_user = $session->Get('SwitchUser');
     if ($switched_user) {
         $userid = $switched_user;
     }
     if ($thisuser->Admin()) {
         $db =& GetDatabase();
         $qry = "SELECT userid, username FROM " . TRACKPOINT_TABLEPREFIX . "users ORDER BY username";
         $result = $db->Query($qry);
         $usercount = 0;
         $GLOBALS['UserList'] = '';
         while ($row = $db->Fetch($result)) {
             $usercount++;
             $selected = '';
             if ($row['userid'] == $userid) {
                 $selected = ' SELECTED';
             }
             $GLOBALS['UserList'] .= '<option value="' . $row['userid'] . '"' . $selected . '>' . $row['username'] . '</option>';
         }
         if ($usercount > 1) {
             $GLOBALS['SelectUser'] = $this->ParseTemplate('CreatePPCBulk_ChooseUser', true, false);
         }
     }
     $action = isset($_GET['Action']) ? strtolower($_GET['Action']) : null;
     switch ($action) {
         case 'upload':
             echo '<span style="font-family: tahoma; font-size: 12px;">';
             $user = $thisuser->userid;
             if (isset($_POST['userid']) && $thisuser->Admin()) {
                 $user = $_POST['userid'];
             }
             if (empty($_FILES) || !isset($_FILES['ppcfile'])) {
                 echo GetLang('ChooseFileToUpload');
                 echo '</span>';
                 break;
             }
             $tmpfile = $_FILES['ppcfile']['tmp_name'];
             if (!is_uploaded_file($tmpfile)) {
                 echo GetLang('ChooseFileToUpload');
                 echo '</span>';
                 break;
             }
             $newfilename = TEMP_DIRECTORY . '/trackpoint_ppc_file_' . $user . md5(time()) . '.tmp';
             if (!move_uploaded_file($tmpfile, $newfilename)) {
                 echo GetLang('UnableToReadFile');
                 echo '</span>';
                 break;
             }
             if (!($handle = fopen($newfilename, 'r'))) {
                 echo GetLang('UnableToReadFile');
                 echo '</span>';
                 break;
             }
             $outputfile = TEMP_DIRECTORY . '/ppc_file_' . $user . '.' . time() . '.csv';
             $output_filehandle = fopen($outputfile, 'w');
             $fieldseparator = isset($_POST['fieldseparator']) && $_POST['fieldseparator'] ? htmlentities($_POST['fieldseparator']) : ',';
             if (strtolower($fieldseparator) == "tab") {
                 $fielseparator = "\t";
             }
             $invalid_rows = array();
             while (($data = fgetcsv($handle, 1000, $fieldseparator)) !== FALSE) {
                 $num = count($data);
                 if ($num != 4) {
                     array_push($invalid_rows, $data);
                     continue;
                 }
                 $search_engine = trim($data[0]);
                 $ppc_name = trim($data[1]);
                 $landing_page = trim($data[2]);
                 $cpc = 0;
                 if (is_numeric($data[3])) {
                     $cpc = (double) trim($data[3]);
                 }
                 $querystring = '';
                 if ($user != 1) {
                     $querystring .= 'u=' . $user . '&';
                 }
                 if (isset($_POST['EncodeInfo'])) {
                     $querystring .= 'e=' . stripslashes($search_engine);
                     $querystring .= '&n=' . stripslashes($ppc_name);
                     $querystring .= '&c=' . (double) $cpc;
                     $querystring = 'ppce=' . urlencode(base64_encode($querystring));
                 } else {
                     $querystring .= 'ppc=' . urlencode(stripslashes($search_engine));
                     $querystring .= '&name=' . urlencode(stripslashes($ppc_name));
                     $querystring .= '&c=' . (double) $cpc;
                 }
                 $url = stripslashes($landing_page) . '/?';
                 if (strpos($landing_page, '?') !== false) {
                     $url = stripslashes($landing_page) . '&' . $querystring;
                 } else {
                     $landingurl = stripslashes($landing_page);
                     $urlparts = explode('/', $landingurl);
                     $filename = array_pop($urlparts);
                     if (strpos($filename, '.') !== false || substr($landingurl, -1) == '/') {
                         $url = $landingurl . '?' . $querystring;
                     } else {
                         $url = $landingurl . '/?' . $querystring;
                     }
                 }
                 $output_data = $data;
                 $output_data[] = $url;
                 $outputline = implode($fieldseparator, $output_data) . "\n";
                 fputs($output_filehandle, $outputline, strlen($outputline));
             }
             fclose($handle);
             fclose($output_filehandle);
             unlink($newfilename);
             chmod($outputfile, 0646);
             if (filesize($outputfile) > 0) {
                 $output_url = str_replace(TEMP_DIRECTORY, TRACKPOINT_APPLICATION_URL . '/temp', $outputfile);
                 echo sprintf(GetLang('Bulk_Conversion_PPC_Finished'), $output_url) . '<br/>';
                 if (!empty($invalid_rows)) {
                     echo '<br/>';
                 }
             }
             if (!empty($invalid_rows)) {
                 echo GetLang('Bulk_PPC_RowsInvalid') . '<br/><br/>';
                 foreach ($invalid_rows as $p => $data) {
                     echo implode('<br/>-', $data) . '<br/>';
                 }
             }
             echo '</span>';
             break;
         default:
             Trackpoint_Functions::Process();
     }
 }