Example #1
0
 /**
  * Construction for class 
  * 
  * @param string $sourceFolder : end with slash '/'
  * @param string $sourceName
  * @param string $destFolder : end with slash '/'
  * @param string $destName
  * @param int $maxWidth
  * @param int $maxHeight
  * @param string $cropRatio
  * @param int $quality
  * @param string $color
  * 
  * @return ImageResizer
  */
 function __construct($sourceFolder, $sourceName, $destFolder, $destName, $maxWidth = 0, $maxHeight = 0, $cropRatio = '', $quality = 90, $color = '')
 {
     $this->sourceFolder = $sourceFolder;
     $this->sourceName = $sourceName;
     $this->destFolder = $destFolder;
     $this->destName = $destName;
     $this->maxWidth = $maxWidth;
     $this->maxHeight = $maxHeight;
     $this->cropRatio = $cropRatio;
     $this->quality = $quality;
     $this->color = $color;
     $klog = new KLogger(Yii::getPathOfAlias('common.log') . DIRECTORY_SEPARATOR . 'resize_image_log', KLogger::INFO);
     if (!file_exists($this->sourceFolder . $this->sourceName)) {
         echo 'Error: image does not exist: ' . $this->sourceFolder . $this->sourceName;
         $this->file_error = true;
         $klog->LogInfo('Error: image does not exist: ' . $this->sourceFolder . $this->sourceName);
         return null;
     }
     $size = GetImageSize($this->sourceFolder . $this->sourceName);
     $mime = $size['mime'];
     // Make sure that the requested file is actually an image
     if (substr($mime, 0, 6) != 'image/') {
         echo 'Error: requested file is not an accepted type: ' . $this->sourceFolder . $this->sourceName;
         $klog->LogInfo('Error: requested file is not an accepted type: ' . $this->sourceFolder . $this->sourceName);
         $this->file_error = true;
         return null;
     }
     $this->size = $size;
     if ($color != '') {
         $this->color = preg_replace('/[^0-9a-fA-F]/', '', $color);
     } else {
         $this->color = FALSE;
     }
 }
 public static function fatal($message)
 {
     if (self::$log == null) {
         return;
     }
     self::$log->LogFatal($message);
 }
 /**
  * Führt eine SQL Query aus und schreibt sie in die Logdatei.
  * @param KLogger $log Logdatei Objekt
  * @param rex_sql $sql SQL Objekt
  * @param String $query SQL Query
  */
 public static function logQuery(&$log, &$sql, $query)
 {
     $sql->setQuery($query);
     if ($sql->getError() == '') {
         $log->logInfo('>> [QRY] ' . htmlentities($query));
     } else {
         $log->logError('>> [QRY] ' . htmlentities($query));
         $log->logError('>> [QRY] ' . $sql->getError());
     }
 }
Example #4
0
 /**
  * Initialize project by calling get_config on the RW server and saving the response. 
  * 
  * @param int $id PK of a project
  * @throws Exception if valid config objects (device, session, project) are not returned from RW
  */
 function __construct(array $config = array())
 {
     $this->CI =& get_instance();
     $this->log = KLogger::syslog(KLogger::DEBUG, TRUE);
     if (isset($config['id'])) {
         $this->project_id = $config['id'];
     }
     // if we don't have an RW session-id, call get config and push the device and project
     // values into the CI session. If we do have an RW session-id, pull those values
     // from the CI session.
     if (FALSE === ($this->rw_session_id = $this->CI->session->userdata('rw_session_id'))) {
         $this->config(json_decode($this->do_curl('get_config')));
         $this->CI->session->set_userdata('rw_session_id', $this->rw_session_id);
         $this->CI->session->set_userdata('rw_device', $this->device);
         $this->CI->session->set_userdata('rw_project', $this->project);
     } else {
         $this->rw_session_id = $this->CI->session->userdata('rw_session_id');
         $this->device = $this->CI->session->userdata('rw_device');
         $this->project = $this->CI->session->userdata('rw_project');
     }
     // we can't do anything without device, session and project objects
     if (!($this->device && $this->rw_session_id && $this->project)) {
         throw new Exception("Roundware could not be initialized with the given project ID.");
     }
 }
 public function lost()
 {
     $log = KLogger::instance(KLOGGER_PATH . "processors/", KLogger::DEBUG);
     $log->logInfo("usergameaction > lost > start userId : " . $this->userId . " opponentId : " . $this->opponentId . " action : " . $this->action_ . " time : " . $this->time . " room groupId : " . $this->roomGroupId . " gameId : " . $this->gameId . " normal : " . $this->normal . " type : " . $this->type . " double : " . $this->double);
     if (!empty($this->userId)) {
         $user = GameUsers::getGameUserById($this->userId);
         if (!empty($user)) {
             $userId = $user->getUserId();
             if (!empty($userId)) {
                 $user->getUserLevel();
                 $opponent = GameUsers::getGameUserById($this->opponentId);
                 $opponentId = null;
                 if (!empty($opponent)) {
                     $opponentId = $opponent->getUserId();
                     $opponent->getUserLevel();
                 }
                 $result = GameUtils::gameResult($user, $opponent, $this->roomGroupId, $this->action_, $this->gameId, $this->double, $this->normal, $this->type, $this->time);
                 if (!empty($result) && $result->success) {
                     $log->logInfo("usergameaction > lost > success ");
                 } else {
                     $log->logError("usergameaction > lost > error :  " . $result->result);
                 }
                 unset($userId);
                 unset($user);
             } else {
                 $log->logError("usergameaction > lost > user Id is empty ");
             }
         } else {
             $log->logError("usergameaction > lost > user Id is empty ");
         }
     } else {
         $log->logError("usergameaction > lost > user Id is empty ");
     }
 }
 public function log()
 {
     $log = KLogger::instance(KLOGGER_PATH . "processors/", KLogger::DEBUG);
     $log->logInfo("userxplog > log > start userId : " . $this->userId . " xp : " . $this->xp . " type : " . $this->type . " time : " . $this->time . " gameId : " . $this->gameId . " result : " . $this->result . " opponentId : " . $this->opponentId);
     if (!empty($this->userId)) {
         $userXPLog = new GameUserXpLog();
         $userXPLog->setUserId($this->userId);
         $userXPLog->setXp($this->xp);
         $userXPLog->setTime($this->time);
         $userXPLog->setType($this->type);
         $userXPLog->setGameId($this->gameId);
         $userXPLog->setResult($this->result);
         $userXPLog->setOpponentId($this->opponentId);
         try {
             $user = GameUsers::getGameUserById($this->userId);
             if (!empty($user)) {
                 $userXPLog->setUserLevel($user->userLevelNumber);
                 $userXPLog->setUserCoin($user->coins);
                 //$userCoinLog->setUserSpentCoin($user->opponentId);
             }
         } catch (Exception $exc) {
             $log->logError("userxplog > log > User Error : " . $exc->getTraceAsString());
         }
         try {
             $userXPLog->insertIntoDatabase(DBUtils::getConnection());
             $log->logInfo("userxplog > log > Success");
         } catch (Exception $exc) {
             $log->logError("userxplog > log > Error : " . $exc->getTraceAsString());
         }
     } else {
         $log->logError("userxplog > log > user Id is empty ");
     }
 }
Example #7
0
 public function __construct()
 {
     date_default_timezone_set("PRC");
     self::$log = \KLogger::instance(dirname(__FILE__) . "/../log", \KLogger::DEBUG);
     require_once '../config/Config.php';
     $this->config = $METAQ_CONFIG;
     $this->initPartitionList();
 }
Example #8
0
 public function __construct($config)
 {
     if ($config['logging']['enabled'] && $config['logging']['level'] > 0) {
         $this->KLogger = KLogger::instance($config['logging']['path'] . '/website', $config['logging']['level']);
         $this->logging = true;
         $this->floatStartTime = microtime(true);
     }
 }
Example #9
0
 public function __construct($class = "GLOBAL", $user = "******", $prefix = "")
 {
     global $LOGS_PATH;
     global $LOGS_SEVERITY;
     if (!isset(Logger::$log)) {
         Logger::$log = KLogger::instance($LOGS_PATH, $LOGS_SEVERITY);
     }
     $this->class = $class;
     $this->user = $user;
     $this->prefix = $prefix;
 }
Example #10
0
 public function saveMIDItoFile()
 {
     //$this->filename = base_convert(mt_rand(), 10, 36);
     if($this->filenameSet === true)
     {
     $this->midi->saveMidFile($this->filepath.'.mid', 0666);
     if (defined('DEBUG')) $log = KLogger::instance(dirname(DEBUG), KLogger::DEBUG);
     if (defined('DEBUG')) $log->logInfo("Saved MIDI to file: $this->filepath");
     return true;
     }
 }
Example #11
0
 public function generateAudio($filepath)
 {
     //we could also make use of FIFOs:
     //http://stackoverflow.com/questions/60942/how-can-i-send-the-stdout-of-one-process-to-multiple-processes-using-preferably
     
     $command =  '/usr/bin/timidity -A110 -Ow --verbose=-2 --reverb=f,100 --output-file=- '.$filepath.'.mid | tee >(lame --silent -V6 - '.$filepath.'.mp3) | oggenc -Q -q1 -o '.$filepath.'.ogg -';
     //file_put_contents('command', $command);
     if (defined('ASYNCHRONOUS_LAUNCH')) $this->launchBackgroundProcess('/bin/bash -c "'.$command.'"');
     else shell_exec('/bin/bash -c "'.$command.'"');
     if (defined('DEBUG')) $log = KLogger::instance(dirname(DEBUG), KLogger::DEBUG);
     if (defined('DEBUG')) $log->logInfo("Converted MIDI to audio files with the command: $command");
     return true;
 }
 public function __construct($template, $action, $urlValues, $standalone = false, $signinRequired = false)
 {
     $this->action = $action;
     $this->urlValues = $urlValues;
     $this->template = $template;
     $this->_standalone = $standalone;
     $this->log = KLogger::instance(KLOGGER_PATH, KLogger::DEBUG);
     $this->language = LANG_TR_TR;
     if (!isset($_SESSION)) {
         session_start();
     }
     if ($signinRequired) {
         $this->redirect("/");
     }
 }
Example #13
0
 public function updateImage()
 {
     $log = KLogger::instance(KLOGGER_PATH . "processors/", KLogger::DEBUG);
     $log->logInfo("user > updateImage > start userId : " . $this->userId);
     try {
         $userId = $this->userId;
         if (!empty($userId)) {
             $result = UserProfileImageUtils::updateUserImage($userId);
             $log->logInfo("user > updateImage >userId : " . $this->userId . " Result " . json_encode($result));
         } else {
             $log->logError("user > updateImage > start userId : " . $this->userId . " user found user id empty");
         }
     } catch (Exception $exc) {
         $log->logError("user > updateImage > error userId : " . $this->userId . " Error :" . $exc->getMessage());
     }
     $log->logInfo("user > updateImage > finished userId : " . $this->userId);
 }
Example #14
0
#!/usr/bin/php
<?php 
// read mails from internal bounce mailbox and set invalidEmail=1 for these email addresses
require '/var/www/yoursite/http/variables.php';
require '/var/www/yoursite/http/variablesdb.php';
require_once '/var/www/yoursite/http/functions.php';
require '/var/www/yoursite/http/log/KLogger.php';
$log = new KLogger('/var/www/yoursite/http/log/bounces/', KLogger::INFO);
$mailbox = imap_open('{localhost:993/ssl/novalidate-cert}', 'bounce', 'bounce01$');
$mailbox_info = imap_check($mailbox);
for ($i = 1; $i <= $mailbox_info->Nmsgs; $i++) {
    $msg = imap_fetch_overview($mailbox, $i);
    $rcpt = $msg[0]->to;
    if (substr($rcpt, 0, 6) == 'bounce') {
        $target = substr($rcpt, 7);
        // exclude 'bounce='
        $target = substr($target, 0, -9);
        // exclude '@yoursite'
        $target = str_replace('=', '@', $target);
        // revert '=' to '@'
        if ($msg[0]->answered == 0) {
            $sql = "UPDATE {$playerstable} SET invalidEmail=1 WHERE invalidEmail=0 AND mail='" . $target . "'";
            mysql_query($sql);
            $affected = mysql_affected_rows();
            $uid = imap_uid($mailbox, $i);
            $status = imap_setflag_full($mailbox, $uid, '\\Answered \\Seen', ST_UID);
            $log->logInfo('sql=[' . $sql . '] affected=[' . $affected . '] status=[' . $status . ']');
        }
    }
}
imap_close($mailbox);
 /**
  * Sets the date format used by all instances of KLogger
  * 
  * @param string $dateFormat Valid format string for date()
  */
 public static function setDateFormat($dateFormat)
 {
     self::$_dateFormat = $dateFormat;
 }
Example #16
0
#!/usr/bin/php
<?php 
require '/var/www/yoursite/http/variables.php';
require '/var/www/yoursite/http/variablesdb.php';
require_once '/var/www/yoursite/cron/functions.php';
require '/var/www/yoursite/http/log/KLogger.php';
$log = new KLogger('/var/www/yoursite/http/log/cron/', KLogger::INFO);
// PES
$log->logInfo('runDaily: start');
// delete old log entries
$sql = "DELETE FROM weblm_log_access WHERE accesstime < ( UNIX_TIMESTAMP( ) - (60*60*24*180))";
mysql_query($sql);
$log->logInfo('runDaily: Deleted old log entries: ' . mysql_affected_rows());
// send email with played games to all users that selected this in their profile
$dateday = date("d/m/Y");
$yesterday = date("d/m/Y", time() - 60 * 60 * 12);
$timespan = 60 * 60 * 24;
$playersquery = "select distinct winner from {$gamestable} where deleted='no' " . "AND dateday = '{$yesterday}' " . "UNION " . "select distinct winner2 from {$gamestable} where deleted='no' " . "AND dateday = '{$yesterday}' " . "UNION " . "select distinct loser from {$gamestable} where deleted='no' " . "AND dateday = '{$yesterday}' " . "UNION " . "select distinct loser2 from {$gamestable} where deleted='no' " . "AND dateday = '{$yesterday}' ";
$result = mysql_query($playersquery);
$playerscount = mysql_num_rows($result);
$adminMessage = "";
$sql_total = "select count(*) AS c from {$gamestable} " . "WHERE deleted = 'no' " . "AND dateday = '{$yesterday}' " . "ORDER BY date DESC";
$res_total = mysql_query($sql_total);
$row_total = mysql_fetch_array($res_total);
$count_total = $row_total['c'];
$sql_deleted = "select count(*) AS c from {$gamestable} " . "WHERE deleted = 'yes' " . "AND dateday = '{$yesterday}' " . "ORDER BY date DESC";
$res_deleted = mysql_query($sql_deleted);
$row_deleted = mysql_fetch_array($res_deleted);
$count_deleted = $row_deleted['c'];
while ($row = mysql_fetch_array($result)) {
    // for each player that played do...
Example #17
0
 public function actionIndex()
 {
     $urlKey = Yii::app()->request->getParam('url_key');
     $urlKey = preg_replace("/^\\.+|\\.+\$/", "", trim($urlKey));
     $sql = "select * from ads_marketing where url_key=:url_key limit 1";
     $cm = Yii::app()->db->createCommand($sql);
     $cm->bindParam(':url_key', $urlKey, PDO::PARAM_STR);
     $ads = $cm->queryRow();
     if ($ads) {
         $userPhone = Yii::app()->user->getState('msisdn');
         $userSub = $this->isSub;
         $source = $ads['code'];
         Yii::app()->session['source'] = $source;
         if ($source == 'ADS') {
             Yii::app()->session['src'] = 'ads';
         }
         //log ads
         $write = 1;
         if (isset($_SESSION[$source])) {
             // check time giua 2 lan visit co > 15 giay hay ko
             $latest_time = $_SESSION[$source];
             $now = date("Y-m-d H:i:s");
             $diff = strtotime($now) - strtotime($latest_time);
             if (intval($diff) < 15) {
                 $write = 0;
             }
         }
         if ($write == 1) {
             // log to table log_ads_click
             $log = new LogAdsClickModel();
             $ip = $_SERVER["REMOTE_ADDR"];
             $is3G = 0;
             if ($this->is3g) {
                 $is3G = 1;
             }
             //$log->logAdsWap($userPhone, $source, $ip, $is3G);
             $log->ads = $source;
             $log->user_phone = $userPhone;
             $log->user_ip = $ip;
             $log->is_3g = $is3G;
             $log->created_time = date("Y-m-d H:i:s");
             $log->save(false);
             // set session value
             $_SESSION[$source] = date("Y-m-d H:i:s");
         }
         //end log
         $destLink = $ads['dest_link'];
         if ($userSub || empty($userPhone)) {
             $this->redirect($destLink);
         }
         $logger = new KLogger("log_sl", KLogger::INFO);
         $logger->LogInfo("action:" . $ads['action'] . "|userSub:" . json_encode($userSub), false);
         if ($ads['action'] == 'subscribe' && !$userSub) {
             //subscribe now
             $this->showPopupKm = false;
             $this->showPopup = false;
             $userPackage = UserSubscribeModel::model()->get($userPhone);
             $package_id = $ads['package_id'];
             $packageCode = PackageModel::model()->findByPk($package_id)->code;
             if (empty($userPackage)) {
                 //doregister
                 $url = Yii::app()->createUrl('account/vasRegister', array('package' => $package_id, 'back_link' => $destLink));
                 $this->redirect($url);
             }
         }
         $this->redirect($destLink);
     } else {
         $this->redirect('http://amusic.vn');
     }
 }
<?php

$page = "recalculatePointsForProfiles";
require '../../variables.php';
require '../../variablesdb.php';
require_once '../functions.php';
require_once './../../functions.php';
require '../../top.php';
$log = new KLogger('/var/www/yoursite/http/log/runonce/', KLogger::INFO);
echo getOuterBoxTop($leaguename . " <span class='grey-small'>&raquo;</span> Recalculate Points For Profiles", "");
?>
<?

$sql = "SELECT * FROM six_profiles where id=591 ORDER BY Id ASC";
$resultX = mysql_query($sql);
while ($profile = mysql_fetch_array($resultX)) {
  $profileId = $profile['id'];
  $log->logInfo('profileId='.$profileId);
  $log->logInfo('RecalculatePointsForProfile='.RecalculatePointsForProfile($profile['id'], $profile['disconnects'], $profile['points'], $profile['rating']));
  $log->logInfo('RecalculateStreak='.RecalculateStreak($profile['id']));
}

?>
<?php 
echo getOuterBoxBottom();
?>
<?


require ('../../bottom.php');
?>
Example #19
0
$cron_name = basename($_SERVER['PHP_SELF'], '.php');
// Include our configuration (holding defines for the requires)
require_once BASEPATH . '../include/bootstrap.php';
require_once BASEPATH . '../include/version.inc.php';
// Command line switches
array_shift($argv);
foreach ($argv as $option) {
    switch ($option) {
        case '-f':
            $monitoring->setStatus($cron_name . "_disabled", "yesno", 0);
            $monitoring->setStatus($cron_name . "_active", "yesno", 0);
            break;
    }
}
// Load 3rd party logging library for running crons
$log = KLogger::instance(BASEPATH . '../logs/' . $cron_name, KLogger::INFO);
$log->LogDebug('Starting ' . $cron_name);
// Load the start time for later runtime calculations for monitoring
$cron_start[$cron_name] = microtime(true);
// Check if our cron is activated
if ($monitoring->isDisabled($cron_name)) {
    $log->logFatal('Cronjob is currently disabled due to errors, use -f option to force running cron.');
    $monitoring->endCronjob($cron_name, 'E0018', 1, true, false);
}
// Mark cron as running for monitoring
$log->logDebug('Marking cronjob as running for monitoring');
if (!$monitoring->startCronjob($cron_name)) {
    $log->logFatal('Unable to start cronjob: ' . $monitoring->getCronError());
    exit;
}
// Check if we need to halt our crons due to an outstanding upgrade
Example #20
0
<?php

$page = "encrytPasswords";
require '../../variables.php';
require '../../variablesdb.php';
require_once '../functions.php';
require_once './../../functions.php';
require '../../top.php';
$log = new KLogger('/var/www/yoursite/http/log/encrypt/', KLogger::INFO);
$startId = $_GET['id'];
echo getOuterBoxTop($leaguename . " <span class='grey-small'>&raquo;</span> Encrypt Passwords", "");
?>
<?

$sql = "SELECT player_id, name FROM `weblm_players` where convert(pwd using 'utf8') like 'xxx%'"; 
$res = mysql_query($sql);
echo "<p>".$sql."</p>";
while ($row = mysql_fetch_array($res)) {
  $id = $row['player_id'];
  $name = $row['name'];
  
  $length = 10;

  $randomString = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
  $pwHash = password_hash($randomString, PASSWORD_DEFAULT);
  
  $msg = "<p>id=".$id." randomString=".$randomString." name=".$name."</p>";
  $log->LogInfo($msg);
  
  $sql = "UPDATE weblm_players set pwd='".$pwHash."' WHERE player_id=".$id;
  mysql_query($sql);
Example #21
0
 public function __construct($log_directory, $debug_level)
 {
     $level = $debug_level != null ? $debug_level : \KLogger::DEBUG;
     $this->log = \KLogger::instance($log_directory, $level);
 }
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
header("Content-Type: text/plain");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
function logAndDie($log, $message, $code)
{
    http_response_code($code);
    $log->logFatal($message);
    die($message);
}
require_once 'KLogger.php';
$log = new KLogger('.', KLogger::INFO);
$log->logDebug('Opened connection from ' . $_SERVER['REMOTE_ADDR']);
$password = '';
$remoteaddr = '';
if ($_REQUEST['password'] != $password || $_SERVER['REMOTE_ADDR'] != $remoteaddr) {
    logAndDie($log, 'Bad Authentication: ' . $_SERVER['REMOTE_ADDR'], 403);
}
$log->logDebug('Authenticated.');
require_once 'mysql_settings.php';
$mysqli = new mysqli(mysqlSettings::HOSTNAME, mysqlSettings::USERNAME, mysqlSettings::PASSWORD, mysqlSettings::DATABASE);
if ($mysqli->connect_error) {
    logAndDie($log, 'MySQL Connection Error', 500);
}
$log->logDebug('Connected to MySQL - Request mode: ' . $_REQUEST['mode']);
if ($_REQUEST['mode'] === 'update') {
    $query = sprintf("UPDATE `logs_users` SET `ip` = '%s' WHERE `name` = '%s'", $mysqli->real_escape_string($_REQUEST['ip']), strtolower($mysqli->real_escape_string($_REQUEST['name'])));
Example #23
0
 function findClosestEquivalent($note1, $note2, $distance = 7, $scale)
 {
     if (defined('DEBUG')) $log = KLogger::instance(dirname(DEBUG), KLogger::DEBUG);
     
     if (defined('DEBUG')) $log->logDebug("finding closest equivalent for $note1 vs $note2 with distance $distance");
     if ($this->checkInterval($note1, $note2) > $distance)
     {
         return $this->oneOctaveTransposeCloser($note1, $note2, $distance, $scale);
     }
     else return $note1;
 }
 public function actionSubscribe()
 {
     /*if(!isset($_SERVER['SERVER_NAME']) || $_SERVER['SERVER_NAME'] != 'msisdn.chacha.vn'){
           $this->redirect('/site/error404');
       }*/
     $userPhone = Yii::app()->user->getState('msisdn');
     $userSub = $this->userSub;
     //WapUserSubscribeModel::model()->findByAttributes(array('user_phone' => $userPhone, 'status' => UserSubscribeModel::ACTIVE));
     $confirm = Yii::app()->request->getParam('confirm', 0);
     $source = Yii::app()->request->getParam('source', 'buzzcity');
     $source = strtoupper($source);
     $result = null;
     $userObj = null;
     if ($confirm == 0) {
         $write = 1;
         if (isset($_SESSION[$source])) {
             // check time giua 2 lan visit co > 15 giay hay ko
             $latest_time = $_SESSION[$source];
             $now = date("Y-m-d H:i:s");
             $diff = strtotime($now) - strtotime($latest_time);
             if (intval($diff) < 15) {
                 $write = 0;
             }
         }
         if ($write == 1) {
             // log to table log_ads_click
             $log = new LogAdsClickModel();
             $ip = $_SERVER["REMOTE_ADDR"];
             $is3G = 0;
             if (Yii::app()->user->getState('is3G')) {
                 $is3G = 1;
             }
             $log->logAdsWap($userPhone, $source, $ip, $is3G);
             // set session value
             $_SESSION[$source] = date("Y-m-d H:i:s");
         }
     }
     $destUrl = Yii::app()->request->getParam('url', Yii::app()->homeUrl);
     //$destUrl = urldecode($destUrl);
     if ($userSub) {
         $this->redirect($destUrl);
     }
     $isPromotion = WapUserSubscribeModel::model()->checkPromotion($userPhone);
     if ($isPromotion) {
         $confirm = 1;
     }
     if ($confirm == 1) {
         try {
             $phone = $userPhone;
             if (!isset($phone) || !Formatter::isVinaphoneNumber($phone)) {
                 $result = new stdClass();
                 $result->errorCode = 401;
                 $result->message = WapUserSubscribeModel::model()->getCustomMetaData('3G_TEXT');
             } else {
                 //anti flood request
                 if (!isset($_SESSION)) {
                     session_start();
                 }
                 //time_nanosleep(0, 500000000);
                 $token = Yii::app()->request->csrfToken;
                 $ssid = session_id();
                 $sql = "INSERT INTO user_phone_subscribe_unduplicate(phone,ssid,token,created_time,status)\n\t\t\t\t\tVALUE('{$userPhone}','{$ssid}','{$token}',NOW(),0)\n\t\t\t\t\t";
                 $connDB = VegaCommonFunctions::getConnectMysql();
                 $res1 = mysql_query($sql);
                 mysql_close($connDB);
                 if ($res1) {
                     $bmUrl = yii::app()->params['bmConfig']['remote_wsdl'];
                     $client = new SoapClient($bmUrl, array('trace' => 1));
                     $params = array('phone' => $userPhone, 'package' => 'CHACHAFUN', 'source' => 'wap', 'promotion' => '', 'bundle' => 0, 'smsId' => null, 'note_event' => $source);
                     $result = $client->__soapCall('userRegister', $params);
                     $timeClear = date('Y-m-d H:i:s', time() - 60 * 5);
                     $sql = "DELETE FROM user_phone_subscribe_unduplicate WHERE created_time<='{$timeClear}'";
                     $res2 = Yii::app()->db->createCommand($sql)->execute();
                 } else {
                     $log = new KLogger("SUBS_DUPLICATE_EXCEPTION", KLogger::INFO);
                     $log->LogInfo("Ex:" . $userPhone, false);
                     $this->redirect($destUrl);
                     exit;
                 }
             }
             if ($result->errorCode == 0 || $result->errorCode == '0') {
                 //$userObj = WapUserSubscribeModel::model()->findByAttributes(array('user_phone' => $userPhone));
                 if ($isPromotion) {
                     Yii::app()->user->setState('DK_MA_MSG', 'Quý khách có 7 ngày vàng trải nghiệm dịch vụ: Nghe, xem, tải MIỄN PHÍ toàn bộ nội dung và miễn cước data (3G/GPRS~30.000đ/ngày).Tặng kèm gói miễn phí tải nhạc chuông và quà tặng âm nhạc. Để từ chối nhận KM Quý khách soạn HUY CHACHA gửi 9234');
                 }
                 $this->redirect($destUrl);
             }
         } catch (Exception $e) {
             $log = new KLogger("SUBS_EXCEPTION", KLogger::INFO);
             $log->LogInfo("Ex:" . $e->getMessage(), false);
             //Yii::log($e->getMessage(), "error", "exeption.BMException");
             $this->redirect($destUrl);
             exit;
         }
     } else {
         $log = new KLogger("SUBS_NOT_PROMOTION", KLogger::INFO);
         $log->LogInfo($userPhone, false);
     }
     $this->renderPartial("subscribe_adv", array('userObj' => $userObj, 'result' => $result, 'confirm' => $confirm, 'source' => strtolower($source), 'isPromotion' => $isPromotion, 'destUrl' => $destUrl));
 }
Example #25
0
}
$page_uri .= '://' . $_SERVER['SERVER_NAME'];
// this is the base uri
$base_uri = $page_uri;
define('BASE_URI', $base_uri);
// add current document
$page_uri .= $_SERVER['REQUEST_URI'];
// Preparing the session
session_name('tzLogin');
// Making the cookie live for 1 day
session_set_cookie_params(24 * 60 * 60);
// Create session
if (!isset($_SESSION)) {
    session_start();
    $auth = new Authentication_Delegated();
    $log = new KLogger("logs/log.txt", KLogger::DEBUG);
    $_SESSION['base_uri'] = $base_uri;
    $_SESSION['page_uri'] = $page_uri;
}
// If you are logged in, but you don't have the tzRemember cookie (browser restart)
if (isset($_SESSION['id']) && !isset($_COOKIE['tzRemember'])) {
    // Destroy the session
    $_SESSION = array();
    session_destroy();
}
// Logout
if (isset($_REQUEST['logout'])) {
    # clear WebID session
    if ($_SESSION['webid']) {
        $auth->logout;
    }
Example #26
0
// on how to sign up is displayed. if it is called with a valid sid that exists in the weblm_signup table 
// (eg.http://www.yoursite/join.php?sid=1234567890), the signup form is displayed. valid sid's can be
// generated using the 'generate signup link' button on the admin control panel.

// requiring to send an email to sign up can be toggled with the $signupEmailRequired-switch in variables.php
$page = "join";
$subpage = "";

require('variables.php');
require('variablesdb.php');
require('functions.php');
require('top.php');

require_once('log/KLogger.php');

$logJoin = new KLogger('/var/www/yoursite/http/log/join/', KLogger::INFO);	

?>

<?= getOuterBoxTop($leaguename. " <span class='grey-small'>&raquo;</span> Join League", "") ?>

<?php

$na = "n/a";
$checked = "checked='checked'";
$back = "<p><a href='javascript:history.back()'>go back</a></p>";
$alias = "";
$uploadSpeed = "";
$downloadSpeed = "";
$message = "";
$ip = Get_ip();
Example #27
0
    $quantity = $_POST['quantity'];
} else {
    if (isset($_GET['quantity'])) {
        $quantity = $_GET['quantity'];
    }
}
if ($quantity < 1) {
    $quantity = 1;
}
if (!UtilFunctions::checkUserSession($userId)) {
    $result->result = "401 : auth error";
    header("HTTP/1.1 401 Unauthorized");
    echo json_encode($result);
    exit(1);
}
$log = KLogger::instance(KLOGGER_PATH . "apis/", KLogger::DEBUG);
$error = false;
if (!empty($userId)) {
    $user = GameUsers::getGameUserById($userId);
    if (empty($user)) {
        $error = false;
        $log->logError(LanguageUtils::getText("LANG_API_USER_EMPTY"));
        $result->result = LanguageUtils::getText("LANG_API_USER_EMPTY");
    } else {
        $error = true;
    }
} else {
    $log->logError(LanguageUtils::getText("LANG_API_USER_ID_EMPTY"));
    $result->result = LanguageUtils::getText("LANG_API_USER_ID_EMPTY");
}
if ($error) {
Example #28
0
    if (strpos($arg, "conf")) {
        $AUTOMAP = strpos($arg, "automap") ? true : false;
        //	    if (!$AUTOMAP) require(IMPORT_ABS_PATH . IMPORT_PATH."/assets/authorize.php");
        $do = "conf";
    }
}
include "assets/XMLStreamer.php";
include "assets/assets.php";
include "classes/Settings.class.php";
include "classes/ImpLib.class.php";
include "classes/IceCat.class.php";
define("CATEGORY_MAPPING_URL_AJAX", IMPORT_BASE_URL . IMPORT_PATH . '/settings/ajax.php?' . $VendorID . '-conf');
define("FEED_PATH", IMPORT_ABS_PATH . "/ib2b-feeds/" . $VendorID . "/");
@mkdir(FEED_PATH, 0777, true);
@mkdir(IMPORT_ABS_PATH . IMPORT_PATH . "/logs/");
$logger = new KLogger(IMPORT_ABS_PATH . IMPORT_PATH . "/logs/" . @date("Y-m-d") . ".txt", $VendorID);
if (IMPORT_PLATFORM == "MAGENTO") {
    $connector_class = "MagConn";
}
if (IMPORT_PLATFORM == "WOOCOMMERCE") {
    $connector_class = "WooCommerceConn";
}
if (IMPORT_PLATFORM == "PRESTASHOP") {
    $connector_class = "PrestaShopConn";
}
if (IMPORT_PLATFORM == "OPENCART") {
    $connector_class = "OpenCartConn";
}
if (IMPORT_PLATFORM == "ZENCART") {
    $connector_class = "ZenCartConn";
}
Example #29
0
 protected function beforeAction($action)
 {
     $params = Yii::app()->params['controllerlog'];
     $act = $this->getAction()->getId();
     $ctr = $this->getId();
     $ctract = $ctr . $act;
     $method = isset($params[$ctract]) ? $params[$ctract] : "";
     $flag = false;
     if (Yii::app()->request->isPostRequest) {
         //Log tat ca cac action la post
         $flag = true;
     } else {
         if (array_key_exists($ctract, $params) && ($method == 'get' || $method == 'all')) {
             // Log cac action la GET va nam trong config 'controllerlog'
             $flag = true;
         } else {
             if ($ctr == 'customer' && Yii::app()->session['phone'] != '' && $act != "logAction" && $act != "viewLogAction") {
                 // Log cac action la GET va nam trong config 'controllerlog'
                 if ($act == "logAction") {
                     $act = "Xem log tác động khách hàng";
                 } else {
                     if ($act == "index") {
                         $act = "Tra cứu thuê bao";
                     } else {
                         if ($act == "register") {
                             $act = "Đăng ký gói cước";
                         } else {
                             if ($act == "subscriber") {
                                 $act = "Xem lịch sử đăng ký, huỷ dịch vụ của thuê bao";
                             } else {
                                 if ($act == "history") {
                                     $act = "Xem lịch sử trừ cước của thuê bao";
                                 } else {
                                     if ($act == "sms") {
                                         $act = "Xem tin nhắn MO/MT của thuê bao";
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $flag = true;
             }
         }
     }
     if ($flag) {
         $model = new AdminLogActionModel();
         $model->adminId = $this->userId;
         $model->adminName = $this->username;
         $model->controller = $ctr;
         $model->action = $act;
         $model->created_time = new CDbExpression("NOW()");
         $model->ip = Yii::app()->request->getUserHostAddress();
         $model->roles = $this->adminGroup;
         $model->msisdn = Yii::app()->session['phone'];
         $model->params = json_encode($_REQUEST);
         $model->save();
     }
     //log action delete
     if (strpos(strtolower($act), 'delete') !== false) {
         $uri = $_SERVER['REQUEST_URI'];
         $ip = $_SERVER['REMOTE_ADDR'];
         $log = new KLogger('LogActionDeleteCMS', KLogger::INFO);
         $log->LogInfo("Log Delete | UserId: " . Yii::app()->user->id . "|IP:{$ip}" . "| URI:" . $uri, false);
     }
     return parent::beforeAction($action);
 }
Example #30
0
<?php

require_once 'KLogger.php';
$log = new KLogger("log.txt", KLogger::DEBUG);
if (empty($_GET['fileid'])) {
    return false;
} else {
    $fileid = $_GET['fileid'];
}
$log->LogInfo("Download: {$fileid}");
// log file
$client_no = rand();
$logfile = uniqid(rand(), true) . '.log';
$outfile = uniqid(rand(), true) . '.out';
system("cd ../bin; ./CLIENT_p -i {$client_no} -a download -f {$fileid} -t {$outfile} > {$logfile} 2>&1");
$log->LogInfo("Downloaded from NCDS FileID: {$fileid}");
send_file("../bin/{$outfile}", $fileid);
unlink("../bin/{$outfile}");
unlink("../bin/{$logfile}");
$log->LogInfo("Sent to Client FileID: {$fileid}");
function send_file($file, $fileid)
{
    if (empty($_GET['filename'])) {
        $filename = $fileid;
    } else {
        $filename = urldecode($_GET['filename']);
    }
    if (file_exists($file)) {
        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header("Content-Disposition: attachment; filename={$filename}");