Jump to content

garethhall

Members
  • Posts

    194
  • Joined

  • Last visited

    Never

Posts posted by garethhall

  1. I have been tying to get the site redirection to work but I keep on getting an internal server error

     

    Here is what I need if the url is not

    http://www2.mydomain.com/content/newzealand/mpc/mpc_newzealand_website/en/home_mpc/van** or http://www2.mydomain.com/content/newzealand/mpc/mpc_newzealand_website/en/home_mpc/truck***

     

    then redirect http://www.mydomain.com

     

     

    This is what I have at present but like I said it does not work.

     

    Options +FollowSymLinks

    RewriteEngine On

    RewriteCond !http://www2.mydomain.com/content/newzealand/mpc/mpc_newzealand_website/en/home_mpc/van.*

    RewriteCond !http://www2.mydomain.com/content/newzealand/mpc/mpc_newzealand_website/en/home_mpc/truck.*

    RewriteRule .* http://www.mydomain.com [R=301,L]

  2. Try

    $sql = "UPDATE `master` SET `LOCATION` = '{$LOCATION}', `Location Name` = '{$Location Name}' WHERE `Asset Number` = '{$Asset Number}'"

    or

    $sql = "UPDATE `master` SET `LOCATION` = '$LOCATION', `Location Name` = '$Location Name' WHERE `Asset Number` = $Asset Number"

    or

    $sql = 'UPDATE `master` SET `LOCATION` = ' . $LOCATION} . ', `Location Name` = ' . $Location Name . ' WHERE `Asset Number` = ' . $Asset Number

  3. This is so frustrating the documentation on SOAP for php is very poor.

     

    Here is a very simple example.

     

    I need this request:

    <soapenv:Body>
       <ns1:retrieveCompanyCompleteDetails v:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" ns1="MED:CompanyDetailsService">
          <companyNumber href="#id0"/>
          <clientBillingReference xsi:type="xsd:string"></clientBillingReference>
       </ns1:retrieveCompanyCompleteDetails>
       <multiRef id="id0" soapenc:root="0" v:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int" soapenc="http://schemas.xmlsoap.org/soap/encoding/">1015969</multiRef>
    </soapenv:Body>
    

     

     

    MY php

    $CompanyDetailsService = new SoapClient('http://ws.eat.business.govt.nz/med-services/services/CompanyDetailsService.svc?wsdl');
    
    $result = $CompanyDetailsService->retrieveCompanyCompleteDetails('1968659');
    

     

    But my php posts this

    <SOAP-ENV:Body>
    <ns1:retrieveCompanyCompleteDetails>
    	<companyNumber xsi:type="xsd:int">1968659</companyNumber>
    	<clientBillingReference xsi:nil="true"/></ns1:retrieveCompanyCompleteDetails>
    </SOAP-ENV:Body>
    

     

    How do I get the right request?

     

  4. Hi

     

    I have to use soap to query an api but I am having some trouble the get the right response.

     

     

    Here is the API information I was supplied

     

    M = mandatory

    L = list parameter

    1-M = list of values containing at least one value, and may contain many values

    1-4 = list on values containing at least one value, and must contain no more than 4 values

     

     

    Parameter                    M  L      Desciption

    addressWordList            Y   1-4   A list of “keyword” elements. See table below for details.

    addressTypeList            Y   1-M   May contain: “ROF”, “AFR”,”AFS” or ”ASR”

    companyBodyTypeList  Y   1-M   May contain: “DOMESTIC”, “I”, “N”, “O” or “T”

    companyStatusList     Y   1-M   May contain: “50”, “55”, “56,57”, “60”, “61,71”, “62”, “63,64,66”, “65”, “70”,”72”,”80”

     

    "keyword" element:

    Component    M    Description

    keyword        Y    A word which must appear in the company’s address (any line of that address)

    operation        Y    May contain: “CONTAINS”, “BEGINSWITH”

     

     

     

    Notes:

    1. for the “addressWordList” parameter:

    a. each address word string must contain exactly one “word” (that is; do not put any <space> characters in the string)

    b. every value in the list of keywords must appear in the target address data (that is; this is an “AND” search condition)

    c. the list of keywords must be supplied in the same order as the words appear in the target address string. For example, for address “10 Ash Road, Nelson” enter the keywords in this order: “10”, “Ash”, “Road”, “Nelson”. Do not enter them in this order (for example):  “Nelson”, “10”, “Ash”, “Road”.

    d. each address word string has leading and trailing blanks removed before being used in the search. The search is case-insensitive.

    2. the element values within each “list” parameter above (other than the “addressWordList” parameter – described separately) will be used in an “OR” search condition (one or more of the individual element values must exist in the target data) to create the filter for that individual parameter. For example, the following partial filter condition is possible: (body_type = ‘U’ OR body_type = ‘X’ OR body_type = ‘P’ OR body_type = ‘L’ OR body_type = ‘O’) AND (status = ‘50’ OR status = ‘80’)

    3. for the “addressTypeList” parameter: see the appendix for a description of each code

    4. for the “companyBodyTypeList” parameter: the value “DOMESTIC” may be used to narrow the search to companies with body types of U, X, P or L (“unlisted company”, “private company”, “public company” or “listed”).

    5. for the “companyStatusList” parameter: the value “61,71” is not a typing error. It may be used to narrow the search to companies with a status of 61 or 71.  The same applies for the values “63,64,66” and “56,57”.

     

     

    This is my code

     

    And I get this error:

    "Fatal error: Uncaught SoapFault exception: [soapenv:Server.generalException] At least one address word must be specified, but no more than four in /Users/garethhall/Sites/querytool/public_html/index.php:58 Stack trace: #0 [internal function]: SoapClient->__call('performAddressS...', Array) #1 /Users/garethhall/Sites/querytool/public_html/index.php(58): SoapClient->performAddressSearch(Array) #2 {main} thrown in /Users/garethhall/Sites/querytool/public_html/index.php on line 58"

     

    <?php
    $CompanyMiscSearchService = new SoapClient('http://ws.eat.business.govt.nz/med-services/services/CompanyMiscSearchService.svc?wsdl');
    
    $result = $CompanyMiscSearchService->performAddressSearch(array(
    'addressWordList' => array('auckland'),
    'addressTypeList' => 'ROF',
    'directorStatus' => array('valueString' => 'CURRENT'),
    'companyBodyTypeList' => array('valueString' => 'DOMESTIC'),
    'companyStatusList' => array('valueString' => 50 ),
    ));
    
    print '<pre>';
    print_r($result);
    print '</pre>';
    
    ?>
    

     

     

     

     

     

  5. Hello,

     

    I have a SQL query below and it works but I have a slight problem.

    When fl.body_value is empty I don't get a result. So how do I Join on a table even if it's empty? In this case f.uri will always have a value.

     

     

    SELECT 
    f.uri ,
    fl.body_value 
    FROM node n 
    RIGHT JOIN field_data_com_slider_image fd 
    ON n.nid = fd.entity_id 
    RIGHT JOIN file_managed f 
    ON fd.com_slider_image_fid = f.fid 
    RIGHT OUTER JOIN field_data_body fl 
    ON n.nid = fl.entity_id
    WHERE n.type = 'com_slider' 
    AND n.status = 1
    

     

  6. Hi I am working on a php module and I am getting this "Notice: Undefined index:" Error.

     

    Now I know that I can change my php settings to not show the error but I would like to fix it properly.

     

    What am I doing wrong?

     

    <?php
    function _com_slider_image_styles() {
      $styles = &drupal_static(__FUNCTION__);
    
      // Grab from cache or build the array.
      if (!isset($styles)) {
        if ($cache = cache_get('image_styles', 'cache')) {
          $styles = $cache->data;
        }
        else {
          // Select all the user-defined styles.
          $user_styles = db_select('image_styles', NULL, array('fetch' => PDO::FETCH_ASSOC))
            ->fields('image_styles')
            ->orderBy('name')
            ->execute()
            ->fetchAllAssoc('name', PDO::FETCH_ASSOC);
        }
      }
    
      $com_styles = null;
      foreach($styles as $key => $value){
    	$com_styles[$key] .= $key; // PROBLEM HERE!
    }
      return $com_styles;
    }
    ?>
    

  7. Yes

     

    I thought I'd better include my encryption, decryption functions

    <?php
    
    define('CYPHER', 'My secret key'); 
    
    /*** Encryption ***/   
    function encrypt($text){
    $ivSize =  mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
    $iv = mcrypt_create_iv($ivSize, MCRYPT_RAND);
    $encrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, CYPHER, $text, MCRYPT_MODE_ECB, $iv);
      $encode = base64_encode($encrypt);
      return trim($encode); 
    } 
    /*** Decryption ***/   
    function decrypt($text) { 
    $ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
    $iv = mcrypt_create_iv($ivSize, MCRYPT_RAND);
    $decode = base64_decode($text);
    $decrypt = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, CYPHER, $decode, MCRYPT_MODE_ECB, $iv);
    	return trim($decrypt);
    }
    
    <?
    

     

     

  8. Hi Guys

     

    I have a $_GET[] variable that is not echoing out correctly.

     

    If I look at $GET in the uri then I have

    upload-swf.php?s=C2YuzOj+FCPieffLIEYdrtPAAQDVeg+yT+P2+N4Echw=

     

    But when I echo

    <?php
    echo $_GET['s'];
    
    //echo decrypt($_GET['s']);
    ?>
    

    I get: C2YuzOj FCPieffLIEYdrtPAAQDVeg yT P2 N4Echw=

     

    As you can see the + signs has been removed thus when I be decrypt $_GET['s'] I get the wrong values.

     

     

  9. Thank you for the reply but I really need the compName in only on column.

     

    However I did solve the problem using UNION

     

    For interest sake I have include the completed statemant

    SELECT 
    *
    FROM 
    compRel 
    RIGHT JOIN 
    comp 
    ON 
    compRel.subCompId = comp.compID
    RIGHT JOIN 
    compSettings 
    ON 
    comp.compID = compSettings.compId
    WHERE 
    compRel.compId = 37
    
    UNION
    
    SELECT 
    *
    FROM 
    compRel 
    RIGHT JOIN 
    comp 
    ON 
    compRel.compId = comp.compID
    RIGHT JOIN 
    compSettings 
    ON 
    comp.compID = compSettings.compId
    WHERE 
    compRel.subCompId = 37
    ORDER BY compName ASC
    

     

  10. Hi Guys

     

    I have 2 tables

    Table 1 called 'comp' (Holds company details) and has fields like

    compID,

    compName,

    compPhone,

    compAddress

     

    Table 2 called compRel (Holds company relational data) has fields

    compId,

    subCompId

     

     

    The sql I need to get all the right company id's is

    SELECT 
       r.compId,
       r.subCompId
    FROM
      compRel AS r
    WHERE
      r.compId = 37
    AND 
      r.subCompId = 37
    

    And like I said this is all correct so far and outputs data like so

    compId                subCompId

    1                              37

    37                            41

    37                            48

    37                            53

    37                            66

     

     

    So need to join the compName from the comp Table on to the id's but the hard part is that the first line needs to join comp.compName on the compRel.compId and rest need to join comp.compName on compRel.subcompId

     

    I can't get this to work

     

    My sql looks like this now

    SELECT
      r.compId,
      r.subCompId,
      IF(r.subCompId = 37, r.compId, r.subCompId) AS rID,
      comp.compID,
      comp.compName
    FROM
      compRel AS r
    RIGHT JOIN
      comp
    ON
      rID = comp.compID
    WHERE
      r.compID = 37
    AND
      r.subCompId = 37
    

     

    So now I get a error "Unknown column rID"

     

    The thing is if I change ON condition to r.subCompId = comp.compID and I look at my result rID is outputting the correct id's so why is rID not working?

  11. If the sql is correct then I suspect it could be something with data you are inserting. Perhaps one of the variables is containing an invalid character and that is breaking the sql. It's bad practice to not check your data anyway so lets fix that first and hopefully it will work.

     

    <?php
    /*** Protect Variables from SQL injection ***/
    function cv($value){
    if (get_magic_quotes_gpc()){
    	$value = stripslashes($value);
    }
    if (!is_numeric($value)){
    	$value = "'" . mysql_real_escape_string($value) . "'";
    }
    return $value;
    }
    
    if($mode=='t')  {
    	$canSend=$_POST['canSend'];
    	if($canSend==1) {
    		$name=$_POST['txtName'];
    		$useremail=$HTTP_SESSION_VARS['useremail'];
    		if($name=="" || $name=="Your Friend\'s Name") $nameflag=1;
    		$email=$_POST['txtEmail'];
    		if($email=='') {
    			$mailflag=1;
    		}
    		$re_user    = "^[a-z0-9\._-]+"; 
    		$re_delim   = "@"; 
    		$re_domain  = "[a-z0-9][a-z0-9_-]*(\.[a-z0-9_-]+)*"; 
    		$re_tld     = "\.([a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|" . "int|mil|museum|name|net|org|pro)$"; 
    		if(eregi($re_user . $re_delim . $re_domain . $re_tld, $email)==0){
    			$mailflag=1;
    		}
    		$subject=$_POST['txtSubject'];
    		if($subject=="" || $subject=="Your Subject Here") $subjectflag=1;
    	  $str=$_POST['txtMessage'];
    	  $order   = array("\r\n", "\n", "\r");
    	  $replace = '<br />';
    	  $message = str_replace($order, $replace, $str);
    		if($message=='') $messageflag=1;
    
    		if($nameflag!=1 && $mailflag!=1 && $subjectflag!=1 && $messageflag!=1) {
    			$message.="<br><a href='".$strsite."?".$username."'>".$strsite."?".$username."</a>";
    			$headers  = "MIME-Version: 1.0\r\n";
    			$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    			$headers .= "From: ". $useremail."\r\n";		
    			$mail=mail($email,$subject,$message,$headers);
    
    			$sql = "INSERT INTO log (user_id,receiver_email,subject,message) values (
    							".cv($userid).",
    							".cv($email).",
    							".cv($subject).",
    							".cv($message).")";
    
    			if(mysql_query($sql)){
    				// insert ok
    			}else{
    				//insert failed
    			}
    
    			if($mail) $sucess_flag=1;
    			else $failure_flag=1;							
    		}
    	}
    }
    ?>
    

  12. Hi, Please update code to:

    $sql = "insert into log (user_id,receiver_email,subject,message) values ($userid,'$email','$subject','$message')";
    

     

    If it still does not work please verify that there is a mysql connection. Typically we pass mysql_query($sql, $connection) how the connection is not required but it depends on your code. So verify you can do a simple select from the DB

  13. Hi,

     

    I don't think using $.post is any harder to write than $.ajax. That said yes having a callback is useful. I fixed some typos in your code but obj is still undefined

     

     

    $.ajax({
      url:'ajax/overview.php',
      type: 'POST',
      data:{'action' : 'noNewFiles'},
      success:function(data, textStatus, obj){
             console.log(obj);
         $('#newFiles').text(data);
      }
    });
    

     

  14. I have updated my code but obj is undefined

     

    $.post(
      'ajax/overview.php',
      {'action' : 'noNewFiles'},
      function(data, textStatus, obj){
             console.log(obj);
      	$('#newFiles').text(data);
      }
    );
    

     

  15. Hey guys,

     

    I am just in the process on converting a system to use jquery instead of normal javascript. But i need to detect the readystate in the jquery. How do I do that?

     

    Normal JS

    function theNewFiles(){
      xhrNewFiles=GetXmlHttpObject()
      if(xhrNewFiles==null){
      	alert("Browser does not support HTTP Request");
      	return;
      }
      var qstr;
      qstr = "action=noNewFiles";
      qstr += "&sid="+Math.random();
      xhrNewFiles.onreadystatechange = theNewFilesR;
      xhrNewFiles.open("POST","ajax/overview.php",true);
      xhrNewFiles.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xhrNewFiles.send(qstr);	
    }
    function theNewFilesR(){
      if(xhrNewFiles.readyState == 3){
      	document.getElementById('newFiles').innerHTML = '<img src="images/loaderWhiteBG.gif" width="105" height="12" />';
      }else if(xhrNewFiles.readyState==4 || xhrNewFiles.readyState=="complete"){ 
      	document.getElementById('newFiles').innerHTML = xhrNewFiles.responseText;
      }
    }
    

     

    Converted to jquery

    $.post(
      'ajax/overview.php',
      {'action' : 'noNewFiles'},
      function(data, textStatus){
      	$('#newFiles').text(data);
      }
    );  
    

  16. Hi

    Can someone help me get this array structure right?

     

    When I do a print_r($regions); I get the following result.

    Array (

    [0] => Array ( [nid] => 1079 [title] => Auckland [regions] => Array ( ) )

    [1] => Array ( [nid] => 1230 [title] => Bay of Plenty [regions] => Array ( ) )

    [2] => Array ( [nid] => 1231 [title] => Hawkes Bay [regions] => Array ( ) )

    )

     

    I am needing to add the following to this array

    [3] => Array ( [nid] => 999 [title] => Show All [regions] => Array ( )

     

     

    I have to following code

    <?php
    $regions = dealer_regions($region); // This builds the current Array THIS IS CORRECT
    
    // Trying to add to the Array  
    $regions[] .= array(
      	'nid' => '999',
      	'title' => 'SHOW ALL',
      	'regions' => array(),
      );
    ?>
    

     

    So with the code above I get the this result

    Array (

    [0] => Array ( [nid] => 1079 [title] => Auckland [regions] => Array ( ) )

    [1] => Array ( [nid] => 1230 [title] => Bay of Plenty [regions] => Array ( ) )

    [2] => Array ( [nid] => 1231 [title] => Hawkes Bay [regions] => Array ( ) )

    [3] => Array

    )

     

     

    So what am I doing wrong

  17. Hi

     

    I wonder if anyone can help me out.

     

    I am using the jquery tools plugins. I have posted this question on their forum to but no one has answered me yet.

     

    I need to run different scrollable objects concurrently. And it's not working for me.

    Actually if I change the class name away from scrollable it won't run at all.

     

    I have the scrollers set in a horizontal accordion.

    Here is my prototype page (it still just in the prototyping stage)

    http://www.communica.co.nz/concepts/prototyping/

     

    As you can see the tab-horizontal accordion works.

    But only the "capacity scroller works"?

     

    Why does the others not work? and why am I forced to use a class of scrollable? Even if the is only one scroller I can not change the class.

     

    Thanks

     

    Gareth

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <title>jQuery Tools standalone demo</title>
    <!-- include the Tools -->
    <script src="http://cdn.jquerytools.org/1.2.4/full/jquery.tools.min.js"></script>
    <!-- accordion styling -->	
    <link rel="stylesheet" type="text/css" href="tabs-accordion-horizontal.css"/> 
    <link rel="stylesheet" type="text/css" href="scrollable-horizontal.css" />
    <link rel="stylesheet" type="text/css" href="http://static.flowplayer.org/tools/css/scrollable-buttons.css" />
    </head>
    <body> 	
    <!-- accordion root -->
    <div id="accordion">
    <!-- accordion header #1 -->
    
    <span class="accord_trigger">Interior</span>
    <div style="width:320px;" class="accord-content">
    	<a class="prev browse left"></a>
    	<div class="interior">	 
    		<div class="items">
    			<img src="http://www.communica.co.nz/concepts/kmsdata.co.nz/images/feature_image_01.png" alt="feature_image_01" width="50" height="50" />
    			<img src="http://www.communica.co.nz/concepts/kmsdata.co.nz/images/feature_image_02.png" alt="feature_image_02" width="50" height="50" />
    			<img src="http://www.communica.co.nz/concepts/kmsdata.co.nz/images/feature_image_03.png" alt="feature_image_03" width="50" height="50" />
    		</div>
    	</div>
    	<a class="next browse right"></a>
    	<script>$(".interior").scrollable();</script>	</div>
    
    <span class="accord_trigger">Exterior</span>
    <div class="accord-content">
    	<a class="prev browse left"></a>
    	<div class="exterior">	 
    		<div class="items">
    			<img src="http://www.communica.co.nz/concepts/kmsdata.co.nz/images/feature_image_01.png" alt="feature_image_01" width="50" height="50" />
    			<img src="http://www.communica.co.nz/concepts/kmsdata.co.nz/images/feature_image_02.png" alt="feature_image_02" width="50" height="50" />
    			<img src="http://www.communica.co.nz/concepts/kmsdata.co.nz/images/feature_image_03.png" alt="feature_image_03" width="50" height="50" />
    		</div>
    	</div>
    	<a class="next browse right"></a>
    	<script>$(".exterior").scrollable();</script>
    </div>
    
    <span class="accord_trigger">Capacity</span>
    <div class="accord-content">
    	<a class="prev browse left"></a>
    	<div class="scrollable">	 
    		<div class="items">
    			<img src="http://www.communica.co.nz/concepts/kmsdata.co.nz/images/feature_image_01.png" alt="feature_image_01" width="50" height="50" />
    			<img src="http://www.communica.co.nz/concepts/kmsdata.co.nz/images/feature_image_02.png" alt="feature_image_02" width="50" height="50" />
    			<img src="http://www.communica.co.nz/concepts/kmsdata.co.nz/images/feature_image_03.png" alt="feature_image_03" width="50" height="50" />
    		</div>
    	</div>
    	<a class="next browse right"></a>
    	<script>$(".scrollable").scrollable();</script>
    </div>
    
    <span class="accord_trigger">Safety</span>
    <div class="accord-content">
    	<a class="prev browse left"></a>
    	<div class="safety">	 
    		<div class="items">
    			<img src="http://www.communica.co.nz/concepts/kmsdata.co.nz/images/feature_image_01.png" alt="feature_image_01" width="50" height="50" />
    			<img src="http://www.communica.co.nz/concepts/kmsdata.co.nz/images/feature_image_02.png" alt="feature_image_02" width="50" height="50" />
    			<img src="http://www.communica.co.nz/concepts/kmsdata.co.nz/images/feature_image_03.png" alt="feature_image_03" width="50" height="50" />
    		</div>
    	</div>
    	<a class="next browse right"></a>
    	<script>$(".safety").scrollable();</script>	</div>
    
    <span class="accord_trigger">Awards</span>
    <div class="accord-content">
    	<a class="prev browse left"></a>
    	<div class="awards">	 
    		<div class="items">
    			<img src="http://www.communica.co.nz/concepts/kmsdata.co.nz/images/feature_image_01.png" alt="feature_image_01" width="50" height="50" />
    			<img src="http://www.communica.co.nz/concepts/kmsdata.co.nz/images/feature_image_02.png" alt="feature_image_02" width="50" height="50" />
    			<img src="http://www.communica.co.nz/concepts/kmsdata.co.nz/images/feature_image_03.png" alt="feature_image_03" width="50" height="50" />
    		</div>
    	</div>
    	<a class="next browse right"></a>
    	<script>$(".awards").scrollable();</script>	</div>
    
    </div>
    <!-- activate tabs with JavaScript -->
    
    <script>
    $("#accordion").tabs("#accordion div.accord-content", {
    tabs: 'span.accord_trigger"', 
    effect: 'horizontal'
    });
    </script>
    </body>
    </html>
    

  18. Hello can some please help me sort this array by asc order.

     

    I have the array below that sorts a company name and it's id. I need to sort the array by company name in asc order

     

    I tried these variations of the sort function  usort(), sort(), asort() but with no luck

     

    Just to show you the data in the array, if I do a print_r($compNames); I get this

    Array ( [48] => Harmony Publishers [49] => Demo Client [50] => johns Printing [51] => creative comps [53] => Myclient [56] => gogo ) 

     

     

    <?php
    $compNames = array();
    
    while($rw = mysql_fetch_assoc($rs)){
         $compNames[$rw['subCompId']] = comp($rw['subCompId'],'compName');
    }
    
    sort($compNames);
    
    foreach($compNames as $name => $idComp){
    echo $name.'-'.$idComp.'<br>';
    }
    
    ?>
    

  19. Hello,

     

    Can someone help me out here please. I have the code below that looks for all the jpg files in the folder and works great but I need the files that are returned to be in a random order. How can I do this?

     

    Here is my code

    <?php
    	$headerImages = "sites/default/files/images/header_images/";
    	$allowed_types = array('png','jpg','jpeg');
    	// create a handler for the directory
    	$headerImageContainer = opendir($headerImages);
    
    	$filecount = count(glob("" . $headerImages . "*.jpg"));
    	$filecount += count(glob("" . $headerImages . "*.jpeg"));
    
    	// keep going until all files in directory have been read
    	while ($file = readdir($headerImageContainer)) {
    		$ext = pathinfo($file, PATHINFO_EXTENSION);//get extention of file
    		if(in_array(strtolower($ext),$allowed_types)){
    		$i++;
    		echo "{ src: '/sites/default/files/images/header_images/".$file."' }".($i!=$filecount?',':'');
    		}
    	}
    	// tidy up: close the handler
    	closedir($headerImageContainer);
    	?>
    	]);
    });
    

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.