By default, Excel Office 2000-XP-2003 disables the ability to execute third-party macros. AT excel go to the menu Tools>>Macro>>Security. On the tab " Trusted Publishers» Check the box « Trust Access Visual Basic project»

Setting Office 2007
1) "Office" button

2) Trust Center >> Security Center Options


3) Macro settings >> check the box "Trust access to object model VBA projects"

The summary report is prepared according to active data! Those. The selections of the “selection panel” (filters, but not groupings of tables), the “Income”, “Expense” tabs are superimposed on it....

To build charts in Excel, click Insert >> Chart in the summary report, select the data in the chart preparation wizard. Read more in the MS Office help section "Pivot tables".

The report is guaranteed to work in rus-en versions of Windows.

Reports in Excel are created based on templates. Pluggable templates are located in the folder My Report in the Home Finance folder, based on them, you can create own templates that will be available in the program.

Brief report allows you to print the contents of a table with a different mechanism for calculating totals.

A versatile reporting tool is upload to HTML corresponding tables, while retaining all settings and groupings. Open HTML document can be opened in almost any MS Office application.

In this tutorial, we will learn such a thing as hiding PHP errors. Along the way, we will also look at how not only to suppress the output of these errors, but also how to write them to a log file, how to protect this log file, how to set the PHP error reporting level (how serious errors to show, whether to show warnings), learn how to set maximum size error lines and turn off the recording of repeated errors.

Should PHP errors be hidden?

PHP errors give a wide variety of information that allows attackers to collect data about your site and your server. But if there was an unequivocal answer to this question “yes”, then everything would be solved by adding one single line to each file with PHP programs

error_reporting(0);

In fact, all errors, including warnings (non-critical errors), should be displayed at the testing stage. The output of errors and warnings will also help to understand the existing (or possible) problems in the working environment. Do not suppress error and warning output in programs intended for free distribution, because if problems arise, all user reports of problems will be the same: “there is a white screen”, which will make it very difficult to try to figure it out.

In general, on development servers (for example, home server), you don't need to clean up PHP errors and warnings with methods error_reporting(0); and @ - you need to study their causes and correct them source.

On working servers, it is highly recommended not to show everyone the errors that occurred in the PHP code, but it is recommended not only to suppress their display, but also to keep a log of them, write them down for system administrator and for a PHP programmer - from these logs they will receive important information about possible problems site/server.

How to enable PHP error logging with .htaccess

In this part of the tutorial, I will show Apache users how to suppress PHP error output and hide them from visitors, while logging PHP errors for further analysis will be enabled, all this configuration will be done through the .htaccess file.

In general, this method has another great advantage - instead of trying to catch all PHP errors and warnings, we will write each of them to our personal log, thanks to this, not a single error will escape, even if it did not occur to you, and someone who visits your site under conditions that, perhaps, would not even have occurred to you for modeling. Thanks there is an easy way to implement this effective strategy.

Hiding PHP errors from visitors

There is different ways suppress PHP errors with .htaccess. This can be done by including the following .htaccess directives in your domain's httpd.conf file or in the root (or any other target directory) of the .htaccess file with the following content:

# suppress php errors php_flag display_startup_errors off php_flag display_errors off php_flag html_errors off php_value docref_root 0 php_value docref_ext 0

This will cause PHP errors to no longer be public on your site. This eliminates potential security risks, and keeps those ugly, obscure PHP errors from breaking your site layout and confusing your visitors. No code editing is required for this.

Enabling Personal PHP Error Logging

Now that we've hidden PHP errors from the public, let's enable logging so we can track them down. This is done by adding the following .htaccess directives to your domain's httpd.conf file or to your .htaccess file located in the root (or any target) directory.

# inclusion PHP entries php_flag errors log_errors on php_value error_log /home/path/public_html/domain/PHP_errors.log

For this to work, you need to edit the path on the last line to match the actual location of your PHP_errors.log file. Of course, along with that, you need to create this file and give it permissions of 755 or 777 if needed. Finally, you need to secure this log file by adding these final lines of code to your .htaccess file:

# prevent access to the PHP error log

Now that everything is in place, check that everything works as it should, raise a few PHP errors. You may also want to test the security of your log file by trying to access it through a browser.

Advanced PHP Error Handling with .htaccess

Let's now dive deeper into this topic, add additional functionality and explore various implementations. We will first look at PHP error handling for the production environment (e.g. websites and applications that are online, active and public), then we will look at error handling for the developer environment (e.g. projects under development, testing , private, etc.).

PHP error message level control

Using .htaccess it is possible to customize the level of error reporting that suits your practical needs. The general fort for controlling the PHP error rate is as follows:

# general view of the directive for setting the php error level php_value error_reporting number

There are several common values ​​that can be substituted for "number", including:

  • The most complete error message(corresponds to E_ALL) - for this, use the value "32767".
  • Full error message- for full logging of PHP errors, use the value "8191", which will include the logging of everything except runtime notices about the use of deprecated constructs (warnings about code that will not work in next versions PHP).
  • Zend error message- to record both fatal and non-fatal compile-time warnings generated by the Zend scripting engine, use "192".
  • Basic Error Message- record runtime notifications. Indicate that something happened during the execution of the script that may indicate an error, although this may also occur during normal program execution. To do this, use the number "8".
  • Minimum error message- Log only fatal run-time errors. These are errors that cannot be recovered by means of the script itself, such as a memory allocation error, etc. Execution of the script in this case is terminated. To do this, use the number "1".

Of course, you can use other values ​​("numbers") for fine tuning what kind of errors you want to fix. Some clarification on this issue at the very bottom.

Setting the maximum file size for your error records

Using .htaccess you can define the maximum size for your PHP errors. This means controlling the size of each recorded error, and not the entire file as a whole. The syntax is as follows:

# general directive for setting the maximum error size log_errors_max_len integer_number

Here "integer_number" represents the maximum size of each recorded error line in bytes. The default value is "1024" (i.e. 1 kilobyte). To remove this limit, you can set the value to "0". Note that this value also applies to displayed errors when they are enabled (for example, during development).

Disable logging of recurring errors

If you have already worked with the error log, you may have noticed that there are many similar entries in it, which differ only in the time of the event. You can get rid of this redundancy by simply adding these lines to your htaccess file:

# disable logging of repeated errors php_flag ignore_repeated_errors on php_flag ignore_repeated_source on

With these settings, repeated errors will not be logged, even if they occur in different sources or addresses. If you want to disable recurring errors from only one source or file, just comment out or remove the last line. Conversely, to make sure your event log file includes all recurring errors, change both values ​​from on on the off.

Putting it all together - working environment

Having discussed the specifics of configuring PHP error recording, let's gather all of our error recordings into a single .htaccess file. These settings are optimized for the working environment.

# обработка ошибок PHP для рабочего сервера php_flag display_startup_errors off php_flag display_errors off php_flag html_errors off php_flag log_errors on php_flag ignore_repeated_errors off php_flag ignore_repeated_source off php_flag report_memleaks on php_flag track_errors on php_value docref_root 0 php_value docref_ext 0 php_value error_log /home/path/public_html/domain/PHP_errors. log php_value error_reporting -1 php_value log_errors_max_len 0 Order allow,deny Deny from all Satisfy All

If you consider code with explanations to be good style, then the same code, but with comments:

# PHP error handling for production server # disable display of startup errors php_flag display_startup_errors off # disable display of all other errors php_flag display_errors off # disable html errors markup php_flag html_errors off # enable error logging php_flag log_errors on # enable ignoring repeated errors php_flag ignore_repeated_errors off # disable ignoring errors from unique sources php_flag ignore_repeated_source off # enable php memory leak logging php_flag report_memleaks on # save most recent mistakes via php_errormsg php_flag track_errors on # disable formatting error reference links php_value docref_root 0 # disable formatting error reference links php_value docref_ext 0 # specify path to php error log file php_value error_log /home/path/public_html/domain/PHP_errors.log # specify entry all php errors php_value error_reporting -1 # disable max error string length php_value log_errors_max_len 0 # protect error log file from public access Order allow,deny Deny from all Satisfy All

The above strategy is ideal for a public server in a production environment. All errors are hidden from prying eyes, while they are carefully collected for administrators and programmers. Of course, you can customize the above directives to suit your needs perfectly. Now let's look at the error handling strategy for the development environment.

Putting it all together - the development environment

When developing or debugging a program, it is more convenient to track PHP errors in real time, right in the browser. An example .htaccess with the appropriate settings for the development environment is shown below:

# работа с ошибками PHP для серверов разработчиков php_flag display_startup_errors on php_flag display_errors on php_flag html_errors on php_flag log_errors on php_flag ignore_repeated_errors off php_flag ignore_repeated_source off php_flag report_memleaks on php_flag track_errors on php_value docref_root 0 php_value docref_ext 0 php_value error_log /home/path/public_html/domain/PHP_errors .log php_value error_reporting -1 php_value log_errors_max_len 0 Order allow,deny Deny from all Satisfy All

We will not explain each line - you can see the corresponding explanations a little higher.

Hints

To find out the absolute path to the log file on the server using PHP methods (for the php_value error_log directive)

echo dirname(__FILE__);

Example .htaccess for .

php_flag display_startup_errors on php_flag display_errors on php_flag html_errors on php_flag log_errors on php_flag ignore_repeated_errors off php_flag ignore_repeated_source off php_flag report_memleaks on php_flag track_errors on php_value docref_root 0 php_value docref_ext 0 php_value error_log C:ServerdatahtdocsPHP_errors.log php_value error_reporting -1 php_value log_errors_max_len 0 Order allow,deny Deny from all Satisfy All

Does not work

This method is not applicable on hostings where PHP works as CGI(possible solutions will be shown in the next article).

-1 and ~0 to display all PHP errors

In directive php_value error_reporting to display all errors, you can specify -1 or ~0 . Those. the lines look like this:

php_value error_reporting -1 php_value error_reporting ~0

Moreover, it is the second method that is considered more correct, i.e. using ~0 .

Predefined constants and bitwise error_reporting operations

  • Predefined Constants
  • Bitwise Operators

For example, if we want to write ONLY the following errors E_ERROR (value 1), E_WARNING (value 2), E_CORE_ERROR (value 16), then in order to obtain the corresponding numerical value, it would be necessary to convert these values ​​into binary numbers and perform the corresponding bitwise operations, and then the resulting binary number convert to decimal. However, this operation can be simplified - just add the values ​​\u200b\u200bof decimal numbers. Those. in our case it is 1+2+16=19

php_value error_reporting 19

will display E_ERROR, E_WARNING and E_CORE_ERROR errors.

An example of an absolute path to a log file on Hostland hosting (for the php_value error_log directive)

/home/host900456/website/blogs/htdocs/www/PHP_errors.log

Instead of host900456 you need to enter your account.

Instead of website you need to specify your domain.

By the way, good hosting, which runs this very site. Recommended!

The article describes the functionality that is available in PHP (relevant for 5.3.x) for handling all types of errors, including code interpretation errors (E_ERROR, E_PARSE, E_WARNING, etc). This processing will help you to manage the display of the page in case of such problems. The article contains a lot of descriptions and working examples (architecture) in order to immediately use it in your software product. In the end, well, they broke the site a little, well, it’s necessary to inform the search engine about this with the heading 4xx or 5xx and amuse the user, instead of returning white screen(or worse than a screen with sacred information, for hackers) with a 200 Ok response.

The idea to write this topic arose when I bravely asked 2 questions:

  • Question about
  • Question about
According to my karma and adding to favorites, I realized that they turned out to be interesting for the PHP habra community. For this reason, I decided to issue solutions to these issues in the form of an article, so that it would be easier and more comprehensive for people and search engines to find the information they need.

If you are interested, then the details are under the cut ...

Reasons for use

The user / search engine needs to clearly answer that there are problems on the server. Without the use of a certain Feng Shui, this is quite difficult to achieve, and sometimes impossible. Here I shed light on all this, well, I leave a note for myself, since a week ago I did not know what to do, and, probably, many beginners will also be discouraged.

Feature Descriptions

This functionality is available in PHP to handle errors and control output. Here is a description of their goodies and shortcomings. I will not provide documentation, I will only refer to its pages and describe my opinion. All that will be given is only a small fraction, I will provide links to the relevant sections of the documentation at the end of the article. So let's meet:

- Control of non-critical errors: notes, warnings, custom errors. In general, everything that does not end the interpretation abnormally.
set_error_handler - Sets user defined error handler.
It is needed in order to write all such errors to the log. If it is not set, then it is not written to the log, but I always want to know under what combat situations comments and warnings can be called. That is, it allows the user to automatically test the product and he will not even notice it.
If the function is not set, then PHP only tries to display data on the screen, and if it is not given this, then there are no signs of life at all from these types of errors.

- Control, exceptions: is an error of type E_ERROR.
set_exception_handler - Sets a custom exception handler
Well, I don’t know why it was invented at all, when there is what is described below and just handling an error of type Exception. So I report that it simply exists. She intercepts critical error"exception" and allows you to do something with it. Either way, the script ends. Her work by default is enough for me personally (writes to the logs, tries to display). I would not redefine it at all, otherwise I would have to write to the logs about the exception that happened.

- Output control functions: Here I will describe 3 functions that you should know for different reasons. For example, for or for header output issues. In our case, we need to display error headers.

Terms
There is a file with code that runs first or before the code in which an error may occur, and this file and all files before it are 100% debugged with the impossibility of an error. Here is a condition that would be easier - without errors until all the registrations of the above functions pass. This file describes these methods of error control in the complex. The buffer is controlled, if there is an error, then reset the buffer and display the error.
Code with comments
I’ll add on my own that I didn’t test the code, since this is a simplified diagram of what I have in the code, comments are accepted

Most functionality available at launch AI-BOLIT scanner in mode command line. This can be done both under Windows/Unix/Mac OS X, and directly on the hosting, if you have SSH access and the hosting does not severely limit the consumed processor resources.

Please note that a console version of PHP 5.3 or later is required to run the scanner. Version 5.2 will have the error "Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ")" in /home/XXX/ai-bolit.php on line...". Check current version php -v command

AI-BOLIT Scanner Command Line Parameter Reference

Show help

php ai-bolit.php --help

php ai-bolit.php --skip=jpg,png,gif,jpeg,JPG,PNG,GIF,bmp,xml,zip,rar,css,avi,mov

Scan only specific extensions

php ai-bolit.php --scan=php,php5,pht,phtml,pl,cgi,htaccess,suspected,tpl

Prepare a quarantine file for sending to security specialists. The archive AI-QUARANTINE-XXXX.zip will be created with a password.

php ai-bolit.php --quarantine

Run the scanner in "paranoid" mode (recommended for getting the most detailed report)

php ai-bolit.php --mode=2

php ai-bolit.php --mode=1

Check one "pms.db" file for malicious code

php ai-bolit.php-jpms.db

Run scanner with 512Mb memory size

php ai-bolit.php --memory=512M

Set the maximum size of the scanned file to 900Kb

php ai-bolit.php --size=900K

Pause 500ms between files when scanning (to reduce load)

php ai-bolit.php --delay=500

Send scan report by email [email protected]

php ai-bolit.php [email protected]

Create a report in /home/scanned/report_site1.html

php ai-bolit.php --report=/home/scanned/report_site1.html

Scan the directory /home/s/site1/public_html/ (the report will be created in this directory by default if the --report=report_file option is not set)

php ai-bolit.php --path=/home/s/site1/public_html/

Execute the command when the scan is complete.

php ai-bolit.php --cmd="~/postprocess.sh"

Get a plain-text report named site1.txt

php ai-bolit.php-lsite1.txt

You can combine calls, for example,

php ai-bolit.php --size=300K --path=/home/s/site1/public_html/ --mode=2 --scan=php,phtml,pht,php5,pl,cgi,suspected

By combining the call of the AI-BOLIT scanner with other unix commands, you can perform, for example, a batch check of sites. Below is an example of checking several sites hosted within an account. For example, if the sites are located inside the /var/www/user1/data/www directory, then the command to launch the scanner will be

find /var/www/user1/data/www -maxdepth 1 -type d -exec php ai-bolit.php --path=() --mode=2 \;

By adding the --report option, you can control the directory in which scan reports will be generated.

php ai-bolit.php parameter list ... --eng

Switch the report interface to English. This parameter must come last.

Integration with other services and hosting panel

php ai-bolit.php --json_report=/path/file.json

Generate report in json format

php ai-bolit.php --progress=/path/progress.json

Save the status of the check to a file in json format. This file will contain structured data in json format: the current scan file, how many files have been scanned, how many files are left to scan, the percentage of scan, the time until the scan is completed. This mechanism can be used to show a progress bar and data about files being checked in the panel. When the scan is completed, the file is deleted automatically.

php ai-bolit.php --handler=/path/hander.php

External event handler. You can add your own handlers for the start/stop of a scan/scan progress/scan errors. An example file can be found in the scanner archive, in the tools/handler.php directory. For example, upon completion of the scan, you can do something with the report file (send it by mail, pack it into an archive, etc.).

In this article, you will learn how to set up authorization in the Analytics Reporting API version 4.

Note. The purpose of these quick guides– help the user to execute with . Since these libraries are constantly updated, information about latest changes may not be here. If you did not find the information you need, check out and.

1. Enable the API

Before you start using the Analytics Reporting API version 4, use to create a project in the Google API Console, enable the API, and register your credentials.

Create Credentials

Note.Click on request Create a new private key. For parameter Key type select value JSON and then save the generated key as client_secrets.json . You will need it later.
  1. Open . Select a project if necessary.
  2. Click Create a service account.
  3. Enter an account name and select Create a new private key. Then press the button Save.

The system will generate a new key pair (public and private) which will be saved to your computer. This copy is the only one and it is your responsibility to maintain it.

Add a service account to Google Analytics

The new service account will have an address Email of this type:

[email protected]

Use this address to add the user to the Google Analytics view you want to access via the API. You only need the Read and Analyze permission to perform the tasks in this guide.

2. Install the client library

composer require google/apiclient:^2.0

3. Customize the example

You need to create a HelloAnalytics.php file with the code for this example.

  • Copy or paste the source code below and then add it to the HelloAnalytics.php file.
  • Move the downloaded service-account-credentials.json key to the same directory as the example code.
  • Change the VIEW_ID value. Use the Account Explorer tool to find this setting.

HelloAnalytics.php

setApplicationName("Hello Analytics Reporting"); $client->setAuthConfig($KEY_FILE_LOCATION); $client->setScopes(["https://www.googleapis.com/auth/analytics.readonly"]); $analytics = new Google_Service_AnalyticsReporting($client); return $analytics; ) /** * Queries the Analytics Reporting API V4. * * @param service An authorized Analytics Reporting API V4 service object. * @return The Analytics Reporting API V4 response. */ function getReport($analytics) ( // Replace with your view ID, for example XXXX. $VIEW_ID = " "; // Create the DateRange object. $dateRange = new Google_Service_AnalyticsReporting_DateRange(); $dateRange->setStartDate("7daysAgo"); $dateRange->setEndDate("today"); // Create the Metrics object. $sessions = new Google_Service_AnalyticsReporting_Metric(); $sessions->setExpression("ga:sessions"); $sessions->setAlias("sessions"); // Create the ReportRequest object. $request = new Google_Service_AnalyticsReporting_ReportRequest(); $request->setViewId($ VIEW_ID); $request->setDateRanges($dateRange); $request->setMetrics(array($sessions)); $body = new Google_Service_AnalyticsReporting_GetReportsRequest(); $body->setReportRequests(array($request)); return $analytics ->reports->batchGet($body); ) /** * Parses and prints the Analytics Reporting API V4 response. * * @param An Analytics Reporting API V4 response. */ function printResults($reports) ( for ($reportIndex = 0;$reportIndex< count($reports); $reportIndex++) { $report = $reports[ $reportIndex ]; $header = $report->getColumnHeader(); $dimensionHeaders = $header->getDimensions(); $metricHeaders = $header->getMetricHeader()->getMetricHeaderEntries(); $rows = $report->getData()->getRows(); for ($rowIndex = 0; $rowIndex< count($rows); $rowIndex++) { $row = $rows[ $rowIndex ]; $dimensions = $row->getDimensions(); $metrics = $row->getMetrics(); for ($i = 0; $i< count($dimensionHeaders) && $i < count($dimensions); $i++) { print($dimensionHeaders[$i] . ": " . $dimensions[$i] . "\n"); } for ($j = 0; $j < count($metrics); $j++) { $values = $metrics[$j]->getValues(); for ($k = 0; $k< count($values); $k++) { $entry = $metricHeaders[$k]; print($entry->getName() . ": " . $values[$k] . "\n"); ) ) ) ) )

4. Run the example

Run the example using the following code:

HelloAnalytics.php

When you complete all the steps, the screen will display the number of sessions in the selected view over the past seven days.

Note. You will need at least one resource and one Google Analytics view to run the example successfully.