Beispiel #1
0
/**
 * handle an uploaded file for import
 *
 * @return status
 */
function Products_adminImportFileUpload()
{
    $vars = (object) AdminVars::getAllStartsWith('productsImport');
    if (!@$vars->productsImportFileUrl['varvalue']) {
        $vars->productsImportFileUrl = array('varvalue' => 'ww.cache/products/import.csv');
    }
    $fname = USERBASE . $vars->productsImportFileUrl['varvalue'];
    if (strpos($fname, '..') !== false) {
        return array('message' => 'invalid file url');
    }
    @mkdir(dirname($fname), 0777, true);
    $from = $_FILES['Filedata']['tmp_name'];
    move_uploaded_file($from, $fname);
    return array('ok' => 1);
}
Beispiel #2
0
/**
 * import via cron
 *
 * @return status
 */
function Products_importFromCron()
{
    $vars = (object) AdminVars::getAllStartsWith('productsImport');
    return Products_importFile($vars);
}
Beispiel #3
0
/**
 * remove a menu item
 *
 * @param string $path the item to remove
 *
 * @return null
 */
function Core_adminMenusRemove($path)
{
    $bits = explode('>', $path);
    $name = array_shift($bits);
    $rs = AdminVars::getAll('admin_menu');
    foreach ($rs as $r) {
        $menus = json_decode($r['varvalue'], true);
        $menus = Core_adminMenusRemoveRecurse($menus, $bits, $name);
        AdminVars::setByAdminId('admin_menu', json_encode($menus), $r['admin_id']);
    }
}
Beispiel #4
0
/**
 * generate a list of external JS scripts and build a <script> tag
 *
 * @return string the HTML
 */
function WW_getScripts()
{
    global $scripts, $scripts_inline, $DBVARS;
    if (!count($scripts)) {
        return '';
    }
    // { set up inline scripts
    // { set up admin vars
    $adminVars = (object) null;
    $rs = AdminVars::getAll();
    if ($rs) {
        foreach ($rs as $r) {
            $adminVars->{$r['varname']} = $r['varvalue'];
        }
    }
    $scripts_inline[] = 'this.adminVars=' . json_encode($adminVars);
    // }
    // { list plugins
    $scripts_inline[] = 'this.webmePlugins=' . json_encode(array_keys($GLOBALS['PLUGINS']));
    // }
    $scripts_inline[] = 'userdata={wasAdmin:1}';
    // for translations
    $inline = '<script>' . join(';', $scripts_inline) . ';</script>';
    // }
    // { set up external scripts
    $external = array();
    $local = array();
    $latest = 0;
    foreach ($scripts as $script) {
        if (strpos($script, '//') !== false) {
            $external[] = $script;
        } else {
            if (strpos($script, '/') === false) {
                $script = '/ww.plugins/' . $script . '/js.js';
            } elseif ($script[0] != '/') {
                // {
                $script = '/ww.plugins/' . $script;
            }
            $ftime = filemtime($_SERVER['DOCUMENT_ROOT'] . $script);
            if (isset($DBVARS['cdn']) && $DBVARS['cdn']) {
                $external[] = '//' . $DBVARS['cdn'] . '/a/f=getScript/ftime=' . $ftime . $script;
            } else {
                $local[] = $script;
                if ($ftime > $latest) {
                    $latest = $ftime;
                }
            }
        }
    }
    $md5 = md5(join('|', $local) . '|' . $latest);
    if (!file_exists(USERBASE . '/ww.cache/admin/' . $md5)) {
        @mkdir(USERBASE . '/ww.cache/admin');
        foreach ($local as $file) {
            file_put_contents(USERBASE . '/ww.cache/admin/' . $md5, file_get_contents($_SERVER['DOCUMENT_ROOT'] . $file) . ';', FILE_APPEND);
        }
    }
    $external = count($external) ? '<script src="' . join('"></script><script src="', $external) . '"></script>' : '';
    // }
    return $external . '<script src="/ww.admin/js.php/' . $md5 . '"></script>' . $inline;
}