From: Steve Sutton Date: Tue, 16 Feb 2016 21:25:33 +0000 (-0500) Subject: new sources X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=4d525eb61f32d03112c13d787908431d25dd15f8;p=prog%2FCouponExport.git new sources --- 4d525eb61f32d03112c13d787908431d25dd15f8 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4015fd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +tmp_c diff --git a/index.php b/index.php new file mode 100644 index 0000000..23c0bed --- /dev/null +++ b/index.php @@ -0,0 +1,144 @@ +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 '
' . print_r(unserialize( $string ), true) . '
'; +//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 '
 image size: ' . print_r($imageSize, true) . '
'; + $thumbSize = getimagesize( FILE_SERVER_URL.IS_OWNER_ID.'/couponThumb/' . $image ); + //echo '
 image size: ' . print_r($imageSize, true) . '
'; + //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 '
' . print_r($data, true) . '
'; +//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'); + diff --git a/tmp/wordPress.tpl b/tmp/wordPress.tpl new file mode 100644 index 0000000..6b55223 --- /dev/null +++ b/tmp/wordPress.tpl @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + {$exportTitle} + http://{$siteUrl} + + {$pubDate} + en-US + 1.2 + http://{$siteUrl} + http://{$siteUrl} + + 1Stevesteve@gaslightmedia.com + + + http://wordpress.org/?v=4.3.1 + {foreach $data as $row} + + {$row.title} + http://{$siteUrl}/{$row.ping_name}/ + {$row.pubDate} + + http://{$siteUrl}/?p={$row.id} + + + + {$row.id} + {$row.pr_date} + {$row.pr_date} + closed + open + {$row.ping_name} + publish + 0 + 0 + glm_coupons + + {if $row.image} + + {/if} + 0 + {foreach $row.categories as $category} + + {/foreach} + {if $row.imageMetadata} + + + + + {/if} + + + + + + + + + + + + + + + + + + + + + + {/foreach} + +