Exemple #1
0
 public function testSplitNumberList()
 {
     $list = MiscHelpers::splitNumberList('');
     //var_dump($list);
     $this->assertTrue(is_array($list));
     $this->assertTrue(count($list) == 0);
     $list = MiscHelpers::splitNumberList(' 123  ');
     //var_dump($list);
     $this->assertTrue(is_array($list));
     $this->assertTrue(count($list) == 1);
     //$a = array_search(123, $list);
     //var_dump($a);
     $this->assertTrue(0 == array_search(123, $list));
     $list = MiscHelpers::splitNumberList('10 11, 12');
     //var_dump($list);
     $this->assertTrue(is_array($list));
     $this->assertTrue(count($list) == 3);
     $this->assertTrue(2 == array_search(12, $list));
     $list = MiscHelpers::splitNumberList('10 11 12 13');
     //var_dump($list);
     $this->assertTrue(is_array($list));
     $this->assertTrue(count($list) == 4);
     $this->assertTrue(2 == array_search(12, $list));
     $list = MiscHelpers::splitNumberList('10 f 12');
     //var_dump($list);
     $this->assertTrue($list == false);
 }
Exemple #2
0
 /**
  * @param int $nDays
  *
  * @return static
  */
 public static function fromInteger($nDays)
 {
     $fourCentury = 365 * 400 + static::nLeapYears(400);
     $century = 365 * 100 + static::nLeapYears(100);
     $fourYear = 365 * 4 + 1;
     $year = 1 + floor(($nDays - 1) / $fourCentury) * 400;
     $nDays -= $fourCentury * floor(($nDays - 1) / $fourCentury);
     if ($nDays == $fourCentury) {
         return new static($year + 399, 12, 31);
     }
     if ($nDays == $fourCentury - 1) {
         return new static($year + 399, 12, 30);
     }
     $year += floor(($nDays - 1) / $century) * 100;
     $nDays -= $century * floor(($nDays - 1) / $century);
     if ($nDays == $century) {
         return new static($year + 99, 12, 31);
     }
     $year += floor(($nDays - 1) / $fourYear) * 4;
     $nDays -= $fourYear * floor(($nDays - 1) / $fourYear);
     if ($nDays == $fourYear) {
         return new static($year + 3, 12, 31);
     }
     $year += floor(($nDays - 1) / 365);
     $nDays -= 365 * floor(($nDays - 1) / 365);
     if (static::isLeapYear($year) && $nDays >= 60) {
         if ($nDays == 60) {
             $month = 2;
             $day = 29;
         } else {
             $month = MiscHelpers::binarySearch($nDays - 1, static::$cumulativeDaysInMonth);
             $day = $nDays - static::$cumulativeDaysInMonth[$month - 1] - 1;
         }
     } else {
         $month = MiscHelpers::binarySearch($nDays, static::$cumulativeDaysInMonth);
         $day = $nDays - static::$cumulativeDaysInMonth[$month - 1];
     }
     return new static($year, $month, $day);
 }
Exemple #3
0
<div class="span-18 last">
	<div class="box">
		<ul class="daemon-status-list">			
			<li class="daemon-status-list-item loud"><div class="list-item-label">File Name:</div><?php 
echo CHtml::encode($model->srcfilename);
?>
</li>
			<li class="daemon-status-list-item loud"><div class="list-item-label">File Size:</div><?php 
echo CHtml::encode(MiscHelpers::fileSizeToStr($model->filesize));
?>
</li>
			<li class="daemon-status-list-item loud"><div class="list-item-label">MD5 Hash:</div><?php 
echo CHtml::encode($model->md5);
?>
</li>
			<li class="daemon-status-list-item"><?php 
echo CHtml::link('Download Entire ZIP Archive', array('crashReport/download', 'id' => $model->id));
?>
</li>			
		</ul>
	</div>
</div>

<div class="span-18 last">

<div class="quiet">You can also download individual files contained in this crash report archive:</div>

<!-- Grid view -->
<?php 
$this->widget('zii.widgets.grid.CGridView', array('dataProvider' => $model->searchFileItems(), 'selectableRows' => null, 'columns' => array(array('name' => 'filename', 'type' => 'raw', 'value' => 'CHtml::link($data->filename, array(\'crashReport/extractFile\', \'name\'=>$data->filename, \'rpt\'=>$data->crashreport_id))'), 'description')));
Exemple #4
0
?>

<div class="span-27 last detail-group-caption">Sender Info:</div>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array(array('name' => 'geo_location', 'type' => 'text', 'value' => CrashReport::geoIdToCountryName($model->geo_location)), 'ipaddress', 'emailfrom', 'description')));
?>

<div class="span-27 last detail-group-caption">Exception Info:</div>

<?php 
$text = $model->exception_thread_id != 0 ? '0x' . dechex($model->exception_thread_id) : null;
$exceptionThread = $model->getExceptionThread();
if ($exceptionThread) {
    $link = CHtml::link(CHtml::encode('View Stack Trace'), array('crashReport/view', 'id' => $model->id, 'tab' => 'Threads', 'thread' => $exceptionThread->id));
    $text .= ' ' . $link;
}
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('exception_type', array('name' => 'exceptionaddress', 'type' => 'text', 'value' => $model->exceptionaddress != 0 ? '0x' . base_convert($model->exceptionaddress, 10, 16) : null), array('name' => 'exception_code', 'type' => 'text', 'value' => $model->exception_code != 0 ? '0x' . base_convert($model->exception_code, 10, 16) : null), 'exe_image', 'exceptionmodule', array('name' => 'exceptionmodulebase', 'type' => 'text', 'value' => $model->exceptionmodulebase != 0 ? '0x' . base_convert($model->exceptionmodulebase, 10, 16) : null), array('name' => 'exception_thread_id', 'type' => 'raw', 'value' => $text))));
?>

<div class="span-27 last detail-group-caption">Machine Info:</div>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('os_name_reg', 'os_ver_mdmp', array('name' => 'os_is_64bit', 'type' => 'text', 'value' => $model->getOsBittnessStr()), 'product_type', 'cpu_architecture', 'cpu_count')));
?>

<div class="span-27 last detail-group-caption">Resource Usage Info:</div>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array(array('name' => 'memory_usage_kbytes', 'type' => 'raw', 'value' => $model->memory_usage_kbytes != null ? MiscHelpers::fileSizeToStr($model->memory_usage_kbytes * 1024) : null), 'open_handle_count', 'gui_resource_count')));
Exemple #5
0
if ($model->statuschange) {
    echo '<div class="bug-change-status"><ul>';
    if (isset($model->statuschange->status)) {
        echo '<li>Status: ' . Lookup::item('BugStatus', $model->statuschange->status);
    }
    if (isset($model->statuschange->merged_into)) {
        echo '<li>Merged into bug: ' . CHtml::link($model->statuschange->merged_into, array('bug/view', 'id' => $model->statuschange->merged_into));
    }
    if (isset($model->statuschange->priority)) {
        echo '<li>Priority: ' . Lookup::item('BugPriority', $model->statuschange->priority);
    }
    if (isset($model->statuschange->reproducability)) {
        echo '<li>Reproducibility: ' . Lookup::item('BugReproducability', $model->statuschange->reproducability);
    }
    if (isset($model->statuschange->assigned_to)) {
        if ($model->statuschange->assigned_to >= 0) {
            echo '<li>Owner: ' . (isset($model->statuschange->owner) ? CHtml::encode($model->statuschange->owner->username) : 'user was deleted');
        } else {
            echo '<li>Owner: nobody';
        }
    }
    echo '</ul></div>';
}
foreach ($model->attachments as $attachment) {
    echo '<div class="bug-change-attach">' . CHtml::image(Yii::app()->baseUrl . '/images/file.png') . 'File attached: ' . CHtml::link(CHtml::encode($attachment->filename), array('bug/downloadAttachment', 'id' => $attachment->id)) . ' (' . MiscHelpers::fileSizeToStr($attachment->filesize) . ')' . '</div>';
}
?>
		
	
</div>
 /**
  * This is the 'uploadFile' action that is invoked
  * when a user wants to upload one or several PDB files using web GUI.	 
  */
 public function actionUploadFile()
 {
     // Check if user is authorized to perform this action
     $this->checkAuthorization(null);
     $model = new DebugInfo('create');
     $submitted = false;
     if (isset($_POST['DebugInfo'])) {
         $submitted = true;
         $model->attributes = $_POST['DebugInfo'];
         $model->guid = 'tmp_' . MiscHelpers::GUID();
         if ($model->validate()) {
             // Get uploaded file
             $model->fileAttachment = CUploadedFile::getInstance($model, 'fileAttachment');
             // This will create a new record in the {{debuginfo}} db table
             // and move the uploaded file to its persistent location.
             $model->save();
         }
     }
     // Display the result
     $this->render('uploadFile', array('model' => $model, 'submitted' => $submitted));
 }
Exemple #7
0
 /**
  * Generates a crash report geographic location distribution graph for currently 
  * selected project and dumps it to stdout.
  * @param type $w Desired image width.
  * @param type $h Desired image height.
  * @throws CHttpException
  * @return void
  */
 public static function generateGeoLocationDistributionGraph($w, $h, $file = null)
 {
     if (!is_numeric($w) || $w <= 0 || $w > 1024) {
         throw new CHttpException(403, 'Invalid parameter');
     }
     if (!is_numeric($h) || $h <= 0 || $h > 960) {
         throw new CHttpException(403, 'Invalid parameter');
     }
     // Get current project info
     $curProjectId = Yii::app()->user->getCurProjectId();
     if ($curProjectId == false) {
         throw new CHttpException(403, 'Invalid parameter');
     }
     // Prepare data
     $criteria = new CDbCriteria();
     $criteria->select = 'geo_location, COUNT(*) as cnt';
     $criteria->group = 'geo_location';
     $criteria->compare('t.project_id', $curProjectId);
     $criteria->order = 'cnt DESC';
     $curVer = '(not set)';
     $versions = Yii::app()->user->getCurProjectVersions($curVer);
     if ($curVer != -1) {
         $criteria->compare('appversion_id', $curVer == 0 ? null : $curVer);
     }
     $data = array();
     $models = CrashReport::model()->findAll($criteria);
     $totalCount = 0;
     foreach ($models as $model) {
         $totalCount += $model->cnt;
         if ($model->geo_location === null) {
             if (isset($data[''])) {
                 $data[''] += $model->cnt;
             } else {
                 $data[''] = $model->cnt;
             }
         } else {
             $data[$model->geo_location] = $model->cnt;
         }
     }
     if ($file == null) {
         $fout = fopen('php://output', 'w');
     } else {
         $fout = fopen($file, 'wt');
     }
     fprintf($fout, '<div class="digest-pane-image" style="width:' . $w . 'px;min-height:' . $h . 'px;max-height:' . $h . 'px;overflow:hidden"><table id="geo-locations">');
     // Check the case when $data is empty.
     if (count($data) == 0) {
         fprintf($fout, '<tr><td><i>No data available</i></td></tr>');
     } else {
         foreach ($data as $name => $val) {
             $percent = 100 * $val / $totalCount;
             $percentStr = sprintf('%0.1f', $percent);
             $nameStr = '(not set)';
             if ($name != '') {
                 $nameStr = MiscHelpers::addEllipsis(CrashReport::geoIdToCountryName($name), 30);
             }
             fprintf($fout, '<tr><td>' . $nameStr . '</td><td>' . $percentStr . '%%</td></tr>');
         }
     }
     fprintf($fout, '</table></div>');
     if ($file != null) {
         fclose($fout);
     }
 }
Exemple #8
0
	
	<?php 
    if (Yii::app()->user->checkAccess('pperm_browse_debug_info', array('project_id' => Yii::app()->user->getCurProjectId()))) {
        ?>
	
	<div class="span-9 loud prepend-top">
		<div class="digest-pane" style="height:240px;">
		<div class="subheader" title="Displays how many debug info files were uploaded for this project">Debug Info Totals (All Versions)</div>
			<ul class="totals">
                <li>
                <?php 
        $totalFileSize = 0;
        $percentOfDiskQuota = 0;
        $fileCount = Yii::app()->user->getCurProject()->getDebugInfoCount($totalFileSize, $percentOfDiskQuota);
        $percentOfDiskQuotaStr = sprintf("%.0f", $percentOfDiskQuota);
        echo $fileCount . ' files (' . MiscHelpers::fileSizeToStr($totalFileSize);
        if ($percentOfDiskQuota > 0) {
            echo ', ' . $percentOfDiskQuotaStr . '% of disk quota';
        }
        echo ')';
        ?>
                
                <?php 
        $this->widget('zii.widgets.jui.CJuiProgressBar', array('value' => $percentOfDiskQuota, 'options' => array(), 'htmlOptions' => array('style' => 'height:20px;margin:5px')));
        ?>
                </li>
            </ul>
		</div>
	</div>
	
	<div class="span-18 last prepend-top">	
Exemple #9
0
    $this->widget('zii.widgets.grid.CGridView', array('dataProvider' => $dataProvider, 'selectableRows' => null, 'columns' => array(array('class' => 'CCheckBoxColumn', 'id' => 'DeleteRows', 'selectableRows' => 2), array('name' => 'id', 'cssClassExpression' => '"column-right-align"'), array('name' => 'filename', 'type' => 'raw', 'value' => 'CHtml::link($data->filename, \'view/\'.$data->id)'), array('header' => 'Size', 'name' => 'filesize', 'value' => 'MiscHelpers::fileSizeToStr($data->filesize)', 'cssClassExpression' => '"column-right-align"'), array('header' => 'Status', 'name' => 'status', 'value' => '$data->getStatusStr()', 'cssClassExpression' => '$data->status==DebugInfo::STATUS_INVALID?"status-invalid":""'), array('name' => 'guid', 'value' => '(isset($data->guid) && substr($data->guid, 0, 4)!="tmp_")?$data->guid:"n/a"'), array('name' => 'dateuploaded', 'value' => 'date("d/m/y H:i", $data->dateuploaded)'))));
    ?>
 </div>
  
 <?php 
    echo CHtml::endForm();
    ?>
 </div>

<div class="span-27 last footnote">
	<?php 
    $curVer = "";
    $totalFileSize = 0;
    $percentOfQuota = 0;
    $count = Yii::app()->user->getCurProject()->getDebugInfoCount($totalFileSize, $percentOfQuota);
    $totalFileSizeStr = MiscHelpers::fileSizeToStr($totalFileSize);
    $percentOfQuotaStr = sprintf("%.0f", $percentOfQuota);
    echo "This project contains total {$totalFileSizeStr} in {$count} file(s)";
    if ($percentOfQuota >= 0) {
        echo " ({$percentOfQuotaStr}% of disc quota).";
    }
    ?>
 	
</div>

 <?php 
    $script = <<<SCRIPT
\$(":checkbox").live('click', function(e)
{\t
\tvar totalSelected = 0;
\t\$("input[name='DeleteRows\\[\\]']").each(function() {if(\$(this).attr('checked')) totalSelected++;});
Exemple #10
0
 /**
  * Imports debug info files for certain project version.
  * @param string $dirName  Directory name.
  * @param string $projectId Project ID.
  * @param string $projVer  Project version.
  * @return integer count of debug info files imported; or -1 on error.
  */
 private function importDebugInfo($dirName, $projectId, $projVerId)
 {
     //echo 'Importing debug info files from dir: '.$dirName.'\n';
     // Get file list in the directory
     $fileList = scandir($dirName);
     if ($fileList == false) {
         Yii::log('Directory name is invalid: ' . $dirName, 'error');
         return -1;
     }
     // Walk through files
     foreach ($fileList as $file) {
         // Get abs path
         $path = $dirName . '/' . $file;
         // Strip file parts
         $path_parts = pathinfo($path);
         if ($file != '.' && $file != '..' && is_file($path) && strtolower($path_parts['extension']) == 'pdb') {
             //echo 'Importing debug info file: '.$path.'\n';
             // Create new AR record
             $debugInfo = new DebugInfo();
             $debugInfo->project_id = $projectId;
             $debugInfo->guid = 'tmp_' . MiscHelpers::GUID();
             $debugInfo->fileAttachment = new CUploadedFile($file, $path, 'application/zip', filesize($path), '');
             // The following is to copy attachment file correctly.
             $debugInfo->fileAttachmentIsUploaded = false;
             // Save changes to database
             if (!$debugInfo->save()) {
                 Yii::log('Could not import debug info file:' . $path, 'error');
             } else {
                 $this->_importedDebugInfoCount++;
             }
         }
     }
     // Done
     return $this->_importedDebugInfoCount;
 }
Exemple #11
0
 /**
  * This method is executed before AR is saved to database.
  * In this method, we set some model attributes.
  * @return boolean True on success.
  */
 protected function beforeSave()
 {
     if (!parent::beforeSave()) {
         return false;
     }
     // Check if this is a new record.
     if ($this->isNewRecord) {
         // Set project id
         $this->project_id = Yii::app()->user->getCurProjectId();
         // Set project version
         $curVer = false;
         $versions = Yii::app()->user->getCurProjectVersions($curVer);
         if ($curVer != Project::PROJ_VER_ALL) {
             $this->appversion_id = $curVer;
         } else {
             // Project version '<all>' currently selected.
             // We have to determine bug version from associated
             // crash reports/collections.
             $numbers = MiscHelpers::splitNumberList($this->crashgroups);
             foreach ($numbers as $number) {
                 $crashGroup = CrashGroup::model()->findByPk($number);
                 if ($crashGroup === Null) {
                     throw new HttpException('Invalid crash group ID');
                 }
                 $curVer = $crashGroup->appversion_id;
                 break;
             }
             if ($curVer == -1) {
                 $numbers = MiscHelpers::splitNumberList($this->crashreports);
                 foreach ($numbers as $number) {
                     $crashReport = CrashReport::model()->findByPk($number);
                     if ($crashReport === Null) {
                         throw new HttpException('Invalid crash report ID');
                     }
                     $curVer = $crashReport->appversion_id;
                     break;
                 }
             }
             if ($curVer == -1) {
                 throw new CHttpException(403, 'Invalid request');
             }
             $this->appversion_id = $curVer;
         }
         // Set date created
         $this->date_created = time();
         // Set date last modified
         $this->date_last_modified = $this->date_created;
         // Set reported by
         $this->reported_by = Yii::app()->user->id;
         if ($this->assigned_to < 0) {
             unset($this->assigned_to);
         }
     } else {
         // Set date last modified
         $this->date_last_modified = time();
         if ($this->status > Bug::STATUS_OPEN_MAX) {
             $this->date_closed = $this->date_last_modified;
         } else {
             unset($this->date_closed);
         }
     }
     // Success.
     return true;
 }
Exemple #12
0
<?php

return array('showErrorSummary' => true, 'attributes' => array('enctype' => 'multipart/form-data'), 'elements' => array('fileAttachment' => array('type' => 'file'), 'guid' => array('type' => 'hidden', 'value' => 'tmp_' . MiscHelpers::GUID())), 'buttons' => array('upload' => array('type' => 'submit', 'label' => 'Upload')));
Exemple #13
0
<!-- Actions Toolbar -->
<div class="span-18 last">
	<div class="div_actions">
		<?php 
echo CHtml::form();
?>
		
		<?php 
echo CHtml::hiddenField('id', $model->id);
?>
		
		<?php 
echo CHtml::link('Download File', $this->createUrl('/debugInfo/download', array('id' => $model->id)));
?>
		<?php 
echo CHtml::link('Delete File', $this->createUrl('/debugInfo/delete', array('id' => $model->id)));
?>
		<?php 
echo CHtml::endForm();
?>
	
	</div>	
</div>

<!-- Detail View -->
<div class="span-18 last">
<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array(array('name' => 'dateuploaded', 'type' => 'text', 'value' => date("d/m/y H:i", $model->dateuploaded)), 'filename', array('name' => 'status', 'type' => 'text', 'value' => $model->getStatusStr()), array('name' => 'filesize', 'type' => 'raw', 'value' => CHtml::encode(MiscHelpers::fileSizeToStr($model->filesize))), array('name' => 'guid', 'type' => 'text', 'value' => substr($model->guid, 0, 4) != "tmp_" ? $model->guid : "n/a"), 'md5')));
?>