Пример #1
0
 /**
  * add method
  *
  * @return void
  */
 public function add()
 {
     if ($this->request->is('post')) {
         //Check to see if the user has selected a file
         $this->Upload->set($this->request->data);
         if ($this->Upload->validates()) {
             //http://milesj.me/code/cakephp/uploader
             $this->Uploader = new Uploader(array('tempDir' => TMP, 'baseDir' => WWW_ROOT, 'uploadDir' => 'files/uploads/' . $userFolder . '/', 'maxNameLength' => 200));
             if ($data = $this->Uploader->upload('fileName')) {
                 // Upload successful, do whatever
                 //debug($data);
                 //Add pertinent data to the array
                 $this->request->data['Upload'] = $data;
                 $this->request->data['Upload']['active'] = 1;
                 //Disable until the user pays
                 $this->request->data['Upload']['user_id'] = $this->Upload->User->getLastInsertID();
                 //$this->request->data['Upload']['caption'] = $this->request->data['Upload']['custom_name'];
                 $this->Upload->create();
                 if ($this->Upload->save($this->request->data)) {
                     //Set the upload id
                     $this->request->data['Upload']['id'] = $this->Upload->getLastInsertID();
                 } else {
                     $this->Session->setFlash(__('Bummer :( Your file could NOT be uploaded.'));
                     $this->log('The file could not be uploaded.', 'upload_debug');
                     Debugger::log($data);
                 }
             }
         }
     }
     $works = $this->Upload->Work->find('list');
     $this->set(compact('works'));
 }
 function activate()
 {
     $setup = Config::get('RPC');
     $class = URL::getPathPart($setup['class']);
     $method = URL::getPathPart($setup['method']);
     list($action, $type) = explode('.', URL::getPathPart($setup['action']), 2);
     $path = $setup["path"] . "/" . $class . "/" . ucwords($method) . ucwords($action) . "Controller";
     if (file_exists(Loader::getPath("controller", $path))) {
         Debugger::log("CONTROLLER: <span style=\"color: #990000\">" . ucwords($method) . ucwords($action) . "Controller</span>");
         $controller = Loader::loadNew("controller", $path);
         $controller->activate();
         if (is_callable(array($controller, $type))) {
             echo $controller->{$type}();
         }
         return;
     }
     $controller_class = ucwords($class) . ucwords($method) . ucwords($action) . "Controller";
     Debugger::log("CONTROLLER: <span style=\"color: #990000\">{$controller_class}</span>");
     if (file_exists(Loader::getPath("controller", "{$setup['path']}/{$controller_class}"))) {
         $controller = Loader::loadNew("controller", "{$setup['path']}/{$controller_class}");
         $controller->activate();
     } else {
         Loader::load("utility", "Server");
         $ip = Server::getIP();
         $self = Server::getSelf();
         Debugger::log("Possible RPC Injection: RPC call to non-existent controller at path {$setup["path"]}/{$controller_class} {$ip} {$self}");
         error_log("Possible RPC Injection: RPC call to non-existent controller at path {$setup['path']}/{$controller_class} {$ip} {$self}");
     }
 }
Пример #3
0
 public function actionCallback($oauth_token)
 {
     try {
         $login_secret = $this->getSession('oauth')->login_secret;
         if (!$oauth_token) {
             echo "Error! There is no OAuth token!";
             exit;
         }
         if (!$login_secret) {
             echo "Error! There is no OAuth secret!";
             exit;
         }
         $this->oauth->enableDebug();
         $this->oauth->setToken($oauth_token, $login_secret);
         $access_token_info = $this->oauth->getAccessToken(self::ACCESS_TOKEN_URL);
         $this->getSession('oauth')->login_secret = false;
         $this->getSession('oauth')->token = $access_token_info['oauth_token'];
         $this->getSession('oauth')->secret = $access_token_info['oauth_token_secret'];
         $this->getUserDetailsAndLoginUser();
     } catch (OAuthException $E) {
         Debugger::log($E);
         //zalogujeme for sichr
         echo "OAuth login failed. Please, contact administrator.";
         $this->terminate();
     }
 }
Пример #4
0
 /**
  * Odstraneni konkretniho tagu
  * @param \App\Model\Entities\Tag $tag
  * @return boolean
  */
 public function deleteTag(Entities\Tag $tag)
 {
     try {
         $this->em->remove($tag);
         $result = $this->em->flush();
     } catch (\Doctrine\ORM\ORMException $e) {
         Debugger::log($e, Debugger::INFO);
         $result = FALSE;
     }
     return $result;
 }
 function route()
 {
     if (isset($this->router)) {
         $router = get_class($this->router);
         Config::set('Router', $router);
         Debugger::log("ROUTER: <span style=\"color:#72b618;\">{$router}</span>");
         $this->router->route();
     } else {
         Debugger::error(new Exception('Cannot route! No router set.'));
     }
 }
 function activate()
 {
     if (!Config::isLive() && file_exists($this->bypass)) {
         Debugger::log("<span style='color: #939393'>Follow {$this->type} Redirect to:</span> <br><a href='{$this->url}' style='color: white;'>{$this->url}</a> ");
         exit;
     } else {
         header("Location: {$this->url}", true, $this->type);
         exit;
     }
     return;
 }
Пример #7
0
 public function beforeFilter()
 {
     parent::beforeFilter();
     $this->_setupAuth();
     $this->_setupLayout();
     $this->Cookie->key = $this->key;
     // mobile
     if ($this->RequestHandler->isMobile()) {
         // required for CakePHP 2.2.2
         $viewDir = App::path('View');
         // returns an array
         /*
          * array(
          *      (int) 0 => '/var/www/maps-cakephp2/app/View/'
          * )
          */
         $mobileViewFile = $viewDir[0] . $this->viewPath . '/mobile/' . $this->params['action'] . '.ctp';
         Debugger::log($this->viewPath);
         // use this to log the output to
         // app/tmp/logs/debug.log
         if (file_exists($mobileViewFile)) {
             // if device is mobile, change layout to mobile
             // but only if a view exists for it.
             $this->layout = 'mobile';
             // and if a mobile view file has been
             // created for the action, serve it instead
             // of the default view file
             $mobileView = $this->viewPath . '/mobile/';
             $this->viewPath = $mobileView;
         }
     }
     // template path
     // switch ($this->here) {
     // case '/users/login' :
     // $this -> layout = 'default';
     // break;
     // }
     // if ($this -> params['action'] == 'login')
     // {
     // $this -> layout = 'default';
     // }
     // if ($this -> params['controller'] == 'templates' ||
     // $this -> params['controller'] == 'keywords' ||
     // $this -> params['controller'] == 'rankhistories' ||
     // $this -> params['controller'] == 'users' ||
     // $this -> params['controller'] == 'sales_keywords'
     // ) {
     // $this -> layout = 'default_new';
     // }
     $this->layout = 'default_new';
 }
 function __construct($dbobject_class_name, Database $db, $table_name, $database_name = null)
 {
     $reflection = new ReflectionClass($dbobject_class_name);
     if ($reflection->isSubclassOf("DBObject")) {
         $this->managed_object = $dbobject_class_name;
         $this->db = $db;
         $this->table = $table_name;
         if (isset($database_name)) {
             $this->database_name = $database_name;
         }
     } else {
         Debugger::log("cannot create manager from {$dbobject_class_name}");
     }
 }
Пример #9
0
 /**
  * @param  Exception
  * @return void
  */
 public function renderDefault($exception)
 {
     if ($this->isAjax()) {
         // AJAX request? Just note this error in payload.
         $this->payload->error = TRUE;
         $this->terminate();
     } elseif ($exception instanceof BadRequestException) {
         $code = $exception->getCode();
         $this->setView(in_array($code, array(403, 404, 405, 410, 500)) ? $code : '4xx');
         // load template 403.latte or 404.latte or ... 4xx.latte
     } else {
         $this->setView('500');
         // load template 500.latte
         Debugger::log($exception, Debugger::ERROR);
         // and log exception
     }
 }
 private function login()
 {
     Loader::load('utility', 'session/Session');
     Loader::load('model', 'com/passinggreen/member/Member');
     $member = Member::findMemberWithEmail(addslashes(Request::getPost('email')));
     $valid = false;
     if (isset($member) && $member->isValid() && ($member->getLevel() == 'admin' || $member->getLevel() == 'superadmin' || $member->getLevel() == 'developer')) {
         $valid = $member->validatePassword(Request::getPost('password'));
     }
     if ($valid) {
         $member->recordLogin();
         Session::instance()->setModelDefault($member);
         Debugger::log('valid');
     } else {
         Debugger::log('invalid');
         $this->setPageData('error', 'Incorrect username or password.');
         $this->show_form();
     }
 }
Пример #11
0
function detect_fatal_error()
{
    $last_error = error_get_last();
    if ($last_error && ($last_error['type'] == E_ERROR || $last_error['type'] == E_PARSE) && class_exists('Loader')) {
        try {
            Loader::load('utility', 'Template');
            if (file_exists(Loader::getPath('view', 'FatalError'))) {
                Debugger::log("Type {$last_error["type"]}: {$last_error["message"]} in {$last_error["file"]} on line {$last_error["line"]}");
                ob_clean();
                header('HTTP/1.1 503 Service Temporarily Unavailable');
                header('Status: 503 Service Temporarily Unavailable');
                Template::insert('FatalError');
                error_log("[Error Caught] {$last_error['message']} in {$last_error['file']} on line {$last_error['line']}");
                ob_end_flush();
            }
        } catch (Exception $e) {
            //echo "We've encountered an error. Please go back and try again.";
        }
    }
}
 public function getTokens()
 {
     if (!isset($this->tokens)) {
         $this->tokens = array();
         //build file path - check for absolute path first
         $stop_words_full_path = "/var/www/script-repository/{$this->type}";
         if (file_exists($stop_words_full_path)) {
             $stops = @file($stop_words_full_path);
             if (is_array($stops)) {
                 //scrub stops list
                 for ($i = 0, $imax = count($stops); $i < $imax; $i++) {
                     $stops[$i] = trim(strtolower(preg_replace('/\\W/', '', $stops[$i])));
                 }
                 $this->tokens = $stops;
             }
             //end if is_array
         } else {
             Debugger::log("{$stop_words_full_path} not found!");
         }
     }
     //end if cache var not set
     return $this->tokens;
 }
 public function __call($name, $arguments)
 {
     /*
      if($this->is_applying_sort($name))
      {
      $order = strtolower(substr($name,5,9)) == "ascending" ? "ASC" : "DESC";
      Debugger::log($order);
      $function = array($this->managed_object(), substr($name, $order == "ASC" ? 14 : 15));
      Debugger::log($function);
      if(method_exists($function[0],$function[1]))
      {
      Debugger::log($function[0] . "::" . $function[1] ." does exist.");
      $this->applySort(call_user_func_array($function,null),$order);
      return $this;
      }
      else
      {
      Debugger::log($function[0] . "::" . $function[1] ." does not exist.");
      error_log($function[0] . "::" . $function[1] ." does not exist.");
      }
     
      }
      else
     */
     if ($this->is_applying_filter($name)) {
         //Debugger::log("filter: $name");
         $function = array($this->managed_object(), substr($name, 5));
         if (method_exists($function[0], $function[1])) {
             $this->applyFilter(call_user_func_array($function, $arguments));
             return $this;
         } else {
             Debugger::log($function[0] . "::" . $function[1] . " does not exist.");
             error_log($function[0] . "::" . $function[1] . " does not exist.");
         }
     }
     trigger_error("Call to undefined method CassandraObjectManager->{$name}() on {$this->managed_object()}");
 }
Пример #14
0
 private function parseRedirect($url, $redirect)
 {
     if (isset(self::$rules['dynamic'])) {
         $dynamic = array_search($redirect, self::$rules['dynamic']);
     }
     $redirect = substr($redirect, 10);
     $redirect = self::parsePath($redirect);
     $to = $redirect['path'];
     if (isset($redirect['scheme']) && isset($redirect['host'])) {
         $to = "{$redirect['scheme']}://{$redirect['host']}{$to}";
     }
     //fix dynamic url
     if (isset($redirect['dynamic'])) {
         $to = str_replace($dynamic, $redirect['dynamic'], $to);
     }
     $to_query = array();
     // replace any param tokens
     if (isset($redirect['params'])) {
         foreach ($redirect['params'] as $name => $val) {
             if (preg_match('/^\\[(.*)\\]$/', $val, $match) === 1) {
                 $to_query[$name] = $url['params'][$match[1]];
                 unset($url['params'][$match[1]]);
             }
         }
     }
     // replace any other tokens
     if (isset($url['params'])) {
         foreach ($url['params'] as $name => $val) {
             $to = str_replace("[{$name}]", $val, $to, $count);
             if ($count == 1) {
                 unset($url['params'][$name]);
             }
         }
     }
     if (isset($url['params'])) {
         $to_query = array_merge($to_query, $url['params']);
     }
     if (count($to_query) > 0) {
         $to .= '?' . http_build_query($to_query);
     }
     Debugger::log("Redirecting to: {$to}");
     Config::set('Redirect', $to);
     return '/controller/RedirectController';
 }
Пример #15
0
/**
 * testLog method
 *
 * @return void
 */
	public function testLog() {
		if (file_exists(LOGS . 'debug.log')) {
			unlink(LOGS . 'debug.log');
		}

		Debugger::log('cool');
		$result = file_get_contents(LOGS . 'debug.log');
		$this->assertRegExp('/DebuggerTest\:\:testLog/i', $result);
		$this->assertRegExp("/'cool'/", $result);

		unlink(LOGS . 'debug.log');

		Debugger::log(array('whatever', 'here'));
		$result = file_get_contents(LOGS . 'debug.log');
		$this->assertRegExp('/DebuggerTest\:\:testLog/i', $result);
		$this->assertRegExp('/\[main\]/', $result);
		$this->assertRegExp('/array/', $result);
		$this->assertRegExp("/'whatever',/", $result);
		$this->assertRegExp("/'here'/", $result);
	}
 protected function loadModel($model, $args = array(), $class = null)
 {
     Debugger::log("MODEL: <span style=\"color:#b147bf;\">{$model}</span>");
     return Loader::loadNew('model', $model, $args, $class);
 }
Пример #17
0
function mainInsert($post, $defaultValue = array())
{
    //my_print_r($post);
    $rs = array();
    $md = array();
    $rs['akce'] = 'error';
    $rs['ok'] = FALSE;
    $rs['report'] = '';
    $rs['data'] = '';
    $md_record = new MdRecord();
    //$md_record->deleteTmpRecords();
    if (count($post) == 0) {
        setMickaLog('INSERT ERROR, POST is empty!', 'ERROR', 'micka_main_lib.main_insert');
        $rs['report'] = 'Error, not complete data!';
        //return $rs;
        Debugger::log('[micka_main_lib.mainInsert] ' . 'POST is empty!', 'ERROR');
        require PHPINC_DIR . '/templates/404_record.php';
    }
    $defaultEditGroup = array_key_exists('edit_group', $defaultValue) === TRUE ? $defaultValue['edit_group'] : MICKA_USER;
    $defaultViewGroup = array_key_exists('view_group', $defaultValue) === TRUE ? $defaultValue['view_group'] : MICKA_USER;
    //	0:ISO 19115 | 10:ISO 19119 | 1:DC | 2:FC | 99:import
    $md['md_standard'] = isset($post['standard']) && $post['standard'] != '' ? htmlspecialchars($post['standard']) : 0;
    // skupina pro prohlížení
    $md['view_group'] = isset($post['group_v']) && $post['group_v'] != '' ? htmlspecialchars($post['group_v']) : $defaultEditGroup;
    // skupina s právem editace
    $md['edit_group'] = isset($post['group_e']) && $post['group_e'] != '' ? htmlspecialchars($post['group_e']) : $defaultViewGroup;
    // hlavní jazyk záznamu
    $lang_main = isset($post['lang_main']) && $post['lang_main'] != '' ? htmlspecialchars($post['lang_main']) : MICKA_LANG;
    // seznam dalších jazyků
    $md['lang'] = isset($post['languages']) ? htmlspecialchars(implode($post['languages'], "|")) : '';
    if ($md['lang'] == '' && $lang_main != '') {
        $md['lang'] = $lang_main;
    }
    // template s default hodnotami
    $template = '';
    if ($md['md_standard'] < 99) {
        if ($md['md_standard'] == 0) {
            $template = PHPCFG_DIR . '/templateMd.xml';
        } elseif ($md['md_standard'] == 10) {
            $template = PHPCFG_DIR . '/templateMs.xml';
        } elseif ($md['md_standard'] == 1) {
            $template = PHPCFG_DIR . '/templateDc.xml';
        } elseif ($md['md_standard'] == 2) {
            $template = PHPCFG_DIR . '/templateFc.xml';
        }
        if ($template != '' && file_exists($template)) {
            $md['file_type'] = 'ISO19139';
            $md['update_type'] = 'skip';
            $md['md_standard'] = 99;
        }
    }
    // IMPORT
    if ($md['md_standard'] == 99) {
        $md['file_type'] = isset($post['fileType']) && $post['fileType'] != '' ? htmlspecialchars($post['fileType']) : 'ISO19139';
        $md['md_rec'] = isset($post['md_rec']) && $post['md_rec'] != '' ? htmlspecialchars($post['md_rec']) : '';
        $md['fc'] = isset($post['fc']) && $post['fc'] != '' ? htmlspecialchars($post['fc']) : '';
        $md['service_type'] = isset($post['serviceType']) && $post['serviceType'] != '' ? htmlspecialchars($post['serviceType']) : 'WMS';
        $md['url'] = isset($post['url']) && $post['url'] != '' ? htmlspecialchars($post['url']) : '';
        $md['url'] = $md['url'] != '' ? str_replace('&amp;', '&', $md['url']) : '';
        $md['update_type'] = isset($post['updateType']) && $post['updateType'] != '' ? htmlspecialchars($post['updateType']) : 'skip';
    }
    if ($md['md_standard'] < 99) {
        // Vytvoření nového záznamu v tmp
        $recno = $md_record->setNewRecord($md, $lang_main);
        if ($recno > 0) {
            $rs['akce'] = 'edit';
            $rs['ok'] = TRUE;
            $rs['data'] = $recno;
            setEditId2Session('recno', 'new');
            setEditId2Session('recnoTmp', $recno);
            $redirectUrl = substr(htmlspecialchars($_SERVER['PHP_SELF']), 0, strrpos($_SERVER['PHP_SELF'], '/')) . '?ak=edit&recno=new';
            setUrlEdit2Session($redirectUrl);
        }
        //return $rs;
        return $redirectUrl;
    }
    if ($md['md_standard'] == 99) {
        // Import ze souboru nebo url
        require PHPPRG_DIR . '/micka_lib_php5.php';
        require PHPPRG_DIR . '/micka_lib_insert.php';
        require PHPPRG_DIR . '/MdImport.php';
        //$prevod = DomainCodes2List();
        $report = array();
        $importer = new MetadataImport();
        if (isset($_FILES['soubor']['tmp_name']) && $_FILES['soubor']['tmp_name'] != '' || $template != '') {
            if ($_FILES['soubor']['tmp_name'] != '') {
                if (!file_exists(PHPINC_DIR . '/temp/upload/')) {
                    mkdir(PHPINC_DIR . '/temp/upload/', 0777);
                }
                $tmpFileName = PHPINC_DIR . '/temp/upload/' . md5(uniqid(rand(), true)) . '.xml';
                if (is_uploaded_file($_FILES['soubor']['tmp_name'])) {
                    move_uploaded_file($_FILES['soubor']['tmp_name'], $tmpFileName);
                } else {
                    $tmpFileName = '';
                }
            } else {
                $tmpFileName = $template;
            }
            if ($tmpFileName != '') {
                //$prevod = DomainCodes2List();
                $xmlstring = file_get_contents($tmpFileName);
                $importer = new MetadataImport();
                $importer->setTableMode('tmp');
                $report = $importer->import($xmlstring, $md['file_type'], MICKA_USER, $md['edit_group'], $md['view_group'], $md['mds'] = 0, $md['lang'], $lang_main, $params = false, $md['update_type'], $md['md_rec']);
            } else {
                $rs['report'] = "File error!";
                return $rs;
            }
        } elseif ($md['url'] != '') {
            setMickaLog($md['url'], 'INFO', 'micka_main_lib.main_insert.url');
            $importer->setTableMode('tmp');
            $report = $importer->importService($md['url'], $md['service_type'], MICKA_USER, $md['edit_group'], $md['view_group'], $md['mds'] = 10, $md['lang'], $lang_main, $public = 0, $md['update_type']);
        } else {
            // není zadán soubor ani url
            $rs['report'] = "Unknown import type!";
            return $rs;
        }
    }
    // zpracování reportu po importu
    if ($report[0]['ok'] == 1) {
        if (substr($report[0]['report'], 0, 11) == 'UUID exists') {
            $rs['report'] = "UUID exists, stop import!";
            $rs['akce'] = 'error';
            $rs['data'] = $report[0];
            return $rs;
        } else {
            $rs['ok'] = TRUE;
            $rs['report'] = $report[0]['report'];
            $md_record->setTableMode('tmp');
            $record = $md_record->getMd('uuid', $report[0]['uuid']);
            if (is_array($record) && count($record) > 1) {
                $rs['akce'] = IMPORT_VALID ? 'import' : 'edit';
                if ($rs['akce'] == 'edit') {
                    $rs['data'] = $record['md']['RECNO'];
                } else {
                    $rs['data']['md'] = $record['md'];
                }
            }
        }
    } else {
        $rs['report'] = $report[0]['report'];
        $rs['data'] = $report[0];
        return $rs;
    }
    if ($rs['akce'] == 'edit') {
        $redirectUrl = substr(htmlspecialchars($_SERVER['PHP_SELF']), 0, strrpos($_SERVER['PHP_SELF'], '/')) . '?ak=edit&recno=new';
        setUrlEdit2Session($redirectUrl);
    } else {
        // TODO: zatím jen editace
        $redirectUrl = substr(htmlspecialchars($_SERVER['PHP_SELF']), 0, strrpos($_SERVER['PHP_SELF'], '/')) . '?ak=edit&recno=new';
        setUrlEdit2Session($redirectUrl);
    }
    return $redirectUrl;
}
 protected function get_select_sql($values = null)
 {
     $custom = $this->custom_sql_select();
     if (isset($custom) && strlen($custom)) {
         $sql = "SELECT {$custom}";
     } else {
         if ($values == null) {
             $sql = "SELECT `{$this->table()}`.*";
         } else {
             //			$sql = "SELECT `" . implode("`,`",(array)$values) . "`";
             $sql = "SELECT `{$this->table()}`.`" . implode("`,`{$this->table()}`.`", (array) $values) . "`";
         }
     }
     $sql .= " FROM `" . $this->db_name() . "`.`" . $this->table() . "` ";
     if (strlen($this->join_clause())) {
         $sql .= $this->join_clause();
     }
     if ($this->index_hints()) {
         $sql .= " {$this->index_hints()} ";
     }
     if (strlen($this->where_clause())) {
         $sql .= " WHERE " . $this->where_clause();
     } else {
         if (!strlen($this->get_limit())) {
             if ($this->callStaticOnManagedObject("dummyMode")) {
                 if ($this->managed_object() != "Employee" && $this->managed_object() != 'VideoCategory' && $this->managed_object() != 'Blacklist' && $this->managed_object() != 'Whitelist' && $this->managed_object() != 'Graylist') {
                     Debugger::log("SELECTING ENTIRE TABLE! {$sql}\n");
                     //throw new Exception("bad programmer, no cookie! {$this->managed_object()}");
                 } else {
                     Debugger::log("{$this->managed_object()} using DEPRECATED dummyMode()");
                 }
             }
         }
     }
     if (strlen($this->group_by_clause())) {
         $sql .= " GROUP BY " . $this->group_by_clause();
     }
     if (strlen($this->order_by_clause())) {
         $sql .= " ORDER BY " . $this->order_by_clause();
     }
     if (strlen($this->get_limit())) {
         $sql .= " LIMIT " . $this->get_limit();
     }
     //error_log("get select sql: $sql");
     return $sql;
 }
 function execute()
 {
     $return = new stdClass();
     $params = Request::_REQUEST();
     Config::set("HideDebugger", true);
     if (isset($params["id"])) {
         $user = new Member($params["id"]);
         if (isset($user) && $user->isValid()) {
             if ($params["passwd"] != "") {
                 $user->setPassword($params["passwd"]);
             }
             $user->setLevel($params["level"]);
             $user->setIsEnabled($params["is_enabled"]);
             $user->setUserFirstname($params["userFirstname"]);
             $user->setUserLastname($params["userLastname"]);
             $user->setUserEmail($params["useremail"]);
             $user->setUserBio($params["userBio"]);
             $user->setWeb($params["web"]);
             $user->setUserCompany($params["userCompany"]);
             $user->setUserCompanyType($params["userCompanyType"]);
             $user->setUserAddr1($params["userAddr1"]);
             $user->setUserAddr2($params["userAddr2"]);
             $user->setUserCity($params["userCity"]);
             $user->setUserState($params["userState"]);
             $user->setUserCountry($params["userCountry"]);
             $user->setUserZip($params["userZip"]);
             $user->setUserPhone($params["userPhone"]);
             $user->setUserAltPhone($params["userAltPhone"]);
             $user->setUserFax($params["userFax"]);
             $user->setSiteAreas($params["siteAreas"]);
             $user->setUpdates($params["updates"]);
             $user->setPaymentType($params["paymentType"]);
             $user->setPaymentTypeDetails($params["paymentTypeDetails"]);
             $user->setShipAddr1($params["shipAddr1"]);
             $user->setShipAddr2($params["shipAddr2"]);
             $user->setShipCity($params["shipCity"]);
             $user->setShipState($params["shipState"]);
             $user->setShipCountry($params["shipCountry"]);
             $user->setShipZip($params["shipZip"]);
             if ($user->save()) {
                 // encrypt any credit card information then set the CC field
                 // check for an existing private key first
                 $existing_privateKey = CryptKey::findCryptKeyByUserID($user->getID());
                 $cc_privateKey = null;
                 if (isset($existing_privateKey) && $existing_privateKey->isValid()) {
                     // retrieve existing key
                     Debugger::log("User crypt private key: " . $existing_privateKey->getKey());
                     $cc_privateKey = $existing_privateKey->getKey();
                 } else {
                     // store key into keys table
                     $user_key = new CryptKey();
                     $user_key->setUserID($user->getID());
                     $user_key->setKey(TwoWayEncryption::genPrivateKey());
                     if ($user_key->save()) {
                         Debugger::log("Saved user crypt private key.");
                         $cc_privateKey = $user_key->getKey();
                     } else {
                         Debugger::log("Saving user crypt private key failed! Refusing to encrypt contents!");
                     }
                 }
                 if (!is_null($cc_privateKey)) {
                     $cc_data = unserialize(TwoWayEncryption::decrypt($user->getCC(), $cc_privateKey));
                     $cc_data = array_merge($cc_data, array("name" => $params["ccc_name"], "ccNum" => $params["ccc_ccNum"], "MM" => $params["ccc_MM"], "YY" => $params["ccc_YY"], "ccCODE" => $params["ccc_ccCode"]));
                     $cc_encrypted_data = TwoWayEncryption::encrypt(serialize($cc_data), $cc_privateKey);
                     $user->setCC($cc_encrypted_data);
                     $user->save();
                 }
                 $return->id = $user->getID();
                 $return->updated = true;
                 echo json_encode($return);
                 return;
             } else {
                 $error = DatabaseFactory::passinggreen_db()->getLastError();
                 $return->error = "could not update Member object because: " . $error;
                 echo json_encode($return);
                 return;
             }
         } else {
             $return->error = "ID is invalid!";
             echo json_encode($return);
             return;
         }
     } else {
         $return->error = "Missing ID!";
         echo json_encode($return);
         return;
     }
 }
 private function create_connection_with_settings($settings, $retry_count = 0)
 {
     $dbc = mysqli_init();
     //set options
     if (isset($settings["timeout"])) {
         $dbc->options(MYSQLI_OPT_CONNECT_TIMEOUT, (int) $settings["timeout"]);
         //if unable to connect after x seconds, give up
     }
     //end set options
     //create actual connection
     if (isset($settings["port"])) {
         $dbc->real_connect($settings["host"], $settings["username"], $settings["passwd"], $settings["dbname"], $settings["port"]);
     } else {
         $dbc->real_connect($settings["host"], $settings["username"], $settings["passwd"], $settings["dbname"]);
     }
     //end creation of connect
     //check connection success
     if (mysqli_connect_errno()) {
         if ($retry_count < 3) {
             $retry_count++;
             Debugger::log("Failed connection to database. Retry count: {$retry_count}. Retrying again in 1 second");
             error_log("Failed connection to database. Retry count: {$retry_count}. Retrying again in 1 second");
             sleep(1);
             return self::create_connection_with_settings($settings, $retry_count);
         }
         error_log("Database connection failed: " . mysqli_connect_error());
         /* record error */
         $error = new MySqliError(mysqli_connect_errno(), mysqli_connect_error());
         $this->connection_errors[] = $error;
         //$this->errors[] = $error;
         return null;
     } else {
         $sql = "SHOW SLAVE STATUS";
         $result = $dbc->query($sql);
         if ($result && ($slave_status = $result->fetch_object())) {
             $concurrency = $slave_status->Seconds_Behind_Master;
             if ($concurrency >= 30 && $retry_count < 3) {
                 $retry_count++;
                 //error_log("Reading from stale slave. $concurrency seconds behind master. Retry count $retry_count");
                 Debugger::log("Reading from stale slave. {$concurrency} seconds behind master. Retry count {$retry_count}");
                 return $this->create_connection_with_settings($settings, $retry_count);
             } else {
                 if ($retry_count >= 5) {
                     error_log("Reading from stale slave. {$concurrency} seconds behind master. Out-of-retry count {$retry_count}");
                     Debugger::log("Reading from stale slave. {$concurrency} seconds behind master. Out-of-retry count {$retry_count}");
                 }
             }
         }
     }
     return $dbc;
 }
 public function __call($name, $arguments)
 {
     if ($this->is_applying_sort($name) || $this->is_applying_filter($name)) {
         return parent::__call($name, $arguments);
     }
     $this->getManagedObjectData();
     $lower_name = strtolower(str_replace('_', '', $name));
     //Debugger::log($this->managed_object_data);
     foreach ($this->managed_object_data as $function => $function_data) {
         foreach ($function_data as $column => $column_data) {
             if ($lower_name == strtolower(str_replace('_', '', "get{$function}For{$column}"))) {
                 return $column_data;
             } else {
                 //error_log($lower_name . " != " . strtolower(str_replace('_', '', "get{$function}For{$column}")));
                 Debugger::log($lower_name . " != " . strtolower(str_replace('_', '', "get{$function}For{$column}")));
             }
         }
     }
     //exit;
     switch ($name) {
         case "get{$this->managed_object}s":
             return $this->getManagedObjects();
         case "getTotal":
             return $this->getManagedObjectCount(true);
         case "get{$this->managed_object}Count":
         case "getSize":
             return $this->getManagedObjectCount();
             break;
     }
     trigger_error("Call to undefined method DBStatistics->{$name}()");
     //error_log(print_r($this->managed_object_data,true));
     //Debugger::log("DBObjectCollection __call($name)");
 }
 protected function loadController($controller, $args = array(), $class = null)
 {
     Debugger::log("CONTROLLER: <span style=\"color:#4882c0;\">{$controller}");
     return Loader::loadNew('controller', $controller, $args, $class);
 }
 public static function mutator($class, $type, $args = null)
 {
     $reflection = new ReflectionClass($class);
     ///determine path -- messy....
     $path = $reflection->getFileName();
     $start_pos = "class-repository/model/";
     $start = strpos($path, "class-repository/model/");
     $model_include = substr($path, $start + strlen($start_pos));
     $end_pos = "{$class}.class.inc.php";
     $end = strpos($model_include, $end_pos);
     $path = substr($model_include, 0, $end);
     //$path .= "{$type}$class";
     //end of determine path
     Debugger::log("MUTATOR: <span style=\"color: #DAA2FF;\">{$path}{$type}{$class}</span>");
     Loader::load("mutator", "{$path}{$type}{$class}.class.inc.php");
     $creatorReflection = new ReflectionClass("{$type}{$class}");
     if (isset($args)) {
         $creator = $creatorReflection->newInstanceArgs($args);
     } else {
         $creator = $creatorReflection->newInstance();
     }
     unset($path);
     unset($creatorReflection);
     unset($reflection);
     return $creator;
 }
Пример #24
0
 /**
  * testLog method
  *
  * @access public
  * @return void
  */
 function testLog()
 {
     if (file_exists(LOGS . 'debug.log')) {
         unlink(LOGS . 'debug.log');
     }
     Debugger::log('cool');
     $result = file_get_contents(LOGS . 'debug.log');
     $this->assertPattern('/DebuggerTest::testLog/', $result);
     $this->assertPattern('/"cool"/', $result);
     unlink(TMP . 'logs' . DS . 'debug.log');
     Debugger::log(array('whatever', 'here'));
     $result = file_get_contents(TMP . 'logs' . DS . 'debug.log');
     $this->assertPattern('/DebuggerTest::testLog/', $result);
     $this->assertPattern('/array/', $result);
     $this->assertPattern('/"whatever",/', $result);
     $this->assertPattern('/"here"/', $result);
 }
Пример #25
0
 /**
  * Executes cleanup
  */
 function cleanup()
 {
     $a = func_get_args();
     Debugger::log(__CLASS__ . ": " . __METHOD__ . "; args: " . print_r($a, true));
 }
Пример #26
0
function getMdPackages($micka_lang, $mds, $profil, $pairs = FALSE)
{
    $rs = array();
    if ($micka_lang === '' || $mds === '' || $profil === '') {
        Debugger::log('[micka_lib.getMdPackages] ' . "LANG={$micka_lang}, MDS={$mds}, PROFIL={$profil}", 'ERROR');
        return $rs;
    }
    $is_packages = 0;
    $sql = array();
    if ($mds == 0 || $mds == 10) {
        array_push($sql, '
			SELECT is_packages FROM profil_names WHERE md_standard=%i AND profil_id=%i
		', $mds, $profil);
        $is_packages = _executeSql('select', $sql, array('single'));
    } else {
        return $rs;
    }
    if ($is_packages == 0) {
        return $rs;
    }
    if ($mds == 10) {
        $mds = 0;
    }
    $sql = array();
    array_push($sql, "\n\t\tSELECT packages.package_id, label.label_text\n    FROM packages INNER JOIN label ON packages.package_id=label.label_join\n\t\tWHERE label.label_type='MB' AND packages.md_standard=%i AND label.lang=%s\n\t\tORDER BY packages.package_order\n\t", $mds, $micka_lang);
    if ($pairs) {
        $rs = _executeSql('select', $sql, array('pairs', 'package_id', 'label_text'));
    } else {
        $rs = _executeSql('select', $sql, array('all'));
    }
    return $rs;
}
 /**
  * testLog method
  *
  * @return void
  */
 public function testLog()
 {
     if (file_exists(LOGS . 'debug.log')) {
         unlink(LOGS . 'debug.log');
     }
     Debugger::log('cool');
     $result = file_get_contents(LOGS . 'debug.log');
     $this->assertRegExp('/DebuggerTest\\:\\:testLog/i', $result);
     $this->assertRegExp('/"cool"/', $result);
     unlink(TMP . 'logs' . DS . 'debug.log');
     Debugger::log(array('whatever', 'here'));
     $result = file_get_contents(TMP . 'logs' . DS . 'debug.log');
     $this->assertRegExp('/DebuggerTest\\:\\:testLog/i', $result);
     $this->assertRegExp('/\\[main\\]/', $result);
     $this->assertRegExp('/array/', $result);
     $this->assertRegExp('/"whatever",/', $result);
     $this->assertRegExp('/"here"/', $result);
 }
Пример #28
0
 /**
  * testLog method
  *
  * @return void
  */
 public function testLog()
 {
     if (file_exists(LOGS . 'debug.log')) {
         unlink(LOGS . 'debug.log');
     }
     CakeLog::config('file', array('engine' => 'File', 'path' => TMP . 'logs' . DS));
     Debugger::log('cool');
     $result = file_get_contents(LOGS . 'debug.log');
     $this->assertRegExp('/DebuggerTest\\:\\:testLog/i', $result);
     $this->assertRegExp("/'cool'/", $result);
     unlink(LOGS . 'debug.log');
     Debugger::log(array('whatever', 'here'));
     $result = file_get_contents(LOGS . 'debug.log');
     $this->assertRegExp('/DebuggerTest\\:\\:testLog/i', $result);
     $this->assertRegExp('/\\[main\\]/', $result);
     $this->assertRegExp('/array/', $result);
     $this->assertRegExp("/'whatever',/", $result);
     $this->assertRegExp("/'here'/", $result);
 }
Пример #29
0
<a name="signup"></a>
<?php 
Debugger::log(MessageLogger::getMessages());
if (MessageLogger::getMessages()) {
    foreach (MessageLogger::getMessages() as $type => $messages) {
        foreach ($messages as $message) {
            ?>
      <div class="<?php 
            echo $type;
            ?>
"><?php 
            echo $message;
            ?>
</div>
      <?php 
        }
    }
}
Пример #30
0
 /**
  * test log() depth
  *
  * @return void
  */
 public function testLogDepth()
 {
     if (file_exists(LOGS . 'debug.log')) {
         unlink(LOGS . 'debug.log');
     }
     CakeLog::config('file', array('engine' => 'File', 'path' => TMP . 'logs' . DS));
     $val = array('test' => array('key' => 'val'));
     Debugger::log($val, LOG_DEBUG, 0);
     $result = file_get_contents(LOGS . 'debug.log');
     $this->assertContains('DebuggerTest::testLog', $result);
     $this->assertNotContains("/'val'/", $result);
     unlink(LOGS . 'debug.log');
 }