public static function info($message)
 {
     if (self::$log == null) {
         return;
     }
     self::$log->LogInfo(self::getTime() . ' ' . $message);
 }
Exemple #2
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;
     }
 }
Exemple #3
0
}
//
// Push to NCDS
//
require_once 'uploaded.class.php';
require_once 'KLogger.php';
$backup_location = "physics@ncds1:/disk1/physics_backup";
$log = new KLogger("log.txt", KLogger::DEBUG);
if (isset($_REQUEST['path']) && !empty($_REQUEST['path'])) {
    // prepare destination name
    $dstpath = str_replace('/', '@', $_REQUEST['path']);
    if (substr($dstpath, -1) != "@") {
        $dstpath = $dstpath . "@";
    }
    $dstpath = $dstpath . $fileName;
    $log->LogInfo("Upload: {$filePath} -> {$dstpath}");
    $file = new Uploaded($filePath);
    $fileid = $file->uploadToNCDS($dstpath);
    $log->LogInfo("Uploaded to NCDS Path: {$dstpath} FileID: {$fileid}");
    if ($file->makeBackup($dstpath, $backup_location)) {
        $log->LogInfo("Backup Successful: {$dstpath} Location: {$backup_location}");
    } else {
        $log->LogError("Backup Error: {$dstpath} Location: {$backup_location}");
    }
    if ($fileid) {
        $file->saveMappingToDb();
        $log->LogInfo("Mapping Saved: {$dstpath} FileId: {$fileid}");
    }
    // remove tmp
    unlink($filePath);
} else {
 public function actionNewimport()
 {
     //$path = _APP_PATH_ . DS . "data";
     //$pathSource = 'E:\phuongnv\Vega\chacha_cloud\src\trunk\chacha\data';
     $pathSource = _APP_PATH_ . DS . "data";
     try {
         $log = new KLogger('LOG_IMPORT_FILE_SONG_PNV', KLogger::INFO);
         $log->LogInfo("Start New Import", false);
         $model = new AdminImportSongModel();
         $importer = self::IMPORT_SONG_CACHE . Yii::app()->user->id;
         $result = array();
         if (isset($_POST['AdminImportSongModel'])) {
             $this->layout = false;
             $autoconfirm = Yii::app()->request->getParam('autoconfirm');
             $autoconfirm = isset($autoconfirm) ? 1 : 0;
             $created_time = $_POST['AdminSongModel']['created_time'];
             $updated_time = $_POST['AdminSongModel']['updated_time'];
             $path = Yii::app()->params['importsong']['store_path'];
             $file_path = $pathSource . DS . "tmp" . DS . $_POST['AdminImportSongModel']['source_path'];
             $fileName = explode(DS, $file_path);
             $fileName = $fileName[count($fileName) - 1];
             if (file_exists($file_path)) {
                 $count = 0;
                 $start_row = $_POST['AdminImportSongModel']['start_row'] > 0 ? $_POST['AdminImportSongModel']['start_row'] : 0;
                 $start_row += self::START_ROW;
                 $limit_row = 65000;
                 $limit_row += $start_row;
                 $log->LogInfo("Start Read File and put Memcache | " . $file_path, false);
                 $data = new ExcelReader($file_path);
                 $resultSql = array();
                 //insert file
                 $sql = "INSERT INTO import_song_file(file_name,importer,status,created_time)\n                \t\t\tVALUE('" . $fileName . "', '{$importer}',0,NOW())\n\t                \t\t\t";
                 $insertFileRess = Yii::app()->db->createCommand($sql)->execute();
                 $fileImportId = Yii::app()->db->getLastInsertID();
                 for ($i = $start_row; $i < $limit_row; $i++) {
                     if ($data->val($i, 'B') != "" && $data->val($i, 'G') != "" && $data->val($i, 'C') != "") {
                         $stt = $data->val($i, Yii::app()->params['importsong']['excelcolumns']['stt']);
                         $name = $model->my_encoding($data->val($i, Yii::app()->params['importsong']['excelcolumns']['name']));
                         $category = $model->my_encoding($data->val($i, Yii::app()->params['importsong']['excelcolumns']['category']));
                         $sub_category = $model->my_encoding($data->val($i, Yii::app()->params['importsong']['excelcolumns']['sub_category']));
                         $composer = $model->my_encoding($data->val($i, Yii::app()->params['importsong']['excelcolumns']['composer']));
                         $artist = $model->my_encoding($data->val($i, Yii::app()->params['importsong']['excelcolumns']['artist']));
                         $album = $model->my_encoding($data->val($i, Yii::app()->params['importsong']['excelcolumns']['album']));
                         $path = str_replace('\\', DS, $data->val($i, Yii::app()->params['importsong']['excelcolumns']['path']));
                         $file = $data->val($i, Yii::app()->params['importsong']['excelcolumns']['file']);
                         $sql = "(";
                         $sql .= "'" . $autoconfirm . "'";
                         $sql .= ",'" . $created_time . "'";
                         $sql .= ",'" . $updated_time . "'";
                         $sql .= ",'" . $stt . "'";
                         $sql .= ",'" . addslashes($name) . "'";
                         $sql .= ",'" . $category . "'";
                         $sql .= ",'" . $sub_category . "'";
                         $sql .= ",'" . addslashes($composer) . "'";
                         $sql .= ",'" . addslashes($artist) . "'";
                         $sql .= ",'" . addslashes($album) . "'";
                         //$sql .= ",'".str_replace('\\', '\\\\', $path)."'";
                         $sql .= ",'" . addslashes($path) . "'";
                         //$sql .= ",'".str_replace('\\', '\\\\', $file)."'";
                         $sql .= ",'" . addslashes($file) . "'";
                         $sql .= ",'" . $importer . "'";
                         //$sql .= ",'".str_replace('\\', '\\\\', $file_path)."'";
                         $sql .= ",'" . addslashes($file_path) . "'";
                         $sql .= ",'" . $fileImportId . "'";
                         $sql .= ")";
                         $resultSql[] = $sql;
                         $count++;
                     }
                     /* if($count==10)
                     		 echo '<pre>';print_r($result);die(); */
                 }
                 //insert data to db
                 if ($insertFileRess) {
                     $sql = "INSERT INTO import_song(autoconfirm,created_time,updated_time,stt,name,category,sub_category,composer,artist,album,path,file,importer,file_name,file_id) VALUES";
                     $sql .= implode(',', $resultSql);
                     if (Yii::app()->db->createCommand($sql)->execute()) {
                         $sql = "UPDATE import_song_file set total_song={$count} WHERE id={$fileImportId}";
                         Yii::app()->db->createCommand($sql)->execute();
                     }
                     //insert false
                 }
                 //remove file source after insert
                 $fileSystem = new Filesystem();
                 $fileSystem->remove($file_path);
                 echo CJSON::encode(array('errorCode' => 0, 'errorDesc' => 'Success imported Total Record: ' . count($resultSql)));
             } else {
                 //if ($_POST['AdminImportSongModel']['ajax'])
                 echo CJSON::encode(array('errorCode' => 1, 'errorDesc' => 'Chưa upload file excel'));
             }
             Yii::app()->end();
         }
     } catch (Exception $e) {
         $log->LogError("actionAjaxImport | Exception Error: " . $e->getMessage(), false);
         echo CJSON::encode(array('errorCode' => 1, 'errorDesc' => 'Chưa upload file excel'));
         Yii::app()->end();
     }
     $uploadModel = new XUploadForm();
     $this->render('newimport', array('model' => $model, 'listSong' => $result, 'uploadModel' => $uploadModel));
 }
#!/usr/bin/php

<?php 
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/report/', KLogger::INFO);
if ($maintenance == 'yes') {
    $log->logInfo('maintenance=yes, not reporting anything');
    die;
}
$start = time();
$log->LogInfo('--- Finished games');
// finished games
$sql = "\n\tSELECT sm.*, smp.home, wp.name, sp1.id AS patchId \n\tFROM six_matches sm\n\tLEFT JOIN six_patches sp1 ON sm.hashHome = sp1.hash\n\tLEFT JOIN six_patches sp2 ON sm.hashAway = sp2.hash\n\tLEFT JOIN six_matches_played smp ON smp.match_id=sm.id \n\tLEFT JOIN six_profiles sp ON smp.profile_id=sp.id \n\tLEFT JOIN weblm_players wp ON wp.player_id=sp.user_id  \n\tWHERE sm.played_on>date_sub(now(), INTERVAL 24 HOUR) \n  AND sp1.id=sp2.id \n  AND sp1.autoReport=1 \n\tAND sp2.autoReport=1 \n\tAND sm.reported=0\n\tORDER BY sm.id ASC, smp.home ASC";
// $log->logInfo('sql='.$sql);
$result = mysql_query($sql);
$smId = 0;
$winner1 = '';
$winner2 = '';
$loser1 = '';
$loser2 = '';
$teamLeft = '';
$teamRight = '';
$scoreLeft = '';
$scoreRight = '';
$homeLeft = true;
$patchId = 0;
while ($row = mysql_fetch_array($result)) {
    $smId = $row['id'];
 public function actionNewimport()
 {
     //$path = _APP_PATH_ . DS . "data";
     //$pathSource = 'E:\phuongnv\Vega\chacha_cloud\src\trunk\chacha\data';
     $pathSource = _APP_PATH_ . DS . "data";
     $log = new KLogger('LOG_CHECK_SONG_IMPORT', KLogger::INFO);
     $log->LogInfo("Start New Import", false);
     try {
         $model = new AdminImportSongModel();
         $importer = self::IMPORT_SONG_CACHE . Yii::app()->user->id;
         $result = array();
         if (isset($_POST['AdminImportSongModel'])) {
             $this->layout = false;
             $file_path = $pathSource . DS . "tmp" . DS . $_POST['AdminImportSongModel']['source_path'];
             $fileName = explode(DS, $file_path);
             $fileName = $fileName[count($fileName) - 1];
             if (file_exists($file_path)) {
                 $log->LogInfo("Start Read File and put Memcache | " . $file_path, false);
                 $data = new ExcelReader($file_path);
                 //insert file
                 $sql = "INSERT INTO import_song_file(file_name,importer,status,created_time,type)\n                \t\t\tVALUE('" . $fileName . "', '{$importer}',0,NOW(),'CHECK')\n\t                \t\t\t";
                 $log->LogInfo("SQL: " . $sql, false);
                 $insertFileRess = Yii::app()->db->createCommand($sql)->execute();
                 $fileImportId = Yii::app()->db->getLastInsertID();
                 $i = 1;
                 $err = 0;
                 $count = 0;
                 $total = 0;
                 $sqlAr = array();
                 $flag = true;
                 while ($flag) {
                     if ($data->val($i, 'A') != "" && $data->val($i, 'B') != "" && $data->val($i, 'C') != "") {
                         $stt = $data->val($i, 'A');
                         $songName = $model->my_encoding($data->val($i, 'B'));
                         $artistName = $model->my_encoding($data->val($i, 'C'));
                         $artistId = $this->getArtistId($artistName);
                         $artistId = implode(',', $artistId);
                         $sqlAr[] = "('{$stt}','" . addslashes($songName) . "', '" . addslashes($artistName) . "', {$fileImportId}, '{$importer}','{$artistId}')";
                         $count++;
                         $total++;
                     } else {
                         $err++;
                     }
                     $i++;
                     if ($err == 3) {
                         $flag = false;
                     }
                     if ($count == 200 || !$flag) {
                         $sql = "INSERT INTO import_song(stt,name,artist,file_id,importer,album) VALUES";
                         $sql .= implode(',', $sqlAr);
                         $log->LogInfo("SQL: " . $sql, false);
                         if (Yii::app()->db->createCommand($sql)->execute()) {
                             //reset
                             $count = 0;
                             $sqlAr = array();
                         }
                     }
                 }
                 $sql = "UPDATE import_song_file set total_song={$total} WHERE id={$fileImportId}";
                 Yii::app()->db->createCommand($sql)->execute();
                 //remove file source after insert
                 /* $fileSystem = new Filesystem();
                 			$fileSystem->remove($file_path); */
                 echo CJSON::encode(array('errorCode' => 0, 'errorDesc' => 'Success imported Total Record: ' . $total . ' Go to <a href="' . Yii::app()->createUrl('/tools/importSong/index&fileId=' . $fileImportId) . '">Scan</a>'));
             } else {
                 echo CJSON::encode(array('errorCode' => 1, 'errorDesc' => 'File không tồn tại:' . $file_path));
                 $log->LogInfo("File không tồn tại: " . $file_path, false);
             }
             Yii::app()->end();
         }
     } catch (Exception $e) {
         echo CJSON::encode(array('errorCode' => 1, 'errorDesc' => 'Exception:' . $e->getMessage()));
         $log->LogError("actionAjaxImport | Exception Error: " . $e->getMessage(), false);
         Yii::app()->end();
     }
     $uploadModel = new XUploadForm();
     $this->render('newimport', array('model' => $model, 'listSong' => $result, 'uploadModel' => $uploadModel));
 }
 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');
     }
 }
Exemple #8
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}");
Exemple #9
0
// Some clients only send HTTP Auth credentials if the server
// responds with a 401 and asks for them.
if (empty($_SERVER['PHP_AUTH_USER'])) {
    header('WWW-Authenticate: Basic realm="CloudFiles Poster"');
    header('HTTP/1.0 401 Unauthorized');
    exit;
}
// Uses kLogger from https://github.com/katzgrau/KLogger
require_once 'KLogger/src/KLogger.php';
$log = new KLogger(dirname(__FILE__), KLogger::INFO);
$container_name = empty($_GET['container']) ? $container_name : $_GET['container'];
if (empty($container_name)) {
    $log->LogError('Container name MUST be set.');
    die('Container name MUST be set.');
}
$log->LogInfo('Received ' . $_FILES['filename']['name']);
include 'php-cloudfiles/cloudfiles.php';
// Extract user and api key from the http auth
$username = $_SERVER['PHP_AUTH_USER'];
$api_key = $_SERVER['PHP_AUTH_PW'];
// If there's a ?name= query variable, use that as the file name
$filename = empty($_GET['name']) ? $_FILES['filename']['name'] : $_GET['name'];
// Authenticate with CloudFiles and create our file and container objects
$auth = new CF_Authentication($username, $api_key);
$auth->authenticate();
$conn = new CF_Connection($auth);
$container = $conn->create_container($container_name);
$file = $container->create_object($filename);
// Set the content-type
if (class_exists('finfo')) {
    // Use the PECL finfo to determine mime type
 public function actionAjaxImport()
 {
     @ini_set("max_execution_time", 18000);
     try {
         $timeStart = time();
         $fileId = Yii::app()->request->getParam('fileId', 0);
         $log = new KLogger('LOG_IMPORT_FILE_SONG_PNV', KLogger::INFO);
         $log->LogInfo("Start Ajax Import", false);
         $model = new AdminImportSongModel();
         $result = ImportSongModel::getSongsAll($fileId);
         $totalRow = count($result);
         //echo '<pre>';print_r($result);die();
         $path = Yii::app()->params['importsong']['store_path'];
         $is_error = 0;
         $imported = array();
         $notImport = array();
         $data = "";
         $success = 0;
         if ($totalRow > 0) {
             $song = $result[0];
             $log->LogInfo("Start import | " . CJSON::encode($song), false);
             $status = 0;
             $insert_id = $model->importSong($song, $path);
             $insert_id = !$insert_id ? -1 : $insert_id;
             // save inserted id to a string, for updating Updated_time column when finish
             if ($insert_id > 0 && !in_array($insert_id, array(2, 3, 4))) {
                 $this->updateTime($insert_id, $song['updated_time']);
                 $imported = array('stt' => $song['stt'], 'name' => $song['name'], 'path' => $song['path'], 'songId' => $insert_id);
                 $this->updateSongImportSource($song['id'], 1, 0, 'Success', $insert_id, $timeStart);
             } else {
                 $errorDesc = array(-1 => 'File không tồn tại', 2 => 'Không save được vào song', 3 => 'Hết quyền upload bài hát', 4 => 'File mp3 trống');
                 $this->updateSongImportSource($song['id'], 2, $insert_id, $errorDesc[$insert_id], 0, $timeStart);
                 $is_error = 1;
                 $notImport = array('stt' => $song['stt'], 'name' => $song['name'], 'path' => $song['path'], 'errorDesc' => $errorDesc[$insert_id]);
                 //$log->LogInfo('Not import > (' . $song['stt'] . ')' . $song['path'] . $song['file'], false);
             }
             $data = $this->renderPartial('ajaxResultRow', array('imported' => $imported, 'notImport' => $notImport), true, true);
         } else {
             //completed
             $success = 1;
             $log->LogError("Error | " . CJSON::encode($result), false);
         }
         $dataJson = array('is_error' => $is_error, 'success' => $success, 'data' => $data);
         echo CJSON::encode($dataJson);
         Yii::app()->end();
     } catch (Exception $e) {
         $log->LogError("actionAjaxImport | Exception Error: " . $e->getMessage(), false);
         $dataJson = array('is_error' => 1, 'success' => 0, 'data' => "actionAjaxImport | Exception Error: " . $e->getMessage());
         echo CJSON::encode($dataJson);
         Yii::app()->end();
     }
     exit;
 }
$res = mysql_query($sql);
echo "<p>".$sql."</p>";
while ($row = mysql_fetch_array($res)) {
  $id = $row['player_id'];
  
  // get old password
  $sqlOld = "SELECT passworddb,name from weblm_players_old where player_id=".$id;
  $resOld = mysql_query($sqlOld);
  while ($rowOld = mysql_fetch_array($resOld)) {
    $pwdOld = $rowOld['passworddb'];
    $pwHash = password_hash($pwdOld, PASSWORD_DEFAULT);
    $name = $rowOld['name'];
    // $verify = password_verify($pwdOld, $pwHash);
    $msg = "<p>id=".$id." pwdOld=".$pwdOld." name=".$name."</p>";
    // echo $msg;
    $log->LogInfo($msg);
    
    $sql = "UPDATE weblm_players set pwd='".$pwHash."', hash6='' WHERE player_id=".$id;
    // echo "<p>".$sql."</p>";
    mysql_query($sql);
    // $log->LogInfo($sql);
    
    /*
    $sqlNew = "SELECT pwd FROM weblm_players where player_id=".$id;
    $resNew = mysql_query($sqlNew);
    while ($rowNew = mysql_fetch_array($resNew)) {
      $hashNew = $rowNew['pwd'];
      $verify = password_verify($pwdOld, $hashNew);
      $msg = "<p>pwdOld=".$pwdOld." name=".$name." verify=".$verify." (reloaded)</p>";
      $log->LogInfo($msg);
      echo $msg;
 public function actionAjaxMap()
 {
     Yii::import("application.models.web.*");
     $fileId = Yii::app()->request->getParam('fileId');
     $offset = Yii::app()->request->getParam('offset', 0);
     $return = new stdClass();
     $return->error = 0;
     $return->errorMessage = "";
     $return->success = 0;
     $return->data = array();
     try {
         $c = new CDbCriteria();
         $c->condition = "id=:FID";
         $c->params = array(":FID" => $fileId);
         $fileInfo = CopyrightInputFileModel::model()->find($c);
         if (isset($fileInfo)) {
             $content_type = $fileInfo->content_type;
             $c = new CDbCriteria();
             $c->condition = "input_file=:FID";
             $c->params = array(":FID" => $fileId);
             $c->order = "id ASC";
             $c->limit = 1;
             $c->offset = $offset;
             $item = CopyrightInputContentModel::model()->find($c);
             $Log = new KLogger("log_map", KLogger::INFO);
             if (empty($item)) {
                 $return->success = 1;
             } else {
                 $inputId = $item->id;
                 $countMapSong = $countMapVideo = 0;
                 if ($content_type == 'song') {
                     $cr = new CDbCriteria();
                     $cr->condition = "LOWER(TRIM(name)) LIKE :NAME AND cp_id=1";
                     $cr->params = array(":NAME" => strtolower(trim($item->name)) . "%");
                     $items = SongModel::model()->findAll($cr);
                     foreach ($items as $song) {
                         if (isset($song['cp_id']) && $song['cp_id'] == 1) {
                             $songName = strtoupper(trim($song['name']));
                             $songArtist = strtoupper(trim($song['artist_name']));
                             $songArtist = Common::strNormal($songArtist);
                             $itemName = strtoupper(trim($item->name));
                             $itemArtist = strtoupper(trim($item->artist));
                             $itemArtist = Common::strNormal($itemArtist);
                             if ($item->id == 574692) {
                                 $s = strlen($songName) - strlen($itemName);
                                 $d = strrpos($songArtist, $itemArtist);
                                 $Log->LogInfo("songName: {$songName} | itemName:{$itemName} |{$s}|| songArtist:{$songArtist} | itemArtist:{$itemArtist} " . json_encode($d), false);
                             }
                             if (strlen($songName) - strlen($itemName) > 3) {
                                 continue;
                             }
                             if (strrpos($songArtist, $itemArtist) === false) {
                                 continue;
                             }
                             $sql = "\n                                                                    INSERT INTO copyright_content_map(input_id,content_id,content_name,content_artist,content_type)\n                                                                    VALUES(:INPUT_ID,:CONTENT_ID,:CONTENT_NAME,:CONTENT_ARTIST,'song')\n                                                                    ON DUPLICATE KEY UPDATE content_name=:CONTENT_NAME_2, content_artist=:CONTENT_ARTIST_2\n                                                                ";
                             $contentId = $song['id'];
                             $contentName = $song['name'];
                             $contentArtist = $song['artist_name'];
                             $dataCmd = Yii::app()->db->createCommand($sql);
                             $dataCmd->bindParam(":INPUT_ID", $inputId, PDO::PARAM_INT);
                             $dataCmd->bindParam(":CONTENT_ID", $contentId, PDO::PARAM_INT);
                             $dataCmd->bindParam(":CONTENT_NAME", $contentName, PDO::PARAM_STR);
                             $dataCmd->bindParam(":CONTENT_ARTIST", $contentArtist, PDO::PARAM_STR);
                             $dataCmd->bindParam(":CONTENT_NAME_2", $contentName, PDO::PARAM_STR);
                             $dataCmd->bindParam(":CONTENT_ARTIST_2", $contentArtist, PDO::PARAM_STR);
                             $dataCmd->execute();
                             $countMapSong++;
                         }
                     }
                     $return->error = 0;
                     $return->errorMessage = $item->name . ">> Bài hát ({$countMapSong})";
                 }
                 if ($content_type == 'video') {
                     $cr = new CDbCriteria();
                     $cr->condition = "LOWER(TRIM(name)) LIKE :NAME AND cp_id=1";
                     $cr->params = array(":NAME" => strtolower(trim($item->name)) . "%");
                     $items = VideoModel::model()->findAll($cr);
                     foreach ($items as $video) {
                         if (isset($video['cp_id']) && $video['cp_id'] == 1) {
                             $videoName = strtoupper(trim($video['name']));
                             $videoArtist = strtoupper(trim($video['artist_name']));
                             $videoArtist = Common::strNormal($videoArtist);
                             $itemName = strtoupper(trim($item->name));
                             $itemArtist = strtoupper(trim($item->artist));
                             $itemArtist = Common::strNormal($itemArtist);
                             if (strlen($videoName) - strlen($itemName) > 3) {
                                 continue;
                             }
                             if (strrpos($videoArtist, $itemArtist) === false) {
                                 continue;
                             }
                             $sql = "\n                                                                    INSERT INTO copyright_content_map(input_id,content_id,content_name,content_artist,content_type)\n                                                                    VALUES(:INPUT_ID,:CONTENT_ID,:CONTENT_NAME,:CONTENT_ARTIST,'video')\n                                                                    ON DUPLICATE KEY UPDATE content_name=:CONTENT_NAME_2, content_artist=:CONTENT_ARTIST_2\n                                                                ";
                             $contentId = $video['id'];
                             $contentName = $video['name'];
                             $contentArtist = $video['artist_name'];
                             $dataCmd = Yii::app()->db->createCommand($sql);
                             $dataCmd->bindParam(":INPUT_ID", $inputId, PDO::PARAM_INT);
                             $dataCmd->bindParam(":CONTENT_ID", $contentId, PDO::PARAM_INT);
                             $dataCmd->bindParam(":CONTENT_NAME", $contentName, PDO::PARAM_STR);
                             $dataCmd->bindParam(":CONTENT_ARTIST", $contentArtist, PDO::PARAM_STR);
                             $dataCmd->bindParam(":CONTENT_NAME_2", $contentName, PDO::PARAM_STR);
                             $dataCmd->bindParam(":CONTENT_ARTIST_2", $contentArtist, PDO::PARAM_STR);
                             $dataCmd->execute();
                             $countMapVideo++;
                         }
                     }
                     $return->error = 0;
                     $return->errorMessage = $item->name . ">> Video ({$countMapVideo})";
                 }
             }
         }
     } catch (Exception $e) {
         $return->error = 500;
         $return->errorMessage = $e->getMessage();
     }
     echo json_encode($return);
     Yii::app()->end();
 }
require_once 'tropo.class.php';
// KLogger is a logging class from
// http://codefury.net/projects/klogger/
require_once 'KLogger.php';
$log = new KLogger("log.txt", KLogger::INFO);
// Does the ?record query string exist? If not, this is an incoming call.
if (!array_key_exists('record', $_GET)) {
    $tropo = new Tropo();
    $tropo->record(array('say' => 'Leave your message at the beep.', 'url' => getself() . '?record'));
    print $tropo;
} else {
    // Change this path to match the location on your server where you want
    // the file to be saved.
    $target_path = 'path/to/recording/' . $_FILES['filename']['name'];
    if (move_uploaded_file($_FILES['filename']['tmp_name'], $target_path)) {
        $log->LogInfo("{$target_path} [{$_FILES['filename']['size']} bytes] was saved");
    } else {
        $log->LogError("{$target_path} could not be saved.");
    }
}
// Simple function to get the full URL of the current script.
function getself()
{
    $pageURL = 'http';
    $url = $_SERVER["HTTPS"] == "on" ? 'https' : 'http';
    $url .= "://" . $_SERVER["SERVER_NAME"];
    $url .= $_SERVER["SERVER_PORT"] != "80" ? ':' . $_SERVER["SERVER_PORT"] : '';
    $url .= $_SERVER["REQUEST_URI"];
    return $url;
}
<?php

// **************************************************************************
//
// This file will setup all objects required by the server (e.g. a database
// connection).
//
date_default_timezone_set('UTC');
require_once 'lib/KLogger.php';
$log = new KLogger("log", KLogger::DEBUG);
$file_db = new PDO('sqlite:db/baker.sqlite3');
$file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
require_once 'tables.php';
require_once 'functions.php';
$log->LogInfo("");
$log->LogInfo("===vvv=============== Received request ================vvv===");
$log->LogInfo($_SERVER["REQUEST_URI"]);
$log->LogInfo("GET " . var_export($_GET, true));
$log->LogInfo("POST " . var_export($_POST, true));
$log->LogInfo("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
$app_id = $_POST['app_id'];
$user_id = $_POST['user_id'];
Exemple #15
0
function elog($logstr, $type = 'info', $dir = "../logs/")
{
    $startweek = date('Y-m-d', time());
    $log = new KLogger($dir . $startweek . ".txt", KLogger::INFO);
    $user = getSessionUser();
    $str = u2utf8('(' . $user . ') ' . $logstr);
    switch ($type) {
        case 'error':
            $log->LogError($str);
            break;
        default:
            $log->LogInfo($str);
            break;
    }
}
Exemple #16
0
    if ($ok == True) {
        if (!isset($_SESSION['myprofile'])) {
            $_SESSION['webid'] = $webid;
            $_SESSION['myprofile'] = new MyProfile($webid, BASE_URI, SPARQL_ENDPOINT);
            // load rest of data only if we can load the profile
            if ($_SESSION['myprofile']->load()) {
                $_SESSION['usr'] = $_SESSION['myprofile']->get_name();
                $_SESSION['img'] = $_SESSION['myprofile']->get_picture();
                $_SESSION['feed_hash'] = $_SESSION['myprofile']->get_feed();
                $_SESSION['user_hash'] = $_SESSION['myprofile']->get_hash();
            }
        }
        // Store some data in the session
        setcookie('tzRemember', '1');
        // Log success
        $log->LogInfo("[SUCCESS] Authenticated " . $webid . " => " . $auth->authnDiagnostic);
    } else {
        // log reason why it failed
        $log->LogInfo("[FAILURE] Fail to authenticate " . $webid . " => " . $auth->authnDiagnostic);
    }
}
// Get the number of messages
if (isset($_SESSION['webid']) && $_SESSION['webid']) {
    $messages = get_msg_count($_SESSION['webid']);
    $wall_msg = get_msg_count($_SESSION['webid'], True, True);
}
// Bad place to add logic for adding/removing friends.
// add a specific person as friend
if (isset($_SESSION['myprofile']) && $_SESSION['myprofile']->is_local($webid) && isset($_REQUEST['action']) && $_REQUEST['action'] == 'addfriend') {
    // add friend and display confirmation
    $confirmation = $_SESSION['myprofile']->add_friend($_REQUEST['add_webid']);
Exemple #17
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);
 }
 public static function _getContentCurl($url)
 {
     $logger = new KLogger("RBT_GET", KLogger::OFF);
     // timeout in seconds
     $timeOut = 5;
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeOut);
     $rawdata = curl_exec($ch);
     if (!curl_errno($ch)) {
         if ($rawdata) {
             curl_close($ch);
             $logger->LogInfo("REQ:" . $url . " - RES: " . $rawdata);
             return $rawdata;
         }
     }
     curl_close($ch);
     $logger->LogInfo("REQ:" . $url . " - RES: FAIL");
     return false;
 }
<?

$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);
  $log->LogInfo($sql);
}

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


require ('../../bottom.php');
?>
 /**
  * get point in hot list
  */
 public function getPoint($content_id, $transaction, $point)
 {
     $log = new KLogger('get_point', KLogger::INFO);
     $log->LogInfo('data:' . $content_id . '||' . $transaction . '||' . $point, false);
     if ($transaction == 'play_song') {
         $id = Yii::app()->params['ctkm']['id_collection_song_hot'];
     }
     if ($transaction == 'play_video') {
         $id = Yii::app()->params['ctkm']['id_collection_video_hot'];
     }
     if ($transaction == 'play_album') {
         $id = Yii::app()->params['ctkm']['id_collection_album_hot'];
     }
     //        $dependency = new CDbCacheDependency("SELECT MAX(created_time) FROM collection_item WHERE collect_id = $id");
     //        $collection_item = CollectionItemModel::model()->cache(21600, $dependency)->findAllByAttributes(array('collect_id'=>$id));
     $collection_item = CollectionItemModel::model()->findAllByAttributes(array('collect_id' => $id));
     $data = array();
     foreach ($collection_item as $item) {
         $data[] = $item->item_id;
     }
     if (in_array($content_id, $data)) {
         $point = 1000;
     }
     return $point;
 }
 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));
 }
Exemple #22
0
<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
include_once $_SERVER['DOCUMENT_ROOT'] . "/eventconfig.php";
require_once CLASSFOLDER . '/KLogger.php';
$log = new KLogger("logFiles/log.log", KLogger::DEBUG);
// Do database work that throws an exception
$log->LogError("An exception was thrown in ThisFunction()");
// Print out some information
$log->LogInfo("Internal Query Time:  milliseconds");
// Print out the value of some variables
//$log->LogDebug("User Count: $User_Count");