/**
  * move a row
  *
  * @param CmsRow $cmsRow CMS Row Entity
  * @param string $position Position
  * @return void
  */
 public function moveRow(CmsRow $cmsRow, $position)
 {
     dlog('new row position: ' . $position);
     $cmsRow->position = $position;
     $this->save($cmsRow);
     $this->restoreSorting(['cms_page_id' => $cmsRow->cms_page_id]);
 }
Beispiel #2
0
 /**
  * Returns true if this map contains no key-value mappings.
  */
 public function isEmpty()
 {
     $map = $this->tr->getIndex();
     if (!is_array($map)) {
         dlog("Array expected from getIndex()", ERROR);
     }
     foreach ($map as $k) {
         return false;
     }
     return true;
 }
Beispiel #3
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     echo `clear`;
     $header_style = new OutputFormatterStyle('green', 'default', ['bold']);
     $output->getFormatter()->setStyle('header', $header_style);
     $output->writeln('<header>Running COGS PHP Server.</header>');
     //$output->writeln('Use `ps -A | grep localhost` to locate sever PID.');
     $output->writeln('php -S http://localhost:8080 -t public');
     $output->writeln('Use ^c to terminate.');
     $output->writeln('--------------------------------------');
     $command = `php -S localhost:8080 -t public`;
     //$command = `php -S localhost:8080 -t public  &> /dev/null &`;
     echo $command;
     dlog('launched COGS server', 'info');
 }
Beispiel #4
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $header_style = new OutputFormatterStyle('green', 'default', ['bold']);
     $output->getFormatter()->setStyle('header', $header_style);
     # check for files
     $cache = glob(LOCAL_CACHE . '/*');
     if (empty($cache)) {
         $output->writeln('<header>The cache is empty.</header>');
     } else {
         $output->writeln('<header>Clearing local caches...</header>');
         $local_cache = LOCAL_CACHE . '/*';
         $command = `rm -R {$local_cache}`;
         echo $command;
         $output->writeln('<header>Local cache has been cleared.</header>');
         dlog('cleared the local cache', 'info');
     }
 }
Beispiel #5
0
            $link_cache['_threads'][$thread]['links'][] = $link;
        }
        if (!$link_cache[$link]['downloaded']) {
            $new_count++;
            dout("Sending link to download: " . $link);
            if (jdremote_download($link)) {
                $link_cache[$link]['downloaded'] = true;
                $link_cache[$link]['downloaded_time'] = time();
            } else {
                $new_fail_count++;
                dout("... FAILED.");
            }
        } else {
            $skipped_count++;
        }
    }
    dout("Site crawl results: " . $new_count . " new links, of which " . $new_fail_count . " could not be sent to JD. " . $skipped_count . " links where skipped.");
}
if ($new_count + $new_fail_count + $skipped_count == 0) {
    dlog(dout("No threads or all threads failed.", true));
} else {
    dlog('New: ' . $new_count . ' Fail: ' . $new_fail_count . ' Skipped: ' . $skipped_count);
}
dout("Writing link cache...");
file_put_contents('data/cache', serialize($link_cache));
dout("Saving site data...");
datafile_write($sites);
dout("Sending start to JD.");
jdremote_start();
jdremote_close();
dout("FINISHED.");
Beispiel #6
0
/**
 * SQL wrapper for all Database accesses
 *
 * @param  string $sql_string The SQL-Statement to execute
 * @return mixed  either the resultset as an array with hashes or the insertid
 */
function runSQL($sql_string, $verify = true)
{
    global $config, $dbh, $SQLtrace;
    if ($config['debug']) {
        dlog("\n" . $_SERVER['REQUEST_URI']);
        if (function_exists('xdebug_get_function_stack')) {
            dlog(join(' -> ', array_extract(xdebug_get_function_stack(), 'function')));
        }
        dlog($sql_string);
        $timestamp = getmicrotime();
    }
    if (!is_resource($dbh)) {
        $dbh = getConnection();
    }
    $res = mysqli_query($dbh, $sql_string);
    // mysqli_db_query returns either positive result ressource or true/false for an insert/update statement
    if ($res === false) {
        $result = false;
        if ($verify) {
            // report DB Problem
            errorpage('Database Problem', mysqli_error($dbh) . "\n<br />\n" . $sql_string, true);
        }
    } elseif ($res === true) {
        // on insert, return id of created record
        $result = mysqli_insert_id($dbh);
    } else {
        // return associative result array
        $result = array();
        for ($i = 0; $i < mysqli_num_rows($res); $i++) {
            $result[] = mysqli_fetch_assoc($res);
        }
        mysqli_free_result($res);
    }
    if ($config['debug']) {
        $timestamp = getmicrotime() - $timestamp;
        dlog('Time: ' . $timestamp);
        // collect all SQL info for debugging
        $SQLtrace[] = array('sql' => $sql_string, 'time' => $timestamp);
    }
    #	mysqli_close($dbh);
    return $result;
}
Beispiel #7
0
            dlog("Course instance closed ({$instanceID}) by {$userName}", "courseQuickClose");
            echo json_encode(true);
        } else {
            echo json_encode(false);
        }
    } else {
        echo json_encode(false);
    }
}
if ($app == "vbzaxman_openInstance") {
    if (isset($_SESSION['vbz_auth_isadmin'])) {
        if ($_SESSION['vbz_auth_isadmin']) {
            $instanceID = db::esc($_GET['instanceID']);
            $userName = db::esc($_SESSION['vbz_auth_username']);
            db::insertQuery("delete from eventsClosed where instanceID = '{$instanceID}' ");
            dlog("Course instance opened ({$instanceID}) by {$userName}", "courseQuickClose");
            echo json_encode(true);
        } else {
            echo json_encode(false);
        }
    } else {
        echo json_encode(false);
    }
}
if ($app == "vbzaxman_getCoupons") {
    if (isset($_SESSION['vbz_auth_isadmin'])) {
        if ($_SESSION['vbz_auth_isadmin']) {
            $coupons = db::runQuery("Select * from coupons");
            $coparr = array();
            $totalRecords = 0;
            if ($coupons) {
 protected function log_authentication_event($event, $username)
 {
     if (defined('REASON_LOG_LOGINS') && REASON_LOG_LOGINS) {
         $logtext = sprintf('%s - %s [%s] "%s" - - "%s" "%s"', $_SERVER['REMOTE_ADDR'], trim($username), date('d/M/Y:H:i:s O'), $event, isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', $_SERVER['HTTP_USER_AGENT']);
         dlog($logtext, REASON_LOG_DIR . 'reason_login.log');
     }
 }
/** @access private */
function _carl_util_log_error($level, $message, $file, $line, $context)
{
    $referrer = !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
    $uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
    $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
    $ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
    $error = array('type' => strtoupper(error_level_name($level)), 'time' => carl_date('r'), 'msg' => $message, 'line' => $line, 'file' => $file, 'uri' => $uri, 'ip' => $ip, 'ua' => $ua, 'errno' => $level, 'referrer' => $referrer);
    $error = implode(',', array_map('_carl_util_escape_error_part', $error));
    dlog($error, PHP_ERROR_LOG_FILE);
}
Beispiel #10
0
function uc_nab_transact_charge_test($order_id, $amount, $data)
{
    global $user;
    // Get the next message ID.
    $message_id = getNABMessageID();
    $message_id = $message_id['ID'];
    $message_id = $message_id + 1;
    setNABMessageID($message_id);
    // Build the post XML from the data array.
    $post_data = uc_nab_transact_xml_test('Payment', $data, $message_id);
    //print $post_data;
    // Build the URL where we'll send the request.
    //$url = 'https://transact.nab.com.au/'. variable_get('uc_nab_xml_mode', 'test') .'/xmlapi/payment';
    $url = "https://transact.nab.com.au/test/xmlapi/payment";
    dlog("NAB Using:  " . $url);
    // Get the response of our payment request.
    //if ( extension_loaded( 'opensslx' ) ) {
    //  $response = drupal_http_request( $url, array( 'Content-Type' => 'text/xml' ), 'POST', $post_data );
    //  $response = $response->data;
    // }
    // if openssl extension is not loaded we use CURL
    //elseif ( extension_loaded( 'curl' ) ) {
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
    curl_setopt($ch, CURLOPT_TIMEOUT, 180);
    //timeout in seconds
    dlog("NAB Sending Request");
    try {
        $response = curl_exec($ch);
    } catch (Exception $e) {
        dlog("NAB - ##EXCEPTION## - " . $e->getMessage());
        $result = array('success' => FALSE, 'comment' => t('Credit card payment failed: @text', array('@text' => 'Bank Returned Error at this time')), 'message' => t('Credit card payment failed: @text', array('@text' => 'Bank Returned Error at this time')), 'uid' => $user->uid);
        return $result;
    }
    dlog("Request Completed");
    curl_close($ch);
    //}
    // Include the XML parser for PHP 4 compatibility.
    //module_load_include('php', 'uc_store', 'includes/simplexml');
    dlog("NAB Creating XML OBject");
    dlog("NAB Response: " . $response);
    // Create the XML object and parse the response string.
    $xml = simplexml_load_string($response);
    dlog("NAB Response XML: " . $xml);
    //print_r($xml);
    // Check to make sure the response parses and payment passed properly.
    if (isset($xml->Status->statusCode) && $xml->Status->statusCode != '000') {
        $approval = 'No';
        $responsecode = $xml->Status->statusCode;
        $responsetext = $xml->Status->statusDescription;
        dlog("NAB - NO APPROVAL");
    } elseif (isset($xml->Payment->TxnList->Txn->approved)) {
        $approval = $xml->Payment->TxnList->Txn->approved;
        $responsecode = $xml->Payment->TxnList->Txn->responseCode;
        $responsetext = $xml->Payment->TxnList->Txn->responseText;
        $charged = $xml->Payment->TxnList->Txn->amount / 100;
        $txnid = $xml->Payment->TxnList->Txn->txnID;
        dlog("NAB - CHECKING");
    } else {
        // Otherwise supply some default values.
        $approval = 'No';
        $responsecode = 'x';
        // If $response is set, we made a request, error was in the response
        if (isset($response)) {
            $responsetext = t('Failed to parse the XML API request or response.');
            // Log the trouble string to the watchdog.
            watchdog('uc_nab_transact', 'Failed XML parse response:<br/>@xml', array('@xml' => $response), WATCHDOG_ERROR);
        } else {
            $responsetext = t('Failed to make the request.');
            // Log the trouble string to the watchdog.
            watchdog('uc_nab_transact', 'Failed to make the request: "openssl" or "curl" PHP extensions are needed.', array(), WATCHDOG_ERROR);
        }
        dlog("NAB - Failed: " . $responsetext);
    }
    if ($approval != 'Yes') {
        $message = t('Credit card declined: !amount', array('!amount' => $amount));
        dlog("NAB - Declined: " . $message);
        $result = array('success' => FALSE, 'comment' => t('Credit card payment declined: @text', array('@text' => $responsetext)), 'message' => t('Credit card payment declined: @text', array('@text' => $responsetext)), 'uid' => $user->uid);
    } else {
        $message = t('Credit card charged: !amount', array('!amount' => $charged)) . '<br />' . t('NAB Transact Txn ID: @txnid', array('@txnid' => $txnid));
        dlog("NAB - Approved: " . $message);
        $result = array('success' => TRUE, 'comment' => t('NAB Transact Txn ID: @txnid<br/>Approval code: @code', array('@txnid' => $txnid, '@code' => $responsecode)), 'message' => t('NAB Transact Txn ID: @txnid<br/>Approval code: @code', array('@txnid' => $txnid, '@code' => $responsecode)), 'data' => array('TxnID' => $txnid), 'uid' => $user->uid);
    }
    $message .= '<br />' . t('Response code: @code - @text', array('@code' => $responsecode, '@text' => $responsetext));
    dlog("NAB - Result: " . $message);
    return $result;
}
Beispiel #11
0
 /**
  * Logs an error to the error file if {@link _log_errors} is true.
  * @param $el string name of the element
  * @param $value mixed element's value
  * @param $msg string The error message
  * @access private
  */
 function _log_error($el, $value, $msg)
 {
     if ($this->_log_errors) {
         $err = array();
         $parts = parse_url(get_current_url());
         $err[] = $parts['host'];
         $err[] = $parts['path'];
         if (isset($parts['query'])) {
             $err[] = $parts['query'];
         }
         $err[] = get_class($this);
         $err[] = $el;
         if (empty($this->no_session) or !in_array($el, $this->no_session)) {
             if (is_array($value) || is_object($value)) {
                 $err[] = serialize($value);
             } else {
                 $err[] = $value;
             }
         } else {
             $err[] = '*** VALUE HIDDEN *** (' . strlen($value) . ' characters)';
         }
         $err[] = $msg;
         $err[] = !empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
         $err[] = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
         $err[] = !empty($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'] : '';
         $err[] = date($this->_disco_log_date_format);
         array_walk($err, 'quote_walk');
         $err_str = join(',', $err);
         dlog($err_str, '/tmp/disco_errors_' . $_SERVER['HTTP_HOST']);
     }
 }
Beispiel #12
0
/**
 * SQL wrapper for all Database accesses
 *
 * @param  string $sql_string The SQL-Statement to execute
 * @return mixed  either the resultset as an array with hashes or the insertid
 */
function runSQL($sql_string, $verify = true)
{
    global $config, $db_link, $SQLtrace;
    if ($config['debug']) {
        dlog("\n" . $_SERVER['REQUEST_URI']);
        if (function_exists('xdebug_get_function_stack')) {
            dlog(join(' -> ', array_extract(xdebug_get_function_stack(), 'function')));
        }
        dlog($sql_string);
        $timestamp = getmicrotime();
    }
    if (!is_resource($db_link)) {
        $db_link = mysql_pconnect($config['db_server'], $config['db_user'], $config['db_password']) or errorpage('DB Connection Error', "<p>Edit the database settings in <code>" . CONFIG_FILE . "</code>.</p>\n                       <p>Alternatively, consider running the <a href='install.php'>installation script</a>.</p>");
        mysql_select_db($config['db_database'], $db_link) || errorpage('DB Connection Error', "Couldn't select database: " . $config['db_database'] . "<p>Please verify your database is up and running and validate your database settings in <code>" . CONFIG_FILE . "</code>.</p>\n                       <p>Alternatively, consider running the <a href='install.php'>installation script</a>.</p>");
        if (DB_CHARSET) {
            mysql_query("SET NAMES '" . DB_CHARSET . "'", $db_link) || errorpage('DB Link Error', 'Couldn\'t set encoding to ' . DB_ENCODING);
        }
    }
    $res = mysql_query($sql_string, $db_link);
    // mysql_db_query returns either positive result ressource or true/false for an insert/update statement
    if ($res === false) {
        if ($verify) {
            // report DB Problem
            errorpage('Database Problem', mysql_error($db_link) . "\n<br />\n" . $sql_string, true);
        } else {
            // ignore problem but forward the information
            $result = false;
        }
    } elseif ($res === true) {
        // on insert, return id of created record
        $result = mysql_insert_id($db_link);
    } else {
        // return associative result array
        $result = array();
        for ($i = 0; $i < mysql_num_rows($res); $i++) {
            $result[] = mysql_fetch_assoc($res);
        }
        mysql_free_result($res);
    }
    if ($config['debug']) {
        $timestamp = getmicrotime() - $timestamp;
        dlog('Time: ' . $timestamp);
        // collect all SQL info for debugging
        $SQLtrace[] = array('sql' => $sql_string, 'time' => $timestamp);
    }
    #	mysql_close($db_link);
    return $result;
}
Beispiel #13
0
function handle_error_log($err_no, $err_str, $err_file, $err_line)
{
    dlog($err_str, "PHP ERROR ({$err_no}) {$err_file} {$err_line}", 'php_errors');
    return TRUE;
}
Beispiel #14
0
 public static function run()
 {
     //get the requested path
     $path = array_key_exists('PATH_INFO', $_SERVER) ? $_SERVER['PATH_INFO'] : $_SERVER['REQUEST_URI'];
     $method = $_SERVER['REQUEST_METHOD'];
     $phpNeedsAGoramFinally = false;
     dlog("Getting handler for path {$path} method {$method}");
     try {
         self::$currentRoute = $route = self::getRoute($path, $method);
         dlog("Handler for [{$method} {$path}] is {$route->handler}, calling");
         call_user_func($route->handler);
     } catch (DeanoRouteErrorException $routeException) {
         dlog("Handler for [{$method} {$path}] not found", DeanoLog::WARN);
         $errorHandler = self::getErrorHandler($routeException->code);
         dlog("Error handler for {$routeException->code} is {$errorHandler->handler}, calling");
         call_user_func($errorHandler->handler, $routeException);
     } catch (Exception $e) {
         echo '<div class="deano-exception" style="border:1px solid red;background-color:#fdd;padding:1em">' . '<div><strong>Uncaught general exception</strong></div>' . "<div>{$e}</div>" . "</div>";
         if (DEANO_LOG && ($phpNeedsAGoramFinally = 'true')) {
             DeanoLog::prettyPrint();
         }
     }
     if (DEANO_LOG && !$phpNeedsAGoramFinally) {
         DeanoLog::prettyPrint();
     }
 }
 function bulkTestRecordLabelMethods($labelToTest, $expected_return)
 {
     $r = array();
     $failed = 0;
     $r['register'] = $this->pe->register("some_content", $labelToTest);
     $r['retrieve'] = $this->pe->retrieve($labelToTest);
     $r['exists'] = $this->pe->exists($labelToTest);
     $r['delete'] = $this->pe->delete($labelToTest);
     foreach ($r as $method => $res) {
         if (!($expected_return[$method] === $res)) {
             dlog("Fail: {$method} returned {$res} instead of " . $expected_return[$method], ERROR);
             $failed++;
         }
     }
     return $failed;
 }
Beispiel #16
0
/**
 * Log the amount of time it took to generate the current page/process
 *
 * @param integer $milliseconds The number of milliseconds that it took to generate the page
 * @return boolean success
 */
function reason_log_page_generation_time($milliseconds)
{
    if (defined('REASON_PERFORMANCE_PROFILE_LOG') && REASON_PERFORMANCE_PROFILE_LOG) {
        $pieces = array(carl_date('r'), get_current_url(), $milliseconds);
        array_walk($pieces, 'quote_walk');
        $msg = implode(',', $pieces);
        return dlog($msg, REASON_PERFORMANCE_PROFILE_LOG);
    }
    return false;
}
function write($line) {  
 dlog("write: $line\n");  
 echo $line."\n";  
}  
Beispiel #18
0
                db::insertQuery("insert into log (type,message,instanceID) values('sync','Istance Created','{$instanceID}')");
            }
        }
        $eventTotal++;
    }
    //var_dump($courses);
    //die();
}
$mergedata = db::runQuery("select * from locations where mergeWithID != '0'");
if ($mergedata) {
    foreach ($mergedata as $merge) {
        $oldLocationID = db::esc($merge['ID']);
        $newLocationID = db::esc($merge['mergeWithID']);
        db::insertQuery("update events set locationID = '{$newLocationID}' where locationID = '{$oldLocationID}'");
        $locationMerge++;
    }
}
dlog("Finalising", "sync");
echo "Total Locations Processed: " . $locationTotal . "<br>\n";
echo "Total Locations Merged: " . $locationMerge . "<br>\n";
echo "Total Events Processed: " . $eventTotal . "<br>\n";
echo "Total Events Closed: " . $closedTotal . "<br>\n";
echo "Completed at: " . date("Y-m-d g:i:s A", strtotime("now"));
dlog("############################################", "sync");
dlog("# Total Locations Processed: {$locationTotal}", "sync");
dlog("# Total Locations Merged: {$locationMerge}", "sync");
dlog("# Total Events Processed: {$eventTotal}", "sync");
dlog("# Total Events Closed: {$closedTotal}", "sync");
dlog("############################################", "sync");
dlog("Finished.", "sync");
 public function handle_shutdown()
 {
     dlog('[' . elapsed_time() . '] application::shutdown', 'debug');
 }