示例#1
0
 public function getCategorys()
 {
     $sql = "SELECT category_name FROM " . self::$categoryTable;
     $result = $this->conn->query($sql);
     if ($result->num_rows > 0) {
         while ($row = $result->fetch_assoc()) {
             Array_push($this->categoryArray, $row["category_name"]);
         }
     } else {
         throw new NoCategorysException();
     }
     return $this->categoryArray;
 }
// to infinity
// fetch url request params
$api_headers = "";
$api_debug = false;
$headersArray = [];
$query = [];
$api_body = "";
$api_form = "JSON";
// default if this is not passed
$api_timeout = 60;
// timeout seconds default if not passed, else use passed value
// ============   convert all the REQUEST params into local $Vars ============
foreach ($_REQUEST as $key => $value) {
    //   add any headers
    if (substr($key, 0, 10) == "api_header") {
        Array_push($headersArray, $value);
    } elseif (substr($key, 0, 4) == "api_") {
        ${$key} = $value;
    } else {
        $query[$key] = $value;
        // build query array with NON api_* params
    }
}
debug("\$_REQUEST", $_REQUEST);
//  Check for missing needed Params
if (!isset($api_url) || !isset($api_mode)) {
    die("Error: Missing parameters required: api_url, api_mode,  ");
}
// if a file was passed, pass it along too
if (count($_FILES)) {
    debug("\$_File submitted:", $_FILES);
    ${$key} = $value;
}
// ================ Uncomment to show request params Array =============
//print_r($_REQUEST);
//exit();
//  Check for missing needed Params
if (!isset($api_mode) or !isset($api_url) or !isset($api_user) or !isset($api_pass)) {
    die("Error: Missing parameters");
}
// Convert Headers to array if any for cURL
if (isset($api_headers)) {
    $headers_array = explode("~", $api_headers);
}
// add any additional headers
Array_push($headersArray, $api_form == "XML" ? "Content-type: application/xml" : "Content-type: application/json");
Array_push($headersArray, $api_form == "XML" ? "Accept: application/xml" : "Accept: application/json");
// Add any request parameters in from the Request array but leave out the ones we use locally
$query = $_REQUEST;
// unset (remove) any local items that dont need to be passed through
unset($query['api_mode'], $query['api_url'], $query['api_user'], $query['api_pass'], $query['api_form'], $query['api_headers'], $query['api_body'], $query['api_timeout'], $query['__utma'], $query['__utmz']);
if (is_array($query)) {
    $api_url .= '?' . http_build_query($query);
    // add parameters to the URL
}
// ============ Make the Call ======================
$ch = curl_init($api_url);
//open connection
// curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0"); // if we want to pass a specific browser agent
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//optional, sends response to a variable
// curl_setopt($curl, CURLOPT_HEADER, false ); 	//True if we are to include the header in the output from the foreign call
 function getSkillByAtomUid($id)
 {
     foreach ($this->character->ego->skills as $sk) {
         if (strcmp($sk->getUid(), $id) == 0) {
             return $sk;
         }
     }
     Array_push($this->errorList, new EPCreatorErrors('EPCharacterCreator:' . __LINE__ . ' (This skill not exist !)', EPCreatorErrors::$SYSTEM_ERROR));
     return null;
 }
示例#5
0
文件: proxy.php 项目: kailIII/pos-erp
               // estos precios si vienen de la tabla de
               // actualizacion de precio
               "precioIntersucursal" => $p->getPrecio(),
               "precioIntersucursalProcesado" => $p->getPrecio()
               ));
     
     
               }
     
               $json = json_encode($json);
     
               printf('{ "success": true, "hash" : "%s" , "datos": %s }', md5($json), $json); */
     $inventario = ProductoDAO::getAll();
     $json = array();
     foreach ($inventario as $producto) {
         Array_push($json, array("productoID" => $producto->getIdProducto(), "descripcion" => $producto->getNombreProducto(), "tratamiento" => 0, "medida" => UnidadMedidaDAO::getByPK($producto->getIdUnidad())->getAbreviacion(), "agrupacion" => UnidadMedidaDAO::getByPK($producto->getIdUnidad())->getAbreviacion(), "agrupacionTam" => 1, "precioPorAgrupacion" => $producto->getPrecio(), "precioVenta" => $producto->getPrecio(), "precioVentaProcesado" => $producto->getPrecio(), "existencias" => 0, "existenciasOriginales" => 0, "existenciasProcesadas" => 0, "precioIntersucursal" => $producto->getPrecio(), "precioIntersucursalProcesado" => $producto->getPrecio()));
     }
     $json = json_encode($json);
     printf('{ "success": true, "hash" : "%s" , "datos": %s }', md5($json), $json);
     break;
 case 500:
     require_once 'controller/personal.controller.php';
     break;
 case 600:
     require_once 'controller/efectivo.controller.php';
     break;
 case 700:
     require_once 'controller/sucursales.controller.php';
     break;
 case 800:
     require_once 'controller/ventas.controller.php';
示例#6
0
 /**
  * @return string - $this->_view
  *
  * Doing search and build page with results
  */
 public function index()
 {
     //check index
     $this->__checkIndex();
     $minInput = $this->Register['Config']->read('min_lenght', $this->module);
     if (!empty($minInput)) {
         $this->minInputStr = (int) $minInput;
     }
     $html = null;
     $error = null;
     $results = null;
     if (isset($_POST['m'])) {
         $modules = array();
         foreach ($_POST['m'] as $m) {
             if ($m == 'forum' or $m == 'news' or $m == 'stat' or $m == 'loads') {
                 Array_push($modules, $m);
             }
         }
     } else {
         $modules = array('forum', 'news', 'stat', 'loads');
     }
     $_SESSION['m'] = $modules;
     if (isset($_POST['search']) || isset($_GET['search'])) {
         $str = isset($_POST['search']) ? h($_POST['search']) : '';
         if (empty($str)) {
             $str = isset($_GET['search']) ? h($_GET['search']) : '';
         }
         if (!is_string($str)) {
             $str = (string) $str;
         }
         $str = trim($str);
         if (empty($str) || mb_strlen($str) < $this->minInputStr) {
             $error = $error . '<li>' . sprintf(__('Very small query'), $this->minInputStr) . '</li>';
         }
         if ($this->cached) {
             $this->cacheKey .= '_' . md5($str);
             if ($this->Cache->check($this->cacheKey)) {
                 $html = $this->Cache->read($this->cacheKey);
                 return $this->_view($html);
             }
         }
         $_SESSION['search_query'] = $str;
         if (!empty($error)) {
             $_SESSION['FpsForm'] = array();
             $_SESSION['FpsForm']['errors'] = $error;
             redirect($this->getModuleURL());
         }
         $str = Plugins::intercept('before_search', $str);
         $results = $this->__search($str, $modules);
         $results = Plugins::intercept('search_results', $results);
         if (count($results) && is_array($results)) {
             foreach ($results as $result) {
                 if (preg_match('#(.{0,100}' . $str . '.{0,100})#miu', $result->getIndex(), $match)) {
                     $announce = $match[1];
                 } else {
                     $announce = mb_substr($result->getIndex(), 0, 150);
                 }
                 $title = h($result->getEntity_title());
                 $announce = str_replace($str, '<strong>' . $str . '</strong>', h($announce));
                 $entry_url = get_url('/' . $result->getModule() . $result->getEntity_view() . $result->getEntity_id());
                 $result->setEntry_url($entry_url);
                 $result->setTitle($title);
                 $result->setAnnounce($announce);
             }
         } else {
             $error = __('No results');
             // TODO
         }
     } else {
         $_SESSION['search_query'] = '';
     }
     // Nav block
     $nav = array();
     $nav['navigation'] = get_link(__('Home'), '/') . __('Separator') . $this->module_title;
     $this->_globalize($nav);
     if (!empty($str)) {
         $this->addToPageMetaContext('entity_title', $str);
     }
     $this->returnForm = false;
     $form = $this->form();
     $source = $this->render('search_list.html', array('context' => array('results' => $results, 'form' => $form, 'error' => $error)));
     //write into cache
     if ($this->cached && !empty($str)) {
         //set users_id that are on this page
         $this->setCacheTag(array('search_str_' . $str));
         $this->cacheKey .= '_' . md5($str);
         $this->Cache->write($source, $this->cacheKey, $this->cacheTags);
     }
     return $this->_view($source);
 }
 //  print " You : ";
 //  fscanf(STDIN, "%s", $in);
 // 入力状態を保管
 switch ($input_data) {
     case 'exit':
         $qStateTemp = "Exit";
         break;
     default:
         $noun = exec('echo ' . $input_data . '| mecab | grep "名詞" | cut -f 1| uniq -c', $ma);
         if (is_array($ma)) {
             // 名詞を抜き出す
             //var_dump($ma);
             for ($i = 0; $i < count($ma); $i++) {
                 $replace = substr($ma[$i], MECAB_STRING_CUT_LENGTH, strlen($ma[$i]) - MECAB_STRING_CUT_LENGTH);
                 if (strcmp($replace, "私") != 0 && strcmp($replace, "する") != 0 && strcmp($replace, "こと") != 0) {
                     Array_push($string_Array, $replace);
                 }
             }
         } else {
             // 名詞確定
             $oneSentence = substr($input_data, MECAB_STRING_CUT_LENGTH, strlen($input_data) - MECAB_STRING_CUT_LENGTH);
         }
         if ($oneSentence == -1) {
             $bindStrings = "";
             for ($i = 0; $i < count($string_Array); $i++) {
                 //ユーザが入力した単語を全て表示
                 // print $string_Array[$i]."\n";
                 $bindStrings .= $string_Array[$i];
             }
             //ユーザが入力した単語に連続する名詞があれば繋げて表示
             $resultCode = nouns_from_wiki($bindStrings);