• EHM uchun dasturni identifikatsiya qiluvchi materiallar dastlabki matni (Dastur kodi)
  • ERROR: Couldnt find language file!
  • Administrator login




    Download 22,51 Kb.
    bet1/2
    Sana19.06.2024
    Hajmi22,51 Kb.
    #264494
    TuriУчебное пособие
      1   2
    Bog'liq
    Ilyos EQ


    Deponentlanadigan materiallarning titul varag‘i
    EHM uchun dastur (Ma’lumotlar bazasi) nomi:
    Amaliy mexanika” fanidan ma’ruza mashg‘ulotlari uchun elektron o‘quv qo‘llanma
    Электронное учебное пособие по лекциям по «Прикладной механике».
    Huquq ega(lar)si :


    1. Qosimov Ilyos Salimovich

    Muallif(lar):

    1. Qosimov Ilyos Salimovich

    EHM uchun dasturni identifikatsiya qiluvchi materiallar dastlabki matni (Dastur kodi)
    /**
    * @author ilyos< i.kasimov@gmail.com>
    * @copyright 2023
    * Version: 1.1.1
    * Author: Ilyos
    * Text Domain: e-book_by_mehriniso
    * Domain Path: /languages
    * Requires PHP: 7.4
    */
    //make sure that URL does not contain something like
    index.php/?parameter1=1&... //
    //include core files
    include("./cfg/connect.inc.php");
    include("./includes/database/mysql.php");
    include("./cfg/general.inc.php");
    include("./cfg/appearence.inc.php");
    include("./cfg/functions.php");
    include("./cfg/category_functions.php");
    include("./cfg/language_list.php");
    session_start();
    //init Smarty
    require’smarty/smarty.class.php';
    $smarty = new Smarty; //core smarty object
    $smarty_mail = new Smarty; //for e-mails
    //select a new language?
    if (isset($_POST["new_language"]))
    {
    $_SESSION["current_language"] = $_POST["new_language"];
    }
    //current language session variable
    if (!isset($_SESSION["current_language"]) ||
    $_SESSION["current_language"] < 0 ||
    $_SESSION["current_language"] > count($lang_list))
    $_SESSION["current_language"] = 0; //set default
    language
    //include a language file
    if (isset($lang_list[$_SESSION["current_language"]]) &&
    file_exists("./languages/".$lang_list[$_SESSION["current_language"]]-
    >filename))
    include("./languages/".$lang_list[$_SESSION["current_language"]]-
    >filename); //include current language file
    else
    {
    die("ERROR: Couldn't find language
    file!
    ");
    }
    //connect to the database
    db_connect(DB_HOST,DB_USER,DB_PASS) or die (db_error());
    db_select_db(DB_NAME) or die (db_error());
    //get currency ISO 3 code
    $currency_iso_3 = (defined('CONF_CURRENCY_ISO3')) ? CONF_CURRENCY_ISO3
    : "USD" ;
    $smarty->assign("currency_iso_3", $currency_iso_3);
    //load all categories to array $cats to avoid multiple DB queries
    (frequently used in future - but not always!)
    $cats = array();
    $i=0;
    $q = db_query("SELECT categoryID, name, parent, products_count,
    description, picture FROM ".CATEGORIES_TABLE." where categoryID<>0 ORDER BY
    name") or die (db_error());
    while ($row = db_fetch_row($q))
    {
    $cats[$i++] = $row;
    }
    //set $categoryID
    if (isset($_GET["categoryID"]) || isset($_POST["categoryID"]))
    $categoryID = isset($_GET["categoryID"]) ? $_GET["categoryID"]
    : $_POST["categoryID"];
    else $categoryID = 0;
    $categoryID = (int)$categoryID;
    //$productID
    if (!isset($_GET["productID"]))
    {
    if (isset($_POST["productID"]))
    {
    $productID = (int)$_POST["productID"];
    }
    }
    else
    {
    $productID = (int)$_GET["productID"];
    }
    //and different vars...
    if (isset($_GET["register"]) || isset($_POST["register"]))
    $register = isset($_GET["register"]) ? $_GET["register"] :
    $_POST["register"];
    if (isset($_GET["update_details"]) || isset($_POST["update_details"]))
    $update_details = isset($_GET["update_details"]) ?
    $_GET["update_details"] : $_POST["update_details"];
    if (isset($_GET["order"]) || isset($_POST["order"]))
    $order = isset($_GET["order"]) ? $_GET["order"] :
    $_POST["order"];
    if (isset($_GET["check_order"]) || isset($_POST["check_order"]))
    $check_order = isset($_GET["check_order"]) ?
    $_GET["check_order"] : $_POST["check_order"];
    if (isset($_GET["proceed_ordering"]) ||
    isset($_POST["proceed_ordering"]))
    $proceed_ordering = isset($_GET["proceed_ordering"]) ?
    $_GET["proceed_ordering"] : $_POST["proceed_ordering"];
    if (!isset($_SESSION["vote_completed"])) $_SESSION["vote_completed"] =
    array();
    //checking for proper $offset init
    $offset = isset($_GET["offset"]) ? $_GET["offset"] : 0;
    if ($offset<0 || $offset % CONF_PRODUCTS_PER_PAGE) $offset = 0;
    if (isset($productID)) //to rollout categories navigation table
    {
    $q = db_query("SELECT categoryID FROM ".PRODUCTS_TABLE." WHERE
    productID='$productID'") or die (db_error());
    $r = db_fetch_row($q);
    if ($r) $categoryID = $r[0];
    }
    //set Smarty include files dir
    $smarty->template_dir = $lang_list[$_SESSION["current_language"]]-
    >template_path;
    $smarty_mail->template_dir =
    $lang_list[$_SESSION["current_language"]]->template_path."/mail";
    //assign core Smarty variables
    $smarty->assign("lang_list", $lang_list);
    $smarty->assign("lang_list_count", count($lang_list));
    if (isset($_SESSION["current_language"])) $smarty-
    >assign("current_language", $_SESSION["current_language"]);
    // - following vars are used as hidden in the customer survey form
    $smarty->assign("categoryID", $categoryID);
    if (isset($productID)) $smarty->assign("productID", $productID);
    if (isset($_GET["currency"])) $smarty->assign("currency",
    $_GET["currency"]);
    if (isset($_GET["user_details"])) $smarty->assign("user_details",
    $_GET["user_details"]);
    if (isset($_GET["aux_page"])) $smarty->assign("aux_page",
    $_GET["aux_page"]);
    if (isset($_GET["show_price"])) $smarty->assign("show_price",
    $_GET["show_price"]);
    if (isset($_GET["adv_search"])) $smarty->assign("adv_search",
    $_GET["adv_search"]);
    if (isset($_GET["searchstring"])) $smarty->assign("searchstring",
    $_GET["searchstring"]);
    if (isset($register)) $smarty->assign("register", $register);
    if (isset($order)) $smarty->assign("order", $order);
    if (isset($check_order)) $smarty->assign("check_order", $check_order);
    //set defualt main_content template to homepage
    $smarty->assign("main_content_template", "home.tpl.html");
    // includes all .php files from includes/ dir
    $includes_dir = opendir("./includes");
    while ( ($inc_file = readdir($includes_dir)) != false )
    if (strstr($inc_file,".php"))
    {
    include("./includes/$inc_file");
    }
    // output:
    //security warnings!
    if (file_exists("./install.php"))
    {
    echo "
    ".WARNING_DELETE_INSTALL_PHP."
    ";
    }
    if (file_exists("./forgot_password.php"))
    {
    echo "
    ".WARNING_DELETE_FORGOTPW_PHP."
    ";
    }
    if (!is_writable("./products_pictures") ||
    !is_writable("./templates_c"))
    {
    echo "
    ".WARNING_WRONG_CHMOD."
    ";
    }
    //show administrative mode link if logged in as administrator
    include("./checklogin.php");
    if (isset($_SESSION["log"]) && isset($_SESSION["pass"]))
    echo "
    color=red>".ADMINISTRATE_LINK."

    ";
    //show Smarty output
    $smarty->display($lang_list[$_SESSION["current_language"]]-
    >template_path."index.tpl.html");
    ?> Admin.php
    ini_set("display_errors", "1");
    //main admin module
    function add_department($admin_dpt)
    //adds new $admin_dpt to departments list
    {
    global $admin_departments;
    $i = 0;
    while ($i$admin_departments[$i]["sort_order"] < $admin_dpt["sort_order"]) $i++;
    for ($j=count($admin_departments)-1; $j>=$i; $j--)
    $admin_departments[$j+1] = $admin_departments[$j];
    $admin_departments[$i] = $admin_dpt;
    }
    function __escape_string($_Data)
    {
    return str_replace("'", "\'", str_replace('\\',’\\\\',
    stripslashes($_Data)));
    }
    include("./cfg/connect.inc.php");
    include("./includes/database/mysql.php");
    include("./cfg/general.inc.php");
    include("./cfg/appearence.inc.php");
    include("./cfg/functions.php");
    include("./cfg/category_functions.php");
    include("./cfg/language_list.php");
    session_start();
    //authorized login check
    include("./checklogin.php");
    if (!isset($_SESSION["log"]) || !isset($_SESSION["pass"]))
    //unauthorized
    {
    //show authorization form
    header("Location: access_admin.php");
    die("");
    }
    define('WORKING_THROUGH_ADMIN_SCRIPT', true); //for security purposes
    //logout?
    if (isset($_GET["logout"])) //logout
    {
    //show authorization form
    $_SESSION["log"] = "";
    $_SESSION["pass"] = "";
    unset($_SESSION["log"]);
    unset($_SESSION["pass"]);
    die("");
    }
    //init Smarty
    require’smarty/smarty.class.php';
    $smarty = new Smarty; //core smarty object
    $smarty_mail = new Smarty; //for e-mails
    if (!isset($_SESSION["current_language"]) ||
    $_SESSION["current_language"] < 0 ||
    $_SESSION["current_language"] > count($lang_list))
    $_SESSION["current_language"] = 0; //set default
    language
    if (isset($lang_list[$_SESSION["current_language"]]) &&
    file_exists("./languages/".$lang_list[$_SESSION["current_language"]]-
    >filename))
    include("./languages/".$lang_list[$_SESSION["current_language"]]-
    >filename); //include current language file
    else
    {
    die("ERROR: Couldn't find language
    file!
    ");
    }
    //connect to database
    db_connect(DB_HOST,DB_USER,DB_PASS) or die (db_error());
    db_select_db(DB_NAME) or die (db_error());
    //set Smarty include files dir
    $smarty->template_dir = $lang_list[$_SESSION["current_language"]]-
    >template_path."/admin";
    $smarty_mail->template_dir =
    $lang_list[$_SESSION["current_language"]]->template_path."/mail";
    //get currency ISO 3 code
    $currency_iso_3 = (defined('CONF_CURRENCY_ISO3')) ? CONF_CURRENCY_ISO3
    : "USD" ;
    $smarty->assign("currency_iso_3", $currency_iso_3);
    // several functions
    function mark_as_selected($a,$b) //required for excel import
    //returns " selected" if $a == $b
    {
    return !strcmp($a,$b) ? " selected" : "";
    } //mark_as_selected
    function get_NOTempty_elements_count($arr) //required for excel import
    //gets how many NOT NULL (not empty strings) elements are
    there in the $arr
    {
    $n = 0;
    for ($i=0;$iif (trim($arr[$i]) != "") $n++;
    return $n;
    } //get_NOTempty_elements_count
    //end of functions definition
    //define department and subdepartment
    if (!isset($_GET["dpt"]))
    {
    $dpt = isset($_POST["dpt"]) ? $_POST["dpt"] : "";
    }
    else $dpt = $_GET["dpt"];
    if (!isset($_GET["sub"]))
    {
    if (isset($_POST["sub"])) $sub = $_POST["sub"];
    }
    else $sub = $_GET["sub"];
    //define smarty template
    $smarty->assign("admin_main_content_template", "default.tpl.html");
    $smarty->assign("current_dpt", $dpt);
    //get new orders count
    $q = db_query("select count(*) from ".ORDERS_TABLE) or die
    (db_error());
    $n = db_fetch_row($q);
    $smarty->assign("new_orders_count", $n[0]);
    $admin_departments = array();
    // includes all .php files from includes/ dir
    $includes_dir = opendir("./includes/admin");
    $file_count = 0;
    while ( ($inc_file = readdir($includes_dir)) != false )
    if (strstr($inc_file,".php"))
    {
    include("./includes/admin/$inc_file");
    $file_count++;
    }
    if (isset($sub)) $smarty->assign("current_sub", $sub);
    $smarty->assign("admin_departments", $admin_departments);
    $smarty->assign("admin_departments_count", $file_count);
    //show Smarty output
    $smarty->display($lang_list[$_SESSION["current_language"]]-
    >template_path."admin/index.tpl.html");
    ini_set("display_errors", "1");
    //admin mode access file
    session_start();
    include("./cfg/connect.inc.php");
    if (isset($_POST["authorize"]))
    {
    if (!strcmp(base64_encode($_POST["login"]), ADMIN_LOGIN) &&
    !strcmp(md5($_POST["password"]), ADMIN_PASS))
    { //login ok
    $_SESSION["log"] = ADMIN_LOGIN;
    $_SESSION["pass"] = ADMIN_PASS;
    //redirect to the admin interface
    header("Location: admin.php");
    }
    else $errorStr = "Invalid login and/or password";
    }
    ?>




    Administrator login


    if (isset($errorStr)) echo "$errorStr";
    ?>




    Download 22,51 Kb.
      1   2




    Download 22,51 Kb.