Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by PhpStorm.
- * User: scott
- * Date: 3/4/19
- * Time: 2:33 PM
- */
- include 'KeywordClass.php';
- $keytext = $_GET['keywords'];
- $customer = $_GET['client'];
- $keywords = explode("\r\n", $keytext);
- $usable = new KeywordClass();
- $table = '<HTML><TABLE><TH> Keyword </TH><TH> Status </TH><TH> Results</TH>';
- foreach ($keywords as $keyword){
- if (preg_match('/^[a-z0-9\040]+$/i',$keyword)) {
- //$URL = "http://abc/api/v1/";
- $URL = "http://127.0.0.1/Espo/api/v1/";
- $keyword = str_replace(" ", '+', $keyword);
- $user = 'xxxxx';
- $password = 'xxxxx';
- $action = "Keyterms?select=name&maxSize=100&offset=0&orderBy=createdAt&order=desc&where%5B0%5D%5Btype%5D=textFilter&where%5B0%5D%5Bvalue%5D=" .$keyword ;
- $json = $usable->accessEspo($URL,$action,$user,$password);
- switch ($json['total']) {
- case 0:
- $use = 'Keyword can be used';
- $results = $usable->getNumResults($keyword);
- break;
- case 1:
- $keyword_id = $json['list'][0]['id'];
- $action = "Keyterms/" . $keyword_id;
- $json1 = $usable->accessEspo($URL, $action, $user, $password);
- if(!$json1['approved']){
- $use = 'Keyword can be used';
- $results = $usable->getNumResults($keyword);
- break;
- }
- $account_id = $json1['accountId'];
- $action = "Account/" . $account_id;
- $json2 = $usable->accessEspo($URL, $action, $user, $password);
- $use = $json2['clientID'];
- break;
- default:
- $use = "Must be checked manually";
- break;
- }
- }
- else{
- $use = "you have an illegal character";
- $results = '';
- }
- if($use == 'Keyword can be used'){
- $action = 'Account?select=name,clientID,website,type&maxSize=20&offset=0&orderBy=createdAt&order=desc&where[0][type]=equals&where[0][attribute]=clientID&where[0][value]=' . $customer;
- $json3 = $usable->accessEspo($URL, $action, $user, $password);
- $espoAccount = $json3['list'][0]['id'];
- $espoName = $json3['list'][0]['name'];
- $action = 'website?accountId,name,websiteURL,siteType&maxSize=20&offset=0&where[0][type]=equals&where[0][attribute]=accountId&where[0][value]='.$espoAccount.'&where[1][type]=equals&where[1][attribute]=siteType&where[1][value]=Primary+SEO+Build';
- $json4 = $usable->accessEspo($URL, $action, $user, $password);
- $webID = $json4['list'][0]['id'];
- $webName = $json4['list'][0]['name'];
- $action = 'Keyterms';
- $params = array('accountId'=>$espoAccount,'accountName'=>$espoName,'generated'=>'True','clientSupplied'=>'false','approved'=>'false','name'=>$keyword);
- $json5 = $usable->editEspo($URL,$action,$params,$user,$password);
- }
- $table = $table . "<TR><TD>$keyword</TD><TD>$use</TD><TD>$results</TD></TR>";
- }
- $table = $table . '</TABLE><HTML>';
- echo $table;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement