--- /dev/null
+<?php
+require '../setup.phtml';
+require '../../CommonApps/Smarty/3.1/Smarty.class.php';
+require_once '../Toolkit/Database.php';
+$smarty = new Smarty();
+$smarty->setTemplateDir('./tmp/');
+$smarty->setCompileDir('./tmp_c/');
+$smarty->setConfigDir('./configs/');
+$smarty->setCacheDir('./cache/');
+
+//$string = 'a:5:{s:5:"width";i:4256;s:6:"height";i:2832;s:4:"file";s:20:"2013/05/DSC_8052.jpg";s:5:"sizes";a:4:{s:9:"thumbnail";a:4:{s:4:"file";s:20:"DSC_8052-150x150.jpg";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:10:"image/jpeg";}s:6:"medium";a:4:{s:4:"file";s:20:"DSC_8052-300x199.jpg";s:5:"width";i:300;s:6:"height";i:199;s:9:"mime-type";s:10:"image/jpeg";}s:5:"large";a:4:{s:4:"file";s:21:"DSC_8052-1024x681.jpg";s:5:"width";i:1024;s:6:"height";i:681;s:9:"mime-type";s:10:"image/jpeg";}s:14:"post-thumbnail";a:4:{s:4:"file";s:20:"DSC_8052-624x415.jpg";s:5:"width";i:624;s:6:"height";i:415;s:9:"mime-type";s:10:"image/jpeg";}}s:10:"image_meta";a:10:{s:8:"aperture";d:2;s:6:"credit";s:0:"";s:6:"camera";s:10:"NIKON D700";s:7:"caption";s:0:"";s:17:"created_timestamp";i:1345570404;s:9:"copyright";s:0:"";s:12:"focal_length";s:2:"85";s:3:"iso";s:4:"1250";s:13:"shutter_speed";s:7:"0.00625";s:5:"title";s:0:"";}}';
+//echo '<pre>' . print_r(unserialize( $string ), true) . '</pre>';
+//exit;
+
+$dbh = Toolkit_Database::getInstance();
+
+$sql = "
+ SELECT *
+ FROM coupons
+ORDER BY id";
+
+$stmt = $dbh->query($sql);
+
+function nicename($name)
+{
+ $name = str_replace('\'"', '', $name);
+ $name = str_replace(' ', '-', $name);
+ return strtolower($name);
+}
+/**
+ * Array structure from an existing export of post from a site.
+ *
+ * Array
+ * (
+ * [width] => 4256
+ * [height] => 2832
+ * [file] => 2013/05/DSC_8052.jpg
+ * [sizes] => Array
+ * (
+ * [thumbnail] => Array
+ * (
+ * [file] => DSC_8052-150x150.jpg
+ * [width] => 150
+ * [height] => 150
+ * [mime-type] => image/jpeg
+ * )
+ * [medium] => Array
+ * (
+ * [file] => DSC_8052-300x199.jpg
+ * [width] => 300
+ * [height] => 199
+ * [mime-type] => image/jpeg
+ * )
+ * [large] => Array
+ * (
+ * [file] => DSC_8052-1024x681.jpg
+ * [width] => 1024
+ * [height] => 681
+ * [mime-type] => image/jpeg
+ * )
+ * [post-thumbnail] => Array
+ * (
+ * [file] => DSC_8052-624x415.jpg
+ * [width] => 624
+ * [height] => 415
+ * [mime-type] => image/jpeg
+ * )
+ * )
+ * [image_meta] => Array
+ * (
+ * [aperture] => 2
+ * [credit] =>
+ * [camera] => NIKON D700
+ * [caption] =>
+ * [created_timestamp] => 1345570404
+ * [copyright] =>
+ * [focal_length] => 85
+ * [iso] => 1250
+ * [shutter_speed] => 0.00625
+ * [title] =>
+ * )
+ * )
+ */
+function getImageMetaData($image)
+{
+ $largeSize = getimagesize( FILE_SERVER_URL.IS_OWNER_ID.'/CKImage/' . $image );
+ //var_dump(FILE_SERVER_URL.IS_OWNER_ID.'/CKImage/' . $image);
+ //var_dump($imageSize);
+ //echo '<pre> image size: ' . print_r($imageSize, true) . '</pre>';
+ $thumbSize = getimagesize( FILE_SERVER_URL.IS_OWNER_ID.'/couponThumb/' . $image );
+ //echo '<pre> image size: ' . print_r($imageSize, true) . '</pre>';
+ //exit;
+ $pathInfo = pathinfo($image);
+ $metaData = array(
+ 'width' => $largeSize[0],
+ 'height' => $largeSize[1],
+ 'file' => $image,
+ 'sizes' => array(
+ 'thumbnail' => array(
+ 'file' => $pathInfo['filename'] . '-' . $thumbSize[0] . 'x' . $thumbSize[1] . '.' . $pathInfo['extension'],
+ 'width' => 150,
+ 'height' => 150
+ ),
+ 'large' => array(
+ 'file' => $pathInfo['filename'] . '-' . $largeSize[0] . 'x' . $largeSize[1] . '.' . $pathInfo['extension'],
+ 'width' => 150,
+ 'height' => 150
+ ),
+ )
+ );
+ return $metaData;
+}
+
+while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
+ $prDate = mktime();
+ if ($row['image']) {
+ $metaData = getImageMetaData( $row['image'] );
+ $row['imageMetadata'] = serialize( $metaData );
+ }
+ $row['pubDate'] = date('r', $prDate);
+ $row['pr_date'] = date('Y-m-d H:i:s', $prDate);
+ $row['sdate'] = strtotime($row['sdate']);
+ $row['edate'] = strtotime($row['edate']);
+ $row['expiration'] = strtotime($row['expiration']);
+ $row['ping_name'] = nicename($row['title']);
+
+ $data[$row['id']] = $row;
+ // getting category
+ $data[$row['id']]['categories'] = array();
+ $data[$row['id']]['categories'][] = array(
+ 'nicename' => nicename($row['category']),
+ 'name' => $row['category']
+ );
+}
+//echo '<pre>' . print_r($data, true) . '</pre>';
+//exit;
+$smarty->assign('created_date', date('Y-m-d H:i'));
+$smarty->assign('exportTitle', SITENAME);
+$smarty->assign('siteUrl', COUPON_SITE_URL);
+$smarty->assign('imageUrl', FILE_SERVER_URL.IS_OWNER_ID.'/');
+$smarty->assign('data', $data);
+header('Content-Type:text/xml');
+$smarty->display('wordPress.tpl');
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
+<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
+<!-- You may use this file to transfer that content from one site to another. -->
+<!-- This file is not intended to serve as a complete backup of your site. -->
+
+<!-- To import this information into a WordPress site follow these steps: -->
+<!-- 1. Log in to that site as an administrator. -->
+<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
+<!-- 3. Install the "WordPress" importer from the list. -->
+<!-- 4. Activate & Run Importer. -->
+<!-- 5. Upload this file using the form provided on that page. -->
+<!-- 6. You will first be asked to map the authors in this export file to users -->
+<!-- on the site. For each author, you may choose to map to an -->
+<!-- existing user on the site or to create a new user. -->
+<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
+<!-- contained in this file into your site. -->
+
+<!-- generator="WordPress/4.3.1" created="{$created_date}" -->
+<rss version="2.0"
+ xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
+ xmlns:content="http://purl.org/rss/1.0/modules/content/"
+ xmlns:wfw="http://wellformedweb.org/CommentAPI/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:wp="http://wordpress.org/export/1.2/"
+>
+
+<channel>
+ <title>{$exportTitle}</title>
+ <link>http://{$siteUrl}</link>
+ <description></description>
+ <pubDate>{$pubDate}</pubDate>
+ <language>en-US</language>
+ <wp:wxr_version>1.2</wp:wxr_version>
+ <wp:base_site_url>http://{$siteUrl}</wp:base_site_url>
+ <wp:base_blog_url>http://{$siteUrl}</wp:base_blog_url>
+
+ <wp:author><wp:author_id>1</wp:author_id><wp:author_login>Steve</wp:author_login><wp:author_email>steve@gaslightmedia.com</wp:author_email><wp:author_display_name><![CDATA[Steve]]></wp:author_display_name><wp:author_first_name><![CDATA[]]></wp:author_first_name><wp:author_last_name><![CDATA[]]></wp:author_last_name></wp:author>
+
+
+ <generator>http://wordpress.org/?v=4.3.1</generator>
+ {foreach $data as $row}
+ <item>
+ <title>{$row.title}</title>
+ <link>http://{$siteUrl}/{$row.ping_name}/</link>
+ <pubDate>{$row.pubDate}</pubDate>
+ <dc:creator><![CDATA[Steve]]></dc:creator>
+ <guid isPermaLink="false">http://{$siteUrl}/?p={$row.id}</guid>
+ <description><![CDATA[]]></description>
+ <content:encoded><![CDATA[{$row.description}]]></content:encoded>
+ <excerpt:encoded><![CDATA[]]></excerpt:encoded>
+ <wp:post_id>{$row.id}</wp:post_id>
+ <wp:post_date>{$row.pr_date}</wp:post_date>
+ <wp:post_date_gmt>{$row.pr_date}</wp:post_date_gmt>
+ <wp:comment_status>closed</wp:comment_status>
+ <wp:ping_status>open</wp:ping_status>
+ <wp:post_name>{$row.ping_name}</wp:post_name>
+ <wp:status>publish</wp:status>
+ <wp:post_parent>0</wp:post_parent>
+ <wp:menu_order>0</wp:menu_order>
+ <wp:post_type>glm_coupons</wp:post_type>
+ <wp:post_password></wp:post_password>
+ {if $row.image}
+ <wp:attachment_url><![CDATA[{$imageUrl}original/{$row.image}]]></wp:attachment_url>
+ {/if}
+ <wp:is_sticky>0</wp:is_sticky>
+ {foreach $row.categories as $category}
+ <category domain="glm_couponscategory" nicename="{$category.nicename}"><![CDATA[{$category.name}]]></category>
+ {/foreach}
+ {if $row.imageMetadata}
+ <wp:postmeta>
+ <wp:meta_key><![CDATA[_wp_attachment_metadata]]></wp:meta_key>
+ <wp:meta_value><![CDATA[{$row.imageMetadata}]]></wp:meta_value>
+ </wp:postmeta>
+ {/if}
+ <wp:postmeta>
+ <wp:meta_key><![CDATA[_edit_last]]></wp:meta_key>
+ <wp:meta_value><![CDATA[3]]></wp:meta_value>
+ </wp:postmeta>
+ <wp:postmeta>
+ <wp:meta_key><![CDATA[glm_coupons_startdate]]></wp:meta_key>
+ <wp:meta_value><![CDATA[{$row.sdate}]]></wp:meta_value>
+ </wp:postmeta>
+ <wp:postmeta>
+ <wp:meta_key><![CDATA[glm_coupons_enddate]]></wp:meta_key>
+ <wp:meta_value><![CDATA[{$row.edate}]]></wp:meta_value>
+ </wp:postmeta>
+ <wp:postmeta>
+ <wp:meta_key><![CDATA[glm_coupons_expdate]]></wp:meta_key>
+ <wp:meta_value><![CDATA[{$row.expiration}]]></wp:meta_value>
+ </wp:postmeta>
+ <wp:postmeta>
+ <wp:meta_key><![CDATA[glm_coupons_url]]></wp:meta_key>
+ <wp:meta_value><![CDATA[{$row.url}]]></wp:meta_value>
+ </wp:postmeta>
+ </item>
+ {/foreach}
+</channel>
+</rss>