PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/memory/TestData.php

https://github.com/orchestra-io/sample-openx
PHP | 301 lines | 235 code | 22 blank | 44 comment | 15 complexity | 84692f1c9eb181d38a1fa96c7fa4f025 MD5 | raw file
  1. <?php
  2. /*
  3. +---------------------------------------------------------------------------+
  4. | OpenX v${RELEASE_MAJOR_MINOR} |
  5. | =======${RELEASE_MAJOR_MINOR_DOUBLE_UNDERLINE} |
  6. | |
  7. | Copyright (c) 2003-2009 OpenX Limited |
  8. | For contact details, see: http://www.openx.org/ |
  9. | |
  10. | This program is free software; you can redistribute it and/or modify |
  11. | it under the terms of the GNU General Public License as published by |
  12. | the Free Software Foundation; either version 2 of the License, or |
  13. | (at your option) any later version. |
  14. | |
  15. | This program is distributed in the hope that it will be useful, |
  16. | but WITHOUT ANY WARRANTY; without even the implied warranty of |
  17. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
  18. | GNU General Public License for more details. |
  19. | |
  20. | You should have received a copy of the GNU General Public License |
  21. | along with this program; if not, write to the Free Software |
  22. | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
  23. +---------------------------------------------------------------------------+
  24. $Id: TestData.php 41443 2009-08-13 09:19:29Z matteo.beccati $
  25. */
  26. /**
  27. * class to insert test dummy data into clean database
  28. * uses DataGenerator
  29. */
  30. require_once MAX_PATH . '/lib/OA/Dal.php';
  31. require_once MAX_PATH . '/lib/OA/Dll.php';
  32. require_once MAX_PATH . '/lib/max/Dal/Common.php';
  33. require_once MAX_PATH . '/lib/OA/Dal/DataGenerator.php';
  34. class Memory_TestData
  35. {
  36. var $agencyId;
  37. var $clientId;
  38. var $campaignId;
  39. var $channelId;
  40. var $zoneId1;
  41. var $bannerId1;
  42. function generate($cHowManyRecords, $cHowManyBanners)
  43. {
  44. $this->cleanUp();
  45. // Set default data value to empty string
  46. DataGenerator::defaultValueByType(MAX_DATAGENERATOR_DEFAULT_TYPE, '');
  47. for($c = 1; $c <= $cHowManyRecords; $c++) {
  48. $this->insertAgency($c);
  49. $this->insertAffiliate($c);
  50. $this->insertClient($c);
  51. $this->insertCampaign($c);
  52. $this->insertZone($c);
  53. $this->insertBanners($c, $cHowManyBanners);
  54. $this->insertAdZoneAssoc($c);
  55. }
  56. }
  57. function cleanUp()
  58. {
  59. $aCleanupTables = array(
  60. 'agency',
  61. 'clients',
  62. 'campaigns',
  63. 'affiliates',
  64. 'zones',
  65. 'ad_zone_assoc',
  66. 'banners',
  67. );
  68. DataGenerator::cleanUp($aCleanupTables);
  69. }
  70. function insertAgency($index)
  71. {
  72. $doAgency = OA_Dal::factoryDO('agency');
  73. $doAgency->name = 'Default Agency '.$index;
  74. $doAgency->contact = 'Agency1';
  75. $doAgency->email = 'agency@example.com';
  76. $doAgency->username = '';
  77. $doAgency->password = '';
  78. $doAgency->permissions = '';
  79. $doAgency->language = '';
  80. $doAgency->logout_url = '';
  81. $doAgency->active = 't';
  82. $doAgency->updated = OA::getNow();
  83. $this->agencyId = DataGenerator::generateOne($doAgency);
  84. }
  85. function insertClient($index)
  86. {
  87. $doClients = OA_Dal::factoryDO('clients');
  88. $doClients->clientname = 'Default Advertiser '.$index;
  89. $doClients->acencyid = $this->agencyId;
  90. $doClients->contact = 'Advertiser'.$index;
  91. $doClients->email = 'advertiser'.$index.'@example.com';
  92. $doClients->clientusername = '';
  93. $doClients->clientpassword = '';
  94. $doClients->permissions = 0;
  95. $doClients->language = '';
  96. $doClients->report = 'f';
  97. $doClients->reportinterval = 7;
  98. $doClients->reportlastdate = OA::getNow('Y-m-d');
  99. $doClients->reportdeactivate = 't';
  100. $doClients->comments = '';
  101. $doClients->updated = OA::getNow();
  102. $this->clientId = DataGenerator::generateOne($doClients);
  103. }
  104. function insertCampaign($index)
  105. {
  106. $doCampaigns = OA_Dal::factoryDO('campaigns');
  107. $doCampaigns->clientid = $this->clientId;
  108. $doCampaigns->campaignname = 'Default Campaign'.$index;
  109. $doCampaigns->views = '-1'; // int(11)
  110. $doCampaigns->clicks = '-1'; // int(11)
  111. $doCampaigns->conversions = '-1'; // int(11)
  112. $doCampaigns->status = OA_ENTITY_STATUS_RUNNING; // int(11) not_null
  113. $doCampaigns->priority = '-1'; // int(11) not_null
  114. $doCampaigns->weight = '1'; // int(4) not_null
  115. $doCampaigns->target_impression = ''; // int(11) not_null
  116. $doCampaigns->target_click = ''; // int(11) not_null
  117. $doCampaigns->target_conversion = ''; // int(11) not_null
  118. $doCampaigns->anonymous = 'f'; // string(1) not_null enum
  119. $doCampaigns->companion = 0; // int(1)
  120. $doCampaigns->comments = ''; // blob(65535) blob
  121. $doCampaigns->revenue = 0; // unknown(12)
  122. $doCampaigns->revenue_type = ''; // int(6)
  123. $doCampaigns->updated = OA::getNow();
  124. $doCampaigns->block = 0; // int(11) not_null
  125. $doCampaigns->capping = 0; // int(11) not_null
  126. $doCampaigns->session_capping = 0; // int(11) not_null
  127. $this->campaignId = DataGenerator::generateOne($doCampaigns);
  128. }
  129. function insertAffiliate($index)
  130. {
  131. $doAffiliate = OA_Dal::factoryDO('affiliates');
  132. $doAffiliate->agencyid = $this->agencyId;
  133. $doAffiliate->name = 'Default Publisher '.$index;
  134. $doAffiliate->mnemonic = 'pub'.$index;
  135. $doAffiliate->comments = '';
  136. $doAffiliate->contact = 'publisher'.$index;
  137. $doAffiliate->email = 'publisher'.$index.'@example.com';
  138. $doAffiliate->website = 'http://www.example.com';
  139. $doAffiliate->username = '';
  140. $doAffiliate->password = '';
  141. $doAffiliate->permissions = '';
  142. $doAffiliate->language = '';
  143. $doAffiliate->publiczones = 't';
  144. //$doAffiliate->last_accepted_agency_agreement = '';
  145. $doAffiliate->updated = OA::getNow();
  146. $this->affiliateId = DataGenerator::generateOne($doAffiliate);
  147. }
  148. function insertZone($index)
  149. {
  150. $doZones = OA_Dal::factoryDO('zones');
  151. $doZones->zonename = 'Default Zone '.$index.' banner';
  152. $doZones->affiliateid = $this->affiliateId;
  153. $doZones->zonetype = 3;
  154. $doZones->width = 468;
  155. $doZones->height = 60;
  156. $doZones->forceappend = 'f';
  157. $doZones->updated = OA::getNow();
  158. $doZones->description = 'Default Banner Zone'.$index;
  159. $doZones->delivery = '0';
  160. // $doZones->zonetype = '3'; // int(6) not_null
  161. // $doZones->category = ''; // blob(65535) not_null blob
  162. // $doZones->ad_selection = ''; // blob(65535) not_null blob
  163. // $doZones->chain = ''; // blob(65535) not_null blob
  164. $doZones->prepend = ''; // blob(65535) not_null blob
  165. $doZones->append = ''; // blob(65535) not_null blob
  166. $doZones->appendtype = '0';
  167. // $doZones->inventory_forecast_type = ''; // int(6) not_null
  168. // $doZones->comments = ''; // blob(65535) blob
  169. // $doZones->cost = ''; // unknown(12)
  170. // $doZones->cost_type = ''; // int(6)
  171. // $doZones->cost_variable_id = ''; // string(255)
  172. // $doZones->technology_cost = ''; // unknown(12)
  173. // $doZones->technology_cost_type = ''; // int(6)
  174. $doZones->block = 0; // int(11) not_null
  175. $doZones->capping = 0; // int(11) not_null
  176. $doZones->session_capping = 0; // int(11) not_null
  177. $doZones->what = ''; // blob(65535) not_null blob
  178. $this->zoneId1 = DataGenerator::generateOne($doZones);
  179. }
  180. function insertAdZoneAssoc($index)
  181. {
  182. $doAdZoneAssoc = OA_Dal::factoryDO('ad_zone_assoc');
  183. $doAdZoneAssoc->ad_zone_assoc_id = $this->bannerId1;
  184. $doAdZoneAssoc->ad_id = $this->bannerId1;
  185. $doAdZoneAssoc->find();
  186. $doAdZoneAssoc->zone_id = $this->zoneId1;
  187. $doAdZoneAssoc->update();
  188. }
  189. function insertBanners($index, $c = 1)
  190. {
  191. $doBanners = OA_Dal::factoryDO('banners');
  192. $doBanners->acls_updated = OA::getNow();
  193. $doBanners->updated = OA::getNow();
  194. $doBanners->campaignid = $this->campaignId;
  195. $doBanners->status = OA_ENTITY_STATUS_RUNNING;
  196. $doBanners->contenttype = '';
  197. $doBanners->pluginversion = '0';
  198. $doBanners->storagetype = 'html';
  199. $doBanners->filename = '';
  200. $doBanners->imageurl = '';
  201. $doBanners->width = '468';
  202. $doBanners->height = '60';
  203. $doBanners->weight = '1';
  204. $doBanners->seq = '0';
  205. $doBanners->target = '_blank';
  206. $doBanners->url = '';
  207. $doBanners->alt = '';
  208. $doBanners->statustext = '';
  209. $doBanners->bannertext = '';
  210. $doBanners->description = 'Default banner 468*60 ('.$index.')';
  211. $doBanners->adserver = 'max';
  212. $doBanners->block = '0';
  213. $doBanners->capping = '0';
  214. $doBanners->session_capping = '0';
  215. $doBanners->compiledlimitation = '';
  216. $doBanners->acl_plugins = '';
  217. $doBanners->append = '';
  218. $doBanners->appendtype = '0';
  219. $doBanners->bannertype = '0';
  220. $doBanners->alt_filename = '';
  221. $doBanners->alt_imageurl = '';
  222. $doBanners->alt_contenttype = 'gif';
  223. $doBanners->comments = '';
  224. $doBanners->keyword = '';
  225. $doBanners->transparent = '';
  226. $doBanners->parameters = '';
  227. $doBanners->htmltemplate = "<script type='text/javascript'><!--//<![CDATA[
  228. var m3_u = (location.protocol=='https:'?'https://ads.openx.org/delivery/ajs.php':'http://ads.openx.org/delivery/ajs.php');
  229. var m3_r = Math.floor(Math.random()*99999999999);
  230. if (!document.MAX_used) document.MAX_used = ',';
  231. document.write (\"<scr\"+\"ipt type='text/javascript' src='\"+m3_u);
  232. document.write (\"?zoneid=9\");
  233. document.write ('&amp;cb=' + m3_r);
  234. if (document.MAX_used != ',') document.write (\"&amp;exclude=\" + document.MAX_used);
  235. document.write (\"&amp;loc=\" + escape(window.location));
  236. if (document.referrer) document.write (\"&amp;referer=\" + escape(document.referrer));
  237. if (document.context) document.write (\"&context=\" + escape(document.context));
  238. if (document.context) document.write (\"&context=\" + escape(document.context));
  239. if (document.mmm_fo) document.write (\"&amp;mmm_fo=1\");
  240. document.write (\"'><\\/scr\"+\"ipt>\");
  241. //]]>--></script><noscript><a href='http://ads.openx.org/delivery/ck.php?n=abc986b1&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://ads.openx.org/delivery/avw.php?zoneid=9&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=abc986b1' border='0' alt='' /></a></noscript>";
  242. $doBanners->htmlcache = "<script type='text/javascript'><!--//<![CDATA[
  243. var m3_u = (location.protocol=='https:'?'https://ads.openx.org/delivery/ajs.php':'http://ads.openx.org/delivery/ajs.php');
  244. var m3_r = Math.floor(Math.random()*99999999999);
  245. if (!document.MAX_used) document.MAX_used = ',';
  246. document.write (\"<scr\"+\"ipt type='text/javascript' src='\"+m3_u);
  247. document.write (\"?zoneid=9\");
  248. document.write ('&amp;cb=' + m3_r);
  249. if (document.MAX_used != ',') document.write (\"&amp;exclude=\" + document.MAX_used);
  250. document.write (\"&amp;loc=\" + escape(window.location));
  251. if (document.referrer) document.write (\"&amp;referer=\" + escape(document.referrer));
  252. if (document.context) document.write (\"&context=\" + escape(document.context));
  253. if (document.context) document.write (\"&context=\" + escape(document.context));
  254. if (document.mmm_fo) document.write (\"&amp;mmm_fo=1\");
  255. document.write (\"'><\\/scr\"+\"ipt>\");
  256. //]]>--></script>";
  257. $this->bannerId1 = DataGenerator::generate($doBanners, $c);
  258. }
  259. function insertTracker($index)
  260. {
  261. $doAffiliate = OA_Dal::factoryDO('affiliates');
  262. $doAffiliate->agencyid = $this->agencyId;
  263. $doAffiliate->name = 'Default Publisher '.$index;
  264. $doAffiliate->mnemonic = 'pub'.$index;
  265. $doAffiliate->comments = '';
  266. $doAffiliate->contact = 'publisher'.$index;
  267. $doAffiliate->email = 'publisher'.$index.'@example.com';
  268. $doAffiliate->website = 'http://www.example.com';
  269. $doAffiliate->username = '';
  270. $doAffiliate->password = '';
  271. $doAffiliate->permissions = '';
  272. $doAffiliate->language = '';
  273. $doAffiliate->publiczones = 't';
  274. //$doAffiliate->last_accepted_agency_agreement = '';
  275. $doAffiliate->updated = OA::getNow();
  276. $this->affiliateId = DataGenerator::generateOne($doAffiliate);
  277. }
  278. }
  279. ?>