Our team intervenes within 48 hours, we recommend you submit a public ticket so that other developers can help to fix the issue as soon as possible.

If you purchased the item 6 months ago, please read the Item Support Policy carefully before submitting a ticket.

Note: don’t share item or server credentials on public, use the private option.

Okay
  Public Ticket #2316607
Message: mkdir(): No such file or directory
Closed

Comments

  •  4
    jugoud26 started the conversation

    Hello

    I install your script on com-prox.com ans i have a php error. can you tell me how to fix this error?

    Severity: Warning

    Message: mkdir(): No such file or directory

    Filename: helpers/translator_helper.php

    Line Number: 37

    Backtrace:

    File: /home/cp1279146p04/public_html/application/modules/nstranslator/helpers/translator_helper.php Line: 37 Function: mkdir

    File: /home/cp1279146p04/public_html/application/modules/nstranslator/controllers/Nstranslator.php Line: 36 Function: init

    File: /home/cp1279146p04/public_html/application/modules/appcore/helpers/fmoduleloader_helper.php Line: 244 Function: onCommitted

    File: /home/cp1279146p04/public_html/application/modules/appcore/helpers/fmoduleloader_helper.php Line: 54 Function: commit

    File: /home/cp1279146p04/public_html/application/modules/appcore/controllers/Appcore.php Line: 37 Function: init

    File: /home/cp1279146p04/public_html/application/core/Pre_controller.php Line: 18 Function: load_all_dependencies

    File: /home/cp1279146p04/public_html/index.php Line: 344 Function: require_once

    A PHP Error was encountered

    Severity: Warning

    Message: file_put_contents(/home/cp1279146p04/public_html/uploads/translates/en.json): failed to open stream: No such file or directory

    Filename: helpers/translator_helper.php

    Line Number: 49

    Backtrace:

    File: /home/cp1279146p04/public_html/application/modules/nstranslator/helpers/translator_helper.php Line: 49 Function: file_put_contents

    File: /home/cp1279146p04/public_html/application/modules/nstranslator/controllers/Nstranslator.php Line: 36 Function: init

    File: /home/cp1279146p04/public_html/application/modules/appcore/helpers/fmoduleloader_helper.php Line: 244 Function: onCommitted

    File: /home/cp1279146p04/public_html/application/modules/appcore/helpers/fmoduleloader_helper.php Line: 54 Function: commit

    File: /home/cp1279146p04/public_html/application/modules/appcore/controllers/Appcore.php Line: 37 Function: init

    File: /home/cp1279146p04/public_html/application/core/Pre_controller.php Line: 18 Function: load_all_dependencies

    File: /home/cp1279146p04/public_html/index.php Line: 344 Function: require_once


  • [deleted] replied

    Hello , 


    This issue has been solved , to fix it in your server please replace the source code in the following path with   :


    Path : application/modules/nstranslator/helpers/translator_helper.php


    <?php
    /** * Created by PhpStorm. * User: Amine * Date: 11/15/2017 * Time: 23:00 */
    class Translate {
        /*     * DEBUGGING MODE     */    public static $in_debugging_mode = FALSE;
        public static $_translate_data_array = array();
        /*     *  $_translate_data_array = array(     *      code => data list     *  )     */
        public static function init(){
            /*         * JSON PATH         */
            $default_language_path_json = Path::getPath(array('uploads','translates'));
            //create a default folder if needed        if(!is_dir($default_language_path_json))            @mkdir($default_language_path_json);
            //get saved json data        $default_language_path_json = Path::getPath(array('uploads','translates',self::getDefaultLang().'.json'));
            //check if the file already exists to avoid problems, we can regenerated        // from yaml or getting the yaml data        if(!file_exists($default_language_path_json)){
                //regenerate from yaml files            $data = self::loadLanguageFromYml();            $data_json = json_encode($data,JSON_FORCE_OBJECT);            @file_put_contents($default_language_path_json,$data_json);
                self::$_translate_data_array = $data;
            }else{
                $default_language_data = file_get_contents($default_language_path_json);            $default_language_data = json_decode($default_language_data,JSON_OBJECT_AS_ARRAY);            self::$_translate_data_array = $default_language_data;
            }
        }
        public static function save($code,$data){
            $default_language_path_json = Path::getPath(array('uploads','translates',$code.'.json'));
            $data_json = json_encode($data,JSON_FORCE_OBJECT);        @file_put_contents($default_language_path_json,$data_json);
        }
        public static function getData($code){
            $default_language_path_json = Path::getPath(array('uploads','translates',$code.'.json'));        $default_language_path_yaml = Path::getPath(array('languages',$code.'.yml'));
            return array(            'cache' => file_get_contents($default_language_path_json),            'origin' => file_get_contents($default_language_path_yaml),        );
        }
        public static function changeSessionLang($lang="en"){        $context =& get_instance();        $context->load->library('session');        $context->session->set_userdata("lang",$lang);        self::getDefaultLangData();    }
        public static function getLangsCodes(){        return self::loadYmls();    }
        public static function test(){        echo "<pre>";        print_r(self::loadYmls());    }
        public static function getDir(){
            if(empty(self::$_translate_data_array)){            self::getDefaultLangData();        }
            $data = self::$_translate_data_array;
            if(isset($data['config'])            AND isset($data['config']['dir'])){
                $data['config']['dir'] = strtolower($data['config']['dir']);            define("__DIR",$data['config']['dir']);            return $data['config']['dir'];        }else{            define("__DIR","ltr");        }
            return "ltr";    }
        public static function sprint($msgId="",$default=""){
            if(self::$in_debugging_mode)            return "*****";
            $msgId = trim($msgId);        $default = trim($default);
            if(empty(self::$_translate_data_array)){            self::getDefaultLangData();        }
            $data = self::$_translate_data_array;
            if(isset($data[$msgId])){
                if(ENVIRONMENT=="development"){
                    if(isset($data[$msgId]) and $data[$msgId]==""){                    $_SESSION['toTranslate'][$msgId] = "********** NEED TO TRANSLATE ***********";                }else if(isset($data[$msgId]) and $data[$msgId]!=""){                    $_SESSION['toTranslate'][$msgId] = $data[$msgId];                }
                }
                return ($data[$msgId]);        }else{
                if(ENVIRONMENT=="development"){                $_SESSION['toTranslate'][$msgId] = "********** NEED TO TRANSLATE ***********";            }
                if($default!="")                return $default;            else                return ($msgId);
            }
        }
        public static function sprintf($msgId="",$args=array(),$default=""){
            if(self::$in_debugging_mode)            return "*****";
            if(empty(self::$_translate_data_array)){            self::getDefaultLangData();        }
            $data = self::$_translate_data_array;
            if(isset($data[$msgId])){            if(empty($args))                return $data[$msgId];            else{
                    if(ENVIRONMENT=="development"){
                        if(isset($_SESSION['toTranslate'][$msgId]) and $_SESSION['toTranslate'][$msgId]==""){                        $_SESSION['toTranslate'][$msgId] = $default;                    }else if(!isset($_SESSION['toTranslate'][$msgId])){                        $_SESSION['toTranslate'][$msgId] = $default;                    }
                    }
                    return vsprintf($data[$msgId],$args);            }
            }
            else            return vsprintf($msgId,$args);
        }
        public static function getDefaultLang(){
            $context =& get_instance();        $lngFromSession = $context->session->userdata('lang');        if($lngFromSession!=""){            return $lngFromSession;        }else{            return DEFAULT_LANG;        }
        }
        public static function getDefaultLangData(){
            $context =& get_instance();        $context->load->library('yaml');
            $lngFromSession = $context->session->userdata('lang');        if($lngFromSession!=""){            $fileYaml = Path::getPath(array("languages",trim($lngFromSession).".yml"));        }else if(defined("DEFAULT_LANG")){            $fileYaml = Path::getPath(array("languages",DEFAULT_LANG.".yml"));        }else{            $fileYaml = Path::getPath(array("languages","en.yml"));        }
            if(file_exists($fileYaml)){
                $context =& get_instance();            //load yanl file            $data = $context->yaml->load($fileYaml);            self::$_translate_data_array = $data;
            }
        }
        public static function loadLanguageFromYml($def=""){
            $context =& get_instance();        $context->load->library('yaml');        $lngFromSession = $context->session->userdata('lang');
            if($def!="" && preg_match("#[a-zA-Z]{2}#",$def)){            $fileYaml = Path::getPath(array("languages",trim($def).".yml"));        }else if($lngFromSession!=""){            $fileYaml = Path::getPath(array("languages",trim($lngFromSession).".yml"));        }else{            $fileYaml = Path::getPath(array("languages",DEFAULT_LANG.".yml"));        }
            if(!file_exists($fileYaml)){            $fileYaml = Path::getPath(array("languages",DEFAULT_LANG.".yml"));        }
            if(file_exists($fileYaml)){
                $context =& get_instance();            //load yanl file            $data = $context->yaml->load($fileYaml);
                return $data;        }
            return  array();
        }
        public static function remove($code=""){
            $path_yml =  Path::getPath(array('languages',$code.'.yml'));        $path_json =  Path::getPath(array('uploads','translates',$code.'.json'));
            @unlink($path_yml);        @unlink($path_json);    }
        public static function loadLanguageFromCache($def=""){
            $context =& get_instance();        $context->load->library('yaml');        $lngFromSession = $context->session->userdata('lang');
            if($def!="" && preg_match("#[a-zA-Z]{2}#",$def)){            $fileJSON = Path::getPath(array("uploads","translates",trim($def).".json"));        }else if($lngFromSession!=""){            $fileJSON = Path::getPath(array("uploads","translates",trim($lngFromSession).".json"));        }else{            $fileJSON = Path::getPath(array("uploads","translates",DEFAULT_LANG.".json"));        }
            if(!file_exists($fileJSON)){            $fileJSON = Path::getPath(array("uploads","translates",DEFAULT_LANG.".json"));        }
            if(file_exists($fileJSON)){
                $json = file_get_contents($fileJSON);            return json_decode($json,JSON_OBJECT_AS_ARRAY);        }
            return  array();
        }
        public static function regenerateJson($code,$data){
            $values = array();
            $cached = self::loadLanguageFromCache($code);        $uncached = self::loadLanguageFromYml($code);
            $values = Translate::merge($uncached,$cached);
            foreach ($data as $val){            $values[$val['key']] = $val['value'];        }
            $language = self::loadLanguageFromYml($code);
            $values['config'] = $language['config'];        $values['config']['last_update'] = date('Y-m-d H:i:s',time());
            self::save($code,$values);
            return TRUE;
        }
        public static function merge($array_new_keys, $array_new_values){
            $merged = array();
            //add new keys        foreach ($array_new_keys as $key => $value){            if(!isset($array_new_values[$key])){                if(is_string($value))                    $merged[$key] = $value;            }        }
            //fetch old values        foreach ($array_new_values as $key => $value){            if(is_string($value))                $merged[$key] = $value;        }
            return $merged;    }
        private static function loadYmls(){
            //get instance of object        $context =& get_instance();        $context->load->library("yaml");
            $data_to_json = array();        $path = Path::getPath(array("languages"));
            if(!is_dir($path)){            mkdir($path);        }
            if ($handle = opendir($path) AND $path!="" AND is_dir($path)) {
                while (false !== ($entry = readdir($handle))) {                if ($entry != "." && $entry != ".." ) {
                        //prepare path of files                    $fileYaml = Path::addPath($path, array($entry));
                        //load yanl file                    $data = $context->yaml->load($fileYaml);
                        //prepare config data for lang
                        if(isset($data['config'])                        AND isset($data['config']['name'])                        AND isset($data['config']['version'])){
                            $lng = preg_replace("#.yml#", "", $entry);
                            $data_to_json[$lng] = array(                            "name"  => $data['config']['name'],                            "version"  => $data['config']['version'],                            "lang"     => $lng,                            "dir"       => "ltr"                        );
                            if(isset($data['config']['dir'])){                            $data_to_json[$lng]['dir'] = $data['config']["dir"];                        }
                            unset($data);
                        }
                    }            }
                closedir($handle);        }
            return $data_to_json;    }
        public static function parse($code,$fileYaml){
            //get instance of object        $context =& get_instance();        $context->load->library("yaml");
            $data_to_json = array();        $path = Path::getPath(array("languages"));
            if(!is_dir($path)){            mkdir($path);        }
            //load yanl file        $data = $context->yaml->load($fileYaml);
            //prepare config data for lang
            if(isset($data['config'])            AND isset($data['config']['name'])            AND isset($data['config']['version'])){
                $data_to_json = $data;
                if(isset($data['config']['dir'])){                $data_to_json[$code]['dir'] = $data['config']["dir"];            }
                unset($data);
            }
            return $data_to_json;    }
    }
    if(!function_exists('_lang')){    function _lang($str,$default=''){        return Translate::sprint($str,$default);    }
    }
    





  •  2
    kalpanassleep replied

    this is what I am getting after updating the code.


    An uncaught Exception was encountered

    Type: ParseError

    Message: syntax error, unexpected 'else' (T_ELSE), expecting function (T_FUNCTION) or const (T_CONST)

    Filename: /var/www/html/nearby/application/modules/nstranslator/helpers/translator_helper.php

    Line Number: 15

    Backtrace:

    File: /var/www/html/nearby/application/third_party/MX/Loader.php Line: 118 Function: load_file

    File: /var/www/html/nearby/application/modules/nstranslator/controllers/Nstranslator.php Line: 20 Function: helper

    File: /var/www/html/nearby/application/modules/appcore/helpers/fmoduleloader_helper.php Line: 233 Function: onLoad

    File: /var/www/html/nearby/application/modules/appcore/helpers/fmoduleloader_helper.php Line: 54 Function: commit

    File: /var/www/html/nearby/application/modules/appcore/controllers/Appcore.php Line: 37 Function: init

    File: /var/www/html/nearby/application/core/Pre_controller.php Line: 18 Function: load_all_dependencies

    File: /var/www/html/nearby/index.php Line: 344 Function: require_once

  •  4
    jugoud26 replied

    hello i have the same error on line 15

    It's a syntax error?

    An uncaught Exception was encountered

    Type: ParseError

    Message: syntax error, unexpected 'else' (T_ELSE), expecting function (T_FUNCTION)

    Filename: /home/cp1279146p04/public_html/application/modules/nstranslator/helpers/translator_helper.php

    Line Number: 15

    Backtrace:

    File: /home/cp1279146p04/public_html/application/third_party/MX/Loader.php Line: 118 Function: load_file

    File: /home/cp1279146p04/public_html/application/modules/nstranslator/controllers/Nstranslator.php Line: 20 Function: helper

    File: /home/cp1279146p04/public_html/application/modules/appcore/helpers/fmoduleloader_helper.php Line: 233 Function: onLoad

    File: /home/cp1279146p04/public_html/application/modules/appcore/helpers/fmoduleloader_helper.php Line: 54 Function: commit

    File: /home/cp1279146p04/public_html/application/modules/appcore/controllers/Appcore.php Line: 37 Function: init

    File: /home/cp1279146p04/public_html/application/core/Pre_controller.php Line: 18 Function: load_all_dependencies

    File: /home/cp1279146p04/public_html/index.php Line: 344 Function: require_once

  •  2
    kalpanassleep replied

    I fixed the mkdir issue by simply creating an uploads folder. But when I tried your code, I got the error last shared and nothing would open. Installing this version has been a nightmare so far.

  •  4
    jugoud26 replied

    yesterday i did this but i can't upload images

  •  2
    kalpanassleep replied

    you are right. I also faced the same. 

  •  4
    jugoud26 replied

    We must wait until the syntax error is resolved @zouhair

  •  2
  •  219
    Amine replied

    Hi,

    Please reset the changes that you made, then try to re-upload attached file at this path 

    Path : application/modules/nstranslator/helpers/translator_helper.php

    Also please check uploads file if it has permission 777.

    Best Regards DT team.

    Dealfly (E-commerce app + Delivery app) => Buy now from envato 

    NearbyStores iOS => Buy now from envato / Android => Buy now from envato / Web => Buy now from envato

  •  2
    kalpanassleep replied

    When you say reset the changes - do you mean to revert to original code and not use the code shared below?

    Uploads folder has 755. Do I give it 777?


  •  2
    kalpanassleep replied

    So I replaced the original code with the code you gave in file you mentioned.

    https://app.mylocallady.com/

    you can see this. There are errors and website stopped opening.

  •  219
    Amine replied

    I forgot to attach the file, please find it below, you can replace it by old file.

    Best Regards DT team.

    Dealfly (E-commerce app + Delivery app) => Buy now from envato 

    NearbyStores iOS => Buy now from envato / Android => Buy now from envato / Web => Buy now from envato

  •  2
    kalpanassleep replied

    Thanks a lot. This fixed the problem.

    Now I have the problem shared below. The email verify link - shop not opening.