$svcobj = Openbiz::getService(AUTH_SERVICE);
     $result = $svcobj->authenticateUser($username, $password_preset);
     if ($result) {
         echo "Authentication Sucessed! " . PHP_EOL;
         echo "Access Grant! " . PHP_EOL;
         break;
     } else {
         echo PHP_EOL . "Access Denied! " . PHP_EOL;
         exit;
     }
 }
 system('stty -echo');
 $password_input = trim(fgets(STDIN));
 system('stty echo');
 echo PHP_EOL;
 $svcobj = Openbiz::getService(AUTH_SERVICE);
 $result = $svcobj->authenticateUser($username, $password_input);
 if ($result) {
     echo "Authentication Sucessed! " . PHP_EOL;
     echo "Access Grant! " . PHP_EOL;
     break;
 } else {
     echo "Authentication Failed! ";
 }
 $auth_counter++;
 if ($auth_counter > 3) {
     echo PHP_EOL . "Access Denied! " . PHP_EOL;
     exit;
 } else {
     echo "Please Try again ({$auth_counter}/3) " . PHP_EOL;
     echo "Password: ";
 /**
  * Validate input on EasyForm level
  * default form validation do nothing.
  * developers need to override this method to implement their logic
  *
  * @return boolean
  */
 protected function validateForm($cleanError = true)
 {
     if ($cleanError == true) {
         $this->validateErrors = array();
     }
     $this->dataPanel->rewind();
     while ($this->dataPanel->valid()) {
         /* @var $element Element */
         $element = $this->dataPanel->current();
         if ($element->label) {
             $elementName = $element->label;
         } else {
             $elementName = $element->text;
         }
         if ($element->checkRequired() === true && ($element->value == null || $element->value == "")) {
             $errorMessage = $this->getMessage("FORM_ELEMENT_REQUIRED", array($elementName));
             $this->validateErrors[$element->objectName] = $errorMessage;
             //return false;
         } elseif ($element->value !== null && $element->Validate() == false) {
             $validateService = Openbiz::getService(VALIDATE_SERVICE);
             $errorMessage = $this->getMessage("FORM_ELEMENT_INVALID_INPUT", array($elementName, $value, $element->validator));
             if ($errorMessage == false) {
                 //Couldn't get a clear error message so let's try this
                 $errorMessage = $validateService->getErrorMessage($element->validator, $elementName);
             }
             $this->validateErrors[$element->objectName] = $errorMessage;
             //return false;
         }
         $this->dataPanel->next();
     }
     if (count($this->validateErrors) > 0) {
         throw new Openbiz\Validation\Exception($this->validateErrors);
         return false;
     }
     return true;
 }
Exemple #3
0
 /**
  * Render the html tabs
  *
  * @global BizSystem $g_BizSystem
  * @return string html content of the tabs
  */
 public function render()
 {
     $curView = Openbiz::$app->getCurrentViewName();
     $curViewobj = $curView ? Openbiz::getObject($curView) : null;
     $profile = Openbiz::$app->getUserProfile();
     $svcobj = Openbiz::getService(ACCESS_SERVICE);
     $role = isset($profile["ROLE"]) ? $profile["ROLE"] : null;
     // list all views and highlight the current view
     // pass $tabs(caption, url, target, icon, current) to template
     $smarty = TemplateHelper::getSmartyTemplate();
     $tabs = array();
     $i = 0;
     $hasForms = false;
     foreach ($this->tabViews as $tview) {
         // tab is renderd if  no definition  is found in accessservice.xml (default)
         if ($svcobj->allowViewAccess($tview->view, $role)) {
             $tabs[$i]['name'] = $tview->objectName;
             //Name of each tab--jmmz
             $tabs[$i]['forms'] = $this->_renderJSCodeForForms($tview->forms);
             //Configuration of the forms to hide or show--jmmz
             $tabs[$i]['caption'] = $tview->caption;
             $tabs[$i]['url'] = $this->_renderURL($tview);
             //Call the method to render the url--jmmz
             //If I have forms to hide or show I add the event because I don't need an URL, I need an event
             if ((bool) $tview->hasForms()) {
                 $tabs[$i]['event'] = $tabs[$i]['url'];
                 //Assign The url rendered to the event on click
                 $tabs[$i]['url'] = 'javascript:void(0)';
                 //If I put url in '' then the href want send me to another direction
                 $this->setCurrentTabInSession($tview, $curViewobj, $curView);
                 //I set the current tab wrote in session
                 $hasForms = TRUE;
             }
             $tabs[$i]['target'] = $tview->target;
             $tabs[$i]['icon'] = $tview->icon;
             $tabs[$i]['current'] = $this->isCurrentTab($tview, $curViewobj, $curView);
             //I get the current tab.
             $i++;
         }
     }
     $this->setClientScripts($tabs, $hasForms);
     $smarty->assign("tabs", $tabs);
     $smarty->assign("tabs_Name", $this->objectName);
     return $smarty->fetch(TemplateHelper::getTplFileWithPath($this->templateFile, $this->package));
 }
Exemple #4
0
 * it reads the cronjob table and runs command based on the command settings 
 */
include_once dirname(dirname(__FILE__)) . "/app_init.php";
if ($argc < 3) {
    echo "usage: php run_svc.php service_name method parameter1 parameter2 ...\n";
    exit;
}
// read service name and parameters
$svcName = $argv[1];
$methodName = $argv[2];
$arg_list = array();
for ($i = 3; $i < $argc; $i++) {
    $arg_list[] = $argv[$i];
}
// get service object
$obj = Openbiz::getService($svcName);
if ($obj) {
    if (method_exists($obj, $methodName)) {
        echo "START - Call {$svcName}" . "::" . "{$methodName}(" . implode(',', $arg_list) . ")\n";
        switch (count($arg_list)) {
            case 0:
                $rt_val = $obj->{$methodName}();
                break;
            case 1:
                $rt_val = $obj->{$methodName}($arg_list[0]);
                break;
            case 2:
                $rt_val = $obj->{$methodName}($arg_list[0], $arg_list[1]);
                break;
            case 3:
                $rt_val = $obj->{$methodName}($arg_list[0], $arg_list[1], $arg_list[2]);
 /**
  * Render single menu item
  *
  * @param array $menuItem menu item metadata xml array
  * @return string html content of each menu item
  */
 protected function renderSingleMenuItem(&$menuItem)
 {
     $profile = Openbiz::$app->getUserProfile();
     $svcobj = Openbiz::getService(ACCESS_SERVICE);
     $role = isset($profile["ROLE"]) ? $profile["ROLE"] : null;
     if (isset($menuItem["ATTRIBUTES"]['URL'])) {
         $url = $menuItem["ATTRIBUTES"]["URL"];
     } elseif (isset($menuItem["ATTRIBUTES"]['VIEW'])) {
         $view = $menuItem["ATTRIBUTES"]["VIEW"];
         // menuitem's containing VIEW attribute is renderd if access is granted in accessservice.xml
         // menuitem's are rendered if no definition is found in accessservice.xml (default)
         if ($svcobj->allowViewAccess($view, $role)) {
             $url = "javascript:GoToView('" . $view . "')";
         } else {
             return '';
         }
     }
     $caption = $this->translate($menuItem["ATTRIBUTES"]["CAPTION"]);
     $target = $menuItem["ATTRIBUTES"]["TARGET"];
     $icon = $menuItem["ATTRIBUTES"]["ICON"];
     $img = $icon ? "<img src='" . Openbiz::$app->getImageUrl() . "/{$icon}' class=menu_img> " : "";
     if ($view) {
         $url = "javascript:GoToView('" . $view . "')";
     }
     if ($target) {
         $sHTML .= "<li><a href=\"" . $url . "\" target='{$target}'>{$img}" . $caption . "</a>";
     } else {
         $sHTML .= "<li><a href=\"" . $url . "\">{$img}" . $caption . "</a>";
     }
     if ($menuItem["MENUITEM"]) {
         $sHTML .= "\n<ul>\n";
         $sHTML .= $this->renderMenuItems($menuItem["MENUITEM"]);
         $sHTML .= "</ul>";
     }
     $sHTML .= "</li>\n";
     return $sHTML;
 }
 * @version   $Id: oauth_callback_handler.php 4032 2012-08-26 06:33:15Z hellojixian@gmail.com $
 */
include_once 'bin/app_init.php';
include_once OPENBIZ_PATH . "/bin/ErrorHandler.php";
$type = Openbiz::$app->getClientProxy()->getRequestParam("type");
$service = Openbiz::$app->getClientProxy()->getRequestParam("service");
$redirectURL = Openbiz::$app->getClientProxy()->getRequestParam("redirect_url");
if ($redirectURL) {
    Openbiz::$app->getSessionContext()->setVar("oauth_redirect_url", $redirectURL);
}
$assocURL = Openbiz::$app->getClientProxy()->getRequestParam("assoc_url");
if ($assocURL) {
    Openbiz::$app->getSessionContext()->setVar("oauth_assoc_url", $assocURL);
}
//$whitelist_arr=array('qq','sina','alipay','google','facebook','qzone','twitter');
$whitelist_arr = Openbiz::getService(CUBI_LOV_SERVICE)->getDictionary("oauth.lov.ProviderLOV(Provider)");
if (!in_array($type, $whitelist_arr)) {
    throw new Exception('Unknown service');
    return;
}
$oatuthType = Openbiz::$app->getModulePath() . "/oauth/libs/{$type}.class.php";
if (!file_exists($oatuthType)) {
    throw new Exception('Unknown type');
    return;
}
include_once $oatuthType;
$obj = new $type();
switch (strtolower($service)) {
    case "callback":
    case "login":
        break;
 /**
  * Render step
  *
  * @param number $step
  * @return void
  */
 public function renderStep($step)
 {
     if ($this->currentStep) {
         $currentStep = $this->currentStep;
     } else {
         $currentStep = $this->getCurrentStep();
     }
     if ($currentStep == $step) {
         return;
     }
     switch (strtoupper($this->naviMethod)) {
         case "SWITCHFORM":
             $targetForm = $this->getStepName($step);
             $currentForm = $this->getStepName($currentStep);
             $this->currentStep = $step;
             $formObj = Openbiz::getObject($currentForm);
             $formObj->switchForm($targetForm);
             break;
         case "SWITCHPAGE":
         default:
             $currentURL = Openbiz::getService(OPENBIZ_UTIL_SERVICE)->getViewURL($this->objectName);
             $url = OPENBIZ_APP_INDEX_URL . '/' . $currentURL . '/step_' . $step;
             Openbiz::$app->getClientProxy()->ReDirectPage($url);
             break;
     }
 }
 /**
  * Render this form (return html content),
  * called by WebPage's render method (called when form is loaded).
  * Query is issued before returning the html content.
  *
  * @return string - HTML text of this form's read mode
  * @example ../../../example/FormObject.php
  */
 public function render()
 {
     if (!$this->allowAccess()) {
         return "";
     }
     //$this->setClientScripts();
     if ($this->cacheLifeTime > 0 && $this->subForms == null) {
         $cache_id = md5($this->objectName);
         //try to process cache service.
         $cacheSvc = Openbiz::getService(CACHE_SERVICE, 1);
         $cacheSvc->init($this->objectName, $this->cacheLifeTime);
         if ($cacheSvc->test($cache_id)) {
             Openbiz::$app->getLog()->log(LOG_DEBUG, "FORM", "Cache Hit. form name = " . $this->objectName);
             $output = $cacheSvc->load($cache_id);
         } else {
             Openbiz::$app->getLog()->log(LOG_DEBUG, "FORM", "Set cache. form name = " . $this->objectName);
             $output = FormRenderer::render($this);
             $cacheSvc->save($output, $cache_id);
         }
         return $output;
     }
     //Moved the renderHTML function infront of declaring subforms
     $output = FormRenderer::render($this);
     // lazy subform loading - prepare the subforms' dataobjs, since the subform relates to parent form by dataobj association
     $this->prepareSubFormsDataObj();
     return $output;
 }