} // Get list of installed styles $tpl = $header['template']; $sql = "SELECT themes_id, style_name FROM " . THEMES_TABLE . " WHERE template_name = '" . $db->sql_escape($tpl) . "'"; $db->sql_return_on_error(true); $result = $db->sql_query($sql); $db->sql_return_on_error(false); if (!$result) { if (defined('XS_CLONING')) { @unlink($tmp_filename); } xs_error($lang['xs_import_notinstall'] . '<br /><br />' . $lang['xs_import_back']); } $style_rowset = $db->sql_fetchrowset($result); // run theme_info.cfg $data = xs_get_themeinfo($tpl); if (!@sizeof($data)) { if (defined('XS_CLONING')) { @unlink($tmp_filename); } xs_error($lang['xs_import_notinstall2'] . '<br /><br />' . $lang['xs_import_back']); } // install styles $default_id = 0; for ($i = 0; $i < sizeof($install); $i++) { $style_name = $install[$i]; $style_data = false; // find entry in theme_info.cfg for ($j = 0; $j < sizeof($data); $j++) { if ($data[$j]['style_name'] === $style_name) { $style_data = $data[$j];
function xs_install_style($tpl, $num) { global $db; $data = xs_get_themeinfo($tpl); if (empty($data[$num])) { return false; } $data = $data[$num]; if (empty($data['style_name'])) { return false; } $sql = "SELECT themes_id FROM " . THEMES_TABLE . " WHERE style_name='" . xs_sql($data['style_name']) . "'"; if (!($result = $db->sql_query($sql))) { return false; } $row = $db->sql_fetchrow($result); if (!empty($row['themes_id'])) { return false; } $vars = array(); $values = array(); foreach ($data as $var => $value) { $vars[] = xs_sql($var); $values[] = xs_sql(stripslashes($value)); } $sql = "INSERT INTO " . THEMES_TABLE . " (" . implode(', ', $vars) . ") VALUES ('" . implode("', '", $values) . "')"; if (!($result = $db->sql_query($sql))) { return false; } // recache themes table if (defined('XS_MODS_CATEGORY_HIERARCHY210')) { global $themes; if (empty($themes)) { $themes = new themes(); } if (!empty($themes)) { $themes->read(true); } } // add configuration global $template; if ($template->add_config($tpl)) { define('REFRESH_NAVBAR', true); } return true; }
} xs_message($lang['Information'], $lang['xs_install_installed'] . '<br /><br />' . $lang['xs_install_back'] . '<br /><br />' . $lang['xs_goto_default']); } } // get all installed styles $sql = 'SELECT themes_id, template_name, style_name FROM ' . THEMES_TABLE . ' ORDER BY template_name'; if (!($result = $db->sql_query($sql))) { xs_error($lang['xs_no_style_info'], __LINE__, __FILE__); } $style_rowset = $db->sql_fetchrowset($result); // find all styles to install $res = @opendir('../templates/'); $styles = array(); while (($file = readdir($res)) !== false) { if ($file !== '.' && $file !== '..' && @file_exists('../templates/' . $file . '/theme_info.cfg') && @file_exists('../templates/' . $file . '/' . $file . '.cfg')) { $arr = xs_get_themeinfo($file); for ($i = 0; $i < count($arr); $i++) { if (isset($arr[$i]['template_name']) && $arr[$i]['template_name'] === $file) { $arr[$i]['num'] = $i; $style = $arr[$i]['style_name']; $found = false; for ($j = 0; $j < count($style_rowset); $j++) { if ($style_rowset[$j]['style_name'] == $style) { $found = true; } } if (!$found) { $styles[$arr[$i]['style_name']] = $arr[$i]; } } }
function xs_install_style($tpl, $num) { global $db; $data = xs_get_themeinfo($tpl); if (empty($data[$num])) { return false; } $data = $data[$num]; if (empty($data['style_name'])) { return false; } $sql = "SELECT themes_id FROM " . THEMES_TABLE . " WHERE style_name='" . xs_sql($data['style_name']) . "'"; if (!($result = $db->sql_query($sql))) { return false; } $row = $db->sql_fetchrow($result); if (!empty($row['themes_id'])) { return false; } $vars = array(); $values = array(); foreach ($data as $var => $value) { $vars[] = xs_sql($var); $values[] = xs_sql(stripslashes($value)); } $sql = "INSERT INTO " . THEMES_TABLE . " (" . implode(', ', $vars) . ") VALUES ('" . implode("', '", $values) . "')"; if (!($result = $db->sql_query($sql))) { return false; } return true; }
function xs_install_style($tpl, $num) { global $db; $data = xs_get_themeinfo($tpl); if (empty($data[$num])) { return false; } $data = $data[$num]; if (empty($data['style_name'])) { return false; } $sql = "SELECT themes_id FROM " . THEMES_TABLE . " WHERE style_name = '" . $db->sql_escape($data['style_name']) . "'"; $db->sql_return_on_error(true); $result = $db->sql_query($sql); $db->sql_return_on_error(false); if (!$result) { return false; } $row = $db->sql_fetchrow($result); if (!empty($row['themes_id'])) { return false; } $vars = array(); $values = array(); foreach ($data as $var => $value) { $vars[] = $db->sql_escape($var); $values[] = $db->sql_escape($value); } $sql = "INSERT INTO " . THEMES_TABLE . " (" . implode(', ', $vars) . ") VALUES ('" . implode("', '", $values) . "')"; $db->sql_return_on_error(true); $result = $db->sql_query($sql); $db->sql_return_on_error(false); if (!$result) { return false; } // add configuration global $template; if ($template->add_config($tpl)) { define('REFRESH_NAVBAR', true); } return true; }