Ejemplo n.º 1
0
 static function process($request)
 {
     $loginModel = Session_Controller::getLoginContext();
     $client = new Vtiger_WSClient($loginModel->getURL());
     $login = $client->doLogin($loginModel->getUsername(), $loginModel->getAccessKey());
     if ($login) {
         TestCodeJS_Controller::doLayout();
         TestCodeJS_Controller::doLayoutCode();
     } else {
         echo "<div class='alert alert-danger'>ERROR: Login failure!</div>";
     }
 }
 static function process()
 {
     $loginModel = Session_Controller::getLoginContext();
     $client = new Vtiger_WSClient($loginModel->getURL());
     $login = $client->doLogin($loginModel->getUsername(), $loginModel->getAccessKey());
     if ($login) {
         echo "<div class='alert alert-info'>Many of these queries are specific to the coreBOS application they were created for and will fail on your install. You should just need to tweek the IDs and conditions to get them working.</div>";
         foreach (QueryExamples_Controller::$queries as $query) {
             echo '<b>' . $query . '</b><br>';
             $result = $client->doQuery($query);
             QueryExamples_Controller::showresult($result);
         }
     } else {
         echo "<div class='alert alert-danger'><strong>ERROR:</strong> Login failure!</div>";
     }
 }
Ejemplo n.º 3
0
 static function process($request)
 {
     if (isset($request['q'])) {
         $query = $request['q'];
     } else {
         $query = '';
     }
     $escapedQuery = $query;
     echo "\n\t\t<form method='POST' action='index.php' onsubmit='return validateForm(this);'>\n\t\t\t<table cellpadding='0' cellspacing='1'>\n\t\t\t\t<tr valign=top>\n\t\t\t\t\t<td>Try a query like: select firstname, lastname from Leads order by firstname desc limit 0,2; or <a href='index.php?action=queryExamples'>have a look at our tests and examples.</a><br/><textarea name='q' rows='5' cols='80'>{$escapedQuery}</textarea></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td><input type='submit' value='Execute &raquo;' name='__submitButton' class='btn btn-primary btn-large'></td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</form>";
     if (!empty($query)) {
         $loginModel = Session_Controller::getLoginContext();
         $client = new Vtiger_WSClient($loginModel->getURL());
         $login = $client->doLogin($loginModel->getUsername(), $loginModel->getAccessKey());
         if ($login) {
             $result = $client->doQuery($query);
             if (is_array($result)) {
                 if (count($result) == 0) {
                     echo "<div class='alert alert-info'><strong>No results found!</strong></div>";
                 } else {
                     echo "<table cellpadding='3' cellspacing='0' class='table table-striped small'>";
                     $columns = $client->getResultColumns($result);
                     echo "<tr>";
                     foreach ($columns as $column) {
                         echo sprintf("<th nowrap='nowrap'>%s</th>", $column);
                     }
                     echo "</tr>";
                     foreach ($result as $row) {
                         echo "<tr>";
                         foreach ($row as $k => $v) {
                             if ($v === '') {
                                 $v = '&nbsp;';
                             }
                             echo sprintf("<td nowrap='nowrap'>%s</td>", $v);
                         }
                         echo "</tr>";
                     }
                     echo "</table>";
                 }
             } else {
                 $lastError = $client->lastError();
                 echo "<div class='alert alert-danger'><strong>ERROR:</strong> " . $lastError['message'] . "</div>";
             }
         } else {
             echo "<div class='alert alert-danger'><strong>ERROR:</strong> Login failure!</div>";
         }
     }
 }
Ejemplo n.º 4
0
$logFile = "info_" . date('Y_m_d_H_i') . ".log";
$dataFile = "data_" . date('Y_m_d_H_i') . ".txt";
$lg = fopen($logFile, 'w') or die("Can't open log file");
$dat = fopen($dataFile, 'w') or die("Can't open data dump file");
//initialize soap client
try {
    $client = new nusoap_client($srcURL, true);
} catch (Exception $err) {
    fwrite($lg, "Exception initializing SOAP client - Termination " . $err->getMessage() . "\n");
    //this is severe, so cleanup and quit
    fclose($dat);
    fclose($lg);
    exit;
}
try {
    $destclient = new Vtiger_WSClient($destURL);
    $login = $destclient->doLogin($destUser, $destAccessKey);
    if (!$login) {
        fwrite($lg, "Login failed \n");
    }
} catch (Exception $lerr) {
    fwrite($lg, "Exception login vtiger " . $lerr->getMessage() . "\n");
}
//initialise flags, counters and exception array
$flag = true;
//to control iteration
$srccnt = 0;
//counter to keep track of records read from source
$destcnt = 0;
$except_array = array();
//holds rec numbers of records that could not be populated into destination
Ejemplo n.º 5
0
 static function doExecCode()
 {
     function debugmsg($name, $var = '')
     {
         $str = "<table border=0><tr><th align=left>{$name}</th></tr><tr><td>";
         $str .= print_r($var, true);
         if (is_array($var) and isset($var['body'])) {
             $str .= $var['body'];
         }
         if (is_array($var) and isset($var['xdebug_message'])) {
             $str .= $var['xdebug_message'];
         }
         $str .= "</td></tr></table>";
         return $str;
     }
     $loginModel = $_SESSION['vtbrowser_auth'];
     $cbURL = $loginModel->getURL() . '/webservice.php';
     $cbUserName = $loginModel->getUsername();
     $cbUserID = $loginModel->getUserId();
     $cbAccessKey = $loginModel->getAccessKey();
     $cbSessionID = $loginModel->getSessionId();
     $cbconn = new Vtiger_WSClient($cbURL);
     $cbconn->doLogin($cbUserName, $cbAccessKey);
     $httpc = $cbconn->_client;
     $dmsg = '';
     $toexec = urldecode($_REQUEST['tcexec']);
     $toexec = preg_replace('[<\\?php|\\?>]', '', $toexec);
     ob_start();
     $execrdo = eval($toexec);
     $out = ob_get_contents();
     ob_end_clean();
     $rdo = array('result' => $execrdo, 'output' => $out, 'debug' => $dmsg);
     echo json_encode($rdo);
 }
Ejemplo n.º 6
0
    static function process($request)
    {
        if (isset($request['url'])) {
            $url = $request['url'];
        } else {
            $url = 'http://localhost/';
        }
        if (isset($request['username'])) {
            $username = $request['username'];
        } else {
            $username = '******';
        }
        if (isset($request['accesskey'])) {
            $accesskey = $request['accesskey'];
        } else {
            $accesskey = '';
        }
        if (!empty($url) && !empty($username) && !empty($accesskey)) {
            $loginModel = new Login_Model($url, $username, $accesskey);
            $client = new Vtiger_WSClient($loginModel->getURL());
            $checkLogin = $client->doLogin($loginModel->getUsername(), $loginModel->getAccessKey());
            if ($checkLogin) {
                Session_Controller::setLoginContext($loginModel);
                $loginModel->setUserId($client->_userid);
                $loginModel->setSessionId($client->_sessionid);
                header('Location: index.php');
                exit;
                //return;
            }
        }
        Header_Controller::process($request);
        ?>
		<form method='POST' action='index.php' onsubmit='$("#wserrmsg").hide();this.__submitButton.value="Verifying"; this.__submitButton.disabled=true;'>
		<div class='form-group'>
			<label for='url'>URL</label>
			<input type='text' name='url' value='<?php 
        echo $url;
        ?>
' size=40 class='form-control'>
		</div>
		<div class='form-group'>
			<label for='username'>Username</label>
			<input type='text' name='username' value='<?php 
        echo $username;
        ?>
' size=40 class='form-control'>
		</div>
		<div class='form-group'>
			<label for='accesskey'>Access key</label>
			<input type='text' name='accesskey' value='<?php 
        echo $accesskey;
        ?>
' size=40 class='form-control'>
		</div>
		<div class='form-group'>
			<input class='btn btn-primary btn-large' type='submit' value='Login &raquo;' name='__submitButton'>
		</div>
		</form>
<?php 
        if (!empty($url) && !empty($username) && !empty($accesskey) && !$checkLogin) {
            echo '<div class="alert alert-danger" id="wserrmsg">There is an error with the validation data given, please review and try again.</div>';
        }
        Footer_Controller::process($request);
    }
Ejemplo n.º 7
0
 public static function connect()
 {
     global $api_client;
     if (isset($GLOBALS['api_user']) && $GLOBALS['api_user'] != "" && isset($GLOBALS['api_pass']) && $GLOBALS['api_pass'] != "") {
         require_once 'lib/vtwsclib/Vtiger/WSClient.php';
         $client = new Vtiger_WSClient($GLOBALS['vtiger_path']);
         $login = $client->doLogin($GLOBALS['api_user'], $GLOBALS['api_pass']);
         if (!$login) {
             $api_client = 'API_LOGIN_FAILED';
         } else {
             $api_client = $client;
             MYCWSApi::connect();
         }
     } else {
         $api_client = "NOT_CONFIGURED";
     }
     return $api_client;
 }
Ejemplo n.º 8
0
 static function process($request)
 {
     $loginModel = Session_Controller::getLoginContext();
     $client = new Vtiger_WSClient($loginModel->getURL());
     $login = $client->doLogin($loginModel->getUsername(), $loginModel->getAccessKey());
     if ($login) {
         $modules = $client->doListTypes();
         asort($modules);
         if ($modules) {
             $modOptions = '';
             foreach ($modules as $module) {
                 $modOptions .= "<option value='" . $module['name'] . "'>" . $module['name'] . "</option>";
             }
             foreach ($modules as $module) {
                 echo "<div class='row' id='" . $module['name'] . "' style='vertical-align:bottom;'><span class='span5 pull-left'><h3>" . $module['name'] . "</h3></span>";
                 echo "<span class='span1 pull-right' style='margin-left:10px;margin-right:60px;margin-top: 30px;'>";
                 echo "<a href='#top'><img src='assets/go_top.png'></a>";
                 echo "</span>";
                 echo "<span class='span4 pull-right' style='margin-top: 30px;'>";
                 echo "<select onchange=\"\$('.modqaselect').val(this.value);document.location='#'+this.value\" class='small modqaselect'>" . $modOptions . "</select>";
                 echo "</span>";
                 echo "</div>";
                 echo "<table class='table table-striped small table-condensed'>";
                 echo "<tr><th>REST ID</th><th>Can Create</th><th>Can Update</th><th>Can Delete</th><th>Can Retrieve</th></tr>";
                 echo "<tr>";
                 $desc = $client->doDescribe($module['name']);
                 if (is_array($desc)) {
                     echo sprintf("<td nowrap='nowrap'>%s</td>", $desc['idPrefix'] . 'x');
                     echo sprintf("<td nowrap='nowrap'>%s&nbsp;</td>", $desc['createable']);
                     echo sprintf("<td nowrap='nowrap'>%s&nbsp;</td>", $desc['updateable']);
                     echo sprintf("<td nowrap='nowrap'>%s&nbsp;</td>", $desc['deleteable']);
                     echo sprintf("<td nowrap='nowrap'>%s&nbsp;</td>", $desc['retrieveable']);
                     echo "</tr></table>";
                     echo "<table class='table table-striped small table-condensed'>";
                     echo "<tr><th>Field</th><th>Information</th><th>Block</th><th>Type</th><th width='30%'>Reference/Values</th></tr>";
                     foreach ($desc['fields'] as $field) {
                         $fieldname = $field['label'];
                         echo "<tr><td nowrap='nowrap'><b>" . $fieldname . '</b><br>' . $field['name'] . '</td>';
                         echo "<td>";
                         $fielddesc = "Mandatory: ";
                         $fielddesc .= ($field['mandatory'] ? 'yes' : 'no') . "<br>Null: " . ($field['nullable'] ? 'yes' : 'no');
                         $fielddesc .= "<br>Editable: " . ($field['editable'] ? 'yes' : 'no');
                         if (isset($field['sequence'])) {
                             $fielddesc .= "<br>Sequence: " . $field['sequence'];
                         }
                         echo $fielddesc . "</td><td>";
                         if (isset($field['block'])) {
                             $blockddesc = "ID: " . $field['block']['blockid'] . '<br>';
                             $blockddesc .= 'Sequence: ' . $field['block']['blocksequence'] . '<br>';
                             $blockddesc .= 'Label: ' . $field['block']['blocklabel'] . '<br>';
                             $blockddesc .= 'Name: ' . $field['block']['blockname'];
                             echo $blockddesc;
                         }
                         echo "</td><td>";
                         $fielddesc = "Type: " . $field['type']['name'];
                         if (isset($field['typeofdata'])) {
                             $fielddesc .= "&nbsp;(" . $field['typeofdata'] . ')';
                         }
                         if (isset($field['uitype'])) {
                             $fielddesc .= "<br>UIType: " . $field['uitype'];
                         }
                         if (isset($field['type']['format'])) {
                             $fielddesc .= "<br>Format: " . $field['type']['format'];
                         }
                         if (isset($field['default'])) {
                             $fielddesc .= "<br>Default: " . $field['default'];
                         }
                         echo $fielddesc . '</td><td>';
                         $addinfo = '';
                         if (isset($field['type']['refersTo'])) {
                             foreach ($field['type']['refersTo'] as $capts) {
                                 $addinfo .= "{$capts}, ";
                             }
                         }
                         if (isset($field['type']['picklistValues'])) {
                             foreach ($field['type']['picklistValues'] as $plvs => $plvn) {
                                 $addinfo .= $plvn['value'] . ", ";
                             }
                         }
                         echo $addinfo . '</td>';
                         echo "</tr>";
                     }
                 }
                 echo "</table>";
             }
         } else {
             $lastError = $client->lastError();
             echo "<div class='alert alert-danger'>ERROR: " . $lastError['message'] . "</div>";
         }
     } else {
         echo "<div class='alert alert-danger'>ERROR: Login failure!</div>";
     }
 }