Пример #1
0
 public function actionIndex()
 {
     if (isset($_GET['queue_id'])) {
         $queue_id = intval($_GET['queue_id']);
         $model = WhitelistJobQueue::model()->findByPk($queue_id);
         if ($model->delete()) {
             Yii::app()->user->setFlash('success', '<strong>Record Deleted!</strong> You successfully deleted ' . $model->queue_name);
         } else {
             Yii::app()->user->setFlash('error', '<strong>Deletion Failed!</strong> Cant delete ' . $model->queue_name);
         }
     } else {
         throw new CHttpException(500, "Incomplete parameter : Please provide queue_id");
     }
     $this->redirect(Yii::app()->request->urlReferrer);
 }
 public function actionIndex()
 {
     if (isset($_GET['queue_id'])) {
         Yii::import("application.modules.dnc.components.*");
         $queue_id = intval($_GET['queue_id']);
         $model = WhitelistJobQueue::model()->findByPk($queue_id);
         $fileName = $model->queue_name . '-cleaneddata';
         header("Pragma: public");
         header("Expires: 0");
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header("Cache-Control: private", false);
         header("Content-Type: application/octet-stream");
         header("Content-Disposition: attachment; filename=\"{$fileName}.csv\";");
         header("Content-Transfer-Encoding: binary");
         echo "Mobile Number" . "\n";
         DncUtilities::printCleanMobileNumbers($model->queue_id);
         die;
     } else {
         throw new CHttpException(500, "Incomplete parameter : Please provide queue_id");
     }
     $this->redirect(Yii::app()->getBaseUrl(true) . "/dnc");
 }
Пример #3
0
 public function actionIndex($id)
 {
     Yii::import("application.modules.dnc.components.*");
     /* @var $model WhitelistJobQueue */
     $model = WhitelistJobQueue::model()->findByPk($id);
     if (isset($_GET['download'])) {
         $fileName = $model->queue_name . '-cleaneddata';
         header("Content-Type: text/plain");
         header("Content-Disposition: attachment; filename=\"{$fileName}.txt\";");
         echo "Mobile Number" . "\r\n";
         DncUtilities::printCleanMobileNumbers($model->queue_id);
         die;
     }
     if ($model) {
         $totalUploadedMobileNumbers = DncUtilities::getTotalUploadedMobileNumbers($model->queue_id);
         $removedMobileNumbersArr = DncUtilities::getRemovedMobileNumber($model->queue_id);
         $removedMobileNumbersArr = array_filter($removedMobileNumbersArr);
         $removedMobileNumbers = count($removedMobileNumbersArr);
         $totalDuplicatesRemoved = DncUtilities::getTotalDuplicatesRemoved($model->queue_id);
         $totalDataToDownload = DncUtilities::getTotalDataToDownload($model->queue_id);
         $this->render('index', array('model' => $model, 'totalUploadedMobileNumbers' => $totalUploadedMobileNumbers, "removedMobileNumbersArr" => $removedMobileNumbersArr, 'totalDuplicatesRemoved' => $totalDuplicatesRemoved, 'totalDataToDownload' => $totalDataToDownload));
     }
 }
Пример #4
0
        <div class="container">
            <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </a>

            <!-- Be sure to leave the brand out there if you want it shown -->
            <a class="brand" href="/"><?php 
echo Yii::app()->name;
?>
</a>

            <div class="nav-collapse">
                <?php 
$this->widget('zii.widgets.CMenu', array('htmlOptions' => array('class' => 'pull-right nav'), 'submenuHtmlOptions' => array('class' => 'dropdown-menu'), 'itemCssClass' => 'item-test', 'encodeLabel' => false, 'items' => array(array('label' => 'Dashboard', 'url' => array('/site/index'), 'visible' => Yii::app()->user->getId() === 'administrator'), array('label' => 'DNC Records ' . '<span class="label label-info">' . $totalDncRecords . '</span>', 'url' => array('/blackListedMobile/admin'), 'visible' => Yii::app()->user->getId() === 'administrator'), array('label' => 'Client Portal', 'url' => array('/client_portal/default'), 'visible' => !Yii::app()->user->isGuest), array('label' => 'De-dup Records ' . '<span class="label label-success">' . WhitelistJobQueue::model()->count() . '</span>', 'url' => array('/de-dupe'), 'visible' => Yii::app()->user->getId() === 'administrator'), array('label' => 'IP Firewall', 'url' => "http://ip.dncsystem.website/", 'visible' => Yii::app()->user->getId() === 'administrator'), array('label' => 'Message board', 'url' => array('/messageBoard/updateStatus'), 'visible' => Yii::app()->user->getId() === 'administrator'), array('label' => 'Login', 'url' => array('/site/login'), 'visible' => Yii::app()->user->isGuest), array('label' => 'Logout (' . Yii::app()->user->name . ')', 'url' => array('/site/logout'), 'visible' => !Yii::app()->user->isGuest))));
?>
            </div>
        </div>
    </div>
</div>

<div class="subnav navbar navbar-fixed-top">
    <div class="navbar-inner">
        <div class="container">
            <?php 
if (false) {
    ?>
            <?php 
    //if (  MessageBoard::isUnderConstruction()   ):
    ?>
 public function actionIndex()
 {
     Yii::import("application.models.*");
     //get a queued file
     $criteria = new CDbCriteria();
     $criteria->addInCondition("status", array("IDLE", "REQUEUE"));
     /* @var $currentQueue WhitelistJobQueue*/
     $currentQueue = WhitelistJobQueue::model()->find($criteria);
     //if no queued file die()
     if (!$currentQueue) {
         echo "No files in queue";
         die;
     }
     // else continue as usuall
     $currentQueue->status = WhitelistJobQueue::$JOBQUEUE_STATUS_ON_GOING;
     $currentQueue->save(false);
     //get contents
     $currentCsvFile = new SplFileObject($currentQueue->filename);
     $currentCsvFile->setFlags(SplFileObject::READ_CSV | SplFileObject::READ_AHEAD | SplFileObject::DROP_NEW_LINE | SplFileObject::SKIP_EMPTY);
     //get total number of lines
     $currentCsvFile->seek(PHP_INT_MAX);
     $linesTotal = $currentCsvFile->key();
     $currentQueue->total_records = $linesTotal;
     $currentQueue->save(false);
     $currentCsvFile->rewind();
     $currentCsvFile->next();
     //foreach content , lookup in the blacklist record
     $index = 0;
     foreach ($currentCsvFile as $content) {
         if ($currentCsvFile->key() === 0) {
             continue;
         }
         $currentQueue->processed_record = ++$index;
         $currentQueue->save(false);
         $currentMobileNumber = $content[0];
         $curMobileObj = new WhiteListedMobile();
         //cleaning time
         $currentMobileNumber = trim($currentMobileNumber);
         $currentMobileNumber = rtrim($currentMobileNumber);
         $currentMobileNumber = ltrim($currentMobileNumber);
         $curMobileObj->mobile_number = $currentMobileNumber;
         $curMobileObj->queue_id = $currentQueue->queue_id;
         $criteria2 = new CDbCriteria();
         $criteria2->addSearchCondition("mobile_number", $currentMobileNumber);
         $isOpted = BlackListedMobile::model()->exists($criteria2);
         //if opted , set status error
         if ($isOpted) {
             $curMobileObj->status = WhiteListedMobile::$WHITELISTEDMOBILE_STATUS_ERROR;
         } else {
             //else status ok
             $curMobileObj->status = WhiteListedMobile::$WHITELISTEDMOBILE_STATUS_OK;
         }
         $curMobileObj->save();
         echo "{$curMobileObj->mobile_number}  : {$curMobileObj->status} \n";
     }
     //done
     $currentQueue->status = WhitelistJobQueue::$JOBQUEUE_STATUS_DONE;
     $currentQueue->date_done = date("Y-m-d H:i:s");
     //set done datetime to now()
     $currentQueue->save();
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return WhitelistJobQueue the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = WhitelistJobQueue::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #7
0
    public function actionIndex()
    {
        $dncFile = CUploadedFile::getInstanceByName("dncFile");
        if (isset($_POST['manualCheck']) && !empty($_POST['manualCheck'])) {
            //write the massive input to a csv file . process it like a whitelistjobqueue
            $criteria = new CDbCriteria();
            $criteria->compare("mobile_number", $_POST['manualCheck']);
            // $criteria->addSearchCondition("mobile_number", $_POST['manualCheck']);
            $mobileIsWhiteListed = BlackListedMobile::model()->exists($criteria);
            if ($mobileIsWhiteListed) {
                Yii::app()->user->setFlash('error', '<strong>Mobile Number opted out!</strong> The mobile number opted out before.');
            } else {
                Yii::app()->user->setFlash('success', '<strong>Mobile Number is Clean!</strong> The mobile number has not been opted yet.');
            }
        } else {
            if (isset($_POST['massiveTextArea'])) {
                //write the posted manual file  to a CSV file
                $tempName = tempnam(Yii::getPathOfAlias('application.tempWrite'), "tempWrite");
                $tempName = $tempName . '.csv';
                $mobileNumsArr = explode("\n", $_POST['massiveTextArea']);
                $mobileNumsArr = array_filter($mobileNumsArr);
                //
                $tempNumsContainer = implode("\n", $mobileNumsArr);
                file_put_contents($tempName, $tempNumsContainer);
                $linecount = count($mobileNumsArr);
                $criteria = new CDbCriteria();
                $criteria->compare("queue_name", $_POST['copyPasteFileName']);
                $whiteListjob = WhitelistJobQueue::model()->find($criteria);
                if (!$whiteListjob) {
                    $whiteListjob = new WhitelistJobQueue();
                    $whiteListjob->filename = $tempName;
                    if (isset($_POST['copyPasteFileName'])) {
                        $whiteListjob->queue_name = $_POST['copyPasteFileName'];
                    } else {
                        $whiteListjob->queue_name = 'Uploaded-' . date("Y.m.d.H.i.s");
                    }
                }
                $whiteListjob->status = WhitelistJobQueue::$JOBQUEUE_STATUS_IDLE;
                //Add scan total
                $whiteListjob->total_records = intval($whiteListjob->total_records) + intval($linecount);
                $whiteListjob->processed_record = intval($whiteListjob->processed_record) + $linecount;
                $whiteListjob->status = WhitelistJobQueue::$JOBQUEUE_STATUS_DONE;
                //status to done
                if ($whiteListjob->save()) {
                    //insert queueid sa file firstColumn,
                    $tempDump = tempnam(sys_get_temp_dir(), "temp");
                    $insertQueueidColCommand = "gawk '{print \"{$whiteListjob->queue_id},0\"\$0}' {$tempName} > {$tempDump}";
                    exec($insertQueueidColCommand);
                    exec("mv \"{$tempDump}\" \"{$tempName}\"  ");
                    //insert the whitelisted data to database;
                    $filePath = $tempName;
                    $sqlCommand = <<<EOL
LOAD DATA LOCAL INFILE "%s"
INTO TABLE white_listed_mobile
FIELDS TERMINATED BY "%s"
LINES TERMINATED BY "%s"
IGNORE 0 LINES
(queue_id,mobile_number)
EOL;
                    $sqlCommand = sprintf($sqlCommand, $filePath, ',', '\\n');
                    $mainCommand = "mysql  --user=dncsyste_dnc --password=hitman052529 --database=dncsyste_dnc -e '{$sqlCommand}'";
                    exec($mainCommand);
                    $referenceLink = Yii::app()->getBaseUrl(true) . "/dnc/" . $whiteListjob->queue_id;
                    Yii::app()->user->setFlash('success', '<strong>File Uploaded!</strong> Please click the link to download your cleaned mobile numbers . ' . CHtml::link('Reference Link', $referenceLink));
                } else {
                    Yii::app()->user->setFlash('error', CHtml::errorSummary($whiteListjob));
                }
            } else {
                if ($dncFile) {
                    $newFileLocation = Yii::getPathOfAlias("application.uploaded_files") . DIRECTORY_SEPARATOR . uniqid();
                    $whileListjob = new WhitelistJobQueue();
                    $dncFile->saveAs($newFileLocation);
                    $whileListjob->queue_name = $dncFile->name;
                    $whileListjob->filename = $newFileLocation;
                    $whileListjob->status = WhitelistJobQueue::$JOBQUEUE_STATUS_IDLE;
                    //add scan total
                    $queueFile = new SplFileObject($whileListjob->filename);
                    //read file
                    $queueFile->setFlags(SplFileObject::READ_CSV | SplFileObject::READ_AHEAD | SplFileObject::DROP_NEW_LINE | SplFileObject::SKIP_EMPTY);
                    $queueFile->seek(PHP_INT_MAX);
                    $linesTotal = $queueFile->key();
                    $whileListjob->total_records = $linesTotal;
                    $whileListjob->processed_record = $linesTotal;
                    $whileListjob->status = WhitelistJobQueue::$JOBQUEUE_STATUS_DONE;
                    //status to done
                    if ($whileListjob->save()) {
                        //insert queueid sa file firstColumn,
                        $tempDump = tempnam(sys_get_temp_dir(), "temp");
                        exec("head -1500000 {$newFileLocation} > {$tempDump}");
                        //cut first 1m 500 k
                        exec("gawk '{print \"{$whileListjob->queue_id},0\"\$0}' {$tempDump} > {$newFileLocation}");
                        //insert queueid
                        $queueFile = null;
                        $queueFile = new SplFileObject($newFileLocation);
                        //read file
                        $queueFile->seek(PHP_INT_MAX);
                        $linesTotal = $queueFile->key();
                        $whileListjob->filename = $newFileLocation;
                        $whileListjob->total_records = $linesTotal;
                        $whileListjob->processed_record = $linesTotal;
                        $whileListjob->save();
                        $sqlCommand = <<<EOL
LOAD DATA LOCAL INFILE "%s"
INTO TABLE white_listed_mobile
FIELDS TERMINATED BY "%s"
LINES TERMINATED BY "%s"
IGNORE 0 LINES
(queue_id,mobile_number)
EOL;
                        $sqlCommand = sprintf($sqlCommand, $newFileLocation, ',', '\\n');
                        $mainCommand = "mysql  --user=dncsyste_dnc --password=hitman052529 --database=dncsyste_dnc -e '{$sqlCommand}'";
                        $result = exec($mainCommand);
                        //unlink($tempDump);
                        $referenceLink = Yii::app()->getBaseUrl(true) . "/dnc/" . $whileListjob->queue_id;
                        Yii::app()->user->setFlash('success', '<strong>File Uploaded!</strong> Please click the link to download your cleaned mobile numbers . ' . CHtml::link('Reference Link', $referenceLink));
                    } else {
                        Yii::app()->user->setFlash('error', CHtml::errorSummary($whileListjob));
                    }
                }
            }
        }
        Yii::app()->user->setFlash('info', '<strong><i class="fa fa-info-circle"></i></strong> Please use the following format  : 07#########.');
        $this->render('index');
    }