PHP directory listing in reverse order, function rsort

By Zilli,

rsort

(PHP 4, PHP 5)

rsort — Sort an array in reverse order

Case history

PHP directory listing in reverse order

Description

bool rsort ( array &$array [, int $sort_flags = SORT_REGULAR ] )

This function sorts an array in reverse order (highest to lowest).

Parameters

array
The input array.

sort_flags
You may modify the behavior of the sort using the optional parameter sort_flags, for details see sort().

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 rsort() example

<?php
$fruits = array("lemon", "orange", "banana", "apple");
rsort($fruits);
foreach ($fruits as $key => $val) {
    echo "$key = $val\n";
}
?>

Output

0 = orange
1 = lemon
2 = banana
3 = apple

 

List files dir in PHP

By Zilli,

<?php
//open the current directory
$directory = opendir('.');
while ($file = readdir($directory))
{
$filenames[] = $file;
}
foreach ($filenames as $file)
{
echo "$file<br>";
}
?>

Delete .DS_Store files on remote disks

By Zilli,

Go to terminal and execute this command:

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

reboot

  Category: OS
  Comments: Comments Off on Delete .DS_Store files on remote disks

PHP function calculate the distance between two coordinates (latitude, longitude)

By Zilli,

function distance($lat1, $lng1, $lat2, $lng2, $miles = true)
{
$pi80 = M_PI / 180;
$lat1 *= $pi80;
$lng1 *= $pi80;
$lat2 *= $pi80;
$lng2 *= $pi80;

$r = 6372.797; // mean radius of Earth in km
$dlat = $lat2 – $lat1;
$dlng = $lng2 – $lng1;
$a = sin($dlat / 2) * sin($dlat / 2) + cos($lat1) * cos($lat2) * sin($dlng / 2) * sin($dlng / 2);
$c = 2 * atan2(sqrt($a), sqrt(1 – $a));
$km = $r * $c;

return ($miles ? ($km * 0.621371192) : $km);
}

Password protect zip files in OS X

By Zilli,

Password protect a zip file archive Creating a password protected zip file is easy in Mac OS X and does not require any add-ons or downloads. Instead, use the zip utility that is bundled with all Macs.

If you’re familiar with the command line, the syntax of the encrypted zip command is as follows:

zip -e [archive] [file]

For encrypting multiple files with a password, such as folder or an entire directory, the syntax would be as follows:

zip -er [archive] [folder]

If you’re not sure how to use that, read on to learn how to create zip archives encrypted with passwords. These encrypted zip files will maintain password protection across platforms, meaning you can send a protected zip file to a Windows user and they will still need to enter the password in order to view the contents.

Zip Password in Mac OS X

Set a Zip Password in Mac OS X

You can create password protected archives of files and folders:

Launch the Terminal from the Applications > Utilities folder

Type the following command:

zip -e archivename.zip filetoprotect.txt

Enter and verify the password – don’t forget this

The resulting archive, in this case named “archivename.zip”, is now encrypted with the password provided. The file that was encrypted, “filetoprotect.txt”, is now inaccessible without entering that password.

If you plan on compressing multiple files within a folder, you will want to slightly modify the command with the -er flag like so:

zip -er archive.zip /path/to/directory/

This is particularly important for encrypting zips of multiple files under OS X Mavericks.

Example: Zipping a Folder and Setting a Password

Here is an example of what this will look like from the command line, in this case we are compressing and password protecting the entire ‘Confidential’ folder located within the users /Documents directory, and the password protected zip is being placed on the users desktop for easy access:

$ zip -er ~/Desktop/encrypted.zip ~/Documents/Confidential/
Enter password:
Verify password:
adding: ~/Documents/Confidential/ (deflated 13%)

Notice the password will not display, this is normal behavior for the Terminal.

Notice that with a folder of multiple files, you will want to use the -er flag, the addition of the r indicates that zip will recursively compress and password protect all files in the folder.

Opening the Password Protected Zip

Despite being created at the command line, you do not need to unzip the file from the terminal, it can be expanded from the Mac OS X Finder or within Windows using standard unzipping apps. Just double click on the file, then enter the password, and it will decompress. You can also decompress the zip archive from the command line with:

unzip filename.zip

Here are some use cases for password protected zip archives:

Password protecting an individual file or directory

Sending a sensitive and encrypted file over an unencrypted network

Emailing confidential data to a Windows user

Adding an additional layer of security to a hidden folder

Password protecting your own backups, outside of Time Machine

While this can provide some protection on a per-file or folder basis, it’s always a good idea to password protect the Mac in general with a login requirement on system boot, wake from sleep, and waking from the screen saver.

  Category: OS
  Comments: None

Dreamweaver Help / Server behaviors, databases, and bindings in Dreamweaver CC

By Zilli,

This document addresses queries around server behaviors, the Bindings panel, and databases in Dreamweaver CC released on June 18 2013.

In Dreamweaver CC, server behaviors are available as an extension, Deprecated_ServerBehaviorsPanel_Support.zxp. After you install the extension, the server behaviors feature is enabled and extensions dependent on it work as they did previously.

In the CC release, based on your OS, you can find the extension at the locations below.

  •  Vista/Windows 7: C:/Program Files (x86)/Adobe/Adobe Dreamweaver CC/Configuration/DisabledFeatures
  •  Mac OS X: /Applications/Adobe Dreamweaver CC/Configuration/DisabledFeatures

Note:

MXP type extensions are not supported in Extension Manager CC. The MXP format has been replaced with the ZXP extension format.

An MXP extension can be converted to a ZXP extension using the “Convert MXP Extension To ZXP” tool. This tool can be found in the Tools menu in Extension Manager for CS6.

source: http://helpx.adobe.com/x-productkb/policy-pricing/dreamweaver-cc-server-extensions.html