PHP Tools for Visual Studio expired

Rédigé par Sozezzo - - Aucun commentaire

Tutorial to add more trial time.


image


Step 1 : Registry - Add fake date


Open  Regedit

Find registry key

Computer\HKEY_CURRENT_USER\Software\DEVSENSE\PHP Tools for Visual Studio\VS 15.0

VS 15.0 it is my version of Visual Studio


Change registry

Delete : DisableStartupTrialWindow

Change date to future date : TrialStart          ex: 2060-01-01T01:00:00


Step 2 : Visual Studio - Get an error


Open Visual Studio

Try to use PHP Tools for Visual Studio

We will have error 9.

Close Visual Studio


image


Step 3 : Registry - Fix date


Change registry

Change date to now : TrialStart          ex: yyyy-MM-ddT00:00:00

Delete TrialSignature


Step 4 : Start new 30 days

image

Classé dans : tutorial - Mots clés : aucun

Mongo DB - Document Database

Rédigé par Sozezzo - - Aucun commentaire

The big thing is … Mongo BD is NOT RDBMS!

In OOP are not tables and rows, objects use polymorphism, inheritance, and it is not uniform. Use objects with RDBMS can be hard.

Mongo DB has no schema to define, no tables and no relationships between collections of objects. Each document can be flat, simple, or complex as we wish. There are no locks of tables, or columns.

Durability vs Consistency

Durability is about whether your data was persisted to durable media before control was returned to you. Eventual consistency in a replica set has to do with whether a document was written to all of the servers, to the primaries and secondaries before control was returned to your application.

· You can ready for inconsistency. Can your application run with? Can it be an issue?

· The application takes control of schema enforcement.

We can backup and restore of Mongo, to import and export information, to monitor the Mongo server, and to share it. You can scale MongoDB horizontally with a replication.

 

What is BSON ? Store byte arrays on disk..

The BSON specifications can be found on bsonspec.org. Basically, BSON is elementary data types into memory into C data types then to read and to write is fast. BSON specification is data storage serialization format with memory mapped files.
BSON documents has length prefixing. It is fast to find particular a field into store arbitrary object structures and not require to adhere to a particular schema, and this is the key of MongoDB.

Index is important in MongoDb, you must be sure the index is useful and with the correct name of column.

Where and When do you use MobgoDB?

  • No transaction at all.
  • Not a lot of updates, less 1% of database.
  • Geo-distributed database;
  • Use for CMS, Logs, Dataware, etc.

Add-on Google search link fix

Rédigé par Sozezzo - - Aucun commentaire

Prevents Google and Yandex search pages from modifying search result links when you click them.Google and Yandex search pages have the annoying habit of changing the result link when you click it. So if you right-click the link in order to copy it you get some gibberish instead of what you wanted.

 

image

This extension disables that behavior – on any Google or Yandex domain, without having to configure anything. Simply install and enjoy! As an added bonus, the search engine can no longer track your clicks.

 

https://addons.mozilla.org/en-US/firefox/addon/google-search-link-fix/

Classé dans : firefox - Mots clés : aucun

SQL Script to send a file by FTP

Rédigé par Sozezzo - - Aucun commentaire

This Stored procedure send a file by FTP.

Check if SQL Agent has access to the file and FTP server.

The little trick is to create a file that will run. It can have conflicts easily because filename is always the same. Next version will be with random name. 

 

Use this code carefully, it is not 100% safe.


USE master;
 PRINT '-- Server name: '+@@servername

IF EXISTS (
         SELECT *
         FROM sysobjects
         WHERE id = object_id(N'[dbo].[sp_FtpSendFile]')
             AND OBJECTPROPERTY(id, N'IsProcedure') = 1
         )
     DROP PROCEDURE [dbo].[sp_FtpSendFile]
 GO

/************************************************************

Description : Send a file by FTP

 @FTPServer      The host name.    ftp.example.com
 @FTPUser        The username for the FTP site.
 @FTPPWD         The password for the FTP site.
 @FTPPath        The ftp subfolder within the FTP site to place the file. Make sure to use forward slashes and leave a trailing slash.
 @FTPFileName    (optional) The filename to write within FTP. Typically the same as the source file name.
 @FTPPASV        (optional) Use passive mode
 @SourcePath     The local path to the directory that contains the source file. Make sure to have a trailing slash. c:\MyLocalPath\
 @SourceFile     The local source file to ftp.
 @workdir        (optional) The working local directory. This is where the stored proc will temporarily write a command file containing the FTP commands it will execute. = %TEMP%

*************************************************************/
 CREATE PROCEDURE sp_FtpSendFile

     -- Remote
      @FTPServer VARCHAR(128)
     ,@FTPUser VARCHAR(128)
     ,@FTPPWD VARCHAR(128)
     ,@FTPPath VARCHAR(128)
     ,@FTPFileName VARCHAR(128) = NULL  -- (optional)
     ,@FTPPASV INT = 1                  -- (optional)

    -- Local
     ,@SourcePath VARCHAR(128)
     ,@SourceFile VARCHAR(128)
     ,@workdir VARCHAR(128) = '%TEMP%'  -- (optional)

    -- debug
     ,@debug int = 0                    -- (optional)

AS
 BEGIN

/*
     
 -- sandbox

DECLARE
      @FTPServer VARCHAR(128)
     ,@FTPUser VARCHAR(128) = ''
     ,@FTPPWD VARCHAR(128)
     ,@FTPPath VARCHAR(128)
     ,@FTPFileName VARCHAR(128) = NULL -- (optional)
     ,@FTPPASV INT = 1 -- (optional)
     ,@SourcePath VARCHAR(128)
     ,@SourceFile VARCHAR(128)
     ,@workdir VARCHAR(128) = '%TEMP%' -- (optional)
     ,@debug int = 0

SELECT
     @FTPServer = 'ftp.mysite.com' ,
     @FTPUser = 'myusername' ,
     @FTPPWD = 'mypassword' ,
     @FTPPath = '/' ,
     @SourcePath = 'K:\temp\Backup\' ,
     @SourceFile = 'myFile.bak' ,
     @debug = 0

*/

    SET nocount on
     DECLARE @cmd VARCHAR(1000)
     DECLARE @workfilename VARCHAR(128)
     DECLARE @noNull table (r NVARCHAR(MAX))

    SET @workfilename =  @workdir + 'ftpcmd.txt'

    -- deal with special characters for echo commands
     SET @FTPServer = replace(replace(replace(@FTPServer, '|', '^|'), '<', '^<'), '>', '^>')
     SET @FTPUser = replace(replace(replace(@FTPUser, '|', '^|'), '<', '^<'), '>', '^>')
     SET @FTPPWD = replace(replace(replace(@FTPPWD, '|', '^|'), '<', '^<'), '>', '^>')
     SET @FTPPath = replace(replace(replace(@FTPPath, '|', '^|'), '<', '^<'), '>', '^>')

    SET @cmd = 'echo open ' + @FTPServer + ' > ' + @workfilename
     INSERT @noNull EXEC master..xp_cmdshell @cmd

    SET @cmd = 'echo ' + @FTPUser + '>> ' + @workfilename
     INSERT @noNull EXEC master..xp_cmdshell @cmd

    SET @cmd = 'echo ' + @FTPPWD + '>> ' + @workfilename
     INSERT @noNull EXEC master..xp_cmdshell @cmd

    IF (@FTPPASV = 1)
     BEGIN
         SET @cmd = 'echo quote PASV >> ' + @workfilename
         INSERT @noNull EXEC master..xp_cmdshell @cmd
     END

    SET @cmd = 'echo cd '+ @FTPPath + '>> ' + @workfilename
     INSERT @noNull EXEC master..xp_cmdshell @cmd

    SET @cmd = 'echo binary >> ' + @workfilename
     INSERT @noNull EXEC master..xp_cmdshell @cmd

    SET @cmd = 'echo put ' + @SourcePath + @SourceFile + ' ' + ISNULL(@FTPFileName, '') + ' >> ' + @workfilename
     INSERT @noNull EXEC master..xp_cmdshell @cmd

    SET @cmd = 'echo dir ' + ISNULL(@FTPFileName, @SourceFile) + ' >> ' + @workfilename
     INSERT @noNull EXEC master..xp_cmdshell @cmd

    SET @cmd = 'echo quit' + ' >> ' + @workfilename
     INSERT @noNull EXEC master..xp_cmdshell @cmd

    SET @cmd = 'ftp -s:' + @workfilename
     DECLARE @a TABLE (
         id INT identity(1, 1)
         ,s VARCHAR(1000)
         );

    IF (@debug = 1)
     BEGIN
         SET @cmd = 'TYPE ' +  @workfilename
         EXEC master..xp_cmdshell @cmd
     END
     ELSE
     BEGIN
     INSERT @a EXEC master..xp_cmdshell @cmd;
         SELECT id, ouputtmp = s
         FROM @a;
     END
 END
 GO

Classé dans : sqlscript - Mots clés : aucun

Install PHP on Windows Server 2016

Rédigé par Sozezzo - - Aucun commentaire

Easy steps to install PHP on Windows Server 2016

This tutorial was create for Windows Server 2016 x64, but you can do it on Windows Workstation x86, but you just need to use x86 everywhere.

 

REQUIREMENTS

  • Windows Server 2016
  • IIS
  • PHP bin files
  • WinCache
  • VC++

 

 

IIS service with CGI extension.

Before to install, verify if you already have it.


Get-WindowsFeature web-cgi

image

 

Powershell command to install


Install-WindowsFeature -name web-server,web-cgi –IncludeManagementTools

 

Installing PHP

 

Download PHP version you want to install.

http://windows.php.net/download/

Extract file to C:\Program Files\php

 

Select PHP configuration to use

You have 2 configuration files:

  • php.ini-development
  • php.ini-production

You must rename the file configuration to php.ini.

 

Add Wincache configuration

Open php.ini file and add this line in the end:

extension=php_wincache.dll

 

Add PHP path on Environment variables

On Explorer click properties on This PC

Click on Advanced system settings

Click on Advanced \ Environment Variables

On System variables, edit variable : Path

Add new path. ( C:\Program Files\php )

 

Install WinCache Extention

https://www.iis.net/downloads/microsoft/wincache-extension

Download and extract it.

Copy files to folder : C:\Program Files\php\ext

  • php_wincache.dll
  • php_wincache.pdb       (optional)

 

 

Configurate PHP in IIS

In IIS open Handler Mappings

Add Module Mapping

  • Request path : *.php
  • Module : FastCgiModule
  • Executable (optional) : C:\Program Files\php\php-cgi.exe
  • Name : PHP

Click on Request Restriction…

Select "FIle or Folder"

 

Installing VC++

https://support.microsoft.com/en-ca/help/2977003/the-latest-supported-visual-c-downloads

Just install it.

 

Verify if it works.

Open the default web site path, root, and create a file <phpinfo.php> with this line:

<?php  phpinfo(); ?>

 

Usually it is this path: C:\inetpub\wwwroot

 

Open in your local server this page:

http://localhost/phpinfo.php

MySql Reset root password

Rédigé par Sozezzo - - Aucun commentaire
Step by step how you can change 'root' password
 
You must have rights to stop/start services, and kill process.
 
Step 1: Stop MySql service
run: services.msc
...
 
Step 2 : Create file to reset password
You can use your password and your file name.
We use password : Pass1Word2
and file name : C:\temp\reset.txt
USE mysql;
UPDATE mysql.user SET Password=PASSWORD('Pass!Word@') WHERE User='root';
FLUSH PRIVILEGES;
 
Step 3 : Find our my.ini file
It is usually locate on 'C:\ProgramData\MySQL\MySQL Server ????\my.ini'
But, you can try to find using :
C:\ dir my.ini /s /b
You can check MySQL service's property.
...
For this sample, we use this:
C:\ProgramData\MySQL\MySQL Server 5.5\my.ini
 
Step 4 : Navigate to MySql bin directory
Open command prompt there.
...
Type command :
mysqld --defaults-file="C:\\ProgramData\\MySQL\\MySQL Server 5.5\\my.ini" --init-file=C:\temp\reset.txt
Attention : Use double "\\" insted "\"
 
Step 5 : Open "Task Manager" and kill process "mysqld.exe"
Step 6: Start service "MySql"
By now, we have a new password.
cls
@echo off
cls
echo.
echo * * * Reset MySql password * * *
echo.
pause
echo.
echo Stop MySql Service
echo.
sc stop MySql
echo.
pause
echo.
echo Kill mysqld.exe
echo.
taskkill -f -im mysqld.exe
echo.
pause
echo.
rem dir "C:\ProgramData\MySQL\MySQL Server 5.5\my.ini"
echo.
echo Run MySqlD
echo.
"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld"   --defaults-file="C:\Program Files\MySQL\MySQL Server 5.5\my.ini" --init-file=C:\Temp\reset.txt
echo.
pause
echo.
echo Start MySql Service
echo.
sc start MySql
echo.
pause
echo.
echo Try to connect
echo.
"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql.exe" "--defaults-file=C:\Program Files\MySQL\MySQL Server 5.5\my.ini" "-uroot" "-p"
echo.
cd\temp
echo.
** Attention : Make sure all file are ANSI

Simple log connections SQLServer 2000

Rédigé par Sozezzo - - Aucun commentaire

This code create a table to log all connections.

It is very simple, it just logs when, who, from where and which database.

For this we use “master.dbo.sysprocesses”

 

https://docs.microsoft.com/en-us/sql/relational-databases/system-compatibility-views/sys-sysprocesses-transact-sql?view=sql-server-2017


Create table to log on [Master] database.

 USE [master] GO CREATE TABLE [dbo].[dbaLogAccess] (     [dbaLogAccessId] [int] IDENTITY (1, 1) NOT NULL ,     [ConnectionDate] [datetime] NULL ,     [loginame] [nvarchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AI NULL ,     [hostname] [nchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AI NOT NULL ,     [dbname] [nvarchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AI NULL ) ON [PRIMARY] 

Script to add logs, you can run each minute to update the log. This script avoids to repeater, it only saves new connections. We recommend using a job and schedule each minute to run this script.

 INSERT INTO master.dbo.dbaLogAccess (ConnectionDate, loginame, hostname, dbname)   SELECT DISTINCT     tbNew.ConnectionDate,     tbNew.loginame,     tbNew.hostname,     tbNew.dbname   FROM (SELECT     CONVERT(char(10), GETDATE(), 126) AS ConnectionDate,     RTRIM(loginame) AS loginame,     hostname,     CASE       WHEN dbid = 0 THEN ''       WHEN dbid <> 0 THEN DB_NAME(dbid)     END AS dbname   FROM master.dbo.sysprocesses   WHERE (hostname <> '')) AS tbNew   LEFT OUTER JOIN master.dbo.dbaLogAccess AS tbOld     ON tbNew.ConnectionDate = tbOld.ConnectionDate     AND tbNew.loginame = tbOld.loginame     AND tbNew.hostname = tbOld.hostname     AND tbNew.dbname = tbOld.dbname   WHERE (tbOld.dbaLogAccessId IS NULL); 

This code limit connection by day, we can change by hour or by minute, you just change how many character you use it:
 print CONVERT(char(14), GETDATE(), 126) + '00:00'
print CONVERT(char(17), GETDATE(), 126) + '00'
print CONVERT(char(20), GETDATE(), 126)

Well, you may do not like to use [master] database, but it is the place to record the system-level information. Good news, you can easily change it.

or you can use : https://www.sqlshack.com/creating-successful-auditing-strategy-sql-server-databases/

 

 

 

Fil RSS des articles