HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
SiteNew.php
Go to the documentation of this file.
1 <?php
2 
7 class SiteNew extends SiteUpdate
8 {
14  public function addNewSite()
15  {
16  $this->opLog = "SITE_NEW";
17  $this->operation = "Add new site";
18  $result = $this->updateSiteInfo();
19  return $result;
20  }
21 
30  public function commandUpdate($reqFile)
31  {
32  // Path to application
33  $api = Yii::app()->params['api'];
34  // Path to folder containing bash scripts
35  $path = Yii::app()->getBasePath() . '/shell/';
36  $cmd = "sh " . $path . "site_new.sh $api $reqFile";
37  //Execute bash script, and get response JSON
38  $json = shell_exec($cmd);
39  $error = Errors::isError($json);
40  if ($error !== 0) {
41  Yii::app()->user->setFlash('error1', $this->operation . ' ERROR: ' . $error);
42  } else {
43  Yii::app()->user->setFlash('success1', $this->operation . ': SUCCESS');
44  }
45  Logger::log("Response ->\n" . $json);
46  return $json;
47  }
48 
49  public function getDefaults()
50  {
51  if (UserModule::isAdmin()) {
52  return array(
53  "priority" => "100",
54  "maxURLs" => "1000",
55  "maxURLsFromPage" => "200",
56  "maxResources" => "200",
57  "maxErrors" => "400",
58  "maxResourceSize" => "1000000",
59  "processingDelay" => "500",
60  "requestDelay" => "500",
61  "httpTimeout" => "30000",
62  );
63  } else {
64  return array(
65  "priority" => "100",
66  "maxURLs" => "200",
67  "maxURLsFromPage" => "50",
68  "maxResources" => "200",
69  "maxErrors" => "400",
70  "maxResourceSize" => "1000000",
71  "processingDelay" => "500",
72  "requestDelay" => "500",
73  "httpTimeout" => "30000",
74  );
75  }
76  }
77  public function getDefaultProps() {
78  return array(
79  "CONTENT_HASH" =>'{ "algorithm": 1, "tags": "title,description,content_encoded,media,pubdate", "delete": 1 }',
80  "PROCESS_CTYPES" =>"text/html",
81  "STORE_HTTP_HEADERS" =>"1",
82  "STORE_HTTP_REQUEST" =>"1",
83  "AUTO_REMOVE_RESOURCES" =>"1",
84  "AUTO_REMOVE_WHERE" =>"ParentMd5<>\"\" AND Status IN (4,7) AND DATE_ADD(UDate, INTERVAL %RecrawlPeriod% MINUTE)<NOW()",
85  "AUTO_REMOVE_ORDER" =>"ContentType ASC, Crawled ASC, TagsCount ASC, UDate ASC",
86  "RECRAWL_DELETE_WHERE" =>"(`Status`=1 OR (`Status`=4 AND Crawled=0 AND Processed=0) OR `PDate`<CURDATE() OR `PDate` IS NULL OR CDate<CURDATE()) AND `ParentMd5`<>''",
87  );
88  }
89  public function getTProps() {
90  $data = Yii::app()->request->getParam("data");
91  return $data["items"][0]["properties"];
92  }
93 }