Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http://www.webdevout.net/articles/escaping-style-and-script-data
- Required / Prerequisite
- 7-zip (http://www.7-zip.org/download.html)
- Opening zip files with 7-zip (zip/tar/exe/7z/gz)
- "C:\Program Files (x86)\7-Zip\7zFM.exe"
- GnuWin32 Tools (http://gnuwin32.sourceforge.net/packages/gzip.htm)
- (http://gnuwin32.sourceforge.net/packages/bzip2.htm)mv /path/to/file/A.current /path/to/file/A.backup
- Opening build sources and compress/uncompress w/ phpMyAdmin MySQL (gz/tar/tgz)
- C:\Program Files (x86)\GnuWin32\bin
- bzip2.exe
- gzip.exe
- Environment Variables
- My Computer (Right-Click)
- -> Properties (Control Panel\All Control Panel Items\System)
- -> Advanced System Settings (> Windows 7 (Left hand menu))
- -> System Properties
- -> Advanced
- -> Environment Variables...
- -> System variables
- -> Path
- Variable: Path (system specific...)
- Value: C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Apache2\bin\;C:\php\;C:\Program Files (x86)\GnuWin32\bin;C:\Program Files (x86)\SMplayer\mplayer\;
- Run CMD.exe as Administrator "Desktop Shortcut"
- Right-Click on the Desktop > New Shortcut
- cmd | cmd.exe
- Start -> Run
- cmd | cmd.exe
- PHP 5.4.8 (http://windows.php.net/download/#php-5.4)
- Install with default settings by copying the files from the latest zip
- +Installing as a modual for Apache2.2, you need -- VC9 x86 Thread Safe (zip)
- http://windows.php.net/downloads/releases/php-5.4.8-Win32-VC9-x86.zip (Threaded)
- comes with - C:\php\php5apache2_2.dll is mentioned later on and loaded with Apache2.2
- copy C:\php\php.ini-production php.ini
- notepad C:\php\php.ini
- extension_dir="C:/php/ext/"
- Line 883:
- ;extension=php_mysqli.dll
- >> extension=php_mysqli.dll
- C:\Users\Dulcie\Downloads\php_http-5.3-svn20091125-vc6-x86.zip
- copy /b test.php +,,
- notepad test.php
- <?php echo 'hello world.'; ?>
- php test.php Result: hello world.
- $var = 'hello world;'
- echo '\'0\'' . ' does not show variables $var'; //Result: 0 does not show variables $var
- echo "\'1\'" . " does show variables $var"; //Result: 1 does show variables hello world
- ------------------------------------------------------------
- PHP 5.5 is in beta (2012-03-21)
- http://downloads.php.net/pierre/
- PhpMyAdmin (http://www.phpmyadmin.net/home_page/downloads.php) [english]
- cd C:\Apache2\htdocs\phpMyAdmin\
- mdkir config
- http://localhost/phpymadmin/setup/index.php
- Create a server profile
- localhost...defaults...
- Apache 2.2 (http://httpd.apache.org/download.cgi)
- notepad C:\Apache2\conf\httpd.conf (change)
- Listen 80
- >> Listen 127.0.0.1:80 (change to only allow from localhost/127.0.0.1:80)
- LoadModule php5_module "c:/php/php5apache2_2.dll"
- AddHandler application/x-httpd-php .php
- # configure the path to php.ini
- PHPIniDir "C:/php"
- <FilesMatch \.php$>
- SetHandler application/x-httpd-php
- </FilesMatch>
- Line 252: DirectoryIndex index.html index.php
- .htaccess (File)
- When operating php from the command prompt, remember to be cautious for extended lines suddenly breaks on with spaces. Default: If the line exceeds 80 characters, it could have a space between it and the line below, if the character ending the initial line is a space then your pretty safe. With out being cautious, you could by with a backspace/delete and accidently remove or forget to add the appropriate space.
- http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
- http://www.javascriptkit.com/howto/htaccess2.shtml
- (.htaccess)
- chmod 644 php.ini
- ErrorDocument 400 /.http/400.shtml
- ErrorDocument 401 /.http/401.shtml
- ErrorDocument 403 /.http/403.shtml
- ErrorDocument 404 /.http/404.shtml
- ErrorDocument 500 /.http/500.shtml
- <!-- SHTML Wrapper - 500 Server Error -->
- <!--#exec cgi="/500.php" -->
- Options -Indexes
- PHP_Value //in the .htaccess
- RewriteEngine On
- RewriteCond %{HTTP_HOST} ^fbcgf\.ca
- RewriteCond %{HTTPS} =on
- RewriteRule .* https://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]
- RewriteCond %{HTTP_HOST} ^fbcgf\.ca
- RewriteCond %{HTTPS} !=on
- RewriteRule .* http://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]
- RewriteBase /b33m
- RewriteRule ^blogs/([0-9]+)$ /view_blog_details.php?post_id=$1 [L]
- Options +FollowSymlinks
- RewriteEngine on
- RewriteRule ^abate /abatepain.com/public_html/abate/ [L]
- RewriteEngine on
- RewriteCond %{REQUEST_URI} ^/$
- RewriteRule (.*) http://www.abatepain.com/abate/ [R=301,L]
- <IfModule dir_module>
- DirectoryIndex default.html index.php home.php
- </IfModule>
- <Files notes.txt>
- order deny,allow
- deny from all
- </Files>
- Services install Service
- Apache 2.2 automatically is applied/added to the services on a default installation. Once restarted!
- Windows 7+
- Control Panel\All Control Panel Items\Administrative Tools\services.lnk
- >>C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools\services.lnk
- %windir%\system32\services.msc
- Add a regular firewall filter to allow port 80, and restart apache2.2 service.
- Windows XP
- %windir%\system32\services.msc
- C:\Apache2\bin\httpd.exe -k install
- C:\Apache2\bin\httpd.exe -k start / stop
- HTTP GET
- PHP
- Request URL (http://localhost/helloworld.php)
- Request URI (/helloworld.php?...)
- When checking to see if a GET values are not set (null), don't use ( is_null() ) :
- http://davidwalsh.name/php-ternary-examples
- Use:
- !empty() Ternary Condition echo 'Is setup ready? ' . (!empty($_GET['setup']) ? true : false);
- Raw Socket connect to make basic request. (\n = new line)
- CMD > telnet localhost 80
- GET /helloworld.php?string=value&bstring=bvalue&cstring=cvalue HTTP/1.1\n
- \n
- --------------
- //$_GET is now populated with 3 values (array)
- print_r($_GET); // returns mentioned below.
- Array { 'string' => 'value', bstring => 'bvalue', cstring => 'cvalue' }
- HTTP POST
- When checking to see if a GET values are not set (null), don't use ( is_null() ) :
- Use:
- !empty() Ternary Condition echo 'Is setup ready? ' . (!empty($_POST['setup']) ? true : false);
- Raw Socket connect to make basic request. (\n = new line)
- CMD > telnet localhost 80
- POST /path/script.cgi HTTP/1.0
- From: frog@jmarshall.com
- User-Agent: HTTPTool/1.0
- Content-Type: application/x-www-form-urlencoded
- Content-Length: 32
- home=Cosby&favorite+flavor=flies\n
- ------------------
- //$_POST is now populated with 3 values (array)
- print_r($_POST); // returns mentioned below.
- Array { 'home' => 'Cosby', 'favorite+flavor' => 'flies' }
- MySQL Server 5.5 (http://www.mysql.com/downloads/installer/)
- Install with default settings.
- Services install Service
- Table Maintenance Statements (13.7.2)
- ANALYZE TABLE Syntax (13.7.2.1)
- ANALYZE TABLE `session`
- BACKUP TABLE Syntax (13.7.2.2)
- BACKUP TABLE `table`
- CHECK TABLE Syntax (13.7.2.3)
- CHECK TABLE `session` (, `table2`... ) EXTENDED ( QUICK | FAST | CHANGED | MEDIUM | EXTENDED )
- QUICK Do not scan the rows to check for incorrect links. Applies to InnoDB and MyISAM tables and views.
- FAST Check only tables that have not been closed properly. Applies only to MyISAM tables and views; ignored for InnoDB.
- CHANGED Check only tables that have been changed since the last check or that have not been closed properly. Applies only to MyISAM tables and views; ignored for InnoDB.
- MEDIUM Scan rows to verify that deleted links are valid. This also calculates a key checksum for the rows and verifies this with a calculated checksum for the keys. Applies only to MyISAM tables and views; ignored for InnoDB.
- EXTENDED Do a full key lookup for all keys for each row. This ensures that the table is 100% consistent, but takes a long time. Applies only to MyISAM tables and views; ignored for InnoDB.
- CHECKSUM TABLE Syntax (13.7.2.4)
- OPTIMIZE TABLE Syntax (13.7.2.5)
- REPAIR TABLE Syntax (13.7.2.6)
- REPAIR TABLE `session` [QUICK] [EXTENDED] [USE_FRM]
- RESTORE TABLE Syntax (13.7.2.7)
- SET SESSION sql_mode='NO_AUTO_VALUE_ON_ZERO';
- ALTER TABLE `table_name` AUTO_INCREMENT = 1
- RENAME TABLE `db_name`.`table_name` TO `db_name`.`table_name` ;
- ALTER TABLE `db_name`.`table_name` ADD PRIMARY KEY ( `id` )
- ALTER TABLE `db_name` ADD `tbl_name` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
- ALTER TABLE `patient_session` CHANGE `ipaddr` `ipaddr` VARCHAR( 15 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '0.0.0.0'
- UPDATE `db_name`.`table_name` SET `timestamp` = '0000-00-00 00:00:00' WHERE `table_name`.`id` =0;
- SELECT timestamp FROM tablename WHERE timestamp >= STR_TO_DATE('" . date('m/d/Y' , strtotime( '-1 hour', $_SESSION['LAST_ACTIVITY'])) . "', '%m/%d/%Y') AND timestamp < STR_TO_DATE('" . date('m/d/Y' , strtotime( '-1 hour', time())) . "', '%m/%d/%Y');
- SELECT timestamp from `account_session` WHERE timestamp >= "01-01-2009 00:00:00" and datetime <= now();
- SELECT timestamp FROM `account_session` WHERE timestamp >= userStartDate AND timestamp < userEndDate
- SELECT timestamp FROM `account_session` WHERE `timestamp` >= UNIX_TIMESTAMP('') AND `timestamp` <= UNIX_TIMESTAMP('')
- http://www.c-integration.com/forum/showthread.php/56-rapid-web-application-using-qcubed
- CREATE TABLE `comment` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `post_id` int(11) NOT NULL,
- `comment_body` varchar(1000) NOT NULL,
- PRIMARY KEY (`id`),
- KEY `post_id` (`post_id`)
- ) ENGINE=InnoDB;
- CREATE TABLE `post` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `title` varchar(128) NOT NULL,
- `body` varchar(10000) NOT NULL,
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB;
- ALTER TABLE `comment`
- ADD CONSTRAINT `comment_ibfk_1` FOREIGN KEY (`post_id`) REFERENCES `post` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
- CURRENT_TIMESTAMP does not have quotes / escape
- NULL does not have quotes / escape
- blob can have a 0 byte string w/o having to use null / default
- '\'\''
- '\'\'' . ', ' .
- -----------------------------------------------------------
- PHP 5.4 (file.php)
- if (isset($_GET['src'])) {
- highlight_file('index.php'); //__FILE__
- die();
- }
- http://www.creotec.com/php-web-development/
- <?php
- /** Error reporting */
- ini_set("log_errors", 1);
- ini_set("error_log", "/path/to/php-error.log");
- error_reporting(E_ALL);
- /** Include path **/
- ini_set('include_path', ini_get('include_path').';../Classes/');
- //include('include.php');
- require_once(dirname(__FILE__) . '/include.php');
- ?>
- error_log
- Will always spit out php errors / dates/time and its corrsponding file / line.
- [01-Jan-1970 12:01:36] PHP Fatal error: Cannot redeclare functionName() (previously declared in /home/parentDirectory/www_dir/public_html/index.php:32) in /home/parentDirectory/www_dir/public_html/include.php on line 37
- include() // Suggested replacment require_once()
- /directory/to/htdocs/phpfiles/
- index.php
- <?php require_once(dirname(__FILE__) . '/include.php'); ?>
- include.php
- http://www.expertrating.com/courseware/PHPcourse/PHP-Advanced-ClassConcepts-11-2.asp
- index.php
- __FILE__ == /directory/to/htdocs/phpfiles/index.php
- http://www.domain.com/phpfiles/index.php?hello
- $_SERVER['PHP_SELF'] == '/phpfiles/index.php'
- if (key($_GET)) {
- switch (key($_GET)) {
- /* case '': $null = NULL; break; */
- case 'hello':
- echo 'hello world from index.php';
- break;
- }
- }
- Result: hello world from include.php
- Unless there is an included file mentioned above the condition ( if (key($_GET)) { ... )
- include('include.php');
- include.php
- __FILE__ == /directory/to/htdocs/phpfiles/include.php
- http://www.domain.com/phpfiles/index.php (if included)
- $_SERVER['PHP_SELF'] == '/phpfiles/index.php'
- (else)
- $_SERVER['PHP_SELF'] == '/phpfiles/include.php'
- if (key($_GET)) {
- switch (key($_GET)) {
- /* case '': $null = NULL; break; */
- case 'hello':
- echo 'hello world from include.php';
- break;
- }
- }
- Result: hello world from include.php
- if(!@include("script.php")) throw new Exception("Failed to include 'script.php'");
- /*
- if (in_array(__FILE__, get_included_files()) === false) {
- header('Location: http://www.domain.com/');
- die();
- }
- /*
- if (array_search(__FILE__, get_included_files()) === false) {
- header('Location: http://www.domain.com/');
- }
- else {
- require_once(dirname(__FILE__) . '/include.php');
- echo __FILE__;
- }
- */
- $_SESSION[]
- ini_set("session.entropy_file", "/dev/urandom");
- ini_set("session.entropy_length", "512");
- if (!isset($_SESSION)) { session_start(); }
- if (empty($_SESSION['CREATED']) || empty($_SESSION['LAST_ACTIVITY'])) {
- $_SESSION['CREATED'] = time();
- $_SESSION['LAST_ACTIVITY'] = time();
- } else { $_SESSION['LAST_ACTIVITY'] = time(); }
- if (time() - $_SESSION['CREATED'] > 450 ) {
- // last request was more than 30 minates ago (1800)
- $_SESSION = array();
- session_destroy(); // destroy session data in storage
- session_unset(); // unset $_SESSION variable for the runtime
- header('Location: http://www.domain.com/');
- } elseif ($_SESSION['LAST_ACTIVITY'] - $_SESSION['CREATED']> 180) {
- session_regenerate_id(true); // change session ID for the current session an invalidate old session ID
- $_SESSION['CREATED'] = time();
- }
- Date / Time
- date_default_timezone_set('America/Vancouver');
- date('Y-m-d H:i:s', strtotime( '-1 hour', time())); datetime
- strtotime('-1 hour', time()) //time() - (60 * 60); // 60 x 60 (secs x secs) 1 hour
- time(); //UNIX Timestamp since 1970
- if ($_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF'] == __FILE__ ){
- header('Location: http://www.domain.com/');
- die();
- }
- If you are choosing to include a file from a subdirectory, and you still want to use relative links, instead of absolute (site-relative...), then you must set the HTML base tag in the head, in order for the browser to know where the src's and links are ... <base href="http://www.domain.com/absolute/location/of/parent/directory" />
- --PHP will always include files parent files, and absolute/relative, so you do not need to worry about adjusting the variables.
- Use absolute file location (__FILE__) when including files, that way you don't have to worry about relative links.
- //comment (single line)
- Does not work with 1-line php script as php is still assuming that comment is still there, even though its reached the end.
- <?php //testing ?>
- /* comment */ (single / multiple lines)
- Does however fix both these issues, and is there more efficient.
- <?php /*Comment*/ ?>
- $variable = ''; //===is_null($variable) ===empty($variable) !==isset($variable) !==$variable ===NULL ===false!
- $variable = '0'; //!==is_null() !==empty() ===isset ===$variable !==NULL ===true
- $_POST['test1'] === NULL !isset()
- $x = NULL;
- if(is_null($x) === true) // null
- if($x === null) // null
- if($x === false)
- if(isset($x) === false) // variable undefined or null
- if(empty($x) === true) // check if variable is empty (length of 0)
- $array = array(); //===empty
- $array['key'] = 'value';
- $array[0] = "is not restrictive to a particular rule";
- $array['just as long as your code ie constructive'] = 'your script won\'t become destructive.';
- $array['1'] = 'You just need to realize the escape rules with ' . 'php.' . " You can you use lots of syntax methods including conditional (if / else) statments and functions() " . "from within the variable definition. " . ((1===1) ? ' This should return (true)' : "I guess not (false).");
- $array["\"2\""] = 'These are just a few of the numerous reasons why ' . 'php is soo cool to play with...';
- $array[3] = array();
- $array[4] = 'Array values can also be defined as objects ... as to have an "array of objects"';
- print_r($array);
- /*
- Returns:
- Array
- (
- [key] => value
- [0] => is not restrictive to a particular rule
- [just as long as your code ie constructive] => your script won't become destructive.
- [1] => You just need to realize the escape rules with php. You can you use lots of syntax methods including conditional (if / else) statments and functions() from within the variable definition. This should return (true)
- ["2"] => These are just a few of the numerous reasons why php is soo cool to play with...
- [3] => Array
- (
- )
- [4] => Array values can also be defined as objects ... as to have an "array of objects"
- )
- */
- PHP MySQL (ext/mysql) Deprecated 5.5/6.0
- Works in 5.4 still (pdo_mysql or MySQLi prefered alternitives)
- mysqli_query($link, $query);
- mysqli_insert_id()
- LAST_INSERT_ID()
- if(!$res = mysql_query("SELECT * FROM `session_active` WHERE `session` =" . $session_id . ';', $myconnect)) { die("ERROR: " . mysql_error()); }
- $row = mysql_fetch_assoc($res);
- foreach ($){
- $row = mysql_fetch_assoc(mysql_query("SELECT * FROM `takenote`.`timesheet` WHERE `timestamp` = '" . date('Y-m-d', strtotime($gdate)) . ' ' . $schedule . "' LIMIT 0 , 30", $myconnect));
- }
- while($row = mysql_fetch_array($result)) {}
- --------------------------------------------------------------
- HTML / XHTML (file.html)
- Document-relative links ../../folder/file.ext
- Site Root Relative /root/folder/file.ext
- (X)HTML
- <base href="http://www.domain.com/abate/">
- Does not affect <link />
- But does however affect <script />
- XHTML
- <base href="http://www.domain.com/abate/" />
- <script type="text/javascript">
- //<![CDATA[
- //]]>
- </script>
Add Comment
Please, Sign In to add comment