function testBuildVehiclesAdGroup() { require_once "../config/keyword_forger.php"; $this->maindb->executeSQL("SELECT * FROM vehicles WHERE l_isActive = 1 ORDER BY RAND() LIMIT 1", $res, $bulk); $record = $res[0]; $item = new GoogleAdGroup($this->db); $item->buildVehiclesAdGroup($record); $this->assertEqual($item->gag_name, $record['l_make'] . " " . $record['l_model'] . " " . $item->gag_id . ":" . $item->gag_l_id); $this->db->executeSQL("SELECT count(*) as cnt FROM m2m_keywords_to_google_ad_groups WHERE gag_id = " . $item->gag_id, $res, $bulk); $this->assertTrue($res[0]['cnt'] > 0); $item->delete(); }
function testBuildAds() { $bck = $this->item->gag_id; $this->item->gag_id = ''; $this->assertFalse($this->item->buildAds()); $this->item->gag_id = $bck; $this->assertFalse($this->item->buildAds()); $this->assertFalse($this->item->buildAds(null)); $this->assertFalse($this->item->buildAds(array())); $this->item->m_ad_types = array("GoogleAdRealEstateRU"); $this->assertFalse($this->item->buildAds(array())); $this->assertFalse($this->item->buildAds(array("a"))); $this->maindb->executeSQL("SELECT * FROM realestate WHERE l_isActive = 1 ORDER BY RAND() LIMIT 1", $res, $bulk); $record = $res[0]; }
$kk++; if ($k >= 2500) { break; } fputs($fp, "{$campaign->ga_campaign_name},,,,,," . $ag->gag_name . "," . MAX_CPC . "," . DEFAULT_MATCH_TYPE . ",{$v['keyword']},,,,,{$v['url']}\r\n"); fputs($fp, "{$campaign->ga_campaign_name},,,,,," . $ag->gag_name . "," . MAX_CPC . ",Phrase,{$v['keyword']},,,,,{$v['url']}\r\n"); } } } $prev_make = $val['l_make']; if ($kk > 60000) { break 2; } $k = 0; echo $c . "/" . ++$i . "/" . $total . "\r\n"; $ag = new GoogleAdGroup($db); $ag->m_sMainTable = 'vehicles'; $ag->gag_l_id = $val['l_id']; $ag->createName($val); $ag->save(); $ag->m_aKeywords[] = array('keyword' => $val['l_make'], 'url' => "http://vehicles.pingola.ru.msn.com/search/" . str_replace(" ", "+", $val['l_make']) . "?make=" . str_replace(" ", "+", $val['l_make']) . "&share&refGoogle=Network=_{network}_&Keyword=_{keyword}_&MatchType=_{matchtype}_&Ad=_{creative}_&AdPos=_{adposition}_"); $ag->buildAds(array('GoogleAdVehiclesRU', 'GoogleAdVehiclesRU3', 'GoogleAdVehiclesRU4'), $val); //, 'GoogleAdRealEstateRU2', 'GoogleAdRealEstateRU3', 'GoogleAdRealEstateRU4'), $val); if (!$ag->is_has_ads) { echo "no good ads\r\n"; continue; } $c++; if ($c == 2000) { $c = 0; $campaign = new GoogleCampaign($db);
fputs($fp, "Campaign,Daily Budget,Language,Location,Proximity Targets,Ad Schedule,Ad Group,Max CPC,Keyword Type,Keyword,Headline,Description Line 1,Description Line 2,Display URL,Destination URL\r\n"); $cur = 0; $step = 10000; $i = 0; $c = 0; $main_db->executeSQL("SELECT *, count(*) as cnt FROM realestate\n\tWHERE \tl_deal_type = 0 and \n\t\t\tl_www_id = 1369 and \n\t\t\tl_isActive = 1 and \n\t\t\tl_d_price > 10000 and\n\t\t\tl_assetType = 'Квартира'\n\tGROUP BY \n\t\tl_geo_city \n\tORDER BY \n\t\tcnt DESC \n\tLIMIT 20", $resultArry, $rowsAffected); if (!$rowsAffected) { break; } $total = $rowsAffected; foreach ($resultArry as $val) { $campaign = new GoogleCampaign($db); $campaign->ga_campaign_name = "Real Estate Sale " . $val['l_geo_city']; $campaign->save(); echo $c . "/" . ++$i . "/" . $total . "\r\n"; $ag = new GoogleAdGroup($db); $ag->m_sMainTable = 'realestate'; $ag->gag_l_id = $val['l_id']; $ag->createName(); $ag->save(); $ag->buildAds(array('GoogleAdRealEstateRU5', 'GoogleAdRealEstateRU6', 'GoogleAdRealEstateRU7', 'GoogleAdRealEstateRU12', 'GoogleAdRealEstateRU13'), $val); $ag->buildRealestateKeywordsRU($val); $ag->saveAds($fp, $campaign->ga_campaign_name); if (!$ag->is_has_ads) { echo "no good ads\r\n"; continue; } $ag->m_aKeywords = array_unique($ag->m_aKeywords); foreach ($ag->m_aKeywords as $val2) { fputs($fp, "{$campaign->ga_campaign_name},,,,,," . $ag->gag_name . "," . MAX_CPC . "," . DEFAULT_MATCH_TYPE . ",{$val2}\r\n"); }
$db = new DBAdapter2(array('host' => KWDB_HOST, 'username' => KWDB_USERNAME, 'password' => KWDB_PASSWORD, 'schema' => KWDB_SCHEMA)); $main_db = new DBAdapter2(array('host' => '192.168.240.15', 'username' => 'eyezeek', 'password' => 'p!n6access', 'schema' => 'il_eyezeek')); $campaign = new GoogleCampaign($db); $campaign->ga_campaign_name = CAMPAIGN_NAME_BASE . " " . date("Y-m-d H i"); $campaign->save(); $fp = fopen("../output/" . str_replace(" ", "_", $campaign->ga_campaign_name) . ".csv", "w+"); fputs($fp, "Campaign,Daily Budget,Language,Location,Proximity Targets,Ad Schedule,Ad Group,Max CPC,Keyword Type,Keyword,Headline,Description Line 1,Description Line 2,Display URL,Destination URL\r\n"); $cur = 0; $step = 10000; $i = 0; $c = 0; $main_db->executeSQL("SELECT l_geo_city, l_rooms, l_assetType, min(l_d_price) as l_d_price, count(*) as cnt FROM realestate WHERE l_www_id = 16 and l_isActive = 1 and l_d_price > 1500 and l_rooms < 4 and l_deal_type = 0 GROUP BY l_geo_city, l_rooms, l_assetType HAVING cnt > 10 ORDER BY cnt DESC", $resultArry, $rowsAffected); $total = $rowsAffected; foreach ($resultArry as $val) { echo $c . "/" . ++$i . "\r\n"; $ag = new GoogleAdGroup($db); $ag->m_sMainTable = 'realestate'; $ag->gag_l_id = $val['l_id']; $ag->gag_name = "Group " . $c; $ag->save(); $ag->buildAds(array("GoogleAdRealEstateIL"), $val); $ag->buildRealEstateKeywordsIL($val); $ag->saveAds($fp, $campaign->ga_campaign_name); if (!$ag->is_has_ads) { echo "no good ads\r\n"; continue; } foreach ($ag->m_aKeywords as $val) { fputs($fp, "{$campaign->ga_campaign_name},,,,,," . $ag->gag_name . "," . MAX_CPC . "," . DEFAULT_MATCH_TYPE . ",{$val}\r\n"); } $c++;
$campaign->save(); $fp = fopen("../output/" . str_replace(" ", "_", $campaign->ga_campaign_name) . ".csv", "w+"); fputs($fp, "Campaign,Daily Budget,Language,Location,Proximity Targets,Ad Schedule,Ad Group,Max CPC,Keyword Type,Keyword,Headline,Description Line 1,Description Line 2,Display URL,Destination URL\r\n"); $cur = 0; $step = 10000; $i = 0; $c = 0; do { $main_db->executeSQL("SELECT l_make, l_model, l_year, l_owners, min(l_price) as l_d_price, count(*) as cnt FROM vehicles WHERE l_isActive = 1 and l_price > 3000 and l_owners = 'שניה' GROUP BY l_make, l_model, l_year HAVING cnt > 5 ORDER BY l_id DESC LIMIT {$cur}, {$step}", $resultArry, $rowsAffected); if (!$rowsAffected) { break; } $total = $rowsAffected; foreach ($resultArry as $val) { echo $c . "/" . ++$i . "/" . $total . "\r\n"; $ag = new GoogleAdGroup($db); $ag->m_sMainTable = 'vehicles'; $ag->gag_l_id = $val['l_id']; $ag->gag_name = $val['l_make'] . " " . $val['l_model'] . " " . $val['l_year'] . " " . $i; $ag->save(); $ag->buildAds(array('GoogleAdVehicles17072011_1IL', 'GoogleAdVehicles17072011_2IL', 'GoogleAdVehicles17072011_3IL', 'GoogleAdVehicles17072011_4IL', 'GoogleAdVehicles17072011_5IL', 'GoogleAdVehicles17072011_6IL', 'GoogleAdVehicles17072011_7IL'), $val); $ag->saveAds($fp, $campaign->ga_campaign_name); if (!$ag->is_has_ads) { echo "no good ads\r\n"; continue; } $ag->buildVehiclesKeywordsIL($val); foreach ($ag->m_aKeywords as $val) { fputs($fp, "{$campaign->ga_campaign_name},,,,,," . $ag->gag_name . "," . MAX_CPC . "," . DEFAULT_MATCH_TYPE . ",{$val}\r\n"); } $c++;
$main_db = new DBAdapter2(array('host' => '192.168.240.15', 'username' => 'eyezeek', 'password' => 'p!n6access', 'schema' => 'il_eyezeek')); $campaign = new GoogleCampaign($db); $campaign->ga_campaign_name = CAMPAIGN_NAME_BASE . " " . date("Y-m-d H i"); $campaign->save(); $fp = fopen("../output/" . str_replace(" ", "_", $campaign->ga_campaign_name) . ".csv", "w+"); fputs($fp, "Campaign,Daily Budget,Language,Location,Proximity Targets,Ad Schedule,Ad Group,Max CPC,Keyword Type,Keyword,Headline,Description Line 1,Description Line 2,Display URL,Destination URL\r\n"); $cur = 0; $step = 10000; $i = 0; $c = 0; do { $main_db->executeSQL("SELECT * FROM vehicles WHERE l_www_id = 16 and l_isActive = 1 and l_price > 1000 ORDER BY l_id DESC LIMIT {$cur}, {$step}", $resultArry, $rowsAffected); $total = $rowsAffected; foreach ($resultArry as $val) { echo $c . "/" . ++$i . "/" . $total . "\r\n"; $ag = new GoogleAdGroup($db); $ag->m_sMainTable = 'vehicles'; $ag->gag_l_id = $val['l_id']; $ag->createName(); $ag->save(); $ag->buildAds(array('GoogleAdVehiclesIL'), $val); $ag->buildVehiclesKeywordsIL($val); $ag->saveAds($fp, $campaign->ga_campaign_name); if (!$ag->is_has_ads) { echo "no good ads\r\n"; continue; } foreach ($ag->m_aKeywords as $val) { fputs($fp, "{$campaign->ga_campaign_name},,,,,," . $ag->gag_name . "," . MAX_CPC . "," . DEFAULT_MATCH_TYPE . ",{$val}\r\n"); } $c++;