Laravel - retrieval of log info to display on view - laravel-5.4

I'm trying to keep a Log of all the activities that a user performs (from clicking on Login button to all the CRUD operation) in my application.
Eg - When the user clicks on a 'Create Item' button I wish to log info(when it was created, what was created, by whom etc.) in a separate file under /storage/logs/my_own_file.log.
I have been able to do that using the Log::info and Log:useDailyFiles() function.
Now whatever information I wish to display from the Log files, should come on some view(assume a random view page). I have thought of extracting the Log files info in JSON format so that I can pass that variable in the view.
I don't know how to go about it as of now.
This the Log file when I click on the Edit button
This is the Log file when I click the Submit button
For the time being assume, I want the timestamps(individually) and the id as JSON format

You should consider storing an activity log in a database instead of the files, you won't be stuck parsing that way. I use this package on several of my projects:
https://github.com/spatie/laravel-activitylog
This gives you much more flexibility in what you save and how deep in the application stack you can access.

Related

Coldfusion - Is it possible to export query data to csv without querying the function again?

I have a cfml page where I display the data and have the ability to download it. I would want to run the page to view the data and when clicked to download it without again hitting the DB to fetch the data. Is this possible to view and download only with one single request to DB?

Return an uploaded file for resubmission in MVC

My use case is this:
User has a file to upload.
File is validated and various metadata is returned to the user.
User now decides whether to commit the file of not.
Part three is the new bit. Currently the user just uploaded the file, it's committed and information about what happened is returned. I'm having to put in the middle bit.
I've added a boolean supressCommit that allows the file to be uploaded, the information to be gathered but then the committing not to take place.
Now I have a problem, I don't want to introduce state on the server and store the file contents there. That would open up a whole other can of worms. This means that if the user clicks the commit button on the confirmation page I have to upload the file again, this time with suppressCommit set to false.
It's not pretty, but acceptable. My problem is this though, how can I re-upload the original file without the user having to go through selecting the file again?
My options seem to be:
Pass the file contents back in the model.
Not great as now I'll have to somehow put those into the HTTP request manually so they show in the RequestContext in the Request.Files collection.
Pass back the original file path.
If I do this then is it possible to pragmatically set the File input box to something or is that a security violation?

Sharepoint mail enabled library receives csv file, import into list

I am wondering what the best approach is (if any) to handle this scenario:
I will set up a mail enabled library to which an external party can send emails with a csv file attached.
What i want to do next is, on each received file into this library (or even once a day process them all) use this csv file and import it into a list for easier viewing.
I was thinking to create a custom workflow on item added that opens the csv file and imports it into another list.
Are there better/easier setups?
I'd say an event receiver may be more suitable for the scenario. That way you can capture the CSV file, extract it's contents, and add each line as an item. I use event receivers for a one-hop event, and workflows as mutiple hops (approvals, feedback, etc.).
Here is more on event receivers: http://msdn.microsoft.com/en-us/library/ee231563.aspx

Temporarily disable MS Access data macros

I have several Access files with data from a group of users that I'm importing into one master file. The tables in the user files are each configured with a Before Change data macro that adds a timestamp each time the user edits the data.
("Data macros" are similar to triggers in SQL Server. They are different from UI macros. For more info, see this page.)
I'd like to import these timestamps into the master file, but since the master file is a clone of the user files, it also contains the same set of data macros. Thus, when I import the data, the timestamps get changed to the time of the import, which is unhelpful.
The only way I can find to edit data macros is by opening each table in Design View and then using the Ribbon to change the settings. There must be an easier way.
I'm using VBA code to perform the merge, and I'm wondering if I can also use it to temporarily disable the data macro feature until the merge has been completed. If there is another way to turn the data macros off for all files/tables at once, even on the users' files/tables, I'd be open to that too.
Disable the code? No. Bypass the code? Yes.
Use a table/field as a flag. Set the status before importing. Check the status of this flag in your event code, and decide if you want to skip the rest of the code. I.e.
If [tblSkipFlag].[SkipFlag] = false
{rest of data macros}
EndIf
Another answer here explains how you can use the (almost-)undocumented SaveAsText and LoadFromText methods with the acTableDataMacro argument to save and retrieve the Data Macros to a text file in XML format. If you were to save the Data Macro XML text for each table, replace ...
<DataMacro Event="BeforeChange"><Statements>
... with ...
<DataMacro Event="BeforeChange"><Statements><Action Name="StopMacro"/>
... and then write the updated macros back to the table then that would presumably have the effect of "short-circuiting" those macros.

Href - File Name taken from mysql database

I currently have a form that uploads the data via PHP to a PDF form and that form is generated and saved on my ftp server. The data is also posted to a mysql database and the name of the file name for the pdf is the unique id of the mysql record (eg. 85124.pdf)
I would like to set up a link where the user can print the generated PDF file as a receipt but cannot figure out how to have the link call up the specific file for that specific record.
For example:
pdf - where the filename would be the same as the unique mysql id (eg. 85124). Is this possible?
I see that I may not have stated properly what I am trying to do and in what enviornment.
I have a page set up where users/clients can book their shipments online ( I work for a small shipping company). The user puts in their shipping adress and such and once they hit the submit button the following happens:
The data is sent to a mysql database on my host (godaddy) and the table is populated with that specific record. The unique id becomes the tracking number for the shipment.
$tracking=mysql_insert_id;
The data is also sent as a FDF file to my ftp and stored in a folder. The name of the FTP is determined by what the the tracking number is after it is put into the mysql database.
$fdf_file=$tracking().'.fdf';
$fdf_dir=dirname(__FILE__).'/results';
The data is then placed into a PDF form that is on my ftp.
$pdf_doc='https://www.mysite.com/shipformrso.pdf';
On the screen after the form is submitted the client receives a confirmation that their from was completed properly and they are given their tracking number.
echo "<font color='red' size='+1'><b>" . 'Your tracking number is '.$tracking() . '. <n\> PLEASE PROCEED TO THE SERVICE DESK TO RECOVER YOUR LABELS.' ."</b></font>";
What I would like to do is have another link where the user can click on and have the browser open up the FDF/PDF file was generated for their specific shipment. This is where I have the problem. I can't seem to figure out how to create the link specific file that was just generated.
Thanks for any help.
As much as I understand, you don't want to show the pdf printing link to your users? At least, the id of the pdf file, which is plainly holded in the db? Then, you can hash your id, POST it to the server and decrypt it on server side then proceed to pdf showing/printing page. In this way no user can understand the hash data, and how to decrypt it. Only your server side script does.;)
For ex:
When user enters here:
blabla.com/?id=SOME_HASHED_VALUE
On the server side:
You decrypt it, and make the SOME_HASHED_VALUE to look like this: 45869 - which is the unique id holded in the db. And then proceed normal flow. ;)