CU3ER PHP XML Configuration

  • 10 posts
  1. Hello, if you want your images randomized (and effects) you can use this little PHP script.
    Just replace default config.xml in HTML/JS with let's say cu3er.php (or whatever you name it).
    Also you need to edit $dir to match one on your host.

    eg. http://repro.babilon.ba/cu3er.php & http://repro.babilon.ba

    http://webarto.com/32/php-cu3er-xml-configuration


    <?
    /**
    * CU3ER PHP XML Configuration
    * @author webarto.com
    * @copyright 2010
    */

    $slides = "";
    $dir = "cu3er";

    function effect(){
    srand((double)microtime()*1234567);
    $effects = array(
    'num="3" slicing="vertical" direction="down" cube_color="0xFFFFFF"',
    'num="4" direction="right" shader="flat" cube_color="0xFFFFFF"',
    'num="6" slicing="vertical" direction="up" shader="flat" delay="0.05" z_multiplier="4" cube_color="0xFFFFFF"',
    'num="4" direction="right" shader="phong" cube_color="0xFFFFFF"');
    return $effects[mt_rand(0,count($effects)-1)];
    }

    $folder = scandir($dir);
    foreach($folder as $file){
    if(strpos(strtolower($file),".jpg")>0){
    $slides.= '<slide><url>/'.$dir.'/'.$file.'</url></slide><transition '.effect().' />'."\n";
    }
    }

    header("Content-Type: text/xml");
    echo('<?xml version="1.0" encoding="utf-8" ?>
    <cu3er>
    <settings>

    <auto_play>
    <defaults symbol="circular" time="3" />
    <tweenOver tint="0xFFFFFF" scaleX="1.1" scaleY="1.1"/>
    <tweenOut tint="0xFFFFFF"/>
    </auto_play>

    <prev_button>
    <defaults round_corners="5,5,5,5"/>
    <tweenOver tint="0xFFFFFF" scaleX="1.1" scaleY="1.1"/>
    <tweenOut tint="0x000000" />
    </prev_button>

    <prev_symbol>
    <tweenOver tint="0x000000" />
    </prev_symbol>

    <next_button>
    <defaults round_corners="5,5,5,5"/>
    <tweenOver tint="0xFFFFFF" scaleX="1.1" scaleY="1.1"/>
    <tweenOut tint="0x000000" />
    </next_button>

    <next_symbol>
    <tweenOver tint="0x000000" />
    </next_symbol>

    </settings>

    <slides>
    '.$slides.'
    </slides>
    </cu3er>');
    ?>

  2. Little correction, upper script only shuffles effects... this one does both.

    <?
    /**
    * CU3ER PHP XML Configuration
    * @author webarto.com
    */

    $slides = "";
    $cu3er = "";
    $dir = "cu3er";

    function effect(){
    srand((double)microtime()*1234567);
    $effects = array(
    'num="3" slicing="vertical" direction="down" cube_color="0xFFFFFF"',
    'num="4" direction="right" shader="flat" cube_color="0xFFFFFF"',
    'num="6" slicing="vertical" direction="up" shader="flat" delay="0.05" z_multiplier="4" cube_color="0xFFFFFF"',
    'num="4" direction="right" shader="phong" cube_color="0xFFFFFF"');
    return $effects[mt_rand(0,count($effects)-1)];
    }

    $folder = scandir($dir);
    foreach($folder as $file){
    if(strpos(strtolower($file),".jpg")>0){
    $slides[]= '<slide><url>/'.$dir.'/'.$file.'</url></slide><transition '.effect().' />'."\n";
    }
    }

    shuffle($slides);
    foreach($slides as $slide){$cu3er.= $slide;}

    header("Content-Type: text/xml");
    echo('<?xml version="1.0" encoding="utf-8" ?>
    <cu3er>
    <settings>

    <auto_play>
    <defaults symbol="circular" time="5" />
    <tweenOver tint="0xFFFFFF" scaleX="1.1" scaleY="1.1"/>
    <tweenOut tint="0xFFFFFF"/>
    </auto_play>

    <prev_button>
    <defaults round_corners="5,5,5,5"/>
    <tweenOver tint="0xFFFFFF" scaleX="1.1" scaleY="1.1"/>
    <tweenOut tint="0x000000" />
    </prev_button>

    <prev_symbol>
    <tweenOver tint="0x000000" />
    </prev_symbol>

    <next_button>
    <defaults round_corners="5,5,5,5"/>
    <tweenOver tint="0xFFFFFF" scaleX="1.1" scaleY="1.1"/>
    <tweenOut tint="0x000000" />
    </next_button>

    <next_symbol>
    <tweenOver tint="0x000000" />
    </next_symbol>

    </settings>

    <slides>
    '.$cu3er.'
    </slides>
    </cu3er>');
    ?>

  3. Hassan Puri

    3 months ago

    Hi,

    I am new user of Cu3er and i just downloaded the cu3er, and i am having so many problems
    in editing XML and adding my own images into cu3er please help me from very start till end.

    i am web site designer but i am new user of cu3er

    I will highly appreciate your help

    Thanks,
    Hassan Puri

  4. Hassan Puri

    3 months ago

    Hey Stefan,

    Thanks for your quick response,

    Dear , i am still having problems, actually !! the thing is that i have my own images and want to put those images in cu3er.
    The link which you sent me its not helping me as i need...is this possible if i can send u those images and you can work on that and then send me back, with the all source files, it will be very helpful for me

    I will be highly appreciate your help

    Thanks,

    Hassan Puri

  5. I modified this script to add in the link or description tags.
    if you have image1.png and would like to add the a link or description tag just add a text file name after the image with .txt at the end so would have image1.png.txt

    in the .txt file simply add what tags you want
    example:

    <link>http://www.google.com</link>
    <description>
      <link>http://www.google.com/hello</link>
      <heading>this is the heading</heading>
      <paragraph>This is the paragraph</paragraph>
    </description>

    When the script is run this will be added to the xml for that image.

    <?
    $slides = "";
    $cu3er = "";
    $dir = "../../images/slider/active";
    $img_url = "http://www.qpharmacorp.com/skins/qpharma/images/slider/active/";
    
    function effect(){
    srand((double)microtime()*1234567);
    $effects = array(
    'num="3" slicing="vertical" direction="down" cube_color="0xFFFFFF"',
    'num="4" direction="right" shader="flat" cube_color="0xFFFFFF"',
    'num="6" slicing="vertical" direction="up" shader="flat" delay="0.05" z_multiplier="4" cube_color="0xFFFFFF"',
    'num="4" direction="right" shader="phong" cube_color="0xFFFFFF"');
    return $effects[mt_rand(0,count($effects)-1)];
    }
    
    chdir($dir);
    $folder = scandir(".");
    foreach($folder as $file){
      $f = pathinfo($file);
      switch($f['extension']) {
        case "jpg":
        case "jpeg":
        case "png":
        case "gif":
          if(file_exists($f['basename'] . ".txt")) {
            $file_info = file_get_contents($f['basename'] . ".txt");
          } else {
            $file_info = "";
          }
    
          $slides[]= "<slide><url>{$img_url}/{$file}</url>{$file_info}</slide><transition " . effect() . " />\n";
          break;
      }
    }
    
    shuffle($slides);
    foreach($slides as $slide){$cu3er.= $slide;}
    
    header("Content-Type: text/xml");
    echo('<?xml version="1.0" encoding="utf-8" ?>
    <cu3er>
    <settings>
    
    <prev_button>
    <defaults round_corners="5,5,5,5"/>
    <tweenOver tint="0xFFFFFF" scaleX="1.1" scaleY="1.1"/>
    <tweenOut tint="0x000000" />
    </prev_button>
    
    <prev_symbol>
    <tweenOver tint="0x000000" />
    </prev_symbol>
    
    <next_button>
    <defaults round_corners="5,5,5,5"/>
    <tweenOver tint="0xFFFFFF"  scaleX="1.1" scaleY="1.1"/>
    <tweenOut tint="0x000000" />
    </next_button>
    
    <next_symbol>
    <tweenOver tint="0x000000" />
    </next_symbol>
    
    <auto_play>
    <defaults symbol="circular" time="7" />
    <tweenIn x="25" y="20" width="35" height="35" tint="0xFFFFFF"  />
    </auto_play>
    
    </settings>
    
    <slides>
    '.$cu3er.'
    </slides>
    </cu3er>');
    ?>
  6. ok so maybe im over doing it but i needed these abilities to work with my site so i figured i would share.
    I wanted to pull in a blog entry to go over an image. so now you can add a php file just like the txt file. (see above)
    I also added the ability to pull the images in in a particular order.

    instructions:

    • add the link or description tags to an image using a text or php file:
      • you must have a file with the same name as the image including the extension .
        so if you have image1.png and image2.png and you want to associate image1.png with a text file then you would add a file image1.png.txt.
        if you wanted to associate image2.png with a php file you would add image2.png.php.
        THESE FILES MUST BE IN THE SAME DIRECTORY AS THE IMAGES
    • Add ability to pull images in a certain order
      • change $order_file to the php file containing the order array.
        the order array must be formated like this.
        $_slide[0] = "image1.png";
        $_slide[1] = "image2.png";
        and so on...

    cu3er_config.php

    <?
    
    //configurable variables
    $dir        = "/path/to/image/directory"; //directory containing the images
    $img_url    = "url/to/image"; //image url to append to the image
    $randomize  = false;  //randomize the images
    $order_file = "_order.php"; //file that hold the order to display the images. if this file exists randomize is ignored
    
    //these variables should be left empty
    $slides = "";
    $cu3er = "";
    
    //you can add any number of transitions here.
    //if you create a cool transitions list please share.
    function effect(){
    srand((double)microtime()*1234567);
    $effects = array(
    'num="1" slicing="vertical" direction="down" cube_color="0xFFFFFF"',
    'num="3" slicing="vertical" direction="down" cube_color="0xFFFFFF"',
    'num="1" direction="right" shader="flat" cube_color="0xFFFFFF"',
    'num="4" direction="right" shader="flat" cube_color="0xFFFFFF"',
    'num="6" slicing="vertical" direction="up" shader="flat" delay="0.05" z_multiplier="6" cube_color="0xFFFFFF"',
    'num="10" slicing="horizontal" direction="left" shader="flat" delay="0.05" z_multiplier="4" cube_color="0xFFFFFF"',
    'num="1" direction="right" shader="phong" cube_color="0xFFFFFF"',
    'num="4" direction="right" shader="phong" cube_color="0xFFFFFF"');
    return $effects[mt_rand(0,count($effects)-1)];
    }
    
    //takes the file name, checks to make sure it is a valid image.
    //checks to see if the image has a corresponding txt or php file to load
    //txt files can contain the slides <link> tag and/or <description> tag
    //php files can generate these tags from blogs, database, ect...
    function build_slide($file) {
      global $img_url, $slides;
      $f = pathinfo($file);
      switch($f['extension']) {
        case "jpg":
        case "jpeg":
        case "png":
        case "gif":
          if(file_exists($f['basename'] . ".txt")) {
            $file_info = file_get_contents($f['basename'] . ".txt");
          } elseif(file_exists($f['basename'] . ".php")) {
            include $f['basename'] . ".php";
          } else {
            $file_info = "";
          }
    
          $slides[] = "<slide>\n  <url>{$img_url}/{$file}</url>\n  {$file_info}\n</slide>\n  <transition " . effect() . " />\n";
          break;
    
      }
    }
    
    //if we change to the directory its just easier to work with, we dont need full paths.
    chdir($dir);
    
    //if there is a file refered to in $order_file exists then that is how we will pull in the images.
    if(file_exists($order_file)) {
      include $order_file;
      //since we are using the order script we should probably make sure shuffle is turned off
      $randomize = false;
      foreach($_slide as $s) {
        build_slide($s);
      }
    } else {
    //if not we'll just loop through the image directoy for the images.
      $folder = scandir(".");
      foreach($folder as $file){
        build_slide($file);
      }
    }
    
    //if we want to shuffle the slides.
    if($randomize) {
      shuffle($slides);
    }
    
    //add in the slides
    foreach($slides as $slide){
        $cu3er.= $slide;
    }
    
    header("Content-Type: text/xml");
    echo('<?xml version="1.0" encoding="utf-8" ?>
    <cu3er>
    <settings>
    
    <prev_button>
    <defaults round_corners="5,5,5,5"/>
    <tweenOver tint="0xFFFFFF" scaleX="1.1" scaleY="1.1"/>
    <tweenOut tint="0x000000" />
    </prev_button>
    
    <prev_symbol>
    <tweenOver tint="0x000000" />
    </prev_symbol>
    
    <next_button>
    <defaults round_corners="5,5,5,5"/>
    <tweenOver tint="0xFFFFFF"  scaleX="1.1" scaleY="1.1"/>
    <tweenOut tint="0x000000" />
    </next_button>
    
    <next_symbol>
    <tweenOver tint="0x000000" />
    </next_symbol>
    
    <auto_play>
    <defaults symbol="circular" time="5" />
    <tweenIn x="25" y="20" width="35" height="35" tint="0xFFFFFF"  />
    </auto_play>
    
    </settings>
    
    <slides>
    '.$cu3er.'
    </slides>
    </cu3er>');
    ?>

    sample order file
    _order.php

    <?php
      $_slide[0] = "image1.png";
      $_slide[1] = "image2.png";
      $_slide[2] = "image3.png";
    ?>

    hope this is usfull to someone else.

  7. Hi, just stopped by to show an example of multi directory xml-php configuration... It uses GET parameter (directory) sent via htaccess, because I am unable to send it through JS(?)... and it will output XML containing files from given directory...

    http://www.mstylefashion.ba/multimedia

  8. percy solis lucero

    2 weeks ago

    Good day everyone, well I used this:

    flashvars.xml = "config.php?val1=1&val2=2";
    It's ok but cu3r when I call val2
    $_GET['val2']
    in config.php does'nt work. I think cu3r works only with one variable. I tried with both variables just xml file and works.

    Now I'm working with one variable but again cu3r dosen't work, this is my code.

    while($Rs = $queryBanner->fetch_array()){
    $xml.='<slide><url>'.$Rs["picture"].'</url></slide><transition num="6" slicing="vertical" direction="up" shader="flat" delay="0.05" z_multiplier="4" />';
    }

    Please help me and sorry for my english is terrible.


Reply

You must log in to post.