Administrative

Administrative (4)

Monday, 01 November 2010 14:42

Setup ssl on whm/cpanel

Written by mark

-make sure account has a dedicated ip

-from cpanel  generate key for the domain name

-from cpanel generate CSR with company info to appear in ssl

-copy CSR and keep it in memory to paste into the order form

-goto ssl order form , order regular ssl fill in your own contact then paste the CSR into appropriate area

-make sure that the email accounts are created so that you can confirm the account and recieve the cert

-once you recieve the cert install it from cpanel.

-goto whm and install it from there by typing the web account and then submit

Tuesday, 12 October 2010 19:59

random mysql row

Written by mark
<?php
  //  random row mysql query example
  $sql = "SELECT * FROM tablename
          WHERE somefield='something'
          ORDER BY RAND() LIMIT 5";

  //  or, something like this
  $sql = "SELECT * FROM tablename
          ORDER BY RAND()";
?>


 
Tuesday, 12 October 2010 19:54

unzip files on apache server

Written by mark

The first thing you'll need to do is make sure you have the ZZIPlib library installed. If you have WHM, goto the Apache Build page, and just build apache with the "Zip" checkbox checked. That simple.

<?php
$zip = zip_open("zip.zip");
if ($zip) {
  while ($zip_entry = zip_read($zip)) {
    $fp = fopen("zip/".zip_entry_name($zip_entry), "w");
    if (zip_entry_open($zip, $zip_entry, "r")) {
      $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
      fwrite($fp,"$buf");
      zip_entry_close($zip_entry);
      fclose($fp);
    }
  }
  zip_close($zip);
}
?>
Monday, 29 March 2010 15:48

Recursively chmod only directories or files

Written by mark

find . -type d -exec chmod 755 {} \;

  • This will “find” all directories, starting at “.“, and chmod them to 755.

find . -type f -exec chmod 644 {} \;
  • This snippet does the opposite and finds only files. The difference (beside the file permissions) is the “-type f“, “f” specifies files and “d” directories.

find . -type f -name '*.htm*' -exec chmod 644 {} \;

  • This lets you “find” files (“-type f“) with a specific extension (“-name '*.htm*'“) and chmod them with your desired permission (“-exec chmod 644 {}“).

chmod -R o+rX

  • This snippet will recursively chmod “other” (“o“) permissions with read/eXecutable (“+rX“), and the capital X ensures that directories and files set (user/group permissions) to executable will be properly modified, while ignoring regular (non-executable) files.