Jump to content

M.O.S. Studios

Members
  • Posts

    282
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

M.O.S. Studios's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

2

Community Answers

  1. Figured it out. Here is my round about way to take a CSV file, and visualize it as a table. <?php require('fpdf.php'); $file = file.csv'; function near5($v){ return round($v * 2) / 2; } function content($file){ $header = array(); if (($handle = fopen($file, "r")) !== FALSE){ $body = array(); $header = fgetcsv($handle); $header[0] = 'Category/Weight(Lbs)'; while (($data = fgetcsv($handle)) !== FALSE){ $body[] = $data; } fclose($handle); } return array($header, $body); } class PDF extends FPDF{ // Simple table function BasicTable($header, $data, $kcal){ // Header $first = 30; foreach($header as $col){ $v = is_numeric($col) ? round(($col*2.2),1) : $col; $this->Cell($first,7,$v,1,0,'C'); $first = 10; } $this->Ln(); // Data foreach($data as $row){ $first = 30; foreach($row as $col){ $v = (is_numeric($col)) ? near5($col/$kcal) : $col; $this->Cell($first,7,$v,1,0,'C'); $first = 10; } $this->Ln(); } } } // Column headings content($file); list($header, $row) = content($file); // Data loading $pdf = new PDF(); $pdf->SetFont('Arial','',5); $pdf->AddPage(); $pdf->BasicTable($header,$row, $kcal); $output = $pdf->Output('S'); $im = new imagick(); $im->setResolution(300, 300); $im->readImageBlob($output); $im->setImageFormat('png'); $im->setImageCompression(imagick::COMPRESSION_JPEG); $im->setImageCompressionQuality(100); $im->borderImage("#ffffff", 20, 20); $im->trimImage(0.3); $im->setImagePage($im->getImageWidth(), $im->getImageHeight(), 0, 0); header("Content-Type: image/" . $im->getImageFormat()); echo $im->getImageBlob(); $im->clear(); $im->destroy(); ?>
  2. So I was working on this for a bit, and I found a round about way to do it. It requires FPDF, and Imagick. <?php require('fpdf.php'); $file = 'file.CSV'; $kcal = 2000 / 1000; function near5($v){ return round($v * 2) / 2; } function content($file){ $header = array(); if (($handle = fopen($file, "r")) !== FALSE){ $body = array(); $header = fgetcsv($handle); $header[0] = 'Category/Weight(Lbs)'; $w = 20 + (count($header)*10); $h = 7; while (($data = fgetcsv($handle)) !== FALSE){ $body[] = $data; $h += 7; } fclose($handle); } return array($header, $body, $h, $w); } class PDF extends FPDF{ // Simple table function BasicTable($header, $data, $kcal){ // Header $first = 30; foreach($header as $col){ $v = is_numeric($col) ? round(($col*2.2),1) : $col; $this->Cell($first,7,$v,1,0,'C'); $first = 10; } $this->Ln(); // Data foreach($data as $row){ $first = 30; foreach($row as $col){ $v = is_numeric($col) ? near5($col/$kcal) : $col; $this->Cell($first,7,$v,1,0,'C'); $first = 10; } $this->Ln(); } } } // Column headings content($file); list($header, $row, $h, $w) = content($file); // Data loading $pdf = new PDF(); $pdf->SetFont('Arial','',5); $pdf->AddPage(); $pdf->BasicTable($header,$row, $kcal); $output = $pdf->Output('f.pdf','F'); $imagick = new Imagick(); $imagick->readImage('f.pdf'); $imagick->setImageCompressionQuality(100); $imagick->setResolution($w*500,$h*500); $imagick->borderImage("#ffffff", 20, 20); $imagick->trimImage(0.3); $imagick->setImagePage($imagick->getImageWidth(), $imagick->getImageHeight(), 0, 0); $imagick->setImageFormat("png"); header("Content-Type: image/" . $imagick->getImageFormat()); echo $imagick->getImageBlob(); unlink('f.pdf'); two problems and this would work perfectly. 1. The resolution is awful. I tried messing around with the settings; I couldn't figure it out. Any ideas? 2. I'd prefer to have it where it doesn't save the PDF file. Is there a way I can send it to imagick without saving the file? Here is the CSV File heaading,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13,h14 Row1, 2,3,4,5,6,7,8,9,10,11,12,13,14 another,12,13,14,15,16,17,18,19,110,111,112,113,114
  3. I haven't had time until now to work on this project. I am going to take a crack at it now. these images are going to be accessed by a design program that can grab photos from a url. Since there is no browser directly involved, I don't think javascript would work. Thanks for the link! I will take a look at the library
  4. At first glance this is what I am looking for. yeah, I wanted to arrange the data as a chart, like how it would be displayed if it was opened in excel. I am going to see if I can work with what you sent me
  5. Php has lots of libraries and functions to turn text into an image. I want to take a CSV file, and use the values to create a JPG image Here is an example of what I am looking for. This requires Java, which I don’t have
  6. I ended up starting over and it worked :/. Don’t know what I did differently
  7. Hey everyone! I’m convert a CSV file into a Jpg file using php. so, the script would take the information from the CSV file, and create a visual version that can be viewed on program that displays JPG. anyone of a script that does that? i was thinking of making it from scratch, but thought I might be reinventing the wheel
  8. excellent! ill try it all again, and look at the files. The html source was of the page sending the request on my end! I had the response sent to the console.log() function so I can more closely examine it. I was getting source code for the html page I wrote to send it
  9. Hey everyone, I’m trying to write an api call to the Trexity API. They have some documentation here. I’ve used apis before, and it’s never been an issue. However I have been trying to get a curl command to connect and I can not. I have an API token, tried using the ‘Bearer’ authentication and I either get a 500 error, or it sends back a response; but it’s just the html source of the page that is sending it. normally I’d attach source code, but I rage deleted it a few days ago. I was hoping someone could maybe take a look at the documentation and let me know if they notice anything unusual… only thing I see is it uses openAPI; and I don’t know what that is I will be making the code again. If I have the same issue, I’ll post the code here thanks everyone
  10. Would this be safe? I believe its possible for one website to read cookies from another. Couln't they copy that cookie to access the site?
  11. Hey everyone, I am working on a project for fun. This is a LAMP application that is going to run on my intranet server, and hold NO VALUABLE data. I am doing it just to get better at programming, and learn some best practices and techniques. at this point, I am working on some things, and I don't know what the best practices are. Can someone help me go down the pest route? 1. A log-in system and I want to include a "remember me" button. What is the best practice for this? Obviously leaving user data in a cookie is asking for trouble, so I was thinking of leaving a unique id of some sort? 2. Information in a login SESSION. What information do you put in a log in session? I have seen lots of different techniques on this. I don't really know which is the best. For the moment, I keep an array like this: array('Status'=>True, 'Username'=>'Users name" ,'email'=>'users Email'). If a hacker can inject session information, this seems like it would be really easy to break, because they only need a user's name and email to gain access. Is there something more I should do? 3. Config file that holds Mysql Information. I made a file that contains all the values that might change over time. That way I only need to change it in one spot. In this file I have things like the Mysql Database information. Should these files be encrypted? Or can I use a .htaccess file to make sure it isn't accessible to a hacker (as I mentioned before, this isn't a project that's going live, its more of an exercise to help me learn) Thanks everyone
  12. I’m asking for educational purposes, I think understanding why is as important as how. so, if I understand correctly, the idea is it strictly prevents comparing hashed password together. So one cracked password doesn’t unlock them all?
  13. Maybe I am using the wrong terminology. if someone got a hold of the DB, the can see the $2y$10$ And assume that’s how it was encrypted. Then run a list of common passwords through password_validate along with the hash. if it tests each hash against the most common passwords, words, etc.. first, then worked its way down to the least common, it could in theory works out the majority of information.
  14. Hey everyone, I’m working on an app for my local intranet sever. My security needs are almost non existent, because it’s only accessible on my local network. Even if someone wanted to mess with it, the only thing this app controls is my fish tank! Yup, it just shows me some information about my water, and let’s me turn on and off devices. So I’m not too worried about it. That being said, I want to add a password just to keep my coding skills sharp, as I haven’t done anything with php in a while. That being said, I would like some help understanding something... while looking up the best practices for working with passwords, I found password_hash and password_verify... don’t these two function completely negate the advantages of salting a password? my understanding is that salting a password makes using a rainbow table impossible. However, what’s stopping someone from just doing a dictionary attack with the password_verify function? as I said above, my application doesn’t require a lot of security, I’m asking for educational reasons
  15. Hey everyone, I’m pretty new to python, but have done a lot of coding with php and JavaScript. here is what I am hoping to do. i want to write a script that will do the following: 1. scan sub directory make an array with the names of each of the files 2. iterate through the files using the array, and make either a object, or a function using the file name (without the extension) as the name, and the contents for the code 3. Run the function/create object that were just created, and with known variables I’m pretty sure I can figure out step one and three. It’s step two that’s giving me problems. I tried using the open() function, and eval(), but it’s giving me some problems, and that feels like a ‘janky’ way to do it. this is for a raspberry Pi project I’m using to control the equipment on my fish tank. The idea is I can write code for each sensor individually, and the program will automatically be able to incorporate it. I’d just have to drop it into the folder any suggestions?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.