Setvir 0 Newbie Poster

I am looking for an method to indicate to mobile customers if a taxi's insurence is up to date or not. Should be bluetooth or wifi based and work from the taxi drivers phone and we must be able to update it remotely. Anyone have an idea what to use to implement this?

Setvir 0 Newbie Poster

here is code that I am working on.
What it is supposed to do is upload a media file (image, audio, video) and then tell me what type of media it is.

            $media_type='image';
            $filename=$_FILES["file"]["name"];
            $extension = explode(".", $filename);
            $extension = end($extension);
            //echo $extension;
            if (($_FILES["file"]["size"] < 50000)
            && (!$_FILES["file"]["error"] > 0) )
            {
              $allowedPicExt = array("jpg", "jpeg", "gif", "png");
              if (in_array($extension, $allowedPicExt))
                {           
                    $media_type='image';
                } 
              $allowedAudioExt = array('mp3', "wav");
              if (in_array($extension, $allowedAudioExt))
                {           
                    $media_type='audio';
                }
              $allowVideoExt=array("mp4","ogg");
              if (in_array($extension,  $allowVideoExt))
                {           
                    $media_type='video';
                }
            }
            echo "--".$extension."--".$media_type;

Tested it with a png and it gives me back --png--image
Tried it with a mp3 and then only gives me back --mp3--

I have looked at every angle on this one but not seeing what I am doing wrong. The part that saves the file is not shown, but it does work and saves the file as it is supposed to...

Any advice??

Setvir 0 Newbie Poster

I am trying to submit to a newsoap service and keep recieving the following error
HTTP/1.1 400 Bad Request
Cache-Control: private
Transfer-Encoding: chunked
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Mon, 03 Sep 2012 10:09:41 GMT

Function I have written looks like the following ($post_xml is shown below and $url is the url of the webservice):

function my_soap_submit($post_xml, $url){
    require_once('lib/nusoap.php');
    $client = new nusoap_client($url, false);
    $soapaction = "http://www.service_domain.co.za/FullApp";
    $msg = $client->serializeEnvelope($post_xml);
    $result = $client->send($msg, $soapaction);
    $err = $client->getError();
    if ($err) {
            echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
            echo $client->response;
            exit();
    }
    return $result;
} 

Here follows my xml:

<FullApp xmlns="http://www.service_domain.co.za/">
      <SourceAppNumber>211-211-103165-20120803-151534</SourceAppNumber>
      <SourceAppForm><NewAppDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Application  SourceSystemCode="TRADER"  TransactionIdentifier="TRADER" TransactionType="001" SourceAppNo="211-211-103165-20120803-151534" SubmitDate="20120903" SubmitTime="120941" VersionNo="002">
        <ApplicationDetail ApplicationType="STD" LoanTypeCode="LD145" Chain="101" BranchName="Staff Benefits" BranchNo="1101" InvoiceNo="0" InvoiceDate="18991230" AccCatLoanType="STL" DealerCode="MTM0002" RepCode="MTM0002">
            <FormalInvoice TotalValueOfGoods="MR" DealContractAmount="MR" />
            <PaymentDetails AccHolderSurname="" AccHolderInitials="" PaymentDeductionDate="1" PaymentMethod="Y">
                <BankAccountDetail BankName="" BranchCode="" AccountNo="" AccountType="S"/>
            </PaymentDetails>
            <MarketingOptions MarketingListIndicator="on" MarketingByEmail="on" MarketingByTelepone="N" LanguageForDocumentation="Afr" />
        </ApplicationDetail>
        <Applicant ApplicantType="INDIV" ClientId="1" PrimaryApplicant="y" Title="Mr" Surname="Vermeulen" Firstname="Daniel" Initials="D" DateOfBirth="19780228" IDType="R" IDNo="8110310539084" MaritalStatus="M" EmploymentStatus="F" OwnAMotorVehicle="y">
            <ContactDetail HomeTelCode="011" HomeTelNo="5234561" WorkTelCode="023" WorkTelNo="3472735" CellularNo="0739470814" />
            <Address>
                <ResidentialAddress PeriodOfResidence="1000">
                    <AddressDetail AddressLine1="38 Nighting Gale street" AddressLine2="Avianpark" Suburb="Worcester" TownCity="" PostCoce="6850"/>
                </ResidentialAddress>
                <PostalAddress PostalSameAsResidential="N">
                    <AddressDetail AddressLine1="38 Nigting Gale Street" AddressLine2="Avianpark" Suburb="Worcester" TownCity="" PostCoce="6850"/>
                </PostalAddress>
            </Address>
            <Employment>
                <CurrentEmployer EmployerName="Woolworths LTD" Occupation="Controller" PeriodAtEmployer="0300" />
            </Employment>
            <NextOfKin Title="Mev" Surname="Vermeulen" FirstName="Ronel" Relationship="Othr">
                <AddressDetail AddressLine1="38 Nightingele street" AddressLine2="Avianpark" Suburb="Worcester" TownCity="" PostCoce="6850"/>
                <ContactDetail HomeTelCode="" HomeTelNo="" WorkTelCode="" WorkTelNo="" CellularNo="0710774719" />
            </NextOfKin>
            <NextOfKin Title="" Surname="" FirstName="" Relationship="">
                <AddressDetail AddressLine1="" AddressLine2="" Suburb="" TownCity="" PostCoce=""/>
                <ContactDetail HomeTelCode="" HomeTelNo="" WorkTelCode="" WorkTelNo="" CellularNo="" …
Setvir 0 Newbie Poster

I am urgently seeking assistance with the following error:
Commands out of sync; you can't run this command now

here's the code:

$sql="select pr1.".$_SESSION['lang'].", pr1.id, pr2.".$_SESSION['lang'].", pr2.id from `project` as pr2 join project as `pr1` on(pr1.id=pr2.parent_project) where pr2.id=?";
        $stmt = $mysqli->stmt_init();   
        $stmt->prepare($sql) or die ("Error preparing statement: ".$mysqli->error);
        $stmt->bind_param('i',$_GET['id']); 
        $stmt->execute() or die("Error, error, error!");
    $stmt->bind_result($group,$group_id,$project,$project_id);

I have tied non prepared statements (they work...) and have even changed the sql to something simple without binding parameters, but as soon as I get to the ececute statement the error is triggered.

Thanks in advance!

Setvir 0 Newbie Poster

Anyone have any ideas??

Setvir 0 Newbie Poster

I'm trying to think how to change this into a js tree view.
It consists of lines that point to a file(no extention)
Each one is a link...

rustenburg
rustenburg/school/hstegnies
rustenburg/school/bergsig/sport/rugby
rustenburg/school/bergsig/sport/tennis
rustenburg/sport
rustenburg/sport/rugby
rustenburg/sport/tennis/rustenburg tenis club
rustenburg/sport/tennis/Impala club
rustenburg/sport/rugby/impala
rustenburg/sport/rugby/xtrata
rustenburg/places/city hall
rustenburg/places/kloof
etc..

ideas??

Setvir 0 Newbie Poster

Thanks hielo,
Works 100% for what I need!
This works even on nested quotes, NICE!

Just a note for future reference, the code should be used on one line at a time - Like:

$str=<<<STR
multipart/alternative; boundary="001636284f500b21f90494114b4d"
STR;
$str=preg_replace('#(\x22|\x27)([^;]*)(?<!\x5C)(;)(.*?)\1#','$1$2'.chr(7).chr(92).';$4$1',$str);
$m=preg_split('#(?<![\x5C]);#',$str);
foreach($m as $i=>$v)
{
	$m[$i]=str_replace(chr(7).chr(92).';',';',$v);
}
//this shows the result
print_r($m);

Now I have to figure out how it works (only way to learn!)

Thanks again!

Setvir 0 Newbie Poster

This would be to parse email headers (nearly impossible task ;-))
from raw emial data.

This preg should use be able to split the following strings:
multipart/alternative; boundary="001636284f500b21f90494114b4d"
multipart/alternative; boundary='001636284f500b21f90494114b4d'
multipart/alternative; boundary="001636284f;500b21f90494114b4d"
foo; fa="001636284f5"\; fy="00b21f90494114b4d"

It should only split on the one (or multiple) ';' character except where it is in quotes or has been escaped.

Thanks for the feedback.

Setvir 0 Newbie Poster

Thanks cwarn23,
Will implement the change you suggested.

Setvir 0 Newbie Poster

Lol, true! But it is an option...

I would not download anything from any site I do not trust.

Setvir 0 Newbie Poster

Another idea. Why not make the zip file a self extracting exe?
Here's a link to a class that does just that!
http://www.phpclasses.org/package/945-PHP-Create-tar-gzip-bzip2-zip-extract-tar-gzip-bzip2-.html

Setvir 0 Newbie Poster

If you want one file downloaded with all the files in them the only way is to do it with a zip file (maybe other formats could be used but zip is standard).

You could offer an option where they can select the files. Then when they click download they are directed to another page. Each download file can then be started with javascript to start downloading by opening the php page (with the above script on) in a different window for each file to be downloaded.

<script>
  window.open('http://www.yourdomain.com/get_file,php?file=bluebird.jpg');
  window.open('http://www.yourdomain.com/get_file,php?file=nice_lady.jpg');
  window.open('http://www.yourdomain.com/get_file,php?file=chinesecrested.gif');
  etc..
</script>
if (file_exists($_GET['file'])) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
}

But you may have problems with popup blockers(!?).


You could go completely different route and send the user an email with the files attached.

I think personally the first and last options are the things you should look at.

Setvir 0 Newbie Poster

Hi there,
Hope this helps. I havent tested it but it looks like something that may help.

Forcing a download

<?php
$file = 'monkey.gif';

if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
}
?>

Refer to example 1 at:http://www.php.net/manual/en/function.readfile.php

Let me know if it works, may be able to use it myself in future!

Setvir 0 Newbie Poster

iammirko,
I agree with evstevemd! Email clients are complex!
Speeking out of experience here. I wrote a system where clients email updates to their websites.

Trust me, try something that is already out there!

Setvir 0 Newbie Poster

Ok, found a much better tutorial for your use.

Flat file database demo

At the bottom there is a link to a second tutorial that explains how to do more advanced things like sorting.

To delete a file you can look at the following tutorial:
Unlink function

Setvir 0 Newbie Poster

Another tutorial on sving data:
Form to flat file

Hope it helps!

Setvir 0 Newbie Poster

Hi nats01282,
You will need to save the data you have entered on the first page either to a database like MySql or you can save it to a file.

Here are tutorial links:
Writing to a file
Saving to MySql database

Setvir 0 Newbie Poster

Hi guys and gals!
I want to know if I am on the right track.

I am working on a simple in-house cms. Here is a templating function I wrote to test an idea. It does work.

  1. The function loads the template file,
  2. finds all the template variables (eg. {_variable_}).
  3. if the variable was passed to the function ($value array) it will be replaced in the template
  4. Else it will replace it with output from a php file with the same name as the variable

Your feedback and ideas welcome!

function humpot_templater($vars=array(), $template="template.html", $php_blocks_folder=""){
	ob_start();
		if(!@include($template)) {
				//include the template file
				print("Template not found at: ./".$template);
		}
	$html=ob_get_clean();
	preg_match_all('/\{_(.*?)_\}/', $html, $matches, PREG_PATTERN_ORDER);
	if (isset($matches[1])){
		foreach($matches[1] as $variable){
			if(isset($vars[$variable]) && is_array($vars)){ 
				//get the variable already set in $vars arry
				$templ_replacements[$variable]=$vars[$variable];
			} else {
				//include the php code block coresponing to the template variable
				//block must output a string (can be script, css or html)
				ob_start();
					if(!@include($php_blocks_folder.$variable.'.php')){
						print ("Error: Template variable '".$variable."' was not set or './".$php_blocks_folder.$variable.".php' does not exist.");
					}
				$templ_replacements[$variable]=ob_get_clean();//if the block exists then this now countains its output
			}
		}
	}
	return  preg_replace("/{_(.*?)_}/ime", "\$templ_replacements['$1']",$html);
}
Setvir 0 Newbie Poster

Hi, my name is Lionel and I'm a computerholic!

I run a small web design and development business in Rustenburg, South Africa.

Specialities (or still getting there)
PHP
HTML
Javascripting

Being a geek, I am still single (dont get out much :'()

Setvir 0 Newbie Poster

The first question
You will use $_SESSION after that or you can say
$user=$_SESSION on the top of the page (or in your case pghead.php)

Second question
Depends...
Read up about session security before you decide what to store there

Setvir 0 Newbie Poster

There are a few ways of doing this.
On your sending page:
Send the variable from a form:

use method post or get for form

<input type="hidden" name="date" value="<?php echo $date; ?>" \>

or by setting sending it in a url

< a href="nexpage.php?date=<?php echo urlencode($date); ?>" \>

or by setting a session variable

$_SESSION['date']= $date;

Then on nexpage.php:

if sent from a form with the post method

$date=$_POST['date'];

if sent from a form using get method
or as part of the url

$date=$_GET['date'];

or if your session is set

$date=$_SESSION['date'];

Hope it helps!

Setvir 0 Newbie Poster

Anyone have an idea what the regex would be for preg_split to split a string at a semicolon ( ; ), but ignore any quoted (single or double) parts as well as ignore escaped ( \; ) semicolons?

I have tried to decipher this one and could not (regex not my strongpoint - YET)

Herewith is a function I wrote that does this what I want.

//split string into characters and process...
function split_at($input, $splitAt=";"){
	$on=1;
	$j=0;
	$output[0]="";
	for($i=0; $i<strlen($input); $i++) {
                //when a quote is reached then set $on switch off to ignore quoted part
                //untill another quote is reached then it switches $on on again
		if($input[$i]=='"' or $input[$i]=="'"){
			if ($on) {$on=0;} else {$on=1;}
		}
                //create new array for new part when a semicolon is reached
                //or ignore if in quoted part or if escaped
		if($input[$i]==";" && $on==1){
		  if(isset($input[$i-1]) && $input[$i-1]!="\\"){
			$output[++$j]="";
			continue;
		  }
		} 
		$output[$j].=$input[$i];
	}
        // array of split parts of input
	return $output;
}

Any help would be appreciated!

Setvir 0 Newbie Poster

Google :-)

Setvir 0 Newbie Poster

Rather than using $_REQUEST['pid'] try using $_POST['pid'] if the form method is post or $_GET['pid'] if the form method is get.

Setvir 0 Newbie Poster

I think you should do something like this on the next page...

$object=new registerClass();
$object->checkLogin($_POST['Username'], $_POST[Password]);
Setvir 0 Newbie Poster

You can try

while (list($key,$value) = each($object)) {
	echo $key.":".$value;
}

$object is an object or an array.