Esempio n. 1
0
function NP_set_i18n($strings, $val = null, $lang = null)
{
    if (is_string($strings)) {
        $tmp = NP_DDBB::decodeI18NSqlValue($strings);
        if (is_array($tmp)) {
            $strings = $tmp;
        }
    } else {
        if (is_null($strings)) {
            $strings = array();
        }
    }
    if (is_array($strings)) {
        if ($val === null && $lang !== null) {
            unset($strings[$lang]);
        } else {
            if ($lang === null) {
                $strings[NP_LANG] = $val;
            } else {
                $strings[$lang] = $val;
            }
        }
        return $strings;
    } else {
        if (!is_null($strings)) {
            return $strings;
        } else {
            return $val;
        }
    }
}
Esempio n. 2
0
function fetchCategories($data)
{
    global $categories, $categoryTitle, $item;
    if ($item->categoryId == $data['CAT_CO_CODIGO']) {
        $categoryTitle = NP_DDBB::decodeSQLValue($data['CAT_VA_NOMBRE'], "STRING_I18N");
    }
    array_push($categories, array($data['CAT_CO_CODIGO'], NP_DDBB::decodeSQLValue($data['CAT_VA_NOMBRE'], "STRING_I18N")));
}
Esempio n. 3
0
function getCountryName($countryId)
{
    global $ddbb;
    if ($countryId != null && trim($countryId) != "") {
        $data = $ddbb->executePKSelectQuery("SELECT name FROM NPS_PAISES WHERE id=" . $countryId);
        return NP_get_i18n(NP_DDBB::decodeSQLValue($data["name"], "STRING_I18N"));
    }
}
Esempio n. 4
0
function fetchCategories($data)
{
    global $categories, $categoryTitle;
    //, $sourceCategoryTitle;
    if ($_GET['categoryId'] == $data['CAT_CO_CODIGO']) {
        $categoryTitle = NP_DDBB::decodeSQLValue($data['CAT_VA_NOMBRE'], "STRING_I18N");
    }
    // if (isset($_GET['sourceCategoryId']) && $_GET['sourceCategoryId'] == $data['CAT_CO_CODIGO'])
    //     $sourceCategoryTitle = $data['CAT_VA_NOMBRE'];
    array_push($categories, array($data['CAT_CO_CODIGO'], NP_DDBB::decodeSQLValue($data['CAT_VA_NOMBRE'], "STRING_I18N")));
}
Esempio n. 5
0
 public static function loadRating($userId, $photoId)
 {
     global $photocontest_ddbb;
     $sql = "SELECT * FROM " . $photocontest_ddbb->getTable('Rating') . " WHERE " . $photocontest_ddbb->getMapping('Rating', 'userId') . " = " . NP_DDBB::encodeSQLValue($userId, $photocontest_ddbb->getType('Rating', 'userId')) . " AND " . $photocontest_ddbb->getMapping('Rating', 'photoId') . " = " . NP_DDBB::encodeSQLValue($photoId, $photocontest_ddbb->getType('Rating', 'photoId'));
     $data = $photocontest_ddbb->executePKSelectQuery($sql);
     if ($data != null) {
         return new Rating($data);
     } else {
         return null;
     }
 }
Esempio n. 6
0
 public function delete()
 {
     global $photocontest_ddbb;
     $sql_1 = "DELETE FROM " . $photocontest_ddbb->getTable('Photo') . " WHERE " . $photocontest_ddbb->getMapping('Photo', 'photoId') . " = " . NP_DDBB::encodeSQLValue($this->photoId, $photocontest_ddbb->getType('Photo', 'photoId'));
     return $photocontest_ddbb->executeDeleteQuery($sql_1) > 0;
 }
Esempio n. 7
0
 function storeSpecialShippingCost($orderId, $lineNumber)
 {
     global $npshop;
     $sql = "INSERT INTO " . $npshop["ddbb"]["PREFIX"] . "PEDIDOSCOSTES " . " VALUES (" . NP_DDBB::encodeSQLValue($orderId, "INT") . ", " . NP_DDBB::encodeSQLValue($lineNumber, "INT") . ", " . NP_DDBB::encodeSQLValue($this->id, "STRING") . ", " . NP_DDBB::encodeSQLValue($this->quantity, "INT") . ", " . NP_DDBB::encodeSQLValue($this->specialShippingCost, "FLOAT") . ", " . NP_DDBB::encodeSQLValue($this->quantity * $this->specialShippingCost, "FLOAT") . ")";
     $ddbb->executeInsertUpdateQuery($sql);
 }
Esempio n. 8
0
function fetchCountries($data)
{
    global $countries;
    $countries[$data['id']] = NP_DDBB::decodeSQLValue($data['name'], "STRING_I18N");
}
Esempio n. 9
0
 function decodeSQLValue($strVal, $sqlType)
 {
     if (isset($strVal) && $strVal !== null) {
         if ($sqlType == "STRING" || $sqlType == "TEXT") {
             return $strVal;
         } else {
             if ($sqlType == "STRING_I18N" || $sqlType == "TEXT_I18N") {
                 return NP_DDBB::decodeI18NSqlValue($strVal);
             } else {
                 if ($sqlType == "BOOL") {
                     if (isset($strVal) && $strVal != "") {
                         return $strVal == "1";
                     } else {
                         return false;
                     }
                 } else {
                     if ($sqlType == "INT") {
                         if (isset($strVal) && $strVal != "") {
                             return intval($strVal);
                         } else {
                             return 0;
                         }
                     } else {
                         if ($sqlType == "FLOAT") {
                             if (isset($strVal) && $strVal != "") {
                                 return number_format((double) $strVal, 2, '.', '');
                             } else {
                                 return 0;
                             }
                         } else {
                             if ($sqlType == "DATE") {
                                 if (isset($strVal) && $strVal != "") {
                                     return date($strVal);
                                 } else {
                                     return null;
                                 }
                             } else {
                                 return $strVal;
                             }
                         }
                     }
                 }
             }
         }
     } else {
         return null;
     }
 }
Esempio n. 10
0
    $skin['path'] = "/sites/";
    $langs = array();
    $langs['es_ES'] = "Spanish";
    $langs['en_US'] = "English";
    $nps = array();
    $nps['ddbb'] = $ddbb;
    $nps['tpv'] = $tpv;
    $nps['skin'] = $skin;
    $nps['constants'] = $constants;
    $nps['avaliable_languages'] = $langs;
    $nps['language'] = "en_US";
    return $nps;
}
$npshop = doConfig($npshop);
define('NP_DEFAULT_LANG', "en_US");
if (isset($_GET) && array_key_exists("LANG", $_GET)) {
    define('NP_LANG', $_GET[LANG]);
    setcookie('NP_LANG', $_GET[LANG]);
} else {
    define('NP_LANG', $_COOKIE['NP_LANG'] != NULL ? $_COOKIE['NP_LANG'] : $npshop['language']);
}
putenv("LC_ALL=" . NP_LANG);
setlocale(LC_ALL, NP_LANG);
bindtextdomain("messages", APP_ROOT . "/i18n");
textdomain("messages");
if (version_compare(phpversion(), '5.0') < 0) {
    $ddbb = new NP_DDBB();
    $ddbb->__construct($npshop['ddbb']);
} else {
    $ddbb = new NP_DDBB($npshop['ddbb']);
}
Esempio n. 11
0
 function _dbUpdate()
 {
     global $ddbb;
     $objectVars = get_object_vars($this);
     $first = true;
     $ddbb_mapping = $ddbb->getMapping("User", null);
     $ddbb_types = $ddbb->getType("User", null);
     $sql = "UPDATE " . $ddbb->getTable("User") . " SET ";
     foreach (array_keys($objectVars) as $var) {
         if (array_key_exists($var, $ddbb_mapping)) {
             if (is_array($ddbb_mapping[$var])) {
                 foreach (array_keys($ddbb_mapping[$var]) as $subvar) {
                     if (!$first) {
                         $sql .= ", ";
                     } else {
                         $first = false;
                     }
                     //echo $var.$subvar.$ddbb_types["User"][$var][$subvar].$objectVars[$var][$subvar]."-->".encodeSQLValue($objectVars[$var][$subvar], $ddbb_types["User"][$var][$subvar])."<br>";
                     $sql .= $ddbb_mapping[$var][$subvar] . "=" . NP_DDBB::encodeSQLValue($objectVars[$var][$subvar], $ddbb_types[$var][$subvar]);
                 }
             } else {
                 if ($var != "id") {
                     if (!$first) {
                         $sql .= ", ";
                     } else {
                         $first = false;
                     }
                     $sql .= $ddbb_mapping[$var] . "=" . NP_DDBB::encodeSQLValue($objectVars[$var], $ddbb_types[$var]);
                 }
             }
         } else {
             //TODO: ERROR
         }
     }
     $sql .= " WHERE " . $ddbb_mapping["id"] . "=" . NP_DDBB::encodeSQLValue($objectVars["id"], $ddbb_types["id"]);
     $ddbb->executeInsertUpdateQuery($sql);
 }
Esempio n. 12
0
 public function photoRatings($photoId, $userId = null)
 {
     global $photocontest_ddbb;
     $result = null;
     if ($userId !== null) {
         $rating = Rating::loadRating($userId, $photoId);
         if ($rating != null) {
             return $rating->rating;
         } else {
             return 0;
         }
     } else {
         $sql = "SELECT SUM(r." . $photocontest_ddbb->getMapping('Rating', 'rating') . ") as total_votes, count(*) number_people FROM " . $photocontest_ddbb->getTable("Rating") . " r JOIN " . $photocontest_ddbb->getTable("Photo") . " p ON r.photo_id=p.photo_id WHERE r.photo_id=" . NP_DDBB::encodeSQLValue($photoId, $photocontest_ddbb->getType('Rating', 'photoId')) . " AND p.contest_id=" . NP_DDBB::encodeSQLValue($this->contestId, $photocontest_ddbb->getType('Photo', 'contestId'));
         $result = $photocontest_ddbb->executePKSelectQuery($sql);
         if ($result['total_votes'] === null) {
             $result['total_votes'] = 0;
         }
     }
     return $result;
 }
Esempio n. 13
0
 function deleteOrder()
 {
     global $npshop, $ddbb;
     foreach ($this->items as $item) {
         $item->deleteFromOrder($this->orderId);
     }
     $sqlShippingCost = "DELETE FROM " . $npshop["ddbb"]["PREFIX"] . "PEDIDOSCOSTES WHERE PED_CO_CODIGO=" . NP_DDBB::encodeSQLValue($this->orderId, $ddbb->getType("Cart", "orderId"));
     $ddbb->executeDeleteQuery($sqlShippingCost);
     $sqlOrder = "DELETE FROM " . $ddbb->getTable("Cart") . " WHERE " . $ddbb->getMapping("Cart", "orderId") . "=" . NP_DDBB::encodeSQLValue($this->orderId, $ddbb->getType("Cart", "orderId"));
     $ddbb->executeDeleteQuery($sqlOrder);
 }