Пример #1
0
function set_session($k, $v)
{
    if ('' === $v || is_NULL($v)) {
        unset($_SESSION($k));
    } else {
        $_SESSION[$k] = $v;
    }
}
 /**
  * Compile coffe script
  *
  * @param string
  * @param bool|NULL
  *
  * @return string
  */
 protected function compileCoffee($source, $bare = NULL)
 {
     if (is_NULL($bare)) {
         $bare = $this->bare;
     }
     $cmd = $this->bin . ' -p -s' . ($bare ? ' -b' : '');
     return $this->run($cmd, $source);
 }
Пример #3
0
 /**
  * Logs the memory usage of the provided variable, or entire script
  *
  * @param string $name   Optional name used to group variables and scripts together
  * @param mixed $variable Optional variable to log the memory usage of
  *
  * @return void
  */
 public function log_memory($name = 'Memory usage at this point', $variable = NULL)
 {
     if (!is_NULL($variable)) {
         $this->log_var_memory($name, $variable);
     }
     $log_item = array('data' => memory_get_usage(), 'name' => $name);
     $this->_write('memory', $log_item);
 }
Пример #4
0
 /**
  * Sets the configuration options for this object and sets the start time.
  *
  * Possible configuration options include:
  * query_explain_callback - Callback used to explain queries. Follow format used by call_user_func
  *
  * @param array $config    List of configuration options
  * @param int   $start_time Time to use as the start time of the profiler
  */
 private function __construct(array $config = array(), $start_time = NULL)
 {
     if (is_NULL($start_time)) {
         $start_time = microtime(TRUE);
     }
     $this->_start_time = $start_time;
     $this->_config = $config;
     $this->_console = new Profiler_Console();
 }
Пример #5
0
 public function __construct()
 {
     $gridfs_conf = Core::config('gridfs_servers');
     $mongo = new \MongoClient($gridfs_conf['host'], $gridfs_conf['opt']);
     $this->conn = $mongo->selectDB($gridfs_conf['db']['file']);
     if (!is_NULL($gridfs_conf['user']) && !is_NULL($gridfs_conf['pwd'])) {
         $this->conn->authenticate($gridfs_conf['user'], $gridfs_conf['pwd']);
     }
 }
Пример #6
0
function set_session($k, $v)
{
    global $session_prefix;
    if (is_NULL($v) || $v === '') {
        unset($_SESSION[$session_prefix . $k]);
    } else {
        $_SESSION[$session_prefix . $k] = $v;
    }
}
Пример #7
0
 public function getlist($content = NULL, $data = NULL, $select = '*')
 {
     $this->db->select($select);
     if (!is_NULL($this->offset)) {
         $this->offset > 0 && ($this->offset = ($this->offset - 1) * $this->limit);
         $this->db->offset($this->offset);
     }
     !is_NULL($this->limit) && $this->db->limit($this->limit);
     if (!is_NULL($content) || !is_NULL($data)) {
         $this->db->where($content, $data);
     }
     $this->db->order_by($this->order_by);
     return $this->db->get($this->table_name)->result_array();
 }
 /**
  * Crea una nueva conexión con la base de datos, de existir, una conexión no hace nada
  *
  * @author jonathan_s_pisis@yahoo.com.mx
  **/
 static function ConectarBD()
 {
     if (!isset(self::$mysqli_obj) || is_NULL(self::$mysqli_obj)) {
         $nombreDB = constant('NOMBRE_BASE_DATOS');
         $usuario = constant('USUARIO');
         $host = constant('HOST');
         $clave = constant('PASSWORD');
         self::$mysqli_obj = new mysqli($host, $usuario, $clave, $nombreDB);
         /* check connection */
         if (self::$mysqli_obj->connect_errno) {
             printf("Connect failed: %s\n", self::$mysqli_obj->connect_error);
             exit;
         }
     }
 }
Пример #9
0
 public function __construct($sourcePath, $logPath = NULL)
 {
     if (empty($sourcePath)) {
         $this->srcPath = getcwd();
     } else {
         $this->srcPath = $sourcePath;
     }
     if (is_NULL($logPath)) {
         $this->logPath = getcwd() . "/fo_integration.log";
         echo "DB: logpath is:{$this->logPath}\n";
     } else {
         $this->logPath = $logPath;
         echo "DB: logpath is:{$this->logPath}\n";
     }
     $this->LOGFD = fopen($this->logPath, 'a+');
     if ($this->LOGFD === FALSE) {
         $error = "Error! cannot open {$this->logPath}" . " File: " . __FILE__ . " on line: " . __LINE__;
         throw new exception($error);
     }
 }
Пример #10
0
 /**
  * Obtains a salting hashing method instance.
  *
  * This function will return an instance of a class that implements
  * tx_saltedpasswords_abstract_salts.
  *
  * Use parameter NULL to reset the factory!
  *
  * @param string $saltedHash (optional) Salted hashed password to determine the type of used method from or NULL to reset the factory
  * @param string $mode (optional) The TYPO3 mode (FE or BE) saltedpasswords shall be used for
  * @return tx_saltedpasswords_abstract_salts	an instance of salting hashing method object
  */
 public static function getSaltingInstance($saltedHash = '', $mode = TYPO3_MODE)
 {
     // Creating new instance when
     // * no instance existing
     // * a salted hash given to determine salted hashing method from
     // * a NULL parameter given to reset instance back to default method
     if (!is_object(self::$instance) || !empty($saltedHash) || is_NULL($saltedHash)) {
         // Determine method by checking the given hash
         if (!empty($saltedHash)) {
             $result = self::determineSaltingHashingMethod($saltedHash);
             if (!$result) {
                 self::$instance = NULL;
             }
         } else {
             $classNameToUse = \TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility::getDefaultSaltingHashingMethod($mode);
             $availableClasses = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/saltedpasswords']['saltMethods'];
             self::$instance = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($availableClasses[$classNameToUse], 'tx_');
         }
     }
     return self::$instance;
 }
Пример #11
0
 /**
  * fillGroupForm($groupName, $user)
  * \breif fill in the manage group fields
  *
  * @param string $groupName the name of the group to create
  * @param string $user the user who will admin the group.
  *
  * @return NULL on success, string on error
  */
 public function fillGroupForm($groupName, $user)
 {
     global $URL;
     if (is_NULL($groupName)) {
         $msg = "FATAL! no group name to set\n";
         $this->fail($msg);
         return $msg;
     }
     if (is_NULL($user)) {
         $msg = "FATAL! no user name to set\n";
         $this->fail($msg);
         return $msg;
     }
     // make sure we are on the page
     $page = $this->mybrowser->get("{$URL}?mod=group_manage");
     $this->assertTrue($this->myassertText($page, '/Manage Group/'), "Did NOT find Title, 'Manage Group'");
     $this->assertTrue($this->myassertText($page, '/Add a Group/'), "Did NOT find phrase, 'Add a Group'");
     // set the fields
     $groupNotSet = 'FATAL! Could Not set the groupname field';
     if (!empty($groupName)) {
         $this->assertTrue($this->mybrowser->setField('groupname', $groupName), $groupNotSet);
     }
     if (!empty($user)) {
         $userNotSet = 'FATAL! Could Not set the userid field in select';
         $this->assertTrue($this->mybrowser->setField('userid', $user), $userNotSet);
         //return($userNotSet);
     }
     return NULL;
 }
Пример #12
0
 /**
  * Evaluate postfix notation
  *
  * @param array $tokens
  *   The list of tokens that make up the expression.
  * @param array $vars
  *   The list of variables set previously.
  *
  * @return number
  *   The final result of the evaluation.
  */
 private function postfixEvaluate($tokens, $vars = array())
 {
     if ($tokens == FALSE) {
         return FALSE;
     }
     $stack = new EvalMathStack();
     foreach ($tokens as $token) {
         if (in_array($token, array('+', '-', '*', '/', '^'))) {
             if (is_NULL($op2 = $stack->pop())) {
                 return $this->trigger(t('internal error'));
             }
             if (is_NULL($op1 = $stack->pop())) {
                 return $this->trigger(t('internal error'));
             }
             switch ($token) {
                 case '+':
                     $stack->push($op1 + $op2);
                     break;
                 case '-':
                     $stack->push($op1 - $op2);
                     break;
                 case '*':
                     $stack->push($op1 * $op2);
                     break;
                 case '/':
                     if ($op2 == 0) {
                         return $this->trigger(t('division by zero'));
                     }
                     $stack->push($op1 / $op2);
                     break;
                 case '^':
                     $stack->push(pow($op1, $op2));
                     break;
             }
         } elseif ($token == "_") {
             $stack->push(-1 * $stack->pop());
         } elseif (preg_match("/^([a-z]\\w*)\\(\$/", $token, $matches)) {
             $fnn = $matches[1];
             if (array_key_exists($fnn, $this->funcAliases)) {
                 $fnn = $this->funcAliases[$fnn];
             }
             if (array_key_exists($fnn, $this->funcBuildIn)) {
                 $argCount = $this->funcBuildIn[$fnn];
                 $args = array();
                 for ($i = $argCount; $i > 0; $i--) {
                     $arg = $stack->pop();
                     if (is_NULL($arg)) {
                         return $this->trigger(t('internal error: argument is null'));
                     }
                     $args[] = $arg;
                     $args = array_reverse($args);
                 }
                 $stack->push(call_user_func_array($fnn, $args));
             } elseif (array_key_exists($fnn, $this->funcUser)) {
                 $args = array();
                 for ($i = count($this->funcUser[$fnn]['args']) - 1; $i >= 0; $i--) {
                     if (is_NULL($args[$this->funcUser[$fnn]['args'][$i]] = $stack->pop())) {
                         return $this->trigger(t('internal error: argument is null'));
                     }
                 }
                 $stack->push($this->postfixEvaluate($this->funcUser[$fnn]['func'], $args));
             }
         } else {
             if (is_numeric($token)) {
                 $stack->push($token);
             } elseif (array_key_exists($token, $this->variables)) {
                 $stack->push($this->variables[$token]);
             } elseif (array_key_exists($token, $vars)) {
                 $stack->push($vars[$token]);
             } else {
                 return $this->trigger(t('undefined variable "%token"', array('%token' => $token)));
             }
         }
     }
     if ($stack->getCount() != 1) {
         return $this->trigger(t('internal error, stack not empty'));
     }
     return $stack->pop();
 }
Пример #13
0
 /**
  * Method to return a language text element.
  *
  * @param  	string 	$itemName   The language code for the item to be looked up
  * @param  	string 	$modulename The module name that owns the string
  * @param 	bool	$default	Default text
  *
  * @return 	string	The language element
  */
 protected function l($itemName, $modulename = NULL, $default = FALSE)
 {
     if (!defined('CHISIMBA_CONTROLLER_OBJLANGUAGE_CREATED')) {
         define('CHISIMBA_CONTROLLER_OBJLANGUAGE_CREATED', TRUE);
         $this->_objLanguage = $this->getObject('language', 'language');
     }
     $module = is_NULL($modulename) ? $this->moduleName : $modulename;
     return $this->_objLanguage->languageText($itemName, $module, $default);
 }
Пример #14
0
 /**
  * 更新商品的货品信息,对应操作5
  * 干掉该商品的所有货品,再将平台上该商品的货品下载下来
  *
  * @param int $supplier_id
  * @param int $supplier_goods_id
  * @param int $command_id,更新列表的id
  * @return array ,array(
  *                  'type' => array(
  *                              $type_id => $type_name,
  *                              $type_id => $type_name
  *                          ),
  *                  'spec' => array(
  *                              $spec_id => $spec_name,
  *                              $spec_id => $spec_name
  *                          ),
  *                  'brand' => array(
  *                              'add' => array(
  *                                  $brand_id => $brand_name,
  *                                  $brand_id => $brand_name,
  *                              ),
  *                              'update' => array(
  *                                  $brand_id => $brand_name,
  *                                  $brand_id => $brand_name,
  *                              )
  *                          ),
  *                  'cat' => array(
  *                              $cat_id => $cat_path,
  *                              $cat_id => $cat_path
  *                          ),
  *                  'locals' => array(
  *                              'local_type_id' => $local_type_id,
  *                              'local_spec_id' => $local_spec_id,
  *                              'local_brand_id' => $local_brand_id
  *                          )
  *              )
  */
 function updateGoodsProduct($supplier_id, $supplier_goods_id, $command_id)
 {
     $return = $this->preDownload($supplier_id, $supplier_goods_id, $command_id);
     $local_goods_info = $this->db->selectrow("SELECT * FROM sdb_goods WHERE supplier_id=" . floatval($supplier_id) . " AND supplier_goods_id=" . intval($supplier_goods_id));
     $local_goods_id = $local_goods_info['goods_id'];
     $local_product_info = $this->db->select("SELECT * FROM sdb_products WHERE goods_id=" . $local_goods_id);
     /*
     //先删除商品的所有货品(比较流氓,开会讨论结果)、sdb_goods_spec_index记录、sdb_supplier_pdtbn记录
     $this->db->exec("DELETE FROM sdb_supplier_pdtbn WHERE local_bn IN (SELECT bn FROM sdb_products WHERE goods_id=".intval($local_goods_id).")");
     $this->db->exec("DELETE FROM sdb_products WHERE goods_id=".intval($local_goods_id));
     $this->db->exec("DELETE FROM sdb_goods_spec_index WHERE goods_id=".intval($local_goods_id));
     */
     //根据货号获取可对应的本地product_id,将对应不到的product_id删除相关记录
     $products = $this->api->getApiData('getProductsByGoodsID', API_VERSION, array('supplier_id' => $supplier_id, 'id' => $supplier_goods_id), true, true);
     $tmp_product_id = array();
     if (!empty($products)) {
         foreach ($products as $v) {
             $tmp = $this->db->selectrow("SELECT p.product_id FROM sdb_products AS p,sdb_supplier_pdtbn AS sp WHERE sp.source_bn='" . $v['bn'] . "' AND sp.supplier_id=" . intval($supplier_id) . " AND sp.local_bn=p.bn");
             if ($tmp) {
                 $tmp_product_id[] = $tmp['product_id'];
             }
         }
     }
     foreach ($local_product_info as $v) {
         if (!in_array($v['product_id'], $tmp_product_id)) {
             $this->db->exec("DELETE FROM sdb_supplier_pdtbn WHERE local_bn='" . $v['bn'] . "'");
             $this->db->exec("DELETE FROM sdb_products WHERE product_id=" . $v['product_id']);
             $this->db->exec("DELETE FROM sdb_goods_spec_index WHERE product_id=" . $v['product_id']);
         }
     }
     //删除商品的pdt_desc,spec_desc
     $rs = $this->db->query("SELECT * FROM sdb_goods WHERE supplier_id=" . $supplier_id . " AND supplier_goods_id=" . $supplier_goods_id);
     $sql = $this->db->GetUpdateSQL($rs, array('spec' => '', 'pdt_desc' => '', 'spec_desc' => ''));
     if ($sql) {
         $this->db->exec($sql);
     }
     $this->addProducts($supplier_id, $supplier_goods_id, $local_goods_id);
     //获取货品的总库存数,取货品最小销售价作为商品销售价,最小重量作为商品重量
     $product_info = $this->db->select("SELECT store,price,weight,cost FROM sdb_products WHERE goods_id=" . intval($local_goods_id));
     $store = 0;
     $price = NULL;
     $weight = NULL;
     $min_cost = NULL;
     foreach ($product_info as $product) {
         if (is_null($product['store']) || $product['store'] === '') {
             $store = NULL;
         } else {
             if (!is_null($store)) {
                 $store += $product['store'];
             }
         }
         if (is_null($price)) {
             $price = empty($product['price']) ? 0.0 : $product['price'];
         } else {
             $price = min($price, $product['price']);
         }
         if (is_null($weight)) {
             $weight = empty($product['weight']) ? 0.0 : $product['weight'];
         } else {
             $weight = min($weight, $product['weight']);
         }
         if (is_NULL($min_cost)) {
             $min_cost = $product['cost'];
         } else {
             $min_cost = min($min_cost, $product['cost']);
         }
     }
     $rs = $this->db->query("SELECT * FROM sdb_goods WHERE goods_id=" . intval($local_goods_id));
     $update_info = array('store' => $store, 'price' => $price, 'weight' => $weight, 'cost' => $min_cost);
     $sql = $this->db->GetUpdateSQL($rs, $update_info);
     $this->db->exec($sql);
     return $return;
 }
 /**
  * Retorna uma lista de registros filtrados de acordo com os parâmetros
  * @return array
  */
 function lista($int_cod_compensado = NULL, $int_ref_cod_escola = NULL, $int_ref_ref_cod_instituicao = NULL, $int_ref_cod_servidor = NULL, $int_ref_usuario_exc = NULL, $int_ref_usuario_cad = NULL, $date_data_inicio_ini = NULL, $date_data_inicio_fim = NULL, $date_data_fim_ini = NULL, $date_data_fim_fim = NULL, $date_data_cadastro_ini = NULL, $date_data_cadastro_fim = NULL, $date_data_exclusao_ini = NULL, $date_data_exclusao_fim = NULL, $int_ativo = NULL)
 {
     $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela}";
     $filtros = '';
     $whereAnd = ' WHERE ';
     if (is_numeric($int_cod_compensado)) {
         $filtros .= "{$whereAnd} cod_compensado = '{$int_cod_compensado}'";
         $whereAnd = ' AND ';
     }
     if (is_numeric($int_ref_cod_escola)) {
         $filtros .= "{$whereAnd} ref_cod_escola = '{$int_ref_cod_escola}'";
         $whereAnd = ' AND ';
     }
     if (is_numeric($int_ref_ref_cod_instituicao)) {
         $filtros .= "{$whereAnd} ref_ref_cod_instituicao = '{$int_ref_ref_cod_instituicao}'";
         $whereAnd = ' AND ';
     }
     if (is_numeric($int_ref_cod_servidor)) {
         $filtros .= "{$whereAnd} ref_cod_servidor = '{$int_ref_cod_servidor}'";
         $whereAnd = ' AND ';
     }
     if (is_numeric($int_ref_usuario_exc)) {
         $filtros .= "{$whereAnd} ref_usuario_exc = '{$int_ref_usuario_exc}'";
         $whereAnd = ' AND ';
     }
     if (is_numeric($int_ref_usuario_cad)) {
         $filtros .= "{$whereAnd} ref_usuario_cad = '{$int_ref_usuario_cad}'";
         $whereAnd = ' AND ';
     }
     if (is_string($date_data_inicio_ini)) {
         $filtros .= "{$whereAnd} data_inicio >= '{$date_data_inicio_ini}'";
         $whereAnd = ' AND ';
     }
     if (is_string($date_data_inicio_fim)) {
         $filtros .= "{$whereAnd} data_inicio <= '{$date_data_inicio_fim}'";
         $whereAnd = ' AND ';
     }
     if (is_string($date_data_fim_ini)) {
         $filtros .= "{$whereAnd} data_fim >= '{$date_data_fim_ini}'";
         $whereAnd = ' AND ';
     }
     if (is_string($date_data_fim_fim)) {
         $filtros .= "{$whereAnd} data_fim <= '{$date_data_fim_fim}'";
         $whereAnd = ' AND ';
     }
     if (is_string($date_data_cadastro_ini)) {
         $filtros .= "{$whereAnd} data_cadastro >= '{$date_data_cadastro_ini}'";
         $whereAnd = ' AND ';
     }
     if (is_string($date_data_cadastro_fim)) {
         $filtros .= "{$whereAnd} data_cadastro <= '{$date_data_cadastro_fim}'";
         $whereAnd = ' AND ';
     }
     if (is_string($date_data_exclusao_ini)) {
         $filtros .= "{$whereAnd} data_exclusao >= '{$date_data_exclusao_ini}'";
         $whereAnd = ' AND ';
     }
     if (is_string($date_data_exclusao_fim)) {
         $filtros .= "{$whereAnd} data_exclusao <= '{$date_data_exclusao_fim}'";
         $whereAnd = ' AND ';
     }
     if (is_NULL($int_ativo) || $int_ativo) {
         $filtros .= "{$whereAnd} ativo = '1'";
         $whereAnd = ' AND ';
     } else {
         $filtros .= "{$whereAnd} ativo = '0'";
         $whereAnd = ' AND ';
     }
     $db = new clsBanco();
     $countCampos = count(explode(',', $this->_campos_lista));
     $resultado = array();
     $sql .= $filtros . $this->getOrderby() . $this->getLimite();
     $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM {$this->_tabela} {$filtros}");
     $db->Consulta($sql);
     if ($countCampos > 1) {
         while ($db->ProximoRegistro()) {
             $tupla = $db->Tupla();
             $tupla['_total'] = $this->_total;
             $resultado[] = $tupla;
         }
     } else {
         while ($db->ProximoRegistro()) {
             $tupla = $db->Tupla();
             $resultado[] = $tupla[$this->_campos_lista];
         }
     }
     if (count($resultado)) {
         return $resultado;
     }
     return FALSE;
 }
Пример #16
0
 /**
  * PHP Calendar (version 2.3), written by Keith Devens
  * http://keithdevens.com/software/php_calendar
  * see example at http://keithdevens.com/weblog
  * License: http://keithdevens.com/software/license
  *
  * @param mixed   $year
  * @param mixed   $month
  * @param array   $days
  * @param integer $day_name_length
  * @param mixed   $month_href
  * @param integer $first_day
  * @param array   $pn
  * @return
  */
 public function generateCalendar($year, $month, $days = array(), $day_name_length = 3, $month_href = null, $first_day = 0, $pn = array())
 {
     $first_of_month = gmmktime(0, 0, 0, $month, 1, $year);
     // remember that mktime will automatically correct if invalid dates are entered
     // for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
     // this provides a built in "rounding" feature to generate_calendar()
     $day_names = array();
     //generate all the day names according to the current locale
     for ($n = 0, $t = (3 + $first_day) * 86400; $n < 7; $n++, $t += 86400) {
         $day_names[$n] = ucfirst(gmstrftime('%A', $t));
     }
     //%A means full textual day name
     list($month, $year, $month_name, $weekday) = explode(',', gmstrftime('%m,%Y,%B,%w', $first_of_month));
     $weekday = ($weekday + 7 - $first_day) % 7;
     //adjust for $first_day
     $title = htmlentities(ucfirst($month_name)) . '&nbsp;' . $year;
     //note that some locales don't capitalize month and day names
     // Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
     @(list($p, $pl) = each($pn));
     @(list($n, $nl) = each($pn));
     //previous and next links, if applicable
     if ($p) {
         $p = '<span class="calendar-prev">' . ($pl ? '<a href="' . htmlspecialchars($pl) . '">' . $p . '</a>' : $p) . '</span>&nbsp;';
     }
     if ($n) {
         $n = '&nbsp;<span class="calendar-next">' . ($nl ? '<a href="' . htmlspecialchars($nl) . '">' . $n . '</a>' : $n) . '</span>';
     }
     $calendar = '<table class="calendar">' . "\n" . '<caption class="calendar-month">' . $p . ($month_href ? '<a href="' . htmlspecialchars($month_href) . '">' . $title . '</a>' : $title) . $n . "</caption>\n<tr>";
     if ($day_name_length) {
         // if the day names should be shown ($day_name_length > 0)
         // if day_name_length is >3, the full name of the day will be printed
         foreach ($day_names as $d) {
             $calendar .= '<th abbr="' . htmlentities($d) . '">' . htmlentities($day_name_length < 4 ? substr($d, 0, $day_name_length) : $d) . '</th>';
         }
         $calendar .= "</tr>\n<tr>";
     }
     if ($weekday > 0) {
         for ($i = 1; $i <= $weekday; $i++) {
             $calendar .= '<td class="noDay">&nbsp;</td>';
         }
     }
     for ($day = 1, $days_in_month = gmdate('t', $first_of_month); $day <= $days_in_month; $day++, $weekday++) {
         if ($weekday == 7) {
             $weekday = 0;
             //start a new week
             $calendar .= "</tr>\n<tr>";
         }
         if (isset($days[$day]) and is_array($days[$day])) {
             @(list($link, $classes, $content) = $days[$day]);
             if (is_NULL($content)) {
                 $content = $day;
             }
             $calendar .= '<td' . ($classes ? ' class="' . htmlspecialchars($classes) . '">' : '>') . ($link ? '<a href="' . htmlspecialchars($link) . '">' . $content . '</a>' : $content) . '</td>';
         } else {
             $calendar .= "<td>{$day}</td>";
         }
     }
     if ($weekday != 7) {
         for ($i = 1; $i <= 7 - $weekday; $i++) {
             $calendar .= '<td class="noDay">&nbsp;</td>';
         }
     }
     return $calendar . "</tr>\n</table>\n";
 }
Пример #17
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     $view = $this->getView();
     $CssClass = NULL;
     if ($this->sbLeft) {
         $CssClass = 'sb-slidebar sb-left';
         if ($this->sbStatic) {
             $CssClass .= ' sb-static';
         }
         if ($this->sbStylePush) {
             $CssClass .= ' sb-style-push';
         } else {
             $CssClass .= ' sb-style-overlay';
         }
         if (!is_null($this->sbWidth)) {
             $CssClass .= ' sb-width-custom';
         }
         echo Html::beginTag('div', ['class' => $CssClass, is_NULL($this->sbWidth) ? NULL : 'data-sb-width' => $this->sbWidth]) . "\n";
         if (isset($view->blocks['sb-left'])) {
             echo $view->blocks['sb-left'];
         }
         echo Html::endTag('div') . "\n";
     }
     if ($this->sbRight) {
         $CssClass = 'sb-slidebar sb-right';
         if ($this->sbStatic) {
             $CssClass .= ' sb-static';
         }
         if ($this->sbStylePush) {
             $CssClass .= ' sb-style-push';
         } else {
             $CssClass .= ' sb-style-overlay';
         }
         if (!is_null($this->sbWidth)) {
             $CssClass .= ' sb-width-custom';
         }
         echo Html::beginTag('div', ['class' => $CssClass, is_NULL($this->sbWidth) ? NULL : 'data-sb-width' => $this->sbWidth]) . "\n";
         if (isset($view->blocks['sb-right'])) {
             echo $view->blocks['sb-right'];
         }
         echo Html::endTag('div') . "\n";
     }
     $this->registerPlugin();
 }
</p>

<?php 
//create connection
$db_connection = mysql_connect("localhost", "cs143", "");
//check connection
if (!$db_connection) {
    $errmsg = mysql_error($db_connection);
    print "Connection failed: {$errmsg} <br/>";
    exit(1);
}
//Choose db
$query = $_GET["query"];
echo "{$query}" . "<br/>";
//if(mysql_errno($db_connection)!=0){
if (!is_NULL($query)) {
    mysql_select_db("CS143", $db_connection);
    mysql_query($query, $db_connection);
    echo "<h3>Result from MySQL: </h3>" . mysql_error($db_connection) . "<br/>";
}
$rs = mysql_query($query, $db_connection);
/*if (!is_null($query) &&  !mysql_errno($db_connection) && !$rs) {
    echo '<b>Sorry! Could not run this query. </b>' ;
    exit(1);
}*/
echo "<table>";
echo "<tr>";
//$row =mysql_fetch_row($rs)
while ($col = mysql_fetch_field($rs)) {
    echo "<th>" . "{$col->name}" . "</th>";
}
Пример #19
0
/**
 * \brief meta function to process cunit reports
 *
 * @param string $unitTest the unit test to process
 *
 * @return mixed NULL on success, newline terminated string on failure
 */
function processCUnit($unitTest)
{
    global $failures;
    global $other;
    $unitTest = preg_replace('#/#', '-', $unitTest);
    $libphp = "lib-php";
    /** ignore lib/php/tests */
    if ($libphp === $unitTest) {
        return NULL;
    }
    if (empty($unitTest)) {
        return "Error! no valid input at line " . __FILE__ . " at line " . __LINE__ . "\n";
    }
    foreach (glob("{$unitTest}*.xml") as $fName) {
        $fileName = lcfirst($fName);
        // Skip Listing files
        if (preg_grep("/Listing/", array($fileName))) {
            $rmlast = exec("rm {$fileName}", $rmOut, $rmRtn);
            continue;
        }
        if (!tweakCUnit($fileName)) {
            return "Error! could not save processed xml file, they may not display properly\n";
        }
        $errors = array();
        // defect: if the report is corrupt, checkCUnit will say everything is OK.
        $errors = checkCUnit($fileName);
        //echo "DB: after checkCUnit, errors for $unitTest are\n";print_r($errors) .  "\n";
        if (is_object($errors[0])) {
            $failures++;
            echo "There were Unit Test Failures in {$unitTest}\n";
            //print_r($errors) . "\n";
        } else {
            if (!is_NULL($errors)) {
                // if we can't even check the file, then skip making the report
                $failures++;
                return "Failure: Could not check file {$fileName} for failures is the file corrupt?\n";
            }
        }
        if (!genCunitRep($fileName)) {
            return "Error!, could not generate html report for {$unitTest}\n";
        }
    }
    // foreach
    return NULL;
}
Пример #20
0
 /**
  *  Get Connection
  *
  *  Get a valid database connection
  *
  *  @return MongoConnection
  */
 protected final function _getConnection()
 {
     if (is_NULL(self::$_conn)) {
         if (is_NULL(self::$_host)) {
             self::$_host = 'localhost';
         }
         self::$_conn = new Mongo(self::$_host);
     }
     if (isset($this)) {
         $dbname = $this->getDatabaseName();
     } else {
         $dbname = self::getDatabaseName();
     }
     if (!isset(self::$_dbs[$dbname])) {
         self::$_dbs[$dbname] = self::$_conn->selectDB($dbname);
     }
     if (!is_null(self::$_user) && !is_null(self::$_pwd)) {
         self::$_dbs[$dbname]->authenticate(self::$_user, self::$_pwd);
     }
     return self::$_dbs[$dbname];
 }
 /**
  * Load an xml locallang file
  *
  * @param string $LLFile
  * @param string $langKey
  * @param array  $confLL
  * @return array
  */
 public function loadLL($LLFile, $langKey = null, $confLL = null)
 {
     $tsfeLoaded = isset($GLOBALS['TSFE']) && is_object($GLOBALS['TSFE']);
     $langLoaded = isset($GLOBALS['LANG']) && is_object($GLOBALS['LANG']);
     // Lang detection
     if (is_NULL($langKey)) {
         if ($tsfeLoaded) {
             $langKey = $GLOBALS['TSFE']->lang;
         } elseif ($langLoaded) {
             $langKey = $GLOBALS['LANG']->lang;
         }
     }
     // Render Charset
     if ($langLoaded) {
         $renderCharset = $GLOBALS['LANG']->charSet;
     } elseif ($tsfeLoaded) {
         $renderCharset = $GLOBALS['TSFE']->renderCharset;
     }
     // Language list
     $LLArray = array();
     $langLoadList = array_unique(array('default', $langKey));
     // Loads locallang file
     if (@is_file($LLFile)) {
         $useXliff = \TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('4.6');
         if ($useXliff) {
             $localizationParser = TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Localization\\Parser\\LocallangXmlParser');
             $LOCAL_LANG_xliff = $localizationParser->getParsedData($LLFile, end($langLoadList), $renderCharset);
             $LOCAL_LANG = array();
             foreach ($LOCAL_LANG_xliff as $currentLang => $langElements) {
                 foreach ($langElements as $key => $value) {
                     $LOCAL_LANG[$currentLang][$key] = !empty($value[0]['target']) ? $value[0]['target'] : $value[0]['source'];
                 }
             }
         } else {
             $parser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Localization\\Parser\\LocallangXmlParser');
             $LOCAL_LANG = $parser->getParsedData($LLFile, $GLOBALS['LANG']->lang);
         }
     } else {
         $LOCAL_LANG = array();
     }
     // Process default langage and requested langage
     foreach ($langLoadList as $tLangKey) {
         if (isset($LOCAL_LANG[$tLangKey]) && is_array($LOCAL_LANG[$tLangKey])) {
             $LLArray[$tLangKey] = count($LLArray[$tLangKey]) ? array_merge($LLArray[$tLangKey], $LOCAL_LANG[$tLangKey]) : $LOCAL_LANG[$tLangKey];
         }
     }
     // Merge arrays (requested langage(s) overrides default language)
     $finalRes = array();
     foreach ($langLoadList as $v) {
         if (isset($LLArray[$v])) {
             $finalRes = array_merge($finalRes, $LLArray[$v]);
             unset($LLArray[$v]);
             // Overlaying labels from TypoScript
             if (is_array($confLL)) {
                 if (!empty($confLL[$v . '.'])) {
                     $finalRes = array_merge($finalRes, $confLL[$v . '.']);
                 }
             }
         }
     }
     unset($LLArray);
     return $finalRes;
 }
Пример #22
0
<?php

include 'cd.php';
ini_set('max_execution_time', '3600');
ob_start();
$CurrentUser = Authentication::Authenticate();
if (!$CurrentUser->hasPermission(RIGHT_EXPORT_CSV)) {
    $e = new Error(RIGHTS_ERR_USERNOTALLOWED);
    Error::AddError($e);
    HTMLstuff::RefererRedirect();
}
$ModelID = Utils::SafeIntFromQS('model_id');
$includepath = Utils::SafeIntFromQS('includepath');
$includepath = in_array($includepath, array(EXPORT_PATH_OPTION_NONE, EXPORT_PATH_OPTION_RELATIVE, EXPORT_PATH_OPTION_FULL)) ? $includepath : EXPORT_PATH_OPTION_NONE;
$Models = Model::GetModels(new ModelSearchParameters(is_NULL($ModelID) ? FALSE : $ModelID));
$Sets = Set::GetSets(new SetSearchParameters(FALSE, FALSE, is_null($ModelID) ? FALSE : $ModelID));
$outfile = 'CandyDollDB.csv';
if ($ModelID && count($Models) > 0) {
    $Model = $Models[0];
    $outfile = sprintf('CandyDollDB %1$s.csv', $Model->GetFullName());
}
header(sprintf('Content-type: %1$s', Utils::GetMime('csv')));
header(sprintf('Content-Disposition: attachment; filename="%1$s"', $outfile));
$commentarray = array(sprintf("Generated by CandyDollDB v%1\$s on %2\$s at %3\$s", CANDYDOLLDB_VERSION, date('Y-m-d'), date('H:i;s')), sprintf("Author: %1\$s", $CurrentUser->getUserName()), "Project website: https://code.google.com/p/candydolldb/");
$commentcount = count($commentarray);
$x = 0;
/* @var $Model Model */
foreach ($Models as $Model) {
    if ($ModelID && $Model->getID() !== $ModelID) {
        continue;
    }
Пример #23
0
 /**
  * soll später einen mysql query verlinken um seine ergebnisse angezeigt zu bekommen
  *
  * @return string
  * @author annemarie
  **/
 function link_querys($old_query, $key = NULL, $function = NULL, $href = 'javascript:FUNCTION;')
 {
     if (preg_match('/(javascript:)(FUNCTION)(;)/i', $href, $match) and !is_NULL($function) or preg_match('/(javascript:)(FUNCTION)(;)/i', $href, $match)) {
         $href = $match[1] . 'alert(' . $key . ')' . $match[3];
     }
     $new_query = '';
     $new_query = '<a href="';
     $new_query .= $href;
     $new_query .= '" title="Query ausf&uuml;hren">QUERY #' . $key . ' ' . $old_query;
     $new_query .= '</a>';
     return $new_query;
 }
Пример #24
0
 function json_encode($data)
 {
     if (is_object($data)) {
         //对象转换成数组
         $data = get_object_vars($data);
     } else {
         if (!is_array($data)) {
             // 普通格式直接输出
             return format_json_value($data);
         }
     }
     // 判断是否关联数组
     if (empty($data) || is_numeric(implode('', array_keys($data)))) {
         $assoc = FALSE;
     } else {
         $assoc = TRUE;
     }
     // 组装 Json字符串
     $json = $assoc ? '{' : '[';
     foreach ($data as $key => $val) {
         if (!is_NULL($val)) {
             if ($assoc) {
                 $json .= "\"{$key}\":" . json_encode($val) . ",";
             } else {
                 $json .= json_encode($val) . ",";
             }
         }
     }
     if (strlen($json) > 1) {
         // 加上判断 防止空数组
         $json = substr($json, 0, -1);
     }
     $json .= $assoc ? '}' : ']';
     return $json;
 }
Пример #25
0
 /**
  * creates the JSON for the dhtmlx tree object
  * @param  integer $id     The id of the current id
  * @param  integer $rootId The id of the shown root node
  * @return JSON         Returns a json array, that can be parsed by dhtmlx tree component
  */
 public function actionJsontreeview($id = NULL, $rootId = NULL)
 {
     $data = array();
     if (!is_NULL($rootId) and is_null($id)) {
         $data = Page::rootTreeAsArray($rootId);
     } else {
         $data = Page::nodeChildren($id, true);
     }
     return Yii::$app->response->sendContentAsFile(Json::encode($data), 'tree.json', 'application/json');
     exit;
 }
Пример #26
0
 /**
  * Method sets minimum allowed log2 number of iterations for password stretching.
  *
  * @param int $minHashCount Minimum allowed log2 number of iterations for password stretching to set
  * @see MIN_HASH_COUNT
  * @see $minHashCount
  * @see getMinHashCount()
  */
 public function setMinHashCount($minHashCount = NULL)
 {
     self::$minHashCount = !is_NULL($minHashCount) && is_int($minHashCount) ? $minHashCount : self::MIN_HASH_COUNT;
 }
Пример #27
0
 /**
  * list all tables in the current database
  *
  * @return mixed  data array on success, a MDB2 error on failure
  * @access public
  */
 public function listDbTables()
 {
     if ($this->dbLayer === 'MDB2') {
         $ret = $this->_db->mgListTables();
         return $ret;
     } elseif ($this->dbLayer === 'PDO') {
         if ($this->objEngine->pdsn['phptype'] == 'pgsql') {
             $sql = "select * from information_schema.tables where table_schema='public' and table_type='BASE TABLE'";
             try {
                 $ret = $this->query($sql);
             } catch (PDOException $e) {
                 throw new customException($e->getMessage());
                 customException::cleanUp();
                 exit;
             }
             foreach ($ret as $tables) {
                 $tbls[] = $tables['table_name'];
             }
             return $tbls;
         } elseif ($this->objEngine->pdsn['phptype'] == 'mysql' || $this->objEngine->pdsn['phptype'] == 'mysqli') {
             $query = "SHOW /*!50002 FULL*/ TABLES";
             if (!is_NULL($this->objEngine->pdsn['database'])) {
                 $database = $this->objEngine->pdsn['database'];
                 $query .= " FROM {$database}";
             }
             $query .= "/*!50002  WHERE Table_type = 'BASE TABLE'*/";
             try {
                 $ret = $this->query($query);
             } catch (PDOException $e) {
                 throw new customException($e->getMessage());
                 customException::cleanUp();
                 exit;
             }
             foreach ($ret as $tables) {
                 $tbls[] = $tables[0];
             }
             return $tbls;
         }
     }
 }