I am trying to Install Bitexhchange script on Localhost, after successfully doing all changes, I am getting PHP code in my browser
bitexchnage support page.
<?
include 'lib/common.php';
ini_set("memory_limit","200M");
$CFG->print = $_REQUEST['print'];
$CFG->url = ($_REQUEST['current_url'] != 'index.php') ? ereg_replace("[^a-zA-Z_\-]", "",$_REQUEST['current_url']) : '';
$CFG->action = ereg_replace("[^a-zA-Z_\-]", "",$_REQUEST['action']);
$CFG->bypass = ($_REQUEST['bypass'] || $CFG->print);
$CFG->is_tab = (!$CFG->url) ? 1 : $_REQUEST['is_tab'];
$CFG->id = ereg_replace("[^0-9]", "",$_REQUEST['id']);
$CFG->target_elem = ereg_replace("[^a-zA-Z_\-]", "",$_REQUEST['target_elem']);
$CFG->in_popup = ($CFG->target_elem == 'edit_box' || $CFG->target_elem == 'message_box' || $CFG->target_elem == 'attributes box');
$CFG->inset_id = false;
$_SESSION['last_query'] = $_SESSION['this_query'];
$_SESSION['this_query'] = 'index.php?'.http_build_query((is_array($_POST)) ? $_POST : $_GET);
date_default_timezone_set($CFG->default_timezone);
String::magicQuotesOff();
Your php is probably not configured to accept the short open tags (<?)
You should either enable it into your php.ini file (see How to enable PHP short tags? ) or use the "long" php open tag : <?php
Related
I'm using the code below to choose an image based on the domain.
the only difference between environments is wamp is running PHP 7 and my host 7.1 and I've been unable to get a copy of wamp with PHP 7.1 included.
on the live site, the end result is a blank white page with the PHP error on the 'else' line
I'm not sure if this is correct but after $logo_img = "3_logo.svg" if I add the semicolon you get a white page but without works just fine.
<?php
$host = $_SERVER['HTTP_HOST'];
$logo_img = '';
if($host == "1.co.uk") {
$logo_img = "1_logo.svg";
}
else if($host == "2.co.uk") {
$logo_img = "2_logo.svg";
}
else($host == "3.co.uk") {
$logo_img = "3_logo.svg" //with semicolon errors - unexpected ';'
}
?>
any help appreciated!!
UPDATE:
var_dump ($_SERVER['HTTP_HOST']); returns
Localhost
string 'localhost' (length=9)
Live site
string(23) "www.domain.co.uk"
Please fix this
here is syntax error
else($host == "3.co.uk") {
$logo_img = "3_logo.svg" //with semicolon errors - unexpected ';'
}
you need to write
elseif($host == "3.co.uk") {
$logo_img = "3_logo.svg";
}
else{ ..... }
I am trying to see if JQuery CDN exists or not via PHP
essentially what Paul Irish did here but with PHP instead.
http://paulirish.com/2010/the-protocol-relative-url/
I am trying following but it's not working. Is this possible without http/https?
This is based on How can I check if a URL exists via PHP?
$jquery_cur = '1.9.1'; // JQuery Version
$jquery_cdn = '//code.jquery.com/jquery-'.$jquery_cur.'.min.js';
$jquery_local = '/assets/js/libs/jquery-'.$jquery_cur.'.min.js';
$jquery_ver = $jquery_cdn; //Load the Jquery CDN version by default
$cdn_headers = #get_headers($jquery_ver);
if(strpos($cdn_headers[0], '404 Not Found')) {
$jquery_ver = $jquery_cdn;
}
else {
$jquery_ver = $jquery_local;
}
Hi check this solution you were check header without any protocol you need to add http or https to check files. test it with or without your internet connection.
$jquery_cur = '1.9.1'; // JQuery Version
$jquery_cdn = '//code.jquery.com/jquery-'.$jquery_cur.'.min.js';
$jquery_local = '/assets/js/libs/jquery-'.$jquery_cur.'.min.js';
$jquery_ver = $jquery_cdn; //Load the Jquery CDN version by default
$jquery_url = ( $_SERVER['SERVER_PORT'] == 443 ? "https:" : "http:").$jquery_cdn;
$test_url = #fopen($jquery_url,'r');
if($test_url === False) {
$jquery_ver = $jquery_local;
}
echo $jquery_ver;
with get_header
$headers = #implode('', #get_headers($jquery_url));
$test_url = (bool)preg_match('#^HTTP/.*\s+[(200|301|302)]+\s#i', $headers);
if($test_url === False) {
$jquery_ver = $jquery_local;
}
echo $jquery_ver;
is it possible to check (with PHP) if the browser supports SVG?
like ...
if( BROWSER support SVG )
{
$iT = 'svg'; // Icon type
}
else
{
$iT = 'png'; // Icon type
}
in HTML code ...
<img src="icons/home.<?=$iT?>" class="icon" />
EDIT:
How about to check the browser and the version? Good idea?
$data['browser'] = strtolower($data['browser']);
if ($data['browser'] == 'firefox' && (int)$data['browser']['version'] >= 10)
$iT = 'svg';
elseif ($data['browser'] == 'safari' && (int)$data['browser']['version'] >= 5)
$iT = 'svg';
.... and so on
PS: Did anybody know a nice SVG-Browser-Support-List?
You could probably do the check using JavaScript and Raphael, and then send that back to the server.
today one of my friends had a problem with his guestbook. We use a small php orientated guestbook which was working fine except for one thing: it had reached its limit of messages.
So what i did is edit the blog file and change the following setting:
//Maximum entry stored in data file
$max_record_in_data_file = 1800;
The moment I did this though, something went very wrong. I uploaded the file back on the server and got the following:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at E:\inetpub\vhosts\trilogianocturnus.com\httpdocs\guestbook.php:1) in E:\inetpub\vhosts\trilogianocturnus.com\httpdocs\guestbook.php on line 95
I don't know what this is, I'm very new to php, but from what I understand, it means something is already being called by the browser before session_start
The page is located at:
http://trilogianocturnus.com/guestbook.php
The code before the head is as follows:
<?
/*-----------------------------------------------------
COPYRIGHT NOTICE
Copyright (c) 2001 - 2008, Ketut Aryadana
All Rights Reserved
Script name : ArdGuest
Version : 1.8
Website : http://www.promosi-web.com/script/guestbook/
Email : aryasmail#yahoo.com.au
Download URL :
- http://www.promosi-web.com/script/guestbook/download/
- http://www.9sites.net/download/ardguest_1.8.zip
This code is provided As Is with no warranty expressed or implied.
I am not liable for anything that results from your use of this code.
------------------------------------------------------*/
//--Change the following variables
//Title of your guestbook
$title = "Guestbook Nocturnus";
//Change "admin" with your own password. It's required when you delete an entry
$admin_password = "***";
//Enter your email here
$admin_email = "***";
//Your website URL
$home = "http://www.trilogianocturnus.com/main.html";
//Send you an email when someone add your guestbook, YES or NO
$notify = "YES";
//Your Operating System
//For Windows/NT user : WIN
//For Linux/Unix user : UNIX
$os = "WIN";
//Maximum entry per page when you view your guestbook
$max_entry_per_page = 10;
//Name of file used to store your entry, change it if necessary
$data_file = "ardgb18.dat";
//Maximum entry stored in data file
$max_record_in_data_file = 1800;
//Maximum entries allowed per session, to prevent multiple entries made by one visitor
$max_entry_per_session = 10;
//Enable Image verification code, set the value to NO if your web server doesn't support GD lib
$imgcode = "YES";
//Color & font setting
$background = "#000";
$table_top = "#000";
$table_content_1a = "#090909";
$table_content_1b = "#000000";
$table_content_2a = "#090909";
$table_content_2b = "#000000";
$table_bottom = "#000";
$table_border = "#1f1f1f";
$title_color = "#9f0000";
$link = "#9f0000";
$visited_link = "#9f0000";
$active_link = "#9f0000";
$font_face = "verdana";
$message_font_face = "arial";
$message_font_size = "2";
//-- Don't change bellow this line unless you know what you're doing
$do = isset($_REQUEST['do']) ? trim($_REQUEST['do']) : "";
$id = isset($_GET['id']) ? trim($_GET['id']) : "";
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$self = $_SERVER['PHP_SELF'];
if (!file_exists($data_file)) {
echo "<b>Error !!</b> Can't find data file : $data_file.<br>";
exit;
} else {
if ($max_record_in_data_file != "0") {
$f = file($data_file);
rsort($f);
$j = count($f);
if ($j > $max_record_in_data_file) {
$rf = fopen($data_file,"w");
if (strtoupper($os) == "UNIX") {
if (flock($rf,LOCK_EX)) {
for ($i=0; $i<$max_record_in_data_file; $i++) {
fwrite($rf,$f[$i]);
}
flock($rf,LOCK_UN);
}
} else {
for ($i=0; $i<$max_record_in_data_file; $i++) {
fwrite($rf,$f[$i]);
}
}
fclose($rf);
}
}
}
session_start();
$newline = (strtoupper($os) == "WIN") ? "\r\n" : "\n";
switch ($do) {
case "":
$record = file($data_file);
rsort($record);
$jmlrec = count($record);
?>
I have of course, removed the password and email for security, now here isthe funny part.
This error started happening the moment i changed that setting up up there, but if i tried to revert it back to 1800 (i changed it to 11800 to test it out), it still gives me that error.
Any idea of what this is?
The guestbook url is: promosi-web.com/script/guestbook/
The most common cause of this error is something being added to the file before the <?
Most likely a space or UTF byte order mark.
Put your session_start() after <? and you should be fine
Note:
To use cookie-based sessions, session_start() must be called before outputing anything to the browser.
http://php.net/manual/en/function.session-start.php
The message says that the “output started at …\guestbook.php:1”. So there must be something in that file on that line that initiated the output.
Make sure that there are no whitespace or other invisible characters (like a BOM) before the opening <? tag.
Check if you have a space or a byte order mark, you can also do an
ob_start(); at the beginning of the page and ob_end_flush(); at the end to solve this issue.
but IMO check for the space or the B.O.M
I'm trying to figure out the visitor's OS is either a Windows, Mac or Linux using PHP(I don't need the version, distro info.. etc). There's several methods out there however they look a bit too complicated for this simple requirement.
Are there any simple ways that could provide this sort of information yet still being quite reliable?
Thanks in advance.
<?php
$agent = $_SERVER['HTTP_USER_AGENT'];
if(preg_match('/Linux/',$agent)) $os = 'Linux';
elseif(preg_match('/Win/',$agent)) $os = 'Windows';
elseif(preg_match('/Mac/',$agent)) $os = 'Mac';
else $os = 'UnKnown';
echo $os;
?>
For an easy solution have a look here.
The user-agent header might reveal some OS information, but i wouldn't count on that.
For your use case i would do an ajax call using javascript from the client side to inform your server of the client's OS. And do it waterproof.
Here is an example.
Javascript (client side, browser detection + ajax call ):
window.addEvent('domready', function() {
if (BrowserDetect) {
var q_data = 'ajax=true&browser=' + BrowserDetect.browser + '&version=' + BrowserDetect.version + '&os=' + BrowserDetect.OS;
var query = 'record_browser.php'
var req = new Request.JSON({url: query, onComplete: setSelectWithJSON, data: q_data}).post();
}
});
PHP (server side):
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$session = session_id();
$user_id = isset($user_id) ? $user_id : 0;
$browser = isset($_POST['browser']) ? $_POST['browser'] : '';
$version = isset($_POST['version']) ? $_POST['version'] : '';
$os = isset($_POST['os']) ? $_POST['os'] : '';
// now do here whatever you like with this information
}
use the Net_UserAgent package
docu is here: http://pear.php.net/package/Net_UserAgent_Detect/docs/latest/Net_UserAgent/Net_UserAgent_Detect.html#methodgetOSString
get the php file here:
package/Net_UserAgent_Detect/docs/latest/__filesource/fsource_Net_UserAgent__Net_UserAgent_Detect-2.5.1Detect.php.html