function get_category_info($catid)
{
    global $mysql_table_prefix;
    $categories['main_list'] = sql_fetch_all("SELECT * FROM " . $mysql_table_prefix . "categories ORDER BY category");
    if (is_array($categories['main_list'])) {
        foreach ($categories['main_list'] as $_val) {
            $categories['categories'][$_val['category_id']] = $_val;
            $categories['subcats'][$_val['parent_num']][] = $_val;
        }
    }
    $categories['subcats'] = $categories['subcats'][$_REQUEST['catid']];
    /* count sites */
    if (is_array($categories['subcats'])) {
        foreach ($categories['subcats'] as $_key => $_val) {
            $categories['subcats'][$_key]['count'] = sql_fetch_all('SELECT count(*) FROM ' . $mysql_table_prefix . 'site_category WHERE 	category_id=' . (int) $_val['category_id']);
        }
    }
    /* make tree */
    $_parent = $catid;
    while ($_parent) {
        $categories['cat_tree'][] = $categories['categories'][$_parent];
        $_parent = $categories['categories'][$_parent]['parent_num'];
    }
    $categories['cat_tree'] = array_reverse($categories['cat_tree']);
    /* list category sites */
    $categories['cat_sites'] = sql_fetch_all('SELECT url, title, short_desc FROM ' . $mysql_table_prefix . 'sites, ' . $mysql_table_prefix . 'site_category WHERE category_id=' . $catid . ' AND ' . $mysql_table_prefix . 'sites.site_id=' . $mysql_table_prefix . 'site_category.site_id order by title');
    return $categories;
}
示例#2
0
function get_discount_action($id_article)
{
    require_once _DIR_PLUGIN_PDK . 'classes/models/PdkRubriqueModel.php';
    $s = 'select * from spip_articles where id_article = ' . $id_article;
    $res = sql_query($s);
    $all = sql_fetch_all($res);
    $id_rubrique = isset($all[0]['id_rubrique']) ? $all[0]['id_rubrique'] : '';
    $id_r = $id_rubrique;
    $rubrique_mdl = new PdkRubriqueModel();
    $rubriques = '';
    do {
        // get all parents id
        $rubrique = $rubrique_mdl->select_by_id($id_rubrique);
        $id_rubrique = $rubrique['id_parent'];
        $rubriques[] = $id_rubrique;
    } while ($id_rubrique != '0');
    $quantity = isset($cart['quantity']) ? (int) $cart['quantity'] : 0;
    $price = isset($cart['price']) ? $cart['price'] : 0;
    $sql = "SELECT * FROM `spip_ecatalogue_discount_signs` t \r\n         JOIN spip_ecatalogue_discount_rules r ON t.id_rule = r.id_rule\r\n\r\n          WHERE\r\n             '" . date("Y-m-d H:i:s") . "' between r.date_start and r.date_end and  \r\n           (`t`.`object`='id_goods' and `t`.`value`='" . $id_article . "')";
    if ($id_r) {
        $sql .= " OR\r\n           (`t`.`object`='id_rubrique' and `t`.`value`='" . $id_r . "') ";
    }
    if (is_array($rubriques)) {
        foreach ($rubriques as $key => $value) {
            if ($value != 0) {
                $sql .= " OR\r\n           (`t`.`object`='id_rubrique' and `t`.`value`='" . $value . "') ";
            }
        }
    }
    if ($visiteur) {
        $sql .= " OR\r\n           (`t`.`object`='visiteur' and `t`.`value`='" . $visiteur . "') ";
    }
    if ($quantity) {
        $sql .= " OR\r\n           (`t`.`object`='quantity' and `t`.`value`='" . $quantity . "') ";
    }
    if ($price) {
        $sql .= "OR\r\n           (`t`.`object`='price' and `t`.`value`<='" . $price . "')";
    }
    $sql .= " LIMIT 1 ";
    //ppr($sql);
    //echo '<pre>';
    //print_r($sql);
    //echo '</pre>';
    $pre_res = sql_query($sql);
    $res_rule = sql_fetch_all($pre_res);
    $action = isset($res_rule[0]['action']) ? $res_rule[0]['action'] : '';
    $value = isset($res_rule[0]['value']) ? $res_rule[0]['value'] : '';
    return array('action' => $action, 'value' => $value);
}
function balise_ECATALOGUE_OPTION_FILTER_RESULT_dyn($template = 'balise/ecatalogue_option_filter_result', $params = array())
{
    include_spip('functions/pdk_url');
    $query = "SELECT A.id_article FROM spip_articles A ";
    $id_options = _request('id_option');
    $clear_options = array();
    if (!empty($id_options)) {
        foreach ($id_options as $id_option) {
            if (!$id_option == intval($id_option)) {
                continue;
            }
            $clear_options[] = $id_option;
        }
    }
    $clear_options = array_unique($clear_options);
    if (!empty($clear_options)) {
        $query .= 'INNER join spip_ecatalogue_articles_options as AO ON A.id_article=AO.id_article WHERE id_option in (' . implode(',', $clear_options) . ')';
    }
    $articles_ids = sql_fetch_all(sql_query($query));
    return array($template, 0, array_merge(array('articles_ids' => $articles_ids), $params));
}
function formulaires_ecatalogue_article_prices_traiter_dist($id_article)
{
    $result = array();
    $prices = _request('price');
    $id_article = _request('id_article');
    if (is_array($prices)) {
        foreach ($prices as $group => $price) {
            $sql_s = '';
            $sql_s = 'select * from spip_ecatalogue_prices where id_article = ' . $id_article . ' and id_group = ' . $group;
            $res = sql_query($sql_s);
            $record = '';
            $record = sql_fetch_all($res);
            if (is_array($record) && !empty($record)) {
                $sql_iu = 'Update spip_ecatalogue_prices set price = ' . $price . ' where id_article = ' . $id_article . ' and id_group = ' . $group;
            } else {
                $sql_iu = 'Insert into spip_ecatalogue_prices (id_article,id_group,price) value(' . $id_article . ',' . $group . ',' . $price . ')';
            }
            sql_query($sql_iu);
        }
    }
    return $result;
}
/**
 * Retourne le tableau de toutes les lignes d'une selection
 *
 * Retourne toutes les lignes de resultat d'une selection
 * comme si l'on appelait successivement sql_select() puis while(sql_fetch())
 *
 * @example
 *    ```
 *    $rubs = sql_allfetsel('id_rubrique', 'spip_articles', 'id_secteur='.sql_quote($id_secteur));
 *    // $rubs = array(array('id_rubrique'=>1), array('id_rubrique'=>3, ...)
 *    ```
 *
 * @api
 * @uses sql_select()
 * @uses sql_fetch()
 *
 * @param array|string $select
 *    Liste des champs a recuperer (Select)
 * @param array|string $from
 *    Tables a consulter (From)
 * @param array|string $where
 *    Conditions a remplir (Where)
 * @param array|string $groupby
 *    Critere de regroupement (Group by)
 * @param array|string $orderby
 *    Tableau de classement (Order By)
 * @param string $limit
 *    Critere de limite (Limit)
 * @param array $having
 *    Tableau des des post-conditions a remplir (Having)
 * @param string $serveur
 *    Le serveur sollicite (pour retrouver la connexion)
 * @param bool|string $option
 *    Peut avoir 3 valeurs :
 *    - true -> executer la requete.
 *    - continue -> ne pas echouer en cas de serveur sql indisponible.
 *    - false -> ne pas l'executer mais la retourner.
 *
 * @return array
 *    Tableau de toutes les lignes de resultat de la selection
 *    Chaque entree contient un tableau des elements demandees dans le SELECT.
 *    {@example
 *      ```
 *      array(
 *        array('id_rubrique' => 1, 'id_secteur' => 2)
 *        array('id_rubrique' => 4, 'id_secteur' => 2)
 *        ...
 *      )
 *      ```
 *    }
 *
 **/
function sql_allfetsel($select = array(), $from = array(), $where = array(), $groupby = array(), $orderby = array(), $limit = '', $having = array(), $serveur = '', $option = true)
{
    $q = sql_select($select, $from, $where, $groupby, $orderby, $limit, $having, $serveur, $option);
    if ($option === false) {
        return $q;
    }
    return sql_fetch_all($q, $serveur, $option);
}
示例#6
0
文件: search.php 项目: dubems/Jabros
if ($results != "") {
    $results_per_page = $results;
}
if (get_magic_quotes_gpc() == 1) {
    $query = stripslashes($query);
}
if (!is_numeric($catid)) {
    $catid = "";
}
if (!is_numeric($category)) {
    $category = "";
}
if ($catid && is_numeric($catid)) {
    $tpl_['category'] = sql_fetch_all('SELECT category FROM ' . $mysql_table_prefix . 'categories WHERE category_id=' . (int) $_REQUEST['catid']);
}
$count_level0 = sql_fetch_all('SELECT count(*) FROM ' . $mysql_table_prefix . 'categories WHERE parent_num=0');
$has_categories = 0;
if ($count_level0) {
    $has_categories = $count_level0[0][0];
}
require_once "{$template_dir}/{$template}/search_form.html";
function getmicrotime()
{
    list($usec, $sec) = explode(" ", microtime());
    return (double) $usec + (double) $sec;
}
function poweredby()
{
    global $sph_messages;
    //If you want to remove this, please donate to the project at http://www.sphider.eu/donate.php
    print $sph_messages['Powered by'];
示例#7
0
function get_category_info($catid)
{
    global $mysql_table_prefix;
    $categories['main_list'] = sql_fetch_all("SELECT * FROM " . $mysql_table_prefix . "categories ORDER BY category");
    if (is_array($categories['main_list'])) {
        foreach ($categories['main_list'] as $_val) {
            $categories['categories'][$_val['category_id']] = $_val;
            $categories['subcats'][$_val['parent_num']][] = $_val;
        }
    }
    $categories['subcats'] = $categories['subcats'][$_REQUEST['catid']];
    /* count sites */
    if (is_array($categories['subcats'])) {
        foreach ($categories['subcats'] as $_key => $_val) {
            $categories['subcats'][$_key]['count'] = sql_fetch_all('SELECT count(*) FROM ' . $mysql_table_prefix . 'site_category WHERE 	category_id=' . (int) $_val['category_id']);
        }
    }
    /* make tree */
    $_parent = $catid;
    while ($_parent) {
        $categories['cat_tree'][] = $categories['categories'][$_parent];
        $_parent = $categories['categories'][$_parent]['parent_num'];
    }
    $categories['cat_tree'] = array_reverse($categories['cat_tree']);
    /* list category sites */
    $categories['cat_sites'] = sql_fetch_all('SELECT url, title, short_desc FROM ' . $mysql_table_prefix . 'sites, ' . $mysql_table_prefix . 'site_category WHERE category_id=' . $catid . ' AND ' . $mysql_table_prefix . 'sites.site_id=' . $mysql_table_prefix . 'site_category.site_id order by title');
    $count = '0';
    if ($categories['cat_sites'] != '') {
        foreach ($categories['cat_sites'] as $value) {
            $mytitle = $categories['cat_sites'][$count][1];
            // try to fetch title as defined in admin settings for each site
            if ($mytitle == '') {
                //  if no personal title is available, try to take title and description from HTML header
                $thisurl = $categories['cat_sites'][$count][0];
                $result = mysql_query("select * from " . $mysql_table_prefix . "links where url = '{$thisurl}'");
                echo mysql_error();
                $num_rows = mysql_num_rows($result);
                if ($num_rows > 0) {
                    //      hopefully the webmaster included some title and description into the site header
                    $thisrow = mysql_fetch_array($result);
                    $thistitle = $thisrow[3];
                    if ($thistitle == '') {
                        //   if no HTML title available, alternative output
                        $thistitle = "No title available for this site.";
                    }
                    $thisdescr = $thisrow[4];
                    if ($thisdescr == '') {
                        //   if no HTML description available, alternative output
                        $thisdescr = "No description available for this site.";
                    }
                    //      now include HTML title and description into array, so we may output them
                    $categories['cat_sites'][$count][1] = $thistitle;
                    $categories['cat_sites'][$count]['title'] = $thistitle;
                    $categories['cat_sites'][$count][2] = $thisdescr;
                    $categories['cat_sites'][$count]['short_desc'] = $thisdescr;
                }
            }
            $count++;
        }
    }
    return $categories;
}
if (isset($results) && $results != "") {
    $results_per_page = $results;
}
if (isset($query) && get_magic_quotes_gpc() == 1) {
    $query = stripslashes($query);
}
if (!isset($catid) || !is_numeric($catid)) {
    $catid = "";
}
if (!isset($category) || !is_numeric($category)) {
    $category = "";
}
if ($catid && is_numeric($catid)) {
    $tpl_['category'] = sql_fetch_all('SELECT category FROM ' . TABLE_PREFIX . 'categories WHERE category_id=:catid', array(':catid' => (int) $_REQUEST['catid']));
}
$count_level0 = sql_fetch_all('SELECT count(*) FROM ' . TABLE_PREFIX . 'categories WHERE parent_num=:parent', array(':parent' => 0));
$has_categories = 0;
if ($count_level0) {
    $has_categories = $count_level0[0][0];
}
require_once "{$template_dir}/{$template}/search_form.html";
function getmicrotime()
{
    list($usec, $sec) = explode(" ", microtime());
    return (double) $usec + (double) $sec;
}
function poweredby()
{
    global $sph_messages;
    //If you want to remove this, please donate to the project at http://www.sphider.eu/donate.php
    print $sph_messages['Powered by'] . '<a href="http://www.sphider.eu/"><img src="sphider-logo.png" border="0" style="vertical-align: middle" alt="Sphider"></a>';
示例#9
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     global $spip_racine;
     global $spip_loaded;
     global $spip_version_branche;
     $restart = $input->getOption('restart');
     $requalifier = $input->getOption('maj');
     include_spip("base/abstract_sql");
     if ($spip_loaded) {
         chdir($spip_racine);
         if (!function_exists('passthru')) {
             $output->writeln("<error>Votre installation de PHP doit pouvoir exécuter des commandes externes avec la fonction passthru().</error>");
         } else {
             // requalifier les types d'apres les fichier du repertoire a_ajouter ?
             if ($requalifier !== "non") {
                 passthru("clear");
                 $output->writeln("<info>Requalification des données</info>");
                 // recaler apres coup
                 // prevoir aussi des : update entites_nommees set entite='Pays basque', type_entite='Pays' where entite='Pays' and extrait like '%Pays basque%' and type_entite='INDETERMINE' ;
                 lire_fichier('plugins/entites_nommees/recaler.txt', $recale);
                 $entites_a_revoir = explode("\n", $recale);
                 if (sizeof($entites_a_revoir) > 1) {
                     foreach ($entites_a_revoir as $e) {
                         if (preg_match(",^//,", $e) or preg_match(",^\$,", $e)) {
                             /**/
                             continue;
                         }
                         list($entite_actuelle, $entite_dans_extrait, $type_entite, $entite) = explode("\t", $e);
                         //var_dump($entite_actuelle,$entite_dans_extrait, $type_entite, $entite);
                         $sel = "select * from entites_nommees where (type_entite = 'INDETERMINE' or type_entite='Personnalités' or type_entite='Institutions automatiques') and entite= " . sql_quote($entite_actuelle) . " and extrait like '%" . addslashes($entite_dans_extrait) . "%'";
                         $q = sql_query($sel);
                         $nb = sql_count($q);
                         if ($nb > 0) {
                             echo "{$nb} {$entite_actuelle} ({$entite_dans_extrait}) => {$entite}\n";
                             $up = "update entites_nommees set entite=" . sql_quote($entite) . ", type_entite=" . sql_quote($type_entite) . " where (type_entite = 'INDETERMINE' or type_entite='Personnalités' or type_entite='Institutions automatiques') and entite= " . sql_quote($entite_actuelle) . " and extrait like '%" . addslashes($entite_dans_extrait) . "%'";
                             echo $up . "\n";
                             sql_query($up);
                         }
                         echo "\n";
                     }
                 }
                 include_spip('iterateur/data');
                 $types_requalif = inc_ls_to_array_dist(_DIR_RACINE . 'plugins/entites_nommees/listes_lexicales/a_ajouter/*');
                 /**/
                 foreach ($types_requalif as $t) {
                     if ($t['filename'] == "a_ajouter") {
                         continue;
                     }
                     $entites_a_revoir = $freq = array();
                     lire_fichier($t['dirname'] . "/" . $t['file'], $freq);
                     //echo $t['file'] . "\n" ;
                     $entites_a_revoir = explode("\n", $freq);
                     if (sizeof($entites_a_revoir) > 1) {
                         foreach ($entites_a_revoir as $e) {
                             $ent = sql_query("select * from entites_nommees where (type_entite = 'INDETERMINE' or type_entite='Personnalités') and entite= " . sql_quote($e));
                             $nb = sql_count($ent);
                             if ($nb > 0) {
                                 echo $nb . " entites " . $e . " de statut INDETERMINE => " . $t['filename'] . "\n";
                                 $up = "update entites_nommees set type_entite=" . str_replace("_", " ", sql_quote($t['filename'])) . " where  (type_entite = 'INDETERMINE' or type_entite='Personnalités') and entite=" . sql_quote($e) . "\n";
                                 echo $up . "\n";
                                 sql_query($up);
                                 echo "\n\n";
                             }
                         }
                     }
                 }
                 exit;
             }
             if ($restart !== "non") {
                 $output->writeln("<info>On efface tout et on recommence.</info>");
                 sql_query("truncate table entites_nommees");
             }
             // articles deja faits
             $articles_faits = array("0");
             $articles_sql = sql_allfetsel("id_article", "entites_nommees", "", "id_article");
             foreach ($articles_sql as $a) {
                 $articles_faits[] = $a['id_article'];
             }
             // chopper les articles non déjà faits ;
             $articles = sql_query("select a.id_article from spip_articles a where a.statut !='prepa' and a.id_secteur=" . _SECTEUR_ENTITES . " and a.id_article not in(" . implode(",", $articles_faits) . ") order by a.date_redac desc limit 0,1000");
             $res = sql_fetch_all($articles);
             // start and displays the progress bar
             $progress = new ProgressBar($output, sizeof($res));
             $progress->setBarWidth(100);
             $progress->setRedrawFrequency(1);
             $progress->setMessage("Génération des entités nommées...", 'message');
             /**/
             $progress->start();
             foreach ($res as $a) {
                 $art = sql_fetsel("id_article, titre, chapo, texte, date_redac", "spip_articles", "id_article=" . $a['id_article']);
                 $m = substr(" Traitement de l'article " . $art['id_article'] . " (" . $art['date_redac'] . ")", 0, 100);
                 $progress->setMessage($m, 'message');
                 // Trouver et enregistrer les entites nommées
                 include_spip("entites_fonctions");
                 $texte = preparer_texte($art['titre'] . " // \n" . $art['chapo'] . " // \n" . $art['texte'] . "\n");
                 $fragments = trouver_entites($texte, $art['id_article']);
                 enregistrer_entites($fragments, $art['id_article']);
                 // Si tout s'est bien passé, on avance la barre
                 $progress->setFormat("<fg=white;bg=blue>%message%</>\n" . '%current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%' . "\n\n");
                 $progress->advance();
             }
             ## FIN
             $output->writeln("<info>Check des entités : done.</info>");
             $output->writeln("\n\nMerci bien.\n");
         }
     } else {
         $output->writeln('<error>Vous n’êtes pas dans une installation de SPIP. Impossible de convertir le texte.</error>');
     }
 }
示例#10
0
 function __construct()
 {
     global $sph_messages;
     $this->default_charset = Configure::read('home_charset');
     if (Configure::read('utf8') == 1) {
         Configure::write('home_charset', 'utf-8');
         // set HTTP header character encoding to UTF-8
     }
     if (Configure::read('mark') == $sph_messages['markbold']) {
         Configure::write('mark', 'markbold');
     }
     if (Configure::read('mark') == $sph_messages['markyellow']) {
         Configure::write('mark', 'markyellow');
     }
     if (Configure::read('mark') == $sph_messages['markgreen']) {
         Configure::write('mark', 'markgreen');
     }
     if (Configure::read('mark') == $sph_messages['markblue']) {
         Configure::write('mark', 'markblue');
     }
     if (isset($_GET['type'])) {
         $this->type = $_GET['type'];
     }
     if ($this->type != "or" && $this->type != "and" && $this->type != "phrase" && $this->type != "tol") {
         $this->type = "and";
     }
     if (isset($_GET['domain']) && preg_match("/[^a-z0-9-.]+/", $_GET['domain'])) {
         $this->domain = "";
     }
     if (isset($_GET['results']) && is_numeric($_GET['results'])) {
         $this->results = $_GET['results'];
         Configure::write('results_per_page', $this->results);
     }
     if (isset($_GET['catid']) && !is_numeric($_GET['catid'])) {
         $this->catid = "";
     } else {
         $this->catid = $_GET['catid'];
     }
     if (isset($_GET['search']) && !empty($_GET['search'])) {
         $this->search = $_GET['search'];
     }
     if (isset($_GET['query'])) {
         $this->query = $_GET['query'];
     }
     if (isset($_GET['start'])) {
         $this->start = $_GET['start'];
     }
     if (!is_numeric($_GET['category'])) {
         $this->category = "";
     } else {
         $this->category = $_GET['category'];
     }
     if ($this->catid && is_numeric($this->catid)) {
         $this->tpl_['category'] = sql_fetch_all('SELECT category FROM ' . TABLE_PREFIX . 'categories WHERE category_id=' . (int) $this->catid);
     }
     $this->count_level0 = sql_fetch_all('SELECT count(*) FROM ' . TABLE_PREFIX . 'categories WHERE parent_num=0');
     $this->has_categories = 0;
     if ($this->count_level0) {
         $this->has_categories = $this->count_level0[0][0];
     }
 }
 public function GetProductPrice($id_article, $currency = 'UAH')
 {
     $price_article = $this->_GetProductPrice($id_article);
     $cart = pdk_load_class('Alohacart', 'classes');
     if ($cart) {
         $products = $cart->GetProducts();
         $cart_quantity = 0;
         if (is_array($products)) {
             foreach ($products as $value) {
                 $cart_quantity += $value[1];
             }
         }
         $cart_price = $cart->CartRetailPrice();
         $cart = array('quantity' => $cart_quantity, 'price' => $cart_price);
     } else {
         $cart = array('quantity' => 0, 'price' => 0);
     }
     //Get info about user
     $visiteur = isset($GLOBALS["visiteur_session"]["statut"]) ? $GLOBALS["visiteur_session"]["statut"] : '';
     // Get actions
     $action = $this->get_discount_action($id_article, $cart, $visiteur);
     // Get price from action
     if (is_array($action) && isset($action['action'])) {
         switch ($action['action']) {
             case 'get_price':
                 // Getting price
                 $id_group = isset($action['value']) ? $action['value'] : 0;
                 $sql_s = 'SELECT * from spip_ecatalogue_prices p where id_article=' . $id_article . ' and id_group = ' . $id_group;
                 //spip_log("S:".$sql_s, 'sql_log.'._LOG_ERREUR);
                 $res_s = sql_query($sql_s);
                 $price_record = sql_fetch_all($res_s);
                 if (is_array($price_record) && !empty($price_record)) {
                     $price_article = isset($price_record[0]['price']) ? $price_record[0]['price'] : 0;
                 }
                 break;
             case 'set_discount':
                 //	Set DISCOUNT
                 $id_group = 1;
                 $discount = isset($action['value']) ? $action['value'] : 0;
                 $sql_s = 'SELECT * from spip_ecatalogue_prices p where id_article=' . $id_article . ' and  id_group = ' . $id_group;
                 $res_s = sql_query($sql_s);
                 $price_record = sql_fetch_all($res_s);
                 if (is_array($price_record) && !empty($price_record)) {
                     $price_article = isset($price_record[0]['price']) ? $price_record[0]['price'] : 0;
                     $price_article = $price_article - $price_article / 100 * $discount;
                 }
                 break;
             default:
                 //  echo '<h1>Default</h1>';
                 $id_group = 1;
                 $sql_s = 'SELECT * from spip_ecatalogue_prices p where id_article=' . $id_article . ' and id_group = ' . $id_group;
                 $res_s = sql_query($sql_s);
                 $price_record = sql_fetch_all($res_s);
                 if (is_array($price_record) && !empty($price_record)) {
                     $price_article = isset($price_record[0]['price']) ? $price_record[0]['price'] : 0;
                 }
                 break;
         }
     }
     return $price_article;
 }