Waraxe IT Security Portal
Login or Register
November 23, 2024
Menu
Home
Logout
Discussions
Forums
Members List
IRC chat
Tools
Base64 coder
MD5 hash
CRC32 checksum
ROT13 coder
SHA-1 hash
URL-decoder
Sql Char Encoder
Affiliates
y3dips ITsec
Md5 Cracker
User Manuals
AlbumNow
Content
Content
Sections
FAQ
Top
Info
Feedback
Recommend Us
Search
Journal
Your Account
User Info
Welcome, Anonymous
Nickname
Password
(Register)

Membership:
Latest: MichaelSnaRe
New Today: 0
New Yesterday: 0
Overall: 9144

People Online:
Visitors: 44
Members: 0
Total: 44
Full disclosure
APPLE-SA-11-19-2024-5 macOS Sequoia 15.1.1
Local Privilege Escalations in needrestart
APPLE-SA-11-19-2024-4 iOS 17.7.2 and iPadOS 17.7.2
APPLE-SA-11-19-2024-3 iOS 18.1.1 and iPadOS 18.1.1
APPLE-SA-11-19-2024-2 visionOS 2.1.1
APPLE-SA-11-19-2024-1 Safari 18.1.1
Reflected XSS - fronsetiav1.1
XXE OOB - fronsetiav1.1
St. Poelten UAS | Path Traversal in Korenix JetPort 5601
St. Poelten UAS | Multiple Stored Cross-Site Scripting in SEH utnserver Pro
Apple web content filter bypass allows unrestricted access to blocked content (macOS/iOS/iPadOS/visionO S/watchOS)
SEC Consult SA-20241112-0 :: Multiple vulnerabilities in Siemens Energy Omnivise T3000 (CVE-2024-38876, CVE-2024-38877, CVE-2024-38878, CVE-2024-38879)
Security issue in the TX Text Control .NET Server for ASP.NET.
SEC Consult SA-20241107-0 :: Multiple Vulnerabilities in HASOMED Elefant and Elefant Software Updater
Unsafe eval() in TestRail CLI
Log in Register Forum FAQ Memberlist Search
IT Security and Insecurity Portal

www.waraxe.us Forum Index -> PHP script decode requests -> how to decode codelock
Post new topicReply to topic View previous topic :: View next topic
how to decode codelock
PostPosted: Fri Sep 14, 2012 6:37 am Reply with quote
gfpoow
Beginner
Beginner
Joined: Sep 14, 2012
Posts: 2




i tried several hours but ended with error T_T
anyone please tell me how to decode codelock

i tried to decode this script
http://dl.dropbox.com/u/22776526/please-decode.zip

thanks for any helps
View user's profile Send private message
PostPosted: Fri Sep 14, 2012 8:05 pm Reply with quote
demon
Moderator
Moderator
Joined: Sep 22, 2010
Posts: 485




i need codelock,php Wink

_________________
Go BIG or go HOME !
View user's profile Send private message
PostPosted: Sat Sep 15, 2012 1:49 am Reply with quote
gfpoow
Beginner
Beginner
Joined: Sep 14, 2012
Posts: 2




demon wrote:
i need codelock,php Wink


i think
codelock,php == template,php

because i only found 2 scripts encrypted

can you gimme hint of steps how to decode it? thanks a alot
View user's profile Send private message
PostPosted: Sat Sep 15, 2012 10:27 am Reply with quote
demon
Moderator
Moderator
Joined: Sep 22, 2010
Posts: 485




see your pm Wink

_________________
Go BIG or go HOME !
View user's profile Send private message
PostPosted: Sat Sep 15, 2012 3:54 pm Reply with quote
demon
Moderator
Moderator
Joined: Sep 22, 2010
Posts: 485




here's your file and see your pm Wink

Code:
<?php
function ts_comot_deactivate()
{
// delete_option('ts_comot_azure_key');
}
function ComotCountWord($content, $searchword)
{
$result = explode($searchword, $content);
return count($result);
}
function ComotGetBetween($content, $start, $end)
{
$r = explode($start, $content);
if (isset($r[1])) {
$r = explode($end, $r[1]);
return $r[0];
}
return '';
}
function ts_comot_activated()
{
if (function_exists('add_theme_support')) {
add_theme_support('post-thumbnails');
set_post_thumbnail_size(150, 150, false);
$untuk = "richprogram@gmail.com";
//$untuk = "admin@local.com";
$subyek = "Plugin COMOT diinstal di " . esc_url(home_url('/'));
$isi = "Ada yang menginstal plugin COMOT di " . esc_url(home_url('/'));
$dari = "From: " . get_bloginfo('admin_email') . "\r\n";
$dari .= "Reply-To: " . get_bloginfo('admin_email') . "\r\n";
$dari .= "Content-type: text/html \r\n";
$dari .= "X-Priority: $priority\r\n";
mail($untuk, $subyek, $isi, $dari);
add_image_size('thumbnail', 150, 150, true);
}
}

function maindomain($longurl)
{
preg_match("/^(http:\/\/)?([^\/]+)/i", $longurl, $matches);
$host = $matches[2];
// get last two segments of host name
preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches);
return $matches[0];
}
function shutdown()
{
$error = error_get_last();
if ($error['type'] == 1) {
//do your stuff
echo 'This error may caused by slow internet connection or failed grabbing.';
}

}
if (is_admin() && $_GET['activate'] = true)
add_action("admin_menu", "ts_comot_menu");
function ts_comot_menu()
{
// add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function);
if (is_admin() && $_GET['activate'] = true) {
add_menu_page('Comot', 'Comot Setting', 'manage_options', 'comot', 'comot_01', plugins_url('images/setting.png', __FILE__));
add_menu_page('Amazon', 'Comot Amazon', 'administrator', 'ts_comot_amazon', 'ts_comotASIN', plugins_url('images/amazon.png', __FILE__));
}
}
register_shutdown_function('shutdown');
function comot_10ASIN($ASINcloud, $IDcategory)
{
require_once 'AmazonECS.class.php';
ini_set('max_execution_time', 300);
//set_time_limit( 300 );
$AmazonAccessKey = get_option('ts_comot_access_key');
$AmazonSecretKey = get_option('ts_comot_secret_key');
$AmazonTagAffilate = get_option('ts_comot_AssociateTag');
$AmazonMarketplace = get_option('ts_comot_marketplace');
$AmazonTitle = get_option('ts_comot_azon_title');
$AmazonContent = get_option('ts_comot_azon_template');
$UsedASIN = explode(',', trim(get_option('ts_comot_used_ASIN')));
$RemainASIN = explode(',', trim(get_option('ts_comot_remain_ASIN')));
$AmazonStartPostDate = get_option('ts_comot_azon_startPost');
$AmazonRandPostStart = get_option('ts_randPost_start');
$AmazonRandPostEnd = get_option('ts_randPost_end');
$AmazonRandPost = rand($AmazonRandPostStart, $AmazonRandPostEnd);
$countRand = 0;
$grupASIN = $successASIN = array();
$post_id = '';
$client = new AmazonECS($AmazonAccessKey, $AmazonSecretKey, $AmazonMarketplace, $AmazonTagAffilate);
$client->setReturnType(AmazonECS::RETURN_TYPE_ARRAY);
$rASIN = explode(',', trim($ASINcloud));
$rASIN = array_merge(array_diff($rASIN, $UsedASIN)); //ini untuk menghilangkan elemen array $rASIN yang sudah ada di $UsedASIN
$numASIN = count($rASIN);
if ($numASIN <= 10) {
$isiGrup = $numASIN;
$grupASIN[0] = array_slice($rASIN, 0, 10);
$ASINcloud0 = array_to_comma($grupASIN[0]);
} else {
$isiGrup = 10;
$grupASIN[0] = array_slice($rASIN, 0, 10);
$ASINcloud0 = array_to_comma($grupASIN[0]);
$first = true;
$grupASIN[1] = array_slice($rASIN, 10, $numASIN - 10); //sisa ASIN dimasukkan lagi.
$remainASIN = array_to_comma($grupASIN[1]);
}
update_option('ts_comot_remain_ASIN', $remainASIN);
$response = $client->responseGroup('Large')->lookup($ASINcloud0);
if ($response['Items']['Request']['Errors']['Error'][0])
$jmlError = count($response['Items']['Request']['Errors']['Error']);
elseif ($response['Items']['Request']['Errors']['Error'])
$jmlError = 1;
else
$jmlError = 0;
//$response = $client->responseGroup('Large')->lookup($grupASIN[0]);
//check that there are items in the response
if ($response['Items']['Item']) {
for ($i = 0; $i < $isiGrup - $jmlError; $i++) {
$AmazonContent = get_option('ts_comot_azon_template');
if (($response['Items']['Item'][$i]['ASIN'])) {
$AmazonContent = str_replace('{amazonASIN}', $response['Items']['Item'][$i]['ASIN'], $AmazonContent);
$AmazonTitle = str_replace('{amazonASIN}', $response['Items']['Item'][$i]['ASIN'], $AmazonTitle);
} elseif (($response['Items']['Item']['ASIN'])) {
$AmazonContent = str_replace('{amazonASIN}', $response['Items']['Item']['ASIN'], $AmazonContent);
$AmazonTitle = str_replace('{amazonASIN}', $response['Items']['Item']['ASIN'], $AmazonTitle);
} else {
$AmazonContent = str_replace('{amazonASIN}', 'not found ASIN', $AmazonContent);
$AmazonTitle = str_replace('{amazonASIN}', 'not found ASIN', $AmazonTitle);
}
if (($response['Items']['Item'][$i]['ItemAttributes']['Title'])) {
$thisTitle = $response['Items']['Item'][$i]['ItemAttributes']['Title'];
$AmazonContent = str_replace('{amazontitle}', $thisTitle, $AmazonContent);
$AmazonTitle = str_replace('{amazontitle}', $thisTitle, $AmazonTitle);
} elseif (($response['Items']['Item']['ItemAttributes']['Title'])) {
$thisTitle = $response['Items']['Item']['ItemAttributes']['Title'];
$AmazonContent = str_replace('{amazontitle}', $thisTitle, $AmazonContent);
$AmazonTitle = str_replace('{amazontitle}', $thisTitle, $AmazonTitle);
} else {
$AmazonContent = str_replace('{amazontitle}', '', $AmazonContent);
$AmazonTitle = str_replace('{amazontitle}', '', $AmazonTitle);
}

if (($response['Items']['Item'][$i]['LargeImage']['URL'])) {
$AmazonContent = str_replace('{amazonlargeimage}', $response['Items']['Item'][$i]['LargeImage']['URL'], $AmazonContent);
$AmazonTitle = str_replace('{amazonlargeimage}', $response['Items']['Item'][$i]['LargeImage']['URL'], $AmazonTitle);
} elseif (($response['Items']['Item']['LargeImage']['URL'])) {
$AmazonContent = str_replace('{amazonlargeimage}', $response['Items']['Item']['LargeImage']['URL'], $AmazonContent);
$AmazonTitle = str_replace('{amazonlargeimage}', $response['Items']['Item']['LargeImage']['URL'], $AmazonTitle);
} else {
$AmazonContent = str_replace('{amazonlargeimage}', '', $AmazonContent);
$AmazonTitle = str_replace('{amazonlargeimage}', '', $AmazonTitle);
}

if (($response['Items']['Item'][$i]['ItemAttributes']['Feature'])) {
if (is_array(($response['Items']['Item'][$i]['ItemAttributes']['Feature']))) {
foreach ($response['Items']['Item'][$i]['ItemAttributes']['Feature'] as $rFeature) {
$rFtr .= '<li>' . $rFeature . '</li>';
}
$AmazonContent = str_replace('{amazonfeature}', $rFtr, $AmazonContent);
$AmazonTitle = str_replace('{amazonfeature}', $rFtr, $AmazonTitle);
} else {
$AmazonContent = str_replace('{amazonfeature}', $response['Items']['Item']['ItemAttributes']['Feature'], $AmazonContent);
$AmazonTitle = str_replace('{amazonfeature}', $response['Items']['Item']['ItemAttributes']['Feature'], $AmazonTitle);
}
} elseif (($response['Items']['Item']['ItemAttributes']['Feature'])) {
if (is_array(($response['Items']['Item']['ItemAttributes']['Feature']))) {
foreach ($response['Items']['Item']['ItemAttributes']['Feature'] as $rFeature) {
$rFtr .= '<li>' . $rFeature . '</li>';
}
$AmazonContent = str_replace('{amazonfeature}', $rFtr, $AmazonContent);
$AmazonTitle = str_replace('{amazonfeature}', $rFtr, $AmazonTitle);
} else {
$AmazonContent = str_replace('{amazonfeature}', $response['Items']['Item']['ItemAttributes']['Feature'], $AmazonContent);
$AmazonTitle = str_replace('{amazonfeature}', $response['Items']['Item']['ItemAttributes']['Feature'], $AmazonTitle);
}
} else {
$AmazonContent = str_replace('{amazonfeature}', 'n/a', $AmazonContent);
$AmazonTitle = str_replace('{amazonfeature}', 'n/a', $AmazonTitle);
}

if (($response['Items']['Item'][$i]['ImageSets']['ImageSet'])) {
if (is_array(($response['Items']['Item'][$i]['ImageSets']['ImageSet']))) {
foreach ($response['Items']['Item'][$i]['ImageSets']['ImageSet'] as $rImageset) {
$rFtr .= '<img src="' . $rImageset['LargeImage']['URL'] . '" />';
}
$AmazonContent = str_replace('{amazonimageset}', $rFtr, $AmazonContent);
$AmazonTitle = str_replace('{amazonimageset}', $rFtr, $AmazonTitle);
} else {
$AmazonContent = str_replace('{amazonimageset}', $response['Items']['Item']['ImageSets']['ImageSet'], $AmazonContent);
$AmazonTitle = str_replace('{amazonimageset}', $response['Items']['Item']['ImageSets']['ImageSet'], $AmazonTitle);
}
} elseif (($response['Items']['Item']['ImageSets']['ImageSet'])) {
if (is_array(($response['Items']['Item']['ImageSets']['ImageSet']))) {
foreach ($response['Items']['Item']['ImageSets']['ImageSet'] as $rImageset) {
$rFtr .= '<img src="' . $rImageset['LargeImage']['URL'] . '" />';
}
$AmazonContent = str_replace('{amazonimageset}', $rFtr, $AmazonContent);
$AmazonTitle = str_replace('{amazonimageset}', $rFtr, $AmazonTitle);
} else {
$AmazonContent = str_replace('{amazonimageset}', $response['Items']['Item']['ImageSets']['ImageSet'], $AmazonContent);
$AmazonTitle = str_replace('{amazonimageset}', $response['Items']['Item']['ImageSets']['ImageSet'], $AmazonTitle);
}
} else {
$AmazonContent = str_replace('{amazonimageset}', 'n/a', $AmazonContent);
$AmazonTitle = str_replace('{amazonimageset}', 'n/a', $AmazonTitle);
}

if (($response['Items']['Item'][$i]['ItemAttributes']['ListPrice']['FormattedPrice'])) {
$AmazonContent = str_replace('{amazonlistprice}', $response['Items']['Item'][$i]['ItemAttributes']['ListPrice']['FormattedPrice'], $AmazonContent);
$AmazonTitle = str_replace('{amazonlistprice}', $response['Items']['Item'][$i]['ItemAttributes']['ListPrice']['FormattedPrice'], $AmazonTitle);
} elseif (($response['Items']['Item']['ItemAttributes']['ListPrice']['FormattedPrice'])) {
$AmazonContent = str_replace('{amazonlistprice}', $response['Items']['Item']['ItemAttributes']['ListPrice']['FormattedPrice'], $AmazonContent);
$AmazonTitle = str_replace('{amazonlistprice}', $response['Items']['Item']['ItemAttributes']['ListPrice']['FormattedPrice'], $AmazonTitle);
} else {
$AmazonContent = str_replace('{amazonlistprice}', 'n/a', $AmazonContent);
$AmazonTitle = str_replace('{amazonlistprice}', 'n/a', $AmazonTitle);
}

if (($response['Items']['Item'][$i]['OfferSummary']['LowestNewPrice']['FormattedPrice'])) {
$AmazonContent = str_replace('{amazonlowestnewprice}', $response['Items']['Item'][$i]['OfferSummary']['LowestNewPrice']['FormattedPrice'], $AmazonContent);
$AmazonTitle = str_replace('{amazonlowestnewprice}', $response['Items']['Item'][$i]['OfferSummary']['LowestNewPrice']['FormattedPrice'], $AmazonTitle);
} elseif (($response['Items']['Item']['OfferSummary']['LowestNewPrice']['FormattedPrice'])) {
$AmazonContent = str_replace('{amazonlowestnewprice}', $response['Items']['Item']['OfferSummary']['LowestNewPrice']['FormattedPrice'], $AmazonContent);
$AmazonTitle = str_replace('{amazonlowestnewprice}', $response['Items']['Item']['OfferSummary']['LowestNewPrice']['FormattedPrice'], $AmazonTitle);
} else {
$AmazonContent = str_replace('{amazonlowestnewprice}', 'n/a', $AmazonContent);
$AmazonTitle = str_replace('{amazonlowestnewprice}', 'n/a', $AmazonTitle);
}

if (isset($response['Items']['Item'][$i]['Offers']['Offer']['OfferListing']['SalePrice']['Amount'])) {
$AmazonContent = str_replace('{amazonsaleprice}', $response['Items']['Item'][$i]['Offers']['Offer']['OfferListing']['SalePrice']['Amount'], $AmazonContent);
$AmazonTitle = str_replace('{amazonsaleprice}', $response['Items']['Item'][$i]['Offers']['Offer']['OfferListing']['SalePrice']['Amount'], $AmazonTitle);
} elseif (isset($response['Items']['Item']['Offers']['Offer']['OfferListing']['SalePrice']['Amount'])) {
$AmazonContent = str_replace('{amazonsaleprice}', $response['Items']['Item']['Offers']['Offer']['OfferListing']['SalePrice']['Amount'], $AmazonContent);
$AmazonTitle = str_replace('{amazonsaleprice}', $response['Items']['Item']['Offers']['Offer']['OfferListing']['SalePrice']['Amount'], $AmazonTitle);
} else {
$AmazonContent = str_replace('{amazonsaleprice}', 'no sale offer', $AmazonContent);
$AmazonTitle = str_replace('{amazonsaleprice}', 'no sale offer', $AmazonTitle);
}

if (isset($response['Items']['Item'][$i]['EditorialReviews']['EditorialReview']['Content'])) {
$AmazonContent = str_replace('{amazoneditorialreviews}', $response['Items']['Item'][$i]['EditorialReviews']['EditorialReview']['Content'], $AmazonContent);
$AmazonTitle = str_replace('{amazoneditorialreviews}', $response['Items']['Item'][$i]['EditorialReviews']['EditorialReview']['Content'], $AmazonTitle);
} elseif (isset($response['Items']['Item']['EditorialReviews']['EditorialReview']['Content'])) {
$AmazonContent = str_replace('{amazoneditorialreviews}', $response['Items']['Item']['EditorialReviews']['EditorialReview']['Content'], $AmazonContent);
$AmazonTitle = str_replace('{amazoneditorialreviews}', $response['Items']['Item']['EditorialReviews']['EditorialReview']['Content'], $AmazonTitle);
} else {
$rERevnum = count($response['Items']['Item'][$i]['EditorialReviews']['EditorialReview']);
if ($rERevnum > 0) {
for ($i = 0; $i < $rERevnum; $i++) {
$rERev .= $response['Items']['Item'][$i]['EditorialReviews']['EditorialReview'][$i]['Content'] . '<br />';
}
$AmazonContent = str_replace('{amazoneditorialreviews}', $rERev, $AmazonContent);
$AmazonTitle = str_replace('{amazoneditorialreviews}', $rERev, $AmazonTitle);
} else {
$AmazonContent = str_replace('{amazoneditorialreviews}', '', $AmazonContent);
$AmazonTitle = str_replace('{amazoneditorialreviews}', '', $AmazonTitle);
}
}

//http://www.amazon.com/gp/aws/cart/add.html?AssociateTag=your-tag-here-20&ASIN.1=B003IXYJYO&Quantity.1=2&ASIN.2=B0002KR8J4&Quantity.2=1&ASIN.3=B0002ZP18E&Quantity.3=1&ASIN.4=B0002ZP3ZA&Quantity.4=2&ASIN.5=B004J2JG6O&Quantity.5=1

//http://www.amazon.de/gp/aws/cart/add.html?AssociateTag=andrygmv-21&ASIN.1=B000VJC9Y0&Quantity.1=1
if (isset($response['Items']['Item'][$i]['DetailPageURL'])) {
$AmazonContent = str_replace('{amazondetailurl}', $response['Items']['Item'][$i]['DetailPageURL'], $AmazonContent);
$AmazonTitle = str_replace('{amazondetailurl}', $response['Items']['Item'][$i]['DetailPageURL'], $AmazonTitle);
$domainutama = maindomain($response['Items']['Item'][$i]['DetailPageURL']);
$addcartURL = 'http://www.' . $domainutama . '/gp/aws/cart/add.html?AssociateTag=' . $AmazonTagAffilate . '&ASIN.1=' . $response['Items']['Item'][$i]['ASIN'] . '&Quantity.1=1';
$AmazonContent = str_replace('{amazonaddtocarturl}', $addcartURL, $AmazonContent);
$AmazonTitle = str_replace('{amazonaddtocarturl}', $addcartURL, $AmazonTitle);
} elseif (isset($response['Items']['Item']['DetailPageURL'])) {
$AmazonContent = str_replace('{amazondetailurl}', $response['Items']['Item']['DetailPageURL'], $AmazonContent);
$AmazonTitle = str_replace('{amazondetailurl}', $response['Items']['Item']['DetailPageURL'], $AmazonTitle);
$domainutama = maindomain($response['Items']['Item']['DetailPageURL']);
$addcartURL = 'http://www.' . $domainutama . '/gp/aws/cart/add.html?AssociateTag=' . $AmazonTagAffilate . '&ASIN.1=' . $response['Items']['Item']['ASIN'] . '&Quantity.1=1';
$AmazonContent = str_replace('{amazonaddtocarturl}', $addcartURL, $AmazonContent);
$AmazonTitle = str_replace('{amazonaddtocarturl}', $addcartURL, $AmazonTitle);
} else {
$AmazonContent = str_replace('{amazondetailurl}', '', $AmazonContent);
$AmazonTitle = str_replace('{amazondetailurl}', '', $AmazonTitle);
$AmazonContent = str_replace('{amazonaddtocarturl}', '', $AmazonContent);
$AmazonTitle = str_replace('{amazonaddtocarturl}', '', $AmazonTitle);
}
$jmlTokenOpen = ComotCountWord($AmazonContent, '{') - 1;
$jmlTokenClose = ComotCountWord($AmazonContent, '}') - 1;
if ($jmlTokenOpen <> $jmlTokenClose) {
echo "There is open {} tag.";
exit;
}
//START Title
$strBad = array(
'{',
'}'
);
$tokenopen = '{';
$tokenclose = '}';
for ($ia = 0; $ia < $jmlTokenOpen; $ia++) {
$oriSpin = $tokenopen . ComotGetBetween($AmazonTitle, $tokenopen, $tokenclose) . $tokenclose;
$rSpinOut = explode("|", $oriSpin);
shuffle($rSpinOut);
$thisOutTitle = str_replace($oriSpin, str_replace($strBad, '', $rSpinOut[0]), $AmazonTitle);
}
//END Title

//START Content
$tokenopen = '{';
$tokenclose = '}';
for ($ib = 0; $ib < $jmlTokenOpen; $ib++) {
$oriSpin = $tokenopen . ComotGetBetween($AmazonContent, $tokenopen, $tokenclose) . $tokenclose;
$rSpinOut = explode("|", $oriSpin);
shuffle($rSpinOut);
$AmazonContent = str_replace($oriSpin, str_replace($strBad, '', $rSpinOut[0]), $AmazonContent);
}
//END Content
if (($response['Items']['Item'][$i]['ASIN']) || ($response['Items']['Item']['ASIN'])) {
//START Creating random POST DATE
$timeAwal = substr(date($AmazonStartPostDate . " H:i:s"), 10);
$timeAkhir = '24:00:00';
list($h, $m, $s) = explode(":", $timeAwal);
$dAwal = mktime($h, $m, $s, "0", "0", "0");
list($h, $m, $s) = explode(":", $timeAkhir);
$dAkhir = mktime($h, $m, $s, "0", "0", "0");
$dSelisih = (abs($dAkhir - $dAwal)) - 30; //30 adalah awal di random
if ($dSelisih < 1)
$dSelisih = 1;
$RandPostDate = date('Y-m-d H:i:s', strtotime(date($AmazonStartPostDate . " H:i:s") . ' +' . rand(30, $dSelisih) . ' seconds'));
if ($countRand >= $AmazonRandPost) {
$countRand = 0;
$AmazonRandPost = rand($AmazonRandPostStart, $AmazonRandPostEnd);
$AmazonStartPostDate = date('Y-m-d', strtotime('+1 days', strtotime($AmazonStartPostDate)));
} else {
$countRand++;
}
// END Creating random POST DATE
if (isset($response['Items']['Item'][$i]['ItemAttributes']['ProductGroup'])) {
$thisCategory = ucwords($response['Items']['Item'][$i]['ItemAttributes']['Department'] . ' ' . $response['Items']['Item'][$i]['ItemAttributes']['ProductGroup']);
} elseif (isset($response['Items']['Item']['ItemAttributes']['ProductGroup'])) {
$thisCategory = ucwords($response['Items']['Item']['ItemAttributes']['Department'] . ' ' . $response['Items']['Item']['ItemAttributes']['ProductGroup']);
} else {
$thisCategory = '';
}
$term_ID = 0;
if ($term = get_term_by('name', $thisCategory, 'category')) {
$term_ID = $term->term_id;
} else {
//$term_ID = wp_create_category( $thisCategory,0 );
$slugCat = str_replace(' ', '-', $thisCategory);
$my_category = array(
'cat_name' => $thisCategory,
'category_description' => $thisCategory,
'category_nicename' => $slugCat,
'category_parent' => ''
);
// Create the category
$term_ID = wp_insert_category($my_category);
}

$my_post = array(
'post_title' => $thisOutTitle,
'post_type' => 'post',
'post_content' => $AmazonContent,
'post_status' => get_option('ts_comot_azon_typePost'),
'post_category' => array(
$term_ID
),
'post_date' => $RandPostDate,
'post_author' => 1
);
// Insert the post into the database
$post_id = wp_insert_post($my_post);
if (($response['Items']['Item'][$i]['LargeImage']['URL']) || ($response['Items']['Item']['LargeImage']['URL'])) {
if (($response['Items']['Item'][$i]['LargeImage']['URL']))
$imageurl = ($response['Items']['Item'][$i]['LargeImage']['URL']);
else
$imageurl = ($response['Items']['Item']['LargeImage']['URL']);
$uploads = wp_upload_dir();

$filename = wp_unique_filename($uploads['path'], basename($imageurl), $unique_filename_callback = null);
$wp_filetype = wp_check_filetype($filename, null);
$fullpathfilename = $uploads['path'] . "/" . $filename;
if (($response['Items']['Item'][$i]['LargeImage']['URL']))
media_sideload_image($imageurl, $post_id, $response['Items']['Item'][$i]['ItemAttributes']['Title']);
else
media_sideload_image($imageurl, $post_id, $response['Items']['Item']['ItemAttributes']['Title']);
// Cara membuat otomatis jadi featured image
$already_has_thumb = has_post_thumbnail($post_id);
if (!$already_has_thumb) {
$attached_image = get_children("post_parent=post_id&post_type=attachment&post_mime_type=image&numberposts=1");
if ($attached_image) {
foreach ($attached_image as $attachment_id => $attachment) {
set_post_thumbnail($post_id, $attachment_id);
}
}
}

//masukin images set
if (($response['Items']['Item'][$i]['ImageSets']['ImageSet'])) {
if (is_array(($response['Items']['Item'][$i]['ImageSets']['ImageSet']))) {
foreach ($response['Items']['Item'][$i]['ImageSets']['ImageSet'] as $rImageset) {
$imageurl = $rImageset['LargeImage']['URL'];
$filename = wp_unique_filename($uploads['path'], basename($imageurl), $unique_filename_callback = null);
$wp_filetype = wp_check_filetype($filename, null);
$fullpathfilename = $uploads['path'] . "/" . $filename;
media_sideload_image($imageurl, $post_id, $response['Items']['Item'][$i]['ItemAttributes']['Title']);
}
} else {
$imageurl = $response['Items']['Item'][$i]['ImageSets']['ImageSet']['LargeImage']['URL'];
$filename = wp_unique_filename($uploads['path'], basename($imageurl), $unique_filename_callback = null);
$wp_filetype = wp_check_filetype($filename, null);
$fullpathfilename = $uploads['path'] . "/" . $filename;
media_sideload_image($imageurl, $post_id, $response['Items']['Item'][$i]['ItemAttributes']['Title']);
}
} elseif (($response['Items']['Item']['ImageSets']['ImageSet'])) {
if (is_array(($response['Items']['Item']['ImageSets']['ImageSet']))) {
foreach ($response['Items']['Item']['ImageSets']['ImageSet'] as $rImageset) {
$imageurl = $rImageset['LargeImage']['URL'];
$filename = wp_unique_filename($uploads['path'], basename($imageurl), $unique_filename_callback = null);
$wp_filetype = wp_check_filetype($filename, null);
$fullpathfilename = $uploads['path'] . "/" . $filename;
media_sideload_image($imageurl, $post_id, $response['Items']['Item']['ItemAttributes']['Title']);
}
} else {
$imageurl = $response['Items']['Item']['ImageSets']['ImageSet']['LargeImage']['URL'];
$filename = wp_unique_filename($uploads['path'], basename($imageurl), $unique_filename_callback = null);
$wp_filetype = wp_check_filetype($filename, null);
$fullpathfilename = $uploads['path'] . "/" . $filename;
media_sideload_image($imageurl, $post_id, $response['Items']['Item']['ItemAttributes']['Title']);
}
} else {
$AmazonContent = str_replace('{amazonimageset}', 'n/a', $AmazonContent);
}
}
}
if ($post_id)
if ($response['Items']['Item'][$i]['ASIN']) {
echo 'ASIN ' . $response['Items']['Item'][$i]['ASIN'] . ' insert into post.<br />';
$successASIN[$i] = $response['Items']['Item'][$i]['ASIN'];
update_option('ts_comot_azon_startPost', $AmazonStartPostDate);
} else {
echo 'ASIN ' . $response['Items']['Item']['ASIN'] . ' insert into post.<br />';
$successASIN[0] = $response['Items']['Item']['ASIN'];
} else
echo 'ASIN ' . $response['Items']['Item']['ASIN'] . ' failed insert into post.<br />';
}
$rSuccessASIN = array_to_comma($successASIN);
//echo get_option('ts_comot_used_ASIN');
// print_r($response);
if (strlen(trim(get_option('ts_comot_used_ASIN'))))
update_option('ts_comot_used_ASIN', get_option('ts_comot_used_ASIN') . ',' . $rSuccessASIN);
else
update_option('ts_comot_used_ASIN', $rSuccessASIN);
$rFailedASIN = array_merge(array_diff($grupASIN[0], $successASIN));
$rFailedASIN = array_to_comma($rFailedASIN);
update_option('ts_comot_failed_ASIN', $rFailedASIN);
} else {
echo 'Grabbing failed. Check your ASIN or internet connection.';
}
}

function comot_list_category()
{
$args = array(
'hide_empty' => 0,
'hierarchical' => 1,
'number' => 0,
'pad_counts' => false
);
$categories = get_categories($args);
$result = '<select name="comot_list_category">';
foreach ($categories as $caty) {
$result .= '<option value="' . $caty->cat_ID . '">' . $caty->cat_name . '</option>';
}
$result .= '<select>';
return $result;
}
//BEGIN remove one column admin
function comot_manage_columns($columns)
{
unset($columns['tags']);
return $columns;
}

function comot_column_init()
{
add_filter('manage_posts_columns', 'comot_manage_columns');
}
add_action('admin_init', 'comot_column_init');
//END remove one column admin

//BEGIN display the post attachment count in a custom admin column.
add_filter('manage_posts_columns', 'posts_columns_attachment_count', 5);
add_action('manage_posts_custom_column', 'posts_custom_columns_attachment_count', 5, 2);
function posts_columns_attachment_count($defaults)
{
$defaults['wps_post_attachments'] = __('Attachments');
return $defaults;
}
function posts_custom_columns_attachment_count($column_name, $id)
{
if ($column_name === 'wps_post_attachments') {
$attachments = get_children(array(
'post_parent' => $id
));
$count = count($attachments);
if ($count != 0) {
echo $count;
}
}
}

//END display the post attachment count in a custom admin column.


//BEGIN Ini untuk menampilkan featured images di post
// Add the posts and pages columns filter. They can both use the same function.
add_filter('manage_posts_columns', 'comot_add_post_thumbnail_column', 5);
add_filter('manage_pages_columns', 'comot_add_post_thumbnail_column', 5);

// Add the column
function comot_add_post_thumbnail_column($cols)
{
$cols['comot_post_thumb'] = __('Featured');
return $cols;
}

// Hook into the posts an pages column managing. Sharing function callback again.
add_action('manage_posts_custom_column', 'comot_display_post_thumbnail_column', 5, 2);
add_action('manage_pages_custom_column', 'comot_display_post_thumbnail_column', 5, 2);

// Grab featured-thumbnail size post thumbnail and display it.
function comot_display_post_thumbnail_column($col, $id)
{
switch ($col) {
case 'comot_post_thumb':
if (function_exists('the_post_thumbnail'))
echo the_post_thumbnail('thumbnail');
else
echo 'Not supported in theme';
break;
}
}
//END untuk menampilkan featured images di dashboard
function array_to_comma($oriArray = array())
{
$first = true;
foreach ($oriArray as $outString) {
if ($first) {
$gagString .= $outString;
$first = false;
} else {
$gagString .= ',' . $outString;
}
}
return trim($gagString);
}
if (is_admin()) {
class ts_Grabit
{
var $imageName;

function ts_Grabit()
{
$this->__construct();
}

function __construct()
{
if (basename($_SERVER['PHP_SELF']) != "media-upload.php")
return;
add_filter("media_upload_tabs", array(
&$this,
"build_tab"
));
add_action("media_upload_ts_grabit", array(
&$this,
"menu_handle"
));
}

/*
* Merge an array into middle of another array
*
* @param array $array the array to insert
* @param array $insert array to be inserted
* @param int $position index of array
*/
function array_insert(&$array, $insert, $position)
{
settype($array, "array");
settype($insert, "array");
settype($position, "int");

//if pos is start, just merge them
if ($position == 0) {
$array = array_merge($insert, $array);
} else {
//if pos is end just merge them
if ($position >= (count($array) - 1)) {
$array = array_merge($array, $insert);
} else {
//split into head and tail, then merge head+inserted bit+tail
$head = array_slice($array, 0, $position);
$tail = array_slice($array, $position);
$array = array_merge($head, $insert, $tail);
}
}
return $array;
}


function build_tab($tabs)
{
$newtab = array(
'ts_grabit' => __('Comot - Grab Images by Keyword', 'ts_grabit')
);
return $this->array_insert($tabs, $newtab, 0);
//return array_merge($tabs,$newtab);
}
function menu_handle()
{
return wp_iframe(array(
$this,
"media_process"
));
}
function fetch_image($url)
{
if (function_exists("curl_init")) {
return $this->curl_fetch_image($url);
} elseif (ini_get("allow_url_fopen")) {
return $this->fopen_fetch_image($url);
}
}
function curl_fetch_image($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$image = curl_exec($ch);
curl_close($ch);
return $image;
}
function fopen_fetch_image($url)
{
$image = file_get_contents($url, false, $context);
return $image;
}

function media_process()
{
if ($_POST['imgKeyword']) {
//START - Take URL from BING
$accountKey = get_option('ts_comot_azure_key');
$ServiceRootURL = 'https://api.datamarket.azure.com/Bing/Search/';
//$WebSearchURL = $ServiceRootURL . 'Image?$format=json&Query=';
//skip = offset
$Skip = rand(0, 10);
$imgNumber = $_POST['imgNumber'];
if ($imgNumber < 0 || $imgNumber > 6)
$imgNumber = 6;
$WebSearchURL = $ServiceRootURL . 'Image?$format=json&$Top=' . $imgNumber . '&$Skip=' . $Skip . '&Adult=%27Moderate%27&ImageFilters=%27Size%3aLarge%27&Query=';
//$WebSearchURL = $ServiceRootURL . 'Image?$format=json&$Top=1&Adult=%27Strict%27&ImageFilters=%27Size%3aLarge%27&Query=';
ini_set('max_execution_time', 300);
$request = $WebSearchURL . urlencode('\'' . $_POST["imgKeyword"] . '\'');
//echo $request;exit;
$process = curl_init($request);
curl_setopt($process, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($process, CURLOPT_USERPWD, $accountKey . ":" . $accountKey);
curl_setopt($process, CURLOPT_HEADER, 0);
curl_setopt($process, CURLOPT_TIMEOUT, 300);
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($process, CURLOPT_HTTPPROXYTUNNEL, FALSE);
curl_setopt($process, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
// curl_setopt ($process, CURLOPT_PROXY, 'http://'.$proxy);
curl_setopt($process, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($process);
$hasil = json_decode($response);
foreach ($hasil->d->results as $ts_comot_img) {
$imageurl = $ts_comot_img->MediaUrl;

//END - Take URL from BING

$imageurl = stripslashes($imageurl);
$uploads = wp_upload_dir();
$post_id = isset($_GET['post_id']) ? (int) $_GET['post_id'] : 0;
$filename = wp_unique_filename($uploads['path'], basename($imageurl), $unique_filename_callback = null);
$wp_filetype = wp_check_filetype($filename, null);
$fullpathfilename = $uploads['path'] . "/" . $filename;

try {
if (!substr_count($wp_filetype['type'], "image")) {
throw new Exception(basename($imageurl) . ' is not a valid image. ' . $wp_filetype['type'] . '');
}

$image_string = $this->fetch_image($imageurl);
$fileSaved = file_put_contents($uploads['path'] . "/" . $filename, $image_string);
if (!$fileSaved) {
throw new Exception("The file cannot be saved.");
}

$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_title' => preg_replace('/\.[^.]+$/', '', $filename),
'post_content' => '',
'post_status' => 'inherit',
'guid' => $uploads['url'] . "/" . $filename
);
$attach_id = wp_insert_attachment($attachment, $fullpathfilename, $post_id);
if (!$attach_id) {
throw new Exception("Failed to save record into database.");
}
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
$attach_data = wp_generate_attachment_metadata($attach_id, $fullpathfilename);
wp_update_attachment_metadata($attach_id, $attach_data);

}
catch (Exception $e) {
$error = '<div id="message" class="error"><p>' . $e->getMessage() . '</p></div>';
}
}
}
media_upload_header();
if (!get_option('ts_comot_azure_key')) {
echo '<div style="height:10px"> ;;</div>';
echo '<div style="padding:0px 10px;">Windows Azure API key not found. <br />Please input your Windows Azure API key on the <strong>Comot Setting</strong> menu.</div>';
exit;
}
if (!function_exists("curl_init") && !ini_get("allow_url_fopen")) {
echo '<div id="message" class="error"><p><b>cURL</b> or <b>allow_url_fopen</b> needs to be enabled. Please consult your server Administrator.</p></div>';
} elseif ($error) {
echo $error;
} else {
if ($fileSaved && $attach_id) {
echo '<div id="message" class="updated"><p>File saved.</p></div>';
}
}
?>

<form action="" method="post" id="image-form" class="media-upload-form type-form">
<h3 class="media-title">Read Me First</h3>
<ol><li>Make sure you have save right Windows Azure API key on the <strong>Plugin >> Comot</strong> menu,<br /> or this plugin will not work.</li>
<li>Try click GRAB button again when this tool fail to grab image or change keyword, because maybe image not available for the keyword. </li>
<li>This plugin will automatically attach all images grabbed into this post.</li>
</ol>
<div style="height:10px"> ;;</div>
<div class="describe">
<h3 class="media-title">Input Keyword</h3><input id="src" type="text" name="imgKeyword"><br />
<h4 class="media-title">How many images do you try to grab? More images take more time. </h4><input type="text" size="3" name="imgNumber" value="1" style="width:30px"> (Max. 6)
</div>
<p> ;;</p>
<input type="submit" class="button" value="Grab">

</form>
<?php

if ($attach_id) {
$this->media_upload_type_form("image", $errors, $attach_id);
}
?>
<!--<div style="padding:10px;"><a href="http://digitalmemo.neobie.net/grab-save/" target="digitalmemo" style="text-decoration:none;font-size:0.8em;">&copy; neobie @ DigitalMemo</a></div>-->
<?php
}


/*
* modification from media.php function
*
* @param unknown_type $type
* @param unknown_type $errors
* @param unknown_type $id
*/
function media_upload_type_form($type = 'file', $errors = null, $id = null)
{
$post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;

$form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
?>

<form enctype="multipart/form-data" method="post" action="<?php
echo esc_attr($form_action_url);
?>" class="media-upload-form type-form validate" id="<?php
echo $type;
?>-form">
<input type="submit" class="hidden" name="save" value="" />
<input type="hidden" name="post_id" id="post_id" value="<?php
echo (int) $post_id;
?>" />
<?php
wp_nonce_field('media-form');
?>

<script type="text/javascript">
//<![CDATA[
jQuery(function($){
var preloaded = $(".media-item.preloaded");
if ( preloaded.length > 0 ) {
preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
}
updateMediaForm();
});
//]]>
</script>
<div id="media-items">
<?php

if ($id) {
if (!is_wp_error($id)) {
add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
echo get_media_items($id, $errors);
} else {
echo '<div id="media-upload-error">' . esc_html($id->get_error_message()) . '</div>';
exit;
}
}
?>
</div>
<p class="savebutton ml-submit">
<input type="submit" class="button" name="save" value="<?php
esc_attr_e('Save all changes');
?>" />
</p>
</form>

<?php
}
}
new ts_Grabit();
}
function cleanarray($arr)
{
//Buang array kembar
$kw = array_values(array_unique($arr));
//Buang array kosong
foreach ($kw as $key => $value) {
if (trim($value) == "") {
unset($kw[$key]);
}
}
return $kw;
}
?>

_________________
Go BIG or go HOME !
View user's profile Send private message
how to decode codelock
www.waraxe.us Forum Index -> PHP script decode requests
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT
Page 1 of 1

Post new topicReply to topic


Powered by phpBB © 2001-2008 phpBB Group



Space Raider game for Android, free download - Space Raider gameplay video - Zone Raider mobile games
All logos and trademarks in this site are property of their respective owner. The comments and posts are property of their posters, all the rest (c) 2004-2024 Janek Vind "waraxe"
Page Generation: 0.045 Seconds