For smart Primates & ROBOTS (oh and ALIENS ).

Thursday, October 10, 2013

Show DOCX meta data in php

Show DOCX meta data in php

 

 <?php
/*<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <dc:title>Title Proforma-For-Application</dc:title>
  <dc:subject>Subject Proforma-For-Application.docx<

/dc:subject>
  <dc:creator>MICROSOFT2012</dc:creator>
  <cp:keywords>Keywords Proforma-For-Application.docx</cp:keywords>
  <dc:description>This is comments Proforma-For-Application.docx</dc:description>
  <cp:lastModifiedBy>MICROSOFT2012</cp:lastModifiedBy>
  <cp:revision>11</cp:revision>
  <dcterms:created xsi:type="dcterms:W3CDTF">2013-07-17T11:50:00Z</dcterms:created>
  <dcterms:modified xsi:type="dcterms:W3CDTF">2013-07-17T12:06:00Z</dcterms:modified>
  <cp:category>Category Proforma-For-Application.docx</cp:category>
</cp:coreProperties>
*/
class Docx{
    var $xml_data = "";
    function openDocx($path_of_file) {
        $zip = new ZipArchive;
        $ans = $zip->open($path_of_file);
        if ($ans === TRUE) {
            $folder = uniqid("", true);
            mkdir($folder, 0700);
            $zip->extractTo($folder, array("docProps/core.xml"));
            $zip->close();
            $this->xml_data = file_get_contents($folder."/docProps/core.xml");    
            unlink($folder."/docProps/core.xml");
            rmdir($folder."/docProps");
            rmdir($folder);
        }                
    }
        
    function showTitle(){
        $title_start = explode("</dc:title>", $this->xml_data);    
        //$meta_title_end = explode("<dc:title>", $meta_title_start[0]);
        //return $meta_title_end[1];    
        return (explode("<dc:title>", $title_start[0])[1]);    
    }
        
    function showSubject(){
        $subject_start = explode("</dc:subject>", $this->xml_data);    
        return (explode("<dc:subject>", $subject_start[0])[1]);    
    }
        
    function showCreator(){
        /*$creator_start = explode("</dc:creator>", $this->xml_data);    
        $creator_end = explode("<dc:creator>", $creator_start[0]);    
        return $creator_end[1];*/    
        //$creator_end = explode("<dc:creator>", (explode("</dc:creator>", $this->xml_data))[0]);    
        return (explode("<dc:creator>", explode("</dc:creator>", $this->xml_data)[0])[1]);
    }
        
    function showKeywords(){
        $keywords_start = explode("</cp:keywords>", $this->xml_data);    
        $keywords_end = explode("<cp:keywords>", $keywords_start[0]);    
        return $keywords_end[1];
    }
        
    function showDescription(){
        $description_start = explode("</dc:description>", $this->xml_data);    
        $description_end = explode("<dc:description>", $description_start[0]);    
        return $description_end[1];
    }
        
    function showLastModifiedBy(){
        $lastmodifiedby_start = explode("</cp:lastModifiedBy>", $this->xml_data);    
        $lastmodifiedby_end = explode("<cp:lastModifiedBy>", $lastmodifiedby_start[0]);    
        return $lastmodifiedby_end[1];
    }
        
    function showRevision(){
        $revision_start = explode("</cp:revision>", $this->xml_data);    
        $revision_end = explode("<cp:revision>", $revision_start[0]);    
        return $revision_end[1];
    }
        
    function showDateCreated(){
        $datecreated_start = explode("</dcterms:created>", $this->xml_data);    
        $datecreated_end = explode("<dcterms:created xsi:type=\"dcterms:W3CDTF\">", $datecreated_start[0]);    
        return $datecreated_end[1];
    }
        
    function showDateModified(){
        $datemodified_start = explode("</dcterms:modified>", $this->xml_data);    
        $datemodified_end = explode("<dcterms:modified xsi:type=\"dcterms:W3CDTF\">", $datemodified_start[0]);    
        return $datemodified_end[1];
    }
        
    function showCategory(){
        $category_start = explode("</cp:category>", $this->xml_data);    
        $category_end = explode("<cp:category>", $category_start[0]);    
        return $category_end[1];
    }
}
$docx = new Docx();
$docx_file_name_with_path = "Proforma-For-Application.docx";
$docx->openDocx($docx_file_name_with_path);
echo "<strong>File : ",$docx_file_name_with_path . "</strong><br>";
echo "Title : " , $docx->showTitle() . "<br>";
echo "Subject : " , $docx->showSubject() . "<br>";
echo "Author : " , $docx->showCreator() . "<br>";
echo "Category : " , $docx->showCategory() . "<br>";
echo "Keywords : " , $docx->showKeywords() . "<br>";
echo "Comments : " , $docx->showDescription() . "<br>";
echo "Last Modified By : " , $docx->showLastModifiedBy() . "<br>";
echo "Revision : " , $docx->showRevision() . "<br>";
echo "Created on: " , $docx->showDateCreated() . "<br>";
echo "Modified on: " , $docx->showDateModified() . "<br>";
?>

 

Share:

Saturday, October 05, 2013

namespace in php

namespace in php

<?php
namespace foo;
class Robot {
    static function says() {echo 'I am Terminator!';}
    }
?>
  
<?php
namespace bar;
class RoboCop {
    static function says() {echo 'I am Robocop!';}
    }
?>
  
<?php namespace terminate;
    class Terminator {
    static function says() {echo 'Terminator';}  }
?>

<?php namespace computer;
    class Comp {
    static function show() {echo 'I am computer';}
    function laptop() { echo "this is laptop ";}
    }
?>

  
<?php

namespace realexample;
//use foo as robo;
//use bar as roboc;
//use terminate;
//echo robo\Robot::says(), "<br />\n";
//echo roboc\RoboCop::says(), "<br />\n";
//echo terminate\Terminator::says(), "<br />\n";


echo \foo\Robot::says(), "<br />\n";
echo \bar\RoboCop::says(), "<br />\n";
echo \terminate\Terminator::says(), "<br />\n";
echo \computer\Comp::show(), "<br />\n";
$comp = new \computer\Comp();
$comp->laptop();
 

  ?>


Share:

Open new Windows in jquery and javascript

Open new Windows in jquery and javascript


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="jquery-1.6.3.min.js" type="text/javascript"></script>
</head>
<body>
    <a href="1.html">Click Here</a>
    <a href="2.html">Click Here</a>

<script type="text/javascript">
    $('a').click(function (event) {
        //event.preventDefault();
        var myurl = $(this).attr('href');
        myurl = "http://www.google.com/";
        var left  = ($(window).width()/2)-(900/2);
        //top   = ($(window).height()/2)-(600/2),
        var top   = 800;
        var popup = window.open (myurl, "_blank", "width=900, height=600, top="+top+", left="+left);
        popup.blur();
        self.focus();
        window.open(this.href,'_self');
        window.focus();
    });
</script>
</body>   
</html>
Share:

openssl_encrypt and openssl_decrypt in PHP

openssl_encrypt and openssl_decrypt in PHP

openssl_encrypt and openssl_decrypt


/*$string = 'This is test';
$pass = '1234';
$method = 'aes128';
file_put_contents ('./file.txt', openssl_encrypt ($string, $method, $pass));*/


$method = 'aes-128-ecb';
$iv = openssl_random_pseudo_bytes(
openssl_cipher_iv_length($method));
$msg="this is the testing for encoding and decoding";

$en=openssl_encrypt($msg, $method, 'def', true, $iv);
echo $en;


$de=openssl_decrypt($en, $method, 'def', true, $iv);
echo $de;

Share:

Remove Controller and it's method form codeigniter

How to remove Controller in  codeigniter and it's method just show it's parameter in url for ex:


http://localhost:90/CodeIgniter_2.1.4_new/category/show/this-is-the-test.html
as
http://localhost:90/CodeIgniter_2.1.4_new/this-is-the-test.html

Goto routes.php under config directory:
write this listed below line
$route['(:any)'] = "category/show/$1";
==============================
====================================================
create a new file "category.php"
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Category extends CI_Controller {
    public function index() {
        $this->load->view('welcome_message');
    }
    public function show($text) {
            echo "aaaaa".$text;  
    }
}
Share:

Send email in Codeigniter

Send email in Codeigniter


$this->load->library('email');
$this->email->from('my@my-site.com', 'My Name');
$this->email->subject('Test subject');
$this->email->message('Testing email.');
$this->email->attach('/path/img1.jpg');
$this->email->send();

Share:

Ads Inside Post

Powered by Blogger.

Archive