DO NOT use on live/production site.
ob_start();
var_dump($something_anything);
$yourResultingString = ob_get_clean();
DO NOT use on live/production site.
ob_start();
var_dump($something_anything);
$yourResultingString = ob_get_clean();
$protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,5))=='https'?'https':'http';
print "The protocol is $protocol";
?>
taken directly from:
http://readytousesolutions.com/phpblog/php-tutorial-get-protocol/
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>File to track
<script type="text/javascript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
</head>
<body onLoad="MM_goToURL('parent','pdfs/file_name_here.pdf');return document.MM_returnValue">
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-1234567-1");
pageTracker._trackPageview();
} catch(err) {}
</script>
</body>
**** note the back ticks not single quote ******
executes the contents of the ticks as if you are at the terminal but as apache or whoever your web server is. this code basically
echo `whoami`; // well who is this script running as
echo `pwd`; // think whereami
echo `mkdir test`; // make a directory
echo `mkdir test/anothertest`; // make a directory in the directory created
echo nl2br(`ls`); // list what is in this directory
`touch log.txt`; // make a text file named log.txt
$date = date("F j, Y, g:i a");
`echo $date > log.txt`; // writes the $date to log.txt
`echo foo >> log.txt`; // writes foo to log.txt
echo nl2br(`cat log.txt`); // echoes what is in log.txt
echo nl2br(`tail /opt/local/apache2/logs/error_log`); // echoes what is in the error_log
$str = “@ % * alpha numeric 0 – 9 only _ – +@_#()()++”;
$str = preg_replace(‘/[^A-Za-z0-9]/’, ”, $str);
echo $str;
returns alphanumeric09only
enable by setting the flag in .htaccess
php_flag short_open_tag on
Open php.ini ( /etc/php.ini or /usr/local/etc/php.ini), enter:
# vi php.ini
Set short_open_tag to On:
short_open_tag = On
Save and close the file. Restart webserver:
# service httpd restart
or
# /etc/init.d/httpd graceful
To replace spaces with underscores and then remove everything that isn’t alpha-numeric open up
wolf/plugins/file_manager.FileManagerController.php
and replace the existing upload function (approx line 259) with this.
public function upload() {
$data = $_POST['upload'];
$path = str_replace('..', '', $data['path']);
$overwrite = isset($data['overwrite']) ? true: false;
if (isset($_FILES)) {
// $file = upload_file($_FILES['upload_file']['name'], FILES_DIR.'/'.$path.'/', $_FILES['upload_file']['tmp_name'], $overwrite);
$clean_file_name = preg_replace('/ /', '_', $_FILES['upload_file']['name'] );
$clean_file_name = preg_replace('/[^A-Za-z0-9_.]/', '', $clean_file_name );
$file = upload_file( $clean_file_name, FILES_DIR.'/'.$path.'/', $_FILES['upload_file']['tmp_name'], $overwrite);
if ($file === false)
Flash::set('error', __('File has not been uploaded!'));
}
redirect(get_url('plugin/file_manager/browse/'.$path));
}
$variable = condition ? if true : if false;
as in:
$age = 24;
$drinkingAge = ($age > 21) ? “have a beer” : “have an iced tea”;
echo $drinkingAge; // returns have a beer
<?php
$today = getdate();
$day = $today['mday'];
$month = $today['mon'];
$year = $today['year'];
$mtharr = array(“January”,”February”,”March”,”April”,
“May”,”June”,”July”,”August”,”September”,
“October”,”November”,”December”);
?>
<select name=”start_day”>
<?php
for ($i=1;$i<=31;$i++) {
echo “nt<option value=”$i”";
if ($i == $day) echo ” selected”;
echo “>$i</option>”;
}
?>
</select>
<select name=”start_month”>
<?php
for ($i=1;$i<=12;$i++) {
echo “nt<option value=”$i”";
if ($i == $month) echo ” selected”;
echo “>” . $mtharr[$i-1] . “</option>”;
}
?>
</select>
<select name=”start_year”>
<?php
for ($i=0;$i<=9;$i++) {
$tmp = $today['year'] + $i;
echo “nt<option value=”$tmp”";
if ($today['year'] == $tmp) echo ” selected”;
echo “>” . $tmp . “</option>”;
}
?>
</select>
neat_trim($your_text, 100);
function neat_trim( $string, $n, $close = '…' ) {
$len = strlen( $string );
if ($len > $n) {
preg_match('/(.{' . $n . '}.*?)b/', $string, $matches);
return rtrim($matches[1]) . $close;
} else {
return $string;
}
}