0

0

Marcin

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.liferay.portal.kernel.events.Action;
import com.liferay.portal.kernel.events.ActionException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.struts.LastPath;
import com.liferay.portal.kernel.util.WebKeys;
import com.uds.hbo.commons.util.PageConstants;
import com.uds.hbo.commons.util.SessionConstants;
import com.uds.hbo.commons.web.url.ApplicationURL;

public class LoginPostAction extends Action {

    private static Log LOG = LogFactoryUtil.getLog(LoginPostAction.class);

    @Override
    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException {

        String voucher = (String) request.getSession().getAttribute(SessionConstants.VOUCHER);
        LastPath lastPath = (LastPath) request.getSession().getAttribute(WebKeys.LAST_PATH);
        String redirectiontUrl = (String) request.getSession().getAttribute(PageConstants.REDIRECTION_URL);
        String uri = request.getRequestURI();

        // In case of order completed or canceled
        if (uri.contains(ApplicationURL.ORDER_CANCEL.getUrl()) || uri.contains(ApplicationURL.ORDER_COMPLETE.getUrl())) {
            return;
        }
        // In case of voucher passed by user
        if (voucher != null && voucher.length() > 0) {
            tryToRedirect(response, redirectiontUrl);
            // In case of redirection to Payex service from iframe
        } else if (redirectiontUrl != null) {
            tryToRedirect(response, PageConstants.CONTINUE_WITH_PAYMENTS);
            // In case there is no last path
        } else if (lastPath == null) {
            tryToRedirect(response, "/home");
            // In other cases redirect to: <host>/<contextPath>/<lastPath>
        } else {
            String contextPath = lastPath.getContextPath();
            String path = lastPath.getPath();

            StringBuffer s = new StringBuffer();
            if (contextPath != null && contextPath.length() > 0) {
                s.append(contextPath);
            }
            s.append(path);

            tryToRedirect(response, s.toString());
        }
    }

    private void tryToRedirect(HttpServletResponse response, String path) {
        try {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Trying to redirect to " + path);
            }
            response.sendRedirect(path);
        } catch (IOException e) {
            LOG.error("Cannot redirect after login to " + path, e);
        }
    }

}

0

0
/*Main*/
	
<fx:Script>
		<![CDATA[
			
			[Embed( source="/assets/fonts/Font04b03.swf", fontFamily="04b03")]
			public static var titleFont:Class;
	          ]]>
</fx:Script>
/* CSS file */

@namespace s "library://ns.adobe.com/flex/spark";

s|ActionBar #titleDisplay
{
	color: #ffffff;
	fontSize: 20;
	fontFamily: "04b03";
	fontWeight: "Bold";
}

0

0
<?php
/**********************
Class Example
**********************/
class Car{
	//Inconsistency with access modifiers
	var $tire_count = 4;
	public $door_count = 2;
	
	function num_of_tires(){
		//You need to explicitely use $ to assign variables but then don't use them for reference
		$string = "This " . get_class($this) . " has " . $this->tire_count . " tires";
		return $string . "<br />";
	}
}

$my_car = new Car();
echo $my_car->tire_count . " :: " . $my_car->door_count . "<br />";
echo $my_car->num_of_tires();

/**********************
Global Variable Example
**********************/
//No use of var or public
$tires = 4;
$doors = 2;

echo $tires . " :: " . $doors . "<br />";
//echo $this->$cat;

//Reference looks ugly
$reference =& $tires;
echo "Reference before: " . $reference . " || ";
$tires = 2;
echo "Reference after: " . $reference;
?>

0

0

gt: greater than lte: less than or equal to not IE:

<!--[if IE]>

<![endif]-->
<!--[if IE 6]> 

<![endif]-->
<!--[if IE 7]>

<![endif]-->
<!--[if IE 8]>

<![endif]-->
<!--[if IE 9]>

<![endif]-->
<!--[if gte IE 8]>

<![endif]-->
<!--[if lt IE 9]>

<![endif]-->
<!--[if lte IE 7]>

<![endif]-->
<!--[if gt IE 6]>

<![endif]-->
<!--[if !IE]> -->

<!-- <![endif]-->

0

0
################################################################
#
#	Mail Header Removal
#		- SPAM Prevention, just removes the headers
#		- Original Source: http://www.digital-web.com/articles/bulletproof_contact_form_with_php/
#
################################################################
function remove_headers($string)
{ 
	$headers = array(
		"/to\:/i",
		"/from\:/i",
		"/bcc\:/i",
		"/cc\:/i",
		"/Content\-Transfer\-Encoding\:/i",
		"/Content\-Type\:/i",
		"/Mime\-Version\:/i"
	); 
	return preg_replace($headers, '', $string); 
}

with strip_tags()

function remove_headers($string)
{ 
	$headers = array(
    	"/to\:/i",
		"/from\:/i",
		"/bcc\:/i",
		"/cc\:/i",
		"/Content\-Transfer\-Encoding\:/i",
		"/Content\-Type\:/i",
		"/Mime\-Version\:/i" 
	); 
	$string = preg_replace($headers, '', $string);
	return strip_tags($string);
}

0

0

Banyan Backup

myBackup sourceDirectory class.

myBackup where:
        [ : path : eachFileDirectoryEntry |
        eachFileDirectoryEntry name first ~= $_ ]; execute.
 
myBackup prepareToMakeTargetLikeSource.

            "directory: '/download/' , self rootTestDirName ;"

ftpRootTestDir := ServerDirectory new
            type: #ftp ;
            server: '192.168.1.2' ;
            directory: '/download/' ;
            keepAlive: true ;
            user: 'pw'.
            
ftpRootTestDir inspect.            

sourceDirectory := (FileDirectory on: 'c:\tmpBackup').
targetDirectory := (FileDirectory on: ftpRootTestDir).

ftpRootTestDir class.
sourceDirectory class.

ftpRootTestDir := ServerDirectory new
            type: #ftp ;
            server: '192.168.1.1' ;
            directory: '/www/tmp' ;
            keepAlive: true ;
            user: 'user';
            password: 'pw';
            yourself.

myBackup :=  MaBanyanBackup
    source:
        (FileDirectory on: 'c:\tmpBackup')
    target:
        (ServerDirectory new
            type: #ftp ;
            server: '192.168.1.1' ;
            directory: '/www/tmp' ;
            keepAlive: true ;
            user: 'user' ;
            yourself).


myBackup :=  MaBanyanBackup
    source:
        (FileDirectory on: 'C:\Documents and Settings\user\Mis documentos')
    target:
        (FileDirectory on: 'C:\Documents and Settings\user\Mis documentos\BACKUP').
        
myBackup viewProposedChanges.
myBackup prepareToMakeTargetLikeSource.
myBackup execute.

x := MaBanyanBackup organization.
x explore.

x := MaBanyanBackup methodDict.
x explore.
    
(FileDirectory on: 'C:\Archivos de Programa') maOpenSizeTreeForEntriesLargerThan: 10000000. "only show lines in the report larger than 10MB"

0

0

jQuery is included via the Google AJAX Libraries repository. Dean Edwards' IE7-js is included via it's Google Code hosting URL. Version numbers of both libraries should be checked and updated to latest versions. Note: While libraries can be referenced from the Google AJAX Libraries repository with abbreviated version numbers (specifying just '1', instead of '1.3.2', for example), it's always better to include the full version number. Otherwise, Google will not sent appropriate cache and expires headers.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head>
  <title>PageTitle</title>
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <meta name="description" content="" />
  <link rel="stylesheet" href="screen.css" type="text/css" media="screen,projection,tv" />
  <link rel="stylesheet" href="print.css" type="text/css" media="print" />
  <!--[if lt IE 7]>
    <link rel="stylesheet" href="ie6.css" type="text/css" media="screen,projection,tv" />
    <script src="http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE7.js" type="text/javascript"></script>
  <![endif]-->
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
</head> 
<body id="" class="">  
  <h1>PageTitle</h1>
  
</body>
</html>

0

0

Defines a new variable and sets the initial value

var varname = 5;

0

0

There are free exchange rates data that are easy to retrieve and parse, here is the code of a mini webbot written in ASP that goes out on Bank of Italy site, get the exchanges rates and print them.

<%
Dim yesterday
yesterday = dateadd("d",-1,date)

Dim objHttp
Set objHttp = Server.CreateObject("Microsoft.XMLHTTP")
objHttp.Open "GET", "http://uif.bancaditalia.it/UICFEWebroot/QueryOneDateAllCur?lang=en&rate=0&initDay=" & Day(yesterday) & "&initMonth=" & Month(yesterday) & "&initYear=" & Year(yesterday) & "&refCur=euro&R1=csv", False
objHttp.Send
If objHttp.Status = 200 Then
	Dim arrLines
	Dim arrFields

	Dim i
	arrLines = Split(objHttp.ResponseText,Chr(10))
	For i = 0 To UBound(arrLines)-1
		If i >= 4 then
			arrFields = Split(arrLines(i),",")
			response.write arrFields(4) & " " & arrFields(1) & " (" & arrFields(2) & ") per 1 EUR<br/>"
		End if
	Next 
Else
	Response.Write(objHttp.Status & " - " & objHttp.StatusText)
End If
Set objHttp = Nothing
%>
Snippets.pw - All rights reserved Raphaël Vigée 2017