Пример #1
0
 public static function generateSitemapWithoutPing()
 {
     global $SITEURL;
     $filenames = getFiles(GSDATAPAGESPATH);
     if (count($filenames)) {
         foreach ($filenames as $file) {
             if (isFile($file, GSDATAPAGESPATH, 'xml')) {
                 $data = getXML(GSDATAPAGESPATH . $file);
                 if ($data->url != '404' && $data->private != 'Y') {
                     $pagesArray[] = array('url' => (string) $data->url, 'parent' => (string) $data->parent, 'date' => (string) $data->pubDate, 'menuStatus' => (string) $data->menuStatus);
                 }
             }
         }
     }
     $pagesSorted = subval_sort($pagesArray, 'menuStatus');
     $languages = return_i18n_available_languages();
     $deflang = return_i18n_default_language();
     $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><urlset></urlset>');
     $xml->addAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', 'http://www.w3.org/2001/XMLSchema-instance');
     $xml->addAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     if (count($pagesSorted)) {
         foreach ($pagesSorted as $page) {
             // set <loc>
             if (count($languages) > 1) {
                 $pos = strrpos($page['url'], '_');
                 if ($pos !== false) {
                     $pageLoc = find_i18n_url(substr($page['url'], 0, $pos), $page['parent'], substr($page['url'], $pos + 1));
                 } else {
                     $pageLoc = find_i18n_url($page['url'], $page['parent'], $deflang);
                 }
             } else {
                 $pageLoc = find_i18n_url($page['url'], $page['parent']);
             }
             // set <lastmod>
             $pageLastMod = makeIso8601TimeStamp(date("Y-m-d H:i:s", strtotime($page['date'])));
             // set <changefreq>
             $pageChangeFreq = 'weekly';
             // set <priority>
             $pagePriority = $page['menuStatus'] == 'Y' ? '1.0' : '0.5';
             //add to sitemap
             $url_item = $xml->addChild('url');
             $url_item->addChild('loc', htmlspecialchars($pageLoc));
             $url_item->addChild('lastmod', $pageLastMod);
             $url_item->addChild('changefreq', $pageChangeFreq);
             $url_item->addChild('priority', $pagePriority);
         }
     }
     //create xml file
     $file = GSROOTPATH . 'sitemap.xml';
     XMLsave($xml, $file);
 }
/**
 * Menu Preview
 *
 * Previews the current main menu hierarchy  
 *
 * @package GetSimple
 * @subpackage Page-Edit
 */
# Setup
$load['plugin'] = true;
include 'inc/common.php';
login_cookie_check();
# get pages
getPagesXmlValues();
$pagesSorted = subval_sort($pagesArray, 'menuOrder');
global $LANG;
$LANG_header = preg_replace('/(?:(?<=([a-z]{2}))).*/', '', $LANG);
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<title>Share GetSimple</title>
	<style>
		.navigate {
			padding:20px;
			width:400px;
			background:#f6f6f6;
		}
		table {border-collapse:collapse;font-family:arial;font-size:12px;margin:0;color:#333;width:100%;}
		td, th {padding:5px 20px 5px 5px;text-shadow:1px 1px 0 #fff;}
Пример #3
0
 $filenames = getFiles($path);
 if (count($filenames) != 0) {
     foreach ($filenames as $file) {
         if (isFile($file, $path, 'xml')) {
             $data = getXML($path . $file);
             $status = $data->menuStatus;
             $pagesArray[$count]['url'] = $data->url;
             $pagesArray[$count]['parent'] = $data->parent;
             $pagesArray[$count]['date'] = $data->pubDate;
             $pagesArray[$count]['private'] = $data->private;
             $pagesArray[$count]['menuStatus'] = $data->menuStatus;
             $count++;
         }
     }
 }
 $pagesSorted = subval_sort($pagesArray, 'menuStatus');
 if (count($pagesSorted) != 0) {
     $xml = @new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><urlset></urlset>');
     $xml->addAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', 'http://www.w3.org/2001/XMLSchema-instance');
     $xml->addAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     foreach ($pagesSorted as $page) {
         if ($page['private'] != 'Y') {
             // set <loc>
             $pageLoc = find_url($page['url'], $page['parent']);
             // set <lastmod>
             $tmpDate = date("Y-m-d H:i:s", strtotime($page['date']));
             $pageLastMod = makeIso8601TimeStamp($tmpDate);
             // set <changefreq>
             $pageChangeFreq = 'weekly';
             // set <priority>
             if ($page['menuStatus'] == 'Y') {
Пример #4
0
            $dircount++;
        } else {
            $filesArray[$count]['name'] = $file;
            $ext = getFileExtension($file);
            $filetype = get_FileTypeToken($ext);
            $filesArray[$count]['type'] = lowercase($filetype);
            clearstatcache();
            $ss = @stat($path . $file);
            $filesArray[$count]['date'] = @date('M j, Y', $ss['ctime']);
            $filesArray[$count]['size'] = fSize($ss['size']);
            $totalsize = $totalsize + $ss['size'];
            $count++;
        }
    }
    $filesSorted = subval_sort($filesArray, 'name');
    $dirsSorted = subval_sort($dirsArray, 'name');
}
echo '<div class="edit-nav clearfix" >';
echo '<select id="imageFilter">';
echo '<option value="all">' . i18n_r('SHOW_ALL') . '</option>';
if (count($filesSorted) > 0) {
    foreach ($filesSorted as $filter) {
        $filterArray[$filter['type']] = '';
    }
    if (count($filterArray) != 0) {
        ksort($filterArray);
        foreach ($filterArray as $type => $value) {
            $sel = false;
            # check for filter querystring
            if (isset($_GET['type']) && $_GET['type'] == $type) {
                $sel = true;
Пример #5
0
     $coArray = array();
     foreach ($ids as $id) {
         if ($title[$ct] != null && $value[$ct] != null) {
             if ($slug[$ct] == null) {
                 $slug_tmp = to7bit($title[$ct], 'UTF-8');
                 $slug[$ct] = clean_url($slug_tmp);
                 $slug_tmp = '';
             }
             $coArray[$ct]['id'] = $ids[$ct];
             $coArray[$ct]['title'] = htmlentities($title[$ct], ENT_QUOTES, 'UTF-8');
             $coArray[$ct]['slug'] = $slug[$ct];
             $coArray[$ct]['value'] = htmlentities($value[$ct], ENT_QUOTES, 'UTF-8');
         }
         $ct++;
     }
     $ids = subval_sort($coArray, 'title');
     $count = 0;
     foreach ($ids as $comp) {
         //body of xml file
         $components = $xml->addChild('item');
         $c_note = $components->addChild('title');
         $c_note->addCData(@$comp['title']);
         $components->addChild('slug', @$comp['slug']);
         $c_note = $components->addChild('value');
         $c_note->addCData(@$comp['value']);
         $count++;
     }
 }
 exec_action('component-save');
 XMLsave($xml, $path . $file);
 header('Location: components.php?upd=comp-success');
Пример #6
0
 function init()
 {
     if (isset($_REQUEST['post'])) {
         $post_id = $_REQUEST['post'];
     } elseif (isset($_REQUEST['post_ID'])) {
         $post_id = $_REQUEST['post_ID'];
     } else {
         $post_id = 99999999999999.0;
     }
     global $md_metabox;
     function subval_sort($a, $subkey)
     {
         foreach ($a as $k => $v) {
             $b[$k] = strtolower($v[$subkey]);
         }
         asort($b);
         foreach ($b as $key => $val) {
             $c[] = $a[$key];
         }
         return $c;
     }
     $md_metabox = subval_sort($md_metabox, 'order');
     $form_helper = new FORM_HELPER($post_id, $md_metabox);
     add_action('add_meta_boxes', 'page_metabox_init');
     add_action('save_post', 'page_metabox_save');
     function page_metabox_init()
     {
         add_meta_box('page-metabox', 'Advanced Page Options', 'page_metabox_ui');
     }
     function page_metabox_ui($post)
     {
         global $md_metabox;
         wp_nonce_field(plugin_basename(__FILE__), 'nonce_page_metabox');
         $form_helper = new FORM_HELPER($post->ID, $md_metabox);
         $form_helper->metabox_init();
     }
     function page_metabox_save($post_id)
     {
         if (isset($_POST['nonce_page_metabox'])) {
             // Autosave, do nothing
             if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
                 return;
             }
             // Ajax not used here
             if (defined('DOING_AJAX') && DOING_AJAX) {
                 return;
             }
             // Check user permissions
             if (!current_user_can('edit_post', $post_id)) {
                 return;
             }
             // Return if it's a post revision
             if (false !== wp_is_post_revision($post_id)) {
                 return;
             }
             // verify this came from the our screen and with proper authorization
             if (!wp_verify_nonce($_POST['nonce_page_metabox'], plugin_basename(__FILE__))) {
                 return;
             }
             // OK, we're authenticated
             global $md_metabox;
             $form_helper = new FORM_HELPER($post_id, $md_metabox);
             $form_helper->metabox_save();
         }
     }
 }
Пример #7
0
/**
 * Creates Sitemap
 *
 * Creates sitemap.xml in the site's root.
 * Pending: read the content path (xml's)
 */
function generate_sitemap()
{
    // Variable settings
    global $SITEURL;
    $path = GSDATAPAGESPATH;
    $count = "0";
    $filenames = getFiles($path);
    if (count($filenames) != 0) {
        foreach ($filenames as $file) {
            if (isFile($file, $path, 'xml')) {
                $data = getXML($path . $file);
                if ($data->url != '404') {
                    $status = $data->menuStatus;
                    $pagesArray[$count]['url'] = $data->url;
                    $pagesArray[$count]['parent'] = $data->parent;
                    $pagesArray[$count]['date'] = $data->pubDate;
                    $pagesArray[$count]['private'] = $data->private;
                    $pagesArray[$count]['menuStatus'] = $data->menuStatus;
                    $count++;
                }
            }
        }
    }
    $pagesSorted = subval_sort($pagesArray, 'menuStatus');
    if (count($pagesSorted) != 0) {
        $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><urlset></urlset>');
        $xml->addAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', 'http://www.w3.org/2001/XMLSchema-instance');
        $xml->addAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
        foreach ($pagesSorted as $page) {
            if ($page['private'] != 'Y') {
                // set <loc>
                $pageLoc = find_url($page['url'], $page['parent']);
                // set <lastmod>
                $tmpDate = date("Y-m-d H:i:s", strtotime($page['date']));
                $pageLastMod = makeIso8601TimeStamp($tmpDate);
                // set <changefreq>
                $pageChangeFreq = 'weekly';
                // set <priority>
                if ($page['menuStatus'] == 'Y') {
                    $pagePriority = '1.0';
                } else {
                    $pagePriority = '0.5';
                }
                //add to sitemap
                $url_item = $xml->addChild('url');
                $url_item->addChild('loc', $pageLoc);
                $url_item->addChild('lastmod', $pageLastMod);
                $url_item->addChild('changefreq', $pageChangeFreq);
                $url_item->addChild('priority', $pagePriority);
                exec_action('sitemap-additem');
            }
        }
        //create xml file
        $file = GSROOTPATH . 'sitemap.xml';
        exec_action('save-sitemap');
        XMLsave($xml, $file);
    }
    if (!defined('GSDONOTPING')) {
        if (file_exists(GSROOTPATH . 'sitemap.xml')) {
            if (200 === ($status = pingGoogleSitemaps($SITEURL . 'sitemap.xml'))) {
                #sitemap successfully created & pinged
                return true;
            } else {
                error_log(i18n_r('SITEMAP_ERRORPING'));
                return i18n_r('SITEMAP_ERRORPING');
            }
        } else {
            error_log(i18n_r('SITEMAP_ERROR'));
            return i18n_r('SITEMAP_ERROR');
        }
    } else {
        #sitemap successfully created - did not ping
        return true;
    }
}
Пример #8
0
            $count++;
        }
    }
    $filesSorted = subval_sort($filesArray, 'name');
    $dirsSorted = subval_sort($dirsArray, 'name');
}
echo '<div class="edit-nav" >';
echo '<select id="imageFilter">';
echo '<option value="All">' . i18n_r('SHOW_ALL') . '</option>';
if (count($filesSorted) > 0) {
    foreach ($filesSorted as $filter) {
        $filterArr[] = $filter['type'];
    }
    if (count($filterArr) != 0) {
        $filterArray = array_unique($filterArr);
        $filterArray = subval_sort($filterArray, 'type');
        foreach ($filterArray as $type) {
            # check for image type
            if (strstr($type, ' Images')) {
                $typeCleaned = 'Images';
                $typeCleaned_2 = str_replace(' Images', '', $type);
            } else {
                $typeCleaned = $type;
                $typeCleaned_2 = $type;
            }
            echo '<option value="' . $typeCleaned . '">' . $typeCleaned_2 . '</option>';
        }
    }
}
echo '</select><div class="clear" ></div></div>';
$pathParts = explode("/", $subPath);
 function eshop_parse_optsets($data)
 {
     global $wpdb;
     $opt['optset'] = $data['optset'];
     $addoprice = $data['addoprice'];
     $oset = $qb = array();
     $optings = unserialize($opt['optset']);
     //then sort it how we want.
     $optings = subval_sort($optings, 'id');
     $c = 0;
     if (isset($newoptings)) {
         unset($newoptings);
     }
     foreach ($optings as $foo => $opst) {
         if (!isset($opst['type']) || ($opst['type'] == '2' || $opst['type'] == '3') && (isset($opst['text']) && trim($opst['text']) != '')) {
             $newoptings[] = $optings[$c];
             $qb[] = "id={$opst['id']}";
         }
         $c++;
     }
     if (isset($newoptings)) {
         $qbs = implode(" OR ", $qb);
         $otable = $wpdb->prefix . 'eshop_option_sets';
         $otablename = $wpdb->prefix . 'eshop_option_names';
         $orowres = $wpdb->get_results("select o.name, o.price, o.id, t.type,t.name as oname from {$otable} as o, {$otablename} as t where ({$qbs}) && o.optid=t.optid ORDER BY id ASC");
         $x = 0;
         foreach ($orowres as $orow) {
             if (isset($newoptings[$x]['id']) && $orow->id == $newoptings[$x]['id']) {
                 if (isset($newoptings[$x]['type']) && isset($newoptings[$x]['text']) && trim($newoptings[$x]['text']) != '' && ($newoptings[$x]['type'] == '2' || $newoptings[$x]['type'] == '3')) {
                     $oset[] = '<span class="eshopoptset"><span class="eshopoptname">' . stripslashes($orow->name) . "</span>\n" . '<span class="eshoptext">' . stripslashes($newoptings[$x]['text']) . '</span></span>';
                 } elseif (($orow->type == '2' || $orow->type == '3') && !isset($newoptings[$x]['text'])) {
                     $xxxx = '';
                 } else {
                     $oset[] = '<span class="eshopoptset"><span class="eshopoptname">' . stripslashes($orow->oname) . "</span>\n" . '<span class="eshoptext">' . stripslashes($orow->name) . '</span></span>';
                 }
                 $addoprice = $addoprice + $orow->price;
                 $x++;
             }
         }
         $optset = "\n" . implode("\n", $oset);
     } else {
         $optset = '';
     }
     $data['optset'] = $optset;
     $data['addoprice'] = $addoprice;
     return $data;
 }
Пример #10
0
/**
 * Get Main Navigation
 *
 * This will return unordered list of main navigation
 * This function uses the menu opitions listed within the 'Edit Page' control panel screen
 *
 * @since 1.0
 * @uses GSDATAOTHERPATH
 * @uses getXML
 * @uses subval_sort
 * @uses find_url
 * @uses strip_quotes 
 * @uses exec_filter 
 *
 * @param string $currentpage This is the ID of the current page the visitor is on
 * @return string 
 */
function get_navigation($currentpage)
{
    $menu = '';
    global $pagesArray;
    $pagesSorted = subval_sort($pagesArray, 'menuOrder');
    if (count($pagesSorted) != 0) {
        foreach ($pagesSorted as $page) {
            $sel = '';
            $classes = '';
            $url_nav = $page['url'];
            if ($page['menuStatus'] == 'Y') {
                if ("{$currentpage}" == "{$url_nav}") {
                    $classes = "current active " . $page['parent'] . " " . $url_nav;
                } else {
                    $classes = trim($page['parent'] . " " . $url_nav);
                }
                if ($page['menu'] == '') {
                    $page['menu'] = $page['title'];
                }
                if ($page['title'] == '') {
                    $page['title'] = $page['menu'];
                }
                $menu .= '<li class="' . $classes . '"><a href="' . find_url($page['url'], $page['parent']) . '" title="' . encode_quotes(cl($page['title'])) . '">' . strip_decode($page['menu']) . '</a></li>' . "\n";
            }
        }
    }
    echo exec_filter('menuitems', $menu);
}
Пример #11
0
$pluginid = isset($_GET['set']) ? $_GET['set'] : null;
$nonce = isset($_GET['nonce']) ? $_GET['nonce'] : null;
if ($pluginid) {
    if (check_nonce($nonce, "set_" . pathinfo_filename($pluginid), "plugins.php")) {
        $plugin = antixss($pluginid);
        change_plugin($plugin);
        redirect('plugins.php?success=' . i18n_r('PLUGIN_UPDATED'));
    } else {
        redirect('plugins.php?error=' . i18n_r('ERROR_OCCURED'));
    }
}
// Variable settings
$counter = 0;
$table = '';
$needsupdate = false;
$plugin_info_sorted = subval_sort($plugin_info, 'name');
foreach ($plugin_info_sorted as $pluginid => $plugininfo) {
    $setNonce = '&amp;nonce=' . get_nonce("set_" . $pluginid, "plugins.php");
    // @todo disabled plugins have a version of (str) 'disabled', should be 0 or null
    $pluginver = $plugininfo['version'] == 'disabled' ? 0 : $plugininfo['version'];
    if (plugin_active($pluginid)) {
        $cls_Enabled = 'hidden';
        $cls_Disabled = '';
        $trclass = 'enabled';
    } else {
        $cls_Enabled = '';
        $cls_Disabled = 'hidden';
        $trclass = 'disabled';
    }
    // get extend api for this plugin filename
    $api_data = json_decode(get_api_details('plugin', $pluginid));
Пример #12
0
 /**
  * displayMonthEvents 
  * 
  * Displays a listing of events for a given month.
  * Used on the homepage with the small calendar view.
  *
  * @param int $month 
  * @param int $year 
  *
  * @return void
  */
 function displayMonthEvents($month, $year)
 {
     $month = (int) $month;
     $month = str_pad($month, 2, 0, STR_PAD_LEFT);
     $year = (int) $year;
     $gm_next = gmdate('Y-m-d H:i:s', gmmktime(gmdate('h'), gmdate('i'), gmdate('s'), $month + 1, 1, $year));
     $nextMonth = fixDate('m', $this->fcmsUser->tzOffset, $gm_next);
     $today = fixDate('Ymd', $this->fcmsUser->tzOffset, gmdate('Y-m-d H:i:s'));
     $today_year = fixDate('Y', $this->fcmsUser->tzOffset, gmdate('Y-m-d H:i:s'));
     $sql = "SELECT `id`, DATE_FORMAT(`date`, '%m%d') as day, `title`, `desc`, \n                    `date`, `private`, `created_by`, `repeat`\n                FROM fcms_calendar \n                WHERE (`date` LIKE '{$year}-{$month}-%%') \n                OR (`date` LIKE '{$year}-{$nextMonth}-%%') \n                OR (`date` LIKE '%%%%-{$month}-%%' AND `repeat` = 'yearly') \n                OR (`date` LIKE '%%%%-{$nextMonth}-%%' AND `repeat` = 'yearly') \n                ORDER BY day";
     $rows = $this->fcmsDatabase->getRows($sql);
     if ($rows === false) {
         $this->fcmsError->displayError();
         return;
     }
     $events = array();
     if (count($rows) > 0) {
         foreach ($rows as $row) {
             $events[] = $row;
         }
     }
     // Get birthdays
     $sql = "SELECT `id`, `fname`, `lname`, `dob_year`, `dob_month`, `dob_day`, \n                    `dod_year`, `dod_month`, `dod_day` \n                FROM `fcms_users` \n                WHERE `dob_month` = ?";
     $rows = $this->fcmsDatabase->getRows($sql, $month);
     if ($rows === false) {
         $this->fcmsError->displayError();
         return;
     }
     if (count($rows) > 0) {
         foreach ($rows as $r) {
             if (empty($r['dob_month']) || empty($r['dob_day'])) {
                 continue;
             }
             if (!empty($r['dod_year']) || !empty($r['dod_month']) || !empty($r['dod_day'])) {
                 continue;
             }
             $age = getAge($r['dob_year'], $r['dob_month'], $r['dob_day'], "{$year}-{$month}-" . $r['dob_day']);
             $r['id'] = 'birthday' . $r['id'];
             $r['day'] = $r['dob_month'] . $r['dob_day'];
             $r['date'] = $r['dob_year'] . '-' . $r['dob_month'] . '-' . $r['dob_day'];
             $r['title'] = $r['fname'] . ' ' . $r['lname'];
             $r['desc'] = sprintf(T_('%s turns %s today.'), $r['fname'], $age);
             $r['private'] = 0;
             $r['repeat'] = 'yearly';
             $r['created_by'] = $r['id'];
             $events[] = $r;
         }
     }
     if (count($events) <= 0) {
         return;
     }
     // show the next 5
     $count = 0;
     // fix order
     $events = subval_sort($events, 'day');
     foreach ($events as $row) {
         if ($count > 5) {
             break;
         }
         $show = false;
         list($event_year, $event_month, $event_day) = explode("-", $row['date']);
         // Fix repeating event year
         if ($row['repeat'] == 'yearly') {
             $event_year = $today_year;
         }
         // Skip events that have already happened
         if ($event_year . $event_month . $event_day < $today) {
             continue;
         }
         if ($row['private'] == 0) {
             $show = true;
         } else {
             if ($row['created_by'] == $this->fcmsUser->id) {
                 $show = true;
             }
         }
         if ($show) {
             $count++;
             $title = !empty($row['desc']) ? $row['desc'] : $row['title'];
             $title = cleanOutput($title);
             $event = cleanOutput($row['title']);
             echo '
             <div class="events">
                 <a title="' . $title . '" href="calendar.php?event=' . $row['id'] . '">' . $event . '</a><br/>
                 ' . formatDate(T_('M. d'), $row['date']) . '
             </div>';
         }
     }
 }
Пример #13
0
$filenames = getFiles($path);
$count = "0";
$pagesArray_tmp = array();
$pagesSorted = array();
if (count($filenames) != 0) {
    foreach ($filenames as $file) {
        if (isFile($file, $path, 'bak')) {
            $data = getXML($path . $file);
            $status = $data->menuStatus;
            $pagesArray_tmp[$count]['title'] = html_entity_decode($data->title, ENT_QUOTES, 'UTF-8');
            $pagesArray_tmp[$count]['url'] = $data->url;
            $pagesArray_tmp[$count]['date'] = $data->pubDate;
            $count++;
        }
    }
    $pagesSorted = subval_sort($pagesArray_tmp, 'title');
}
if (count($pagesSorted) != 0) {
    foreach ($pagesSorted as $page) {
        $counter++;
        $table .= '<tr id="tr-' . $page['url'] . '" >';
        if ($page['title'] == '') {
            $page['title'] = '[No Title] &nbsp;&raquo;&nbsp; <em>' . $page['url'] . '</em>';
        }
        $table .= '<td class="pagetitle"><a title="' . i18n_r('VIEWPAGE_TITLE') . ' ' . cl($page['title']) . '" href="backup-edit.php?p=view&amp;id=' . $page['url'] . '">' . cl($page['title']) . '</a></td>';
        $table .= '<td style="width:80px;text-align:right;" ><span>' . output_date($page['date']) . '</span></td>';
        $table .= '<td class="delete" ><a class="delconfirm" title="' . i18n_r('DELETEPAGE_TITLE') . ' ' . cl($page['title']) . '?" href="backup-edit.php?p=delete&amp;id=' . $page['url'] . '&amp;nonce=' . get_nonce("delete", "backup-edit.php") . '">&times;</a></td>';
        $table .= '</tr>';
    }
}
$pagetitle = i18n_r('BAK_MANAGEMENT');
Пример #14
0
for ($i = 0; $i < count($regional_map_results); $i++) {
    if ($regional_map_results[$i]["info"]["type"] == "Map") {
        $mapinfo[$i] = array_merge($regional_map_results[$i]["map_info"][0]);
    }
    if ($regional_map_results[$i]["info"]["type"] == "Group") {
        $groupinfo[$i] = array_merge($regional_map_results[$i]["map_info"]);
    }
}
foreach ($groupinfo as $key => $groupvalue) {
    $groupmapinfo[] = array_merge($groupinfo[$key]);
}
foreach ($groupmapinfo as $array) {
    $group = array_merge($group, $array);
}
$merged_maps_tosort = array_merge($mapinfo, $group);
$merged_maps = subval_sort($merged_maps_tosort, "title");
$total_maps = count($merged_maps);
//code for pagination
$mapsperpage = get_option('arcgis_maps_per_page') != '' ? get_option('arcgis_maps_per_page') : '8';
if (isset($regional_map_results)) {
    $total_pages = ceil($total_maps / $mapsperpage);
} else {
    $total_pages = 1;
    $total_maps = 0;
}
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
    $currentpage = (int) $_GET['currentpage'];
} else {
    $currentpage = 1;
}
if ($currentpage > $total_pages) {
Пример #15
0
/**
 * Creates Sitemap
 *
 * Creates GSSITEMAPFILE (sitemap.xml) in the site's root.
 */
function generate_sitemap()
{
    if (getDef('GSNOSITEMAP', true)) {
        return;
    }
    global $pagesArray;
    // Variable settings
    $SITEURL = getSiteURL(true);
    $path = GSDATAPAGESPATH;
    getPagesXmlValues(false);
    $pagesSorted = subval_sort($pagesArray, 'menuStatus');
    if (count($pagesSorted) > 0) {
        $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><urlset></urlset>');
        $xml->addAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', 'http://www.w3.org/2001/XMLSchema-instance');
        $xml->addAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
        foreach ($pagesSorted as $page) {
            if ($page['url'] != '404') {
                if ($page['private'] != 'Y') {
                    // set <loc>
                    $pageLoc = find_url($page['url'], $page['parent'], 'full');
                    // set <lastmod>
                    $tmpDate = date("Y-m-d H:i:s", strtotime($page['pubDate']));
                    $pageLastMod = makeIso8601TimeStamp($tmpDate);
                    // set <changefreq>
                    $pageChangeFreq = 'weekly';
                    // set <priority>
                    if ($page['menuStatus'] == 'Y') {
                        $pagePriority = '1.0';
                    } else {
                        $pagePriority = '0.5';
                    }
                    //add to sitemap
                    $url_item = $xml->addChild('url');
                    $url_item->addChild('loc', $pageLoc);
                    $url_item->addChild('lastmod', $pageLastMod);
                    $url_item->addChild('changefreq', $pageChangeFreq);
                    $url_item->addChild('priority', $pagePriority);
                }
            }
        }
        //create xml file
        $file = GSROOTPATH . GSSITEMAPFILE;
        $xml = exec_filter('sitemap', $xml);
        // @filter sitemap (obj) filter the sitemap $xml obj
        $status = XMLsave($xml, $file);
        exec_action('sitemap-aftersave');
        // @hook sitemap-aftersave after a sitemap data file was saved
        #sitemap successfully created
        return $status;
    } else {
        return true;
    }
}
Пример #16
0
 public static function getPages()
 {
     if (self::$pages) {
         return self::$pages;
     }
     $cachefile = GSDATAOTHERPATH . I18N_CACHE_FILE;
     if (!I18N_USE_CACHE || !file_exists($cachefile)) {
         // read pages into associative array
         self::$pages = array();
         $dir_handle = @opendir(GSDATAPAGESPATH) or die("Unable to open pages directory");
         while ($filename = readdir($dir_handle)) {
             if (strrpos($filename, '.xml') === strlen($filename) - 4 && !is_dir(GSDATAPAGESPATH . $filename)) {
                 $data = getXML(GSDATAPAGESPATH . $filename);
                 if (strpos($filename, '_') !== false) {
                     $pos = strpos($data->url, '_');
                     $url = substr($data->url, 0, $pos);
                     $lang = substr($data->url, $pos + 1);
                     if (!isset(self::$pages[$url])) {
                         self::$pages[$url] = array('url' => $url);
                     }
                     $menu = (string) $data->menu ? (string) $data->menu : (string) $data->title;
                     $title = (string) $data->title ? (string) $data->title : (string) $data->menu;
                     if ($menu) {
                         self::$pages[$url]['menu_' . $lang] = stripslashes($menu);
                     }
                     if ($title) {
                         self::$pages[$url]['title_' . $lang] = stripslashes($title);
                     }
                     if (isset($data->link) && (string) $data->link) {
                         self::$pages[$url]['link_' . $lang] = (string) $data->link;
                     }
                 } else {
                     $url = (string) $data->url;
                     if (!isset(self::$pages[$url])) {
                         self::$pages[$url] = array('url' => $url);
                     }
                     self::$pages[$url]['menuStatus'] = (string) $data->menuStatus;
                     self::$pages[$url]['menuOrder'] = (int) $data->menuOrder;
                     self::$pages[$url]['menu'] = stripslashes($data->menu);
                     self::$pages[$url]['title'] = stripslashes($data->title);
                     self::$pages[$url]['parent'] = (string) $data->parent;
                     self::$pages[$url]['private'] = (string) $data->private;
                     self::$pages[$url]['tags'] = (string) stripslashes($data->meta);
                     if (isset($data->link) && (string) $data->link) {
                         self::$pages[$url]['link'] = (string) $data->link;
                     }
                 }
             }
         }
         // sort pages
         $urlsToDelete = array();
         $sortedpages = array();
         foreach (self::$pages as $url => $page) {
             if (isset($page['parent']) && $page['private'] != 'Y') {
                 $sortedpages[] = array('url' => $url, 'parent' => $page['parent'], 'sort' => sprintf("%s%03s%s", $page['parent'], $page['menuOrder'], $url));
             } else {
                 $urlsToDelete[] = $url;
             }
         }
         $sortedpages = subval_sort($sortedpages, 'sort');
         if (count($urlsToDelete) > 0) {
             foreach ($urlsToDelete as $url) {
                 unset(self::$pages[$url]);
             }
         }
         // save cache file
         if (I18N_USE_CACHE) {
             $data = @new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><pages></pages>');
             foreach ($sortedpages as $sortedpage) {
                 $url = $sortedpage['url'];
                 $page = self::$pages[$url];
                 $pagedata = $data->addChild('page');
                 foreach ($page as $key => $value) {
                     $propdata = $pagedata->addChild($key);
                     $propdata->addCData($value);
                 }
             }
             XMLsave($data, $cachefile);
         }
     } else {
         $sortedpages = array();
         $data = getXML($cachefile);
         foreach ($data->page as $pagedata) {
             $url = '' . $pagedata->url;
             self::$pages[$url] = array();
             foreach ($pagedata as $propdata) {
                 self::$pages[$url][$propdata->getName()] = (string) $propdata;
             }
             $sortedpages[] = array('url' => $url, 'parent' => self::$pages[$url]['parent']);
         }
     }
     // fill children
     self::$pages[null] = array();
     foreach ($sortedpages as $sortedpage) {
         $parent = $sortedpage['parent'];
         if (isset(self::$pages[$parent])) {
             if (!isset(self::$pages[$parent]['children'])) {
                 self::$pages[$parent]['children'] = array();
             }
             self::$pages[$parent]['children'][] = $sortedpage['url'];
         }
     }
     return self::$pages;
 }
 function getAttribute_json()
 {
     $iParticipantId = Yii::app()->request->getQuery('pid');
     $records = ParticipantAttributeName::model()->getParticipantVisibleAttribute($iParticipantId);
     $records = subval_sort($records, "attribute_name", "asc");
     $i = 0;
     $doneattributes = array();
     //If the user has any actual attribute values, they'll be stored here
     /* Iterate through each attribute owned by this user */
     foreach ($records as $row) {
         $outputs[$i] = array("", $row['participant_id'] . "_" . $row['attribute_id'], $row['attribute_type'], $row['attribute_id'], $row['attribute_name'], $row['value']);
         /* Collect allowed values for a DropDown attribute */
         if ($row['attribute_type'] == "DD") {
             $attvalues = ParticipantAttributeName::model()->getAttributesValues($row['attribute_id']);
             if (!empty($attvalues)) {
                 $attval = "";
                 foreach ($attvalues as $val) {
                     $attval .= $val['value'] . ":" . $val['value'];
                     $attval .= ";";
                 }
                 $attval = substr($attval, 0, -1);
                 array_push($outputs[$i], $attval);
             } else {
                 array_push($outputs[$i], "");
             }
         } else {
             array_push($outputs[$i], "");
         }
         array_push($doneattributes, $row['attribute_id']);
         $i++;
     }
     /* Build a list of attribute names for which this user has NO values stored, keep it in $attributenotdone */
     $attributenotdone = array();
     /* The user has NO values stored against any attribute */
     if (count($doneattributes) == 0) {
         $attributenotdone = ParticipantAttributeName::model()->getCPDBAttributes();
     } else {
         $attributenotdone = ParticipantAttributeName::model()->getnotaddedAttributes($doneattributes);
     }
     /* Go through the empty attributes and build an entry in the output for them */
     foreach ($attributenotdone as $row) {
         $outputs[$i] = array("", $iParticipantId . "_" . $row['attribute_id'], $row['attribute_type'], $row['attribute_id'], $row['attribute_name'], "");
         if ($row['attribute_type'] == "DD") {
             $attvalues = ParticipantAttributeName::model()->getAttributesValues($row['attribute_id']);
             if (!empty($attvalues)) {
                 $attval = "";
                 foreach ($attvalues as $val) {
                     $attval .= $val['value'] . ":" . $val['value'];
                     $attval .= ";";
                 }
                 $attval = substr($attval, 0, -1);
                 array_push($outputs[$i], $attval);
             } else {
                 array_push($outputs[$i], "");
             }
         } else {
             array_push($outputs[$i], "");
         }
         $i++;
     }
     $outputs = subval_sort($outputs, 3, "asc");
     $aData = new stdClass();
     $aData->page = 1;
     $aData->rows[0]['id'] = $iParticipantId;
     $aData->rows[0]['cell'] = array();
     $aData->records = count($outputs);
     $aData->total = ceil($aData->records / 10);
     foreach ($outputs as $key => $output) {
         $aData->rows[$key]['id'] = $output[1];
         $aData->rows[$key]['cell'] = $output;
     }
     /* TODO: It'd be nice to do a natural sort on the attribute list at some point.
         Currently they're returned in order of attributes WITH values, then WITHOUT values
        */
     echo ls_json_encode($aData);
 }
Пример #18
0
function eshop_base_manager()
{
    global $wpdb, $eshopoptions;
    include 'eshop-base-functions.php';
    if (!isset($_GET['change'])) {
        ?>
	<div class="wrap">
	<div id="eshopicon" class="icon32"></div><h2><?php 
        _e('eShop Base Products', 'eshop');
        ?>
</h2>
	<?php 
        eshop_admin_mode();
        ?>
	<ul>
	<?php 
        $dlpage = '?page=' . $_GET['page'] . '&amp;eshopbasedl=yes';
        ?>
	<li><a href="<?php 
        echo $dlpage;
        ?>
&amp;d=1"><?php 
        _e('Download the xml file', 'eshop');
        ?>
</a></li>
	<li><a href="<?php 
        echo $dlpage;
        ?>
&amp;d=1&amp;os=mac"><?php 
        _e('Mac - Download the xml file', 'eshop');
        ?>
</a></li>
	<li><a href="<?php 
        echo $dlpage;
        ?>
"><?php 
        _e('View xml file', 'eshop');
        ?>
</a></li>
	<li><?php 
        echo sprintf(__('Direct link to file for Google Base: <a href="%1$s">%1$s</a>', 'eshop'), trim(site_url(), '/') . '/?eshopbasefeed');
        ?>
</li>
	</ul>
	<?php 
        //sort by switch statement
        $csa = $csb = $csc = $csd = $cse = $csf = '';
        if (isset($_GET['by'])) {
            switch ($_GET['by']) {
                case 'sa':
                    //date descending
                    $sortby = 'sku';
                    $csa = ' class="current"';
                    break;
                case 'sb':
                    //description alphabetically
                    $sortby = 'description';
                    $csb = ' class="current"';
                    break;
                    /*
                    	case'sd'://stock availability 
                    		$sortby='_eshop_stock';
                    		$csd=' class="current"';
                    		break;
                    */
                /*
                	case'sd'://stock availability 
                		$sortby='_eshop_stock';
                		$csd=' class="current"';
                		break;
                */
                case 'sf':
                    //date ascending
                //date ascending
                default:
                    $sortby = 'id';
                    $csf = ' class="current"';
            }
        } else {
            $csf = ' class="current"';
            $sortby = 'id';
        }
        $numoptions = $eshopoptions['options_num'];
        $metatable = $wpdb->prefix . 'postmeta';
        $poststable = $wpdb->prefix . 'posts';
        $stocktable = $wpdb->prefix . "eshop_stock";
        $range = 10;
        $max = $wpdb->get_var("SELECT COUNT(meta.post_id) FROM {$metatable} as meta, \n\t{$poststable} as posts where meta.meta_key='_eshop_product' \n\tAND posts.ID = meta.post_id\t\n\tAND posts.post_status != 'trash' AND posts.post_status != 'revision'");
        if ($eshopoptions['records'] != '' && is_numeric($eshopoptions['records'])) {
            $records = $eshopoptions['records'];
        } else {
            $records = '10';
        }
        if (isset($_GET['_p']) && is_numeric($_GET['_p'])) {
            $epage = $_GET['_p'];
        } else {
            $epage = '1';
        }
        if (!isset($_GET['eshopall'])) {
            $page_links = paginate_links(array('base' => add_query_arg('_p', '%#%'), 'format' => '', 'total' => ceil($max / $records), 'current' => $epage, 'type' => 'array'));
            $offset = $epage * $records - $records;
        } else {
            $page_links = paginate_links(array('base' => add_query_arg('_p', '%#%'), 'format' => '', 'total' => ceil($max / $records), 'current' => $epage, 'type' => 'array', 'show_all' => true));
            $offset = '0';
            $records = $max;
        }
        if ($max > 0) {
            $apge = get_admin_url() . 'admin.php?page=eshop-base.php';
            echo '<ul id="eshopsubmenu" class="stuffbox">';
            echo '<li><span>' . __('Sort Orders by &raquo;', 'eshop') . '</span></li>';
            echo '<li><a href="' . $apge . '&amp;by=sf"' . $csf . '>' . __('ID Number', 'eshop') . '</a></li>';
            echo '<li><a href="' . $apge . '&amp;by=sa"' . $csa . '>' . __('Sku', 'eshop') . '</a></li>';
            echo '<li><a href="' . $apge . '&amp;by=sb"' . $csb . '>' . __('Product', 'eshop') . '</a></li>';
            // echo '<li><a href="'.$apge.'&amp;by=sd"'.$csd.'>'.__('Stock','eshop').'</a></li>';
            echo '</ul>';
            $myrowres = $wpdb->get_results("\n\t\tSELECT DISTINCT meta.post_id\n\t\tFROM {$metatable} as meta, {$poststable} as posts\n\t\tWHERE meta.meta_key = '_eshop_product'\n\t\tAND posts.ID = meta.post_id\n\t\tAND posts.post_status != 'trash' AND posts.post_status != 'revision'\n\t\tORDER BY meta.post_id");
            $calt = 0;
            $currsymbol = $eshopoptions['currency_symbol'];
            $x = 0;
            //add in post id( doh! )
            foreach ($myrowres as $row) {
                $grabit[$x] = maybe_unserialize(get_post_meta($row->post_id, '_eshop_product', true));
                //get_post_custom($row->post_id);
                $grabit[$x]['_eshop_stock'] = get_post_meta($row->post_id, '_eshop_stock', true);
                //get_post_custom($row->post_id);
                $grabit[$x]['id'] = $row->post_id;
                $grabit[$x]['_featured'] = '1';
                $grabit[$x]['_stock'] = '1';
                if (strtolower($grabit[$x]['featured']) == 'yes') {
                    $grabit[$x]['_featured'] = '0';
                }
                if (strtolower($grabit[$x]['_eshop_stock']) == '1') {
                    $grabit[$x]['_stock'] = '0';
                }
                $x++;
            }
            $array = $grabit;
            $grab = subval_sort($array, $sortby);
            ?>
	
		<table class="widefat" summary="<?php 
            _e('product listing', 'eshop');
            ?>
">
		<caption><?php 
            _e('Product Quick reference table', 'eshop');
            ?>
</caption>
		<thead>
		<tr>
		<th id="sku"><?php 
            _e('Sku', 'eshop');
            ?>
</th>
		<th id="page"><?php 
            _e('Page', 'eshop');
            ?>
</th>
		<th id="desc"><?php 
            _e('Description', 'eshop');
            ?>
</th>
		<th id="down"><?php 
            _e('Download', 'eshop');
            ?>
</th>
		<th id="stkavail"><abbr title="<?php 
            _e('Stock Available', 'eshop');
            ?>
"><?php 
            _e('Stk avail.', 'eshop');
            ?>
</abbr></th>
		<th id="stk"><?php 
            _e('Stock', 'eshop');
            ?>
</th>
		<th id="opt"><?php 
            _e('Option/Price', 'eshop');
            ?>
</th>
		<th id="imga"><?php 
            _e('Image', 'eshop');
            ?>
</th>

		</tr>
		</thead>
		<tbody>
		<?php 
            $start = $epage * $records - $records;
            $grab = array_slice($grab, $start, $records);
            foreach ($grab as $foo => $grabit) {
                $eshop_product = $grabit;
                if (isset($grabit['_eshop_stock'])) {
                    $stkav = $grabit['_eshop_stock'];
                } else {
                    $stkav = 0;
                }
                if (isset($eshop_product['products']['1']['price']) && $eshop_product['products']['1']['price'] != '') {
                    //get page title
                    $ptitle = get_post($grabit['id']);
                    $pdown = '';
                    //check if downloadable product
                    for ($i = 1; $i <= $eshopoptions['options_num']; $i++) {
                        if ($eshop_product['products'][$i]['option'] != '') {
                            if (isset($eshop_product['products'][$i]['download']) && $eshop_product['products'][$i]['download'] != '') {
                                $dltable = $wpdb->prefix . 'eshop_downloads';
                                $fileid = $eshop_product['products'][$i]['download'];
                                $filetitle = $wpdb->get_var("SELECT title FROM {$dltable} WHERE id='{$fileid}'");
                                $pdown .= '<a href="admin.php?page=eshop-downloads.php&amp;edit=' . $fileid . '">' . $filetitle . '</a>';
                                $pdownloads = 'yes';
                            } else {
                                $pdown .= '<br />';
                            }
                        }
                    }
                    if ($ptitle->post_title == '') {
                        $posttitle = __('(no title)', 'eshop');
                    } else {
                        $posttitle = $ptitle->post_title;
                    }
                    $calt++;
                    $alt = $calt % 2 ? '' : ' class="alternate"';
                    echo '<tr' . $alt . '>';
                    echo '<td id="sku' . $calt . '" headers="sku"><a href="admin.php?page=eshop-base.php&amp;change=' . $grabit['id'] . '" title="' . __('Change details', 'eshop') . '">' . $eshop_product['sku'] . '</a></td>';
                    echo '<td headers="page sku' . $calt . '"><a href="post.php?action=edit&amp;post=' . $grabit['id'] . '">' . $posttitle . '</a></td>';
                    echo '<td headers="desc sku' . $calt . '">' . stripslashes(esc_attr($eshop_product['description'])) . '</td>';
                    echo '<td headers="down sku' . $calt . '">' . $pdown . '</td>';
                    if ($stkav == '1') {
                        $stkchk = __('Yes', 'eshop');
                    } else {
                        $stkchk = __('No', 'eshop');
                    }
                    echo '<td headers="stkavail sku' . $calt . '">' . $stkchk . '</td>';
                    $pid = $grabit['id'];
                    if ($eshopoptions['stock_control'] == 'yes') {
                        $pravailable = '';
                        $getid = $grabit['id'];
                        for ($i = 1; $i <= $numoptions; $i++) {
                            if ($eshop_product['products'][$i]['option'] != '') {
                                $available = $wpdb->get_var("select available from {$stocktable} where post_id={$getid} && option_id={$i} limit 1");
                                if ($available == '' || $available < 0) {
                                    $available = '0';
                                }
                                if (is_numeric($available) && $eshopoptions['stock_control'] == 'yes') {
                                    $pravailable .= $available . '<br />' . "\n";
                                }
                            }
                        }
                    } else {
                        $pravailable = __('n/a', 'eshop') . '<br />';
                    }
                    echo '<td headers="stk sku' . $calt . '">' . $pravailable . '</td>';
                    echo '<td headers="opt sku' . $calt . '">';
                    for ($i = 1; $i <= $numoptions; $i++) {
                        if ($eshop_product['products'][$i]['option'] != '') {
                            echo sprintf(__('%1$s @ %2$s%3$s', 'eshop'), stripslashes(esc_attr($eshop_product['products'][$i]['option'])), $currsymbol, number_format_i18n($eshop_product['products'][$i]['price'], __('2', 'eshop'))) . '<br />';
                        }
                    }
                    echo '</td>';
                    echo '<td>';
                    $getid = $grabit['id'];
                    $w = get_option('thumbnail_size_w');
                    $h = get_option('thumbnail_size_h');
                    $imgsize = '50';
                    $w = round($w * $imgsize / 100);
                    $h = round($h * $imgsize / 100);
                    if (has_post_thumbnail($getid)) {
                        echo '<a class="itemref" href="' . get_permalink($getid) . '">' . get_the_post_thumbnail($getid, array($w, $h)) . '</a>' . "\n";
                    } else {
                        $eimage = eshop_files_directory();
                        $eshopnoimage = apply_filters('eshop_no_image', $eimage['1'] . 'noimage.png');
                        echo '<a class="itemref" href="' . get_permalink($getid) . '"><img src="' . $eshopnoimage . '" height="' . $h . '" width="' . $w . '" alt="" /></a>' . "\n";
                    }
                    echo '</td>';
                    echo '</tr>';
                }
            }
            ?>
		</tbody>
		</table>
		<?php 
            //paginate
            echo '<div class="paginate tablenav-pages stuffbox">';
            if ($records != $max) {
                $eecho = $page_links;
            }
            echo sprintf('<span class="displaying-num">' . __('Displaying %s&#8211;%s of %s') . '</span>', number_format_i18n(($epage - 1) * $records + 1), number_format_i18n(min($epage * $records, $max)), number_format_i18n($max));
            if (isset($eecho)) {
                $thispage = esc_url(add_query_arg('eshopall', 'yes', $_SERVER['REQUEST_URI']));
                echo "<ul class='page-numbers'>\n\t<li>" . join("</li>\n\t<li>", $eecho) . "</li>\n<li>" . '<a href="' . $thispage . '">' . __('View All', 'eshop') . '</a>' . "</li>\n</ul>\n";
            }
            echo '<br /></div>';
            //end
        } else {
            echo '<p>' . __('There are no products available.', 'eshop') . '</p>';
        }
        echo '</div>';
    } else {
        //////////change one.
        //form checks:
        $basetable = $wpdb->prefix . "eshop_base_products";
        $change = $_GET['change'];
        if (is_numeric($change)) {
            if (isset($_POST['submit'])) {
                include 'cart-functions.php';
                if (get_magic_quotes_gpc() == 0) {
                    $_POST = stripslashes_array($_POST);
                }
                $_POST = sanitise_array($_POST);
                $err = '';
                if (isset($_POST['baseimg'])) {
                    $baseimg = $wpdb->escape($_POST['baseimg']);
                } else {
                    $baseimg = '';
                }
                $basebrand = $wpdb->escape($_POST['basebrand']);
                $baseean = $wpdb->escape($_POST['baseean']);
                $baseisbn = $wpdb->escape($_POST['baseisbn']);
                $basempn = $wpdb->escape($_POST['basempn']);
                $baseptype = $wpdb->escape($_POST['baseptype']);
                $baseqty = $wpdb->escape($_POST['baseqty']);
                $basecondition = $wpdb->escape($_POST['basecondition']);
                $baseexpiration_year = $_POST['baseexpiration_year'];
                $baseexpiration_month = $_POST['baseexpiration_month'];
                $baseexpiration_day = $_POST['baseexpiration_day'];
                if (!is_numeric($baseqty)) {
                    $baseqty = '25';
                    $err .= '<li>' . __('Quantity was not numeric, a default of 25 has been applied.', 'eshop') . '</li>';
                }
                $baseexpiration = $wpdb->escape($baseexpiration_year . '-' . $baseexpiration_month . '-' . $baseexpiration_day);
                //enter in db - delete old record first,
                //then it will always be an insert and easier than checking for update.
                $wpdb->query("DELETE FROM {$basetable} WHERE post_id = {$change} limit 1");
                $wpdb->query("INSERT INTO {$basetable} (\n\t\t\tpost_id,img,brand,ptype,thecondition,expiry,ean,isbn,mpn,qty\n\t\t\t)VALUES(\n\t\t\t'{$change}','{$baseimg}','{$basebrand}','{$baseptype}','{$basecondition}','{$baseexpiration}',\n\t\t\t'{$baseean}','{$baseisbn}','{$basempn}','{$baseqty}'\n\t\t\t)");
                if ($err != '') {
                    echo '<div id="message" class="error fade"><p>' . __('<strong>Error</strong> the following were not valid:', 'eshop') . '</p><ul>' . $err . '</ul></div>' . "\n";
                } else {
                    echo '<div id="message" class="updated fade"><p>' . __('eshop Base details for this product have been updated.', 'eshop') . '</p></div>' . "\n";
                }
            }
            $basedata = $wpdb->get_row("SELECT * FROM {$basetable} WHERE post_id = {$change}");
            if ($basedata == '') {
                $basedata->post_id = $basedata->img = $basedata->brand = $basedata->ptype = $basedata->thecondition = $basedata->expiry = $basedata->ean = $basedata->isbn = $basedata->mpn = $basedata->qty = '';
            }
            ?>
		<div class="wrap">
		<div id="eshopicon" class="icon32"></div><h2><?php 
            _e('eShop Base Product', 'eshop');
            ?>
</h2>
		<?php 
            eshop_admin_mode();
            ?>

		<?php 
            //sort by switch statement
            $sortby = 'id';
            $csf = ' class="current"';
            $numoptions = $eshopoptions['options_num'];
            $metatable = $wpdb->prefix . 'postmeta';
            $calt = 0;
            $currsymbol = $eshopoptions['currency_symbol'];
            $x = 0;
            //add in post id( doh! )
            $grabit[$x] = get_post_custom($change);
            $grabit[$x]['id'] = array($change);
            $x++;
            /*
             * remove the bottom array to try and flatten
             * could be rather slow, but easier than trying to create
             * a different method, at least for now!
             */
            foreach ($grabit as $foo => $k) {
                foreach ($k as $bar => $v) {
                    if ($bar == '_eshop_product') {
                        $y = unserialize($v[0]);
                        foreach ($y as $nowt => $val) {
                            $grab[$foo][$nowt] = $val;
                        }
                    }
                    foreach ($v as $nowt => $val) {
                        $grab[$foo][$bar] = $val;
                    }
                }
            }
            ?>
	
		<table class="widefat" summary="<?php 
            _e('product listing', 'eshop');
            ?>
">
		<caption><?php 
            _e('Product Quick reference table', 'eshop');
            ?>
</caption>
		<thead>
		<tr>
		<th id="sku"><?php 
            _e('Sku', 'eshop');
            ?>
</th>
		<th id="page"><?php 
            _e('Page', 'eshop');
            ?>
</th>
		<th id="desc"><?php 
            _e('Description', 'eshop');
            ?>
</th>
		<th id="down"><?php 
            _e('Download', 'eshop');
            ?>
</th>
		<th id="stk"><?php 
            _e('Stock', 'eshop');
            ?>
</th>
		<th id="opt"><?php 
            _e('Option/Price', 'eshop');
            ?>
</th>
		<th id="imga"><?php 
            _e('Image', 'eshop');
            ?>
</th>
		</tr>
		</thead>
		<tbody>
		<?php 
            foreach ($grab as $foo => $grabit) {
                $pdownloads = 'no';
                if ($grabit['products']['1']['price'] != '') {
                    if (isset($grabit['_eshop_stock'])) {
                        $stkav = $grabit['_eshop_stock'];
                    } else {
                        $stkav = 0;
                    }
                    //get page title
                    $ptitle = get_post($grabit['id']);
                    $pdown = '';
                    //check if downloadable product
                    for ($i = 1; $i <= $eshopoptions['options_num']; $i++) {
                        if (isset($grabit['products'][$i]['option']) && $grabit['products'][$i]['option'] != '') {
                            if (isset($grabit['products'][$i]['download']) && $grabit['products'][$i]['download'] != '') {
                                $dltable = $wpdb->prefix . 'eshop_downloads';
                                $fileid = $grabit['products'][$i]['download'];
                                $filetitle = $wpdb->get_var("SELECT title FROM {$dltable} WHERE id='{$fileid}'");
                                $pdown .= '<a href="admin.php?page=eshop-downloads.php&amp;edit=' . $fileid . '">' . $filetitle . '</a>';
                                $pdownloads = 'yes';
                            } else {
                                $pdown .= '<br />';
                            }
                        }
                    }
                    $calt++;
                    $alt = $calt % 2 ? '' : ' class="alternate"';
                    echo '<tr' . $alt . '>';
                    echo '<td id="sku' . $calt . '" headers="sku">' . $grabit['sku'] . '</td>';
                    echo '<td headers="page sku' . $calt . '"><a href="page.php?action=edit&amp;post=' . $grabit['id'] . '">' . $ptitle->post_title . '</a></td>';
                    echo '<td headers="desc sku' . $calt . '">' . stripslashes(esc_attr($grabit['description'])) . '</td>';
                    echo '<td headers="down sku' . $calt . '">' . $pdown . '</td>';
                    $pid = $grabit['id'];
                    $stocktable = $wpdb->prefix . "eshop_stock";
                    $pravailable = '';
                    if ($eshopoptions['stock_control'] == 'yes') {
                        for ($i = 1; $i <= $numoptions; $i++) {
                            if ($grabit['products'][$i]['option'] != '') {
                                $available = $wpdb->get_var("select available from {$stocktable} where post_id={$pid} && option_id={$i} limit 1");
                                if ($available == '' || $available < 0) {
                                    $available = '0';
                                }
                                if (is_numeric($available) && $eshopoptions['stock_control'] == 'yes') {
                                    $pravailable .= $available . '<br />' . "\n";
                                }
                            }
                        }
                    } else {
                        $pravailable .= __('n/a', 'eshop') . '<br />';
                    }
                    echo '<td headers="stk sku' . $calt . '">' . $pravailable . '</td>';
                    echo '<td headers="opt sku' . $calt . '">';
                    for ($i = 1; $i <= $numoptions; $i++) {
                        if (isset($grabit['products'][$i]['option']) && $grabit['products'][$i]['option'] != '') {
                            echo sprintf(__('%1$s @ %2$s%3$s', 'eshop'), stripslashes(esc_attr($grabit['products'][$i]['option'])), $currsymbol, number_format_i18n($grabit['products'][$i]['price'], __('2', 'eshop'))) . '<br />';
                        }
                    }
                    echo '</td>';
                    echo '<td>';
                    $w = get_option('thumbnail_size_w');
                    $h = get_option('thumbnail_size_h');
                    $imgsize = '50';
                    if ($imgsize != '') {
                        $w = round($w * $imgsize / 100);
                        $h = round($h * $imgsize / 100);
                    }
                    if (has_post_thumbnail($change)) {
                        echo '<a class="itemref" href="' . get_permalink($change) . '">' . get_the_post_thumbnail($change, array($w, $h)) . '</a>' . "\n";
                    } else {
                        $eimage = eshop_files_directory();
                        $eshopnoimage = apply_filters('eshop_no_image', $eimage['1'] . 'noimage.png');
                        echo '<a class="itemref" href="' . get_permalink($change) . '"><img src="' . $eshopnoimage . '" height="' . $h . '" width="' . $w . '" alt="" /></a>' . "\n";
                    }
                    echo '</td>' . "\n";
                    echo '</tr>' . "\n";
                }
                ?>
		</tbody>
		</table>
		<?php 
            }
            echo '<h3>' . __('Additional settings', 'eshop') . '</h3>' . "\n";
            $id = $grabit['id'];
            ?>
		<form method="post" action="" id="eshop-gbase-alt">
		<fieldset id="baseothers"><legend><?php 
            _e('Others', 'eshop');
            ?>
</legend>
		<?php 
            if (has_post_thumbnail($id)) {
                $grabimg = get_post_thumbnail_id($id);
                $src = wp_get_attachment_image_src($grabimg);
                ?>
		<input type="hidden" name="baseimg" value="<?php 
                echo $src['0'];
                ?>
" />
		<?php 
            }
            ?>
		<label for="basebrand"><?php 
            _e('Brand <small>The brand name of the product</small>', 'eshop');
            ?>
</label>
		<input type="text" name="basebrand" id="basebrand" value="<?php 
            echo esc_html($basedata->brand);
            ?>
" />
		<label for="baseean"><?php 
            _e('EAN <small>European Article Number is a 13 digit number often below the bar code of the item.</small>', 'eshop');
            ?>
</label>
		<input type="text" name="baseean" id="baseean" value="<?php 
            echo esc_html($basedata->ean);
            ?>
" />
		<label for="baseisbn"><?php 
            _e('ISBN <small>The unique 10- or 13-digit number assigned to every printed book.</small>', 'eshop');
            ?>
</label>
		<input type="text" name="baseisbn" id="baseisbn" value="<?php 
            echo esc_html($basedata->isbn);
            ?>
" />
		<label for="basempn"><?php 
            _e('MPN <small>Manufacturer\'s Part Number is a unique code determined by the manufacturer for that product.</small>', 'eshop');
            ?>
</label>
		<input type="text" name="basempn" id="basempn" value="<?php 
            echo esc_html($basedata->mpn);
            ?>
" />
		<label for="baseptype"><?php 
            _e('Product type <small>The type of product being offered.</small>', 'eshop');
            ?>
</label>
		<input type="text" name="baseptype" id="baseptype" value="<?php 
            echo esc_html($basedata->ptype);
            ?>
" />
		<label for="baseqty"><?php 
            _e('Quantity', 'eshop');
            ?>
</label>
		<input type="text" name="baseqty" id="baseqty" value="<?php 
            echo esc_html($basedata->qty);
            ?>
" />
	  <label for="basecondition"><?php 
            _e('Condition <small>the condition of this product</small>', 'eshop');
            ?>
</label>
	  <select name="basecondition" id="basecondition">
		<?php 
            //'
            foreach ($currentconditions as $code) {
                if ($basedata->thecondition == '') {
                    if ($code == $eshopoptions['base_condition']) {
                        $sel = ' selected="selected"';
                    } else {
                        $sel = '';
                    }
                } elseif ($code == $eshopoptions['base_condition']) {
                    $sel = ' selected="selected"';
                } else {
                    $sel = '';
                }
                echo '<option value="' . $code . '"' . $sel . '>' . $code . '</option>' . "\n";
            }
            ?>
	  </select>
	  <fieldset><legend><?php 
            _e('Expiration date <small>(or how long a product will be available.)</small>', 'eshop');
            ?>
</legend>
	  <label for="baseexpiration_year"><?php 
            _e('Year', 'eshop');
            ?>
</label>
	  <select name="baseexpiration_year" id="baseexpiration_year">
		<?php 
            // work this out!!!
            if ($basedata->expiry == '') {
                $baseexpiry = $eshopoptions['base_expiry'];
                $basedate = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") + $baseexpiry, date("Y")));
                list($baseexpiration_year, $baseexpiration_month, $baseexpiration_day) = explode('-', $basedate);
            } else {
                list($baseexpiration_year, $baseexpiration_month, $baseexpiration_day) = explode('-', $basedata->expiry);
            }
            for ($i = date('Y'); $i <= date('Y') + 5; $i++) {
                if ($i == $baseexpiration_year) {
                    $sel = ' selected="selected"';
                } else {
                    $sel = '';
                }
                echo '<option value="' . $i . '"' . $sel . '>' . $i . '</option>' . "\n";
            }
            ?>
	  </select>
		<label for="baseexpiration_month"><?php 
            _e('Month', 'eshop');
            ?>
</label>

		  <select name="baseexpiration_month" id="baseexpiration_month">
		<?php 
            for ($i = 1; $i <= 12; $i++) {
                if ($i == $baseexpiration_month) {
                    $sel = ' selected="selected"';
                } else {
                    $sel = '';
                }
                echo '<option value="' . $i . '"' . $sel . '>' . $i . '</option>' . "\n";
            }
            ?>
	  </select>
		<label for="baseexpiration_day"><?php 
            _e('Day', 'eshop');
            ?>
</label>

		  <select name="baseexpiration_day" id="baseexpiration_day">
		<?php 
            for ($i = 1; $i <= 31; $i++) {
                if ($i == $baseexpiration_day) {
                    $sel = ' selected="selected"';
                } else {
                    $sel = '';
                }
                echo '<option value="' . $i . '"' . $sel . '>' . $i . '</option>' . "\n";
            }
            ?>
	  </select>
	  </fieldset>
	  </fieldset>
	  <p class="submit">
	  <input type="submit" name="submit" class="button-primary" value="<?php 
            _e('Update');
            ?>
" />
	</p>
		<?php 
            echo '</form></div>';
        } else {
            ?>
	<div class="wrap">
	<div id="eshopicon" class="icon32"></div><h2><?php 
            _e('Error', 'eshop');
            ?>
</h2>
	<p><?php 
            _e('That product does not exist!', 'eshop');
            ?>
</p>
	</div>
	<?php 
        }
    }
}
 public function all_files_read()
 {
     if ($this->auth()) {
         $patho = (string) $this->xml->data->path;
         $path = tsl(GSDATAUPLOADPATH . $patho);
         $filesArray = array();
         $count = 0;
         global $SITEURL;
         $filenames = getFiles($path);
         if (count($filenames) != 0) {
             foreach ($filenames as $file) {
                 if ($file == "." || $file == ".." || $file == ".htaccess") {
                     // not a upload file
                 } else {
                     $filesArray[$count]['name'] = $file;
                     if (is_dir($path . $file)) {
                         $filesArray[$count]['type'] = 'folder';
                     } else {
                         $filesArray[$count]['type'] = 'file';
                         $filesArray[$count]['url'] = tsl($SITEURL . 'data/uploads/' . $patho) . $file;
                         $ext = pathinfo($file, PATHINFO_EXTENSION);
                         $extention = get_FileType($ext);
                         $filesArray[$count]['category'] = $extention;
                         clearstatcache();
                         $ss = stat($path . $file);
                         $filesArray[$count]['date'] = date('c', $ss['ctime']);
                         $filesArray[$count]['size'] = $ss['size'];
                     }
                 }
                 $count++;
             }
         }
         $filesArray = subval_sort($filesArray, 'name');
         $filesArray = subval_sort($filesArray, 'type');
         $wrapper = array('status' => 'success', 'message' => 'all_files_read ok', 'response' => $filesArray);
         return json_encode($wrapper);
     }
 }
Пример #20
0
                                        <table class="table table-striped table-bordered table-hover text-center" id="dataTables-example">
                                            <thead>
                                                <tr>
                                                    <th><div align="center">รอบที่</div></th>
                                                    <th><div align="center">วันเริ่มต้น</div></th>
                                                    <th><div align="center">วันสิ้นสุด</div></th>
                                                    <th><div align="center">จำนวนโรงงานที่ยังทำไม่เสร็จ/ทั้งหมด</div></th>
                                                    <th><div align="center">การกระทำ</div></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
//ดึงข้อมูลจากตาราง
require_once 'function/func_shipment.php';
$getShipment_period = getShipment_period();
$var_arr_des_by_indxB = subval_sort($getShipment_period, "date_start", "DES");
//กลับลำดับ
//print_r($var_arr_des_by_indxB);
$getLastidShipment = getLastidShipment();
$val_last_idshipment_period = $getLastidShipment['idshipment_period'];
$num = sizeof($var_arr_des_by_indxB);
//ลำดับของรอบ โดยหาขนาดของarray
foreach ($var_arr_des_by_indxB as $value) {
    $val_last_idshipment_period;
    $val_idshipment_period = $value['idshipment_period'];
    $val_date_start = $value['date_start'];
    $date_start = date_create($val_date_start);
    $date_start->add(new DateInterval('P543Y0M0DT0H0M0S'));
    $val_date_end = $value['date_end'];
    $date_end = date_create($val_date_end);
    $date_end->add(new DateInterval('P543Y0M0DT0H0M0S'));
function eshop_products_manager()
{
    global $wpdb, $user_ID, $eshopoptions;
    get_currentuserinfo();
    //add in if current user can here
    if (current_user_can('eShop_admin')) {
        $eshopfilter = 'all';
        if (isset($_POST['eshopfiltering'])) {
            $eshopfilter = $_POST['eshopfilter'];
        }
        ?>
		<div class="wrap">
		<div id="eshopicon" class="icon32"></div><h2><?php 
        _e('Products', 'eshop');
        ?>
</h2>
		<?php 
        eshop_admin_mode();
        ?>
		<h3><?php 
        _e('Authors', 'eshop');
        ?>
</h3>
		<?php 
        if (isset($msg)) {
            echo '<div class="updated fade"><p>' . $msg . '</p></div>';
        }
        ?>
		<form action="" method="post" class="eshop filtering">
		<p><label for="eshopfilter"><?php 
        _e('Show products for', 'eshop');
        ?>
</label><select name="eshopfilter" id="eshopfilter">
		<?php 
        echo eshop_authors($eshopfilter);
        ?>
		</select><input type="submit" name="eshopfiltering" id="submit"  class="submit button-primary" value="Filter" /></p>
		</form>
		</div>
	<?php 
    }
    ?>
	<div class="wrap">
	<h3><?php 
    _e('Products Table', 'eshop');
    ?>
</h3>
	<p><?php 
    _e('A reference table for identifying products', 'eshop');
    ?>
.</p>
	<?php 
    if (isset($_POST['eshopqp']) && isset($_POST['product'])) {
        foreach ($_POST['product'] as $id => $type) {
            $pid = $id;
            $stocktable = $wpdb->prefix . "eshop_stock";
            $eshop_product = maybe_unserialize(get_post_meta($pid, '_eshop_product', true));
            $total = 0;
            for ($i = 1; $i <= $eshopoptions['options_num']; $i++) {
                if (isset($type[$i]['stkqty']) && is_numeric($type[$i]['stkqty'])) {
                    $meta_value = $type[$i]['stkqty'];
                    $results = $wpdb->get_results("select post_id from {$stocktable} where post_id={$pid} && option_id={$i}");
                    if (!empty($results)) {
                        $wpdb->query($wpdb->prepare("UPDATE {$stocktable} set available={$meta_value} where post_id={$pid} && option_id={$i}"));
                    } else {
                        $wpdb->query($wpdb->prepare("INSERT INTO {$stocktable} (post_id,option_id,available,purchases) VALUES ({$pid},{$i},{$meta_value},0)"));
                    }
                    $total = $total + $type[$i]['stkqty'];
                }
            }
            if (isset($type['sale'])) {
                $eshop_product['sale'] = 'yes';
                update_post_meta($id, '_eshop_sale', 'yes');
            } else {
                $eshop_product['sale'] = 'no';
                delete_post_meta($id, '_eshop_sale');
            }
            if (isset($type['featured'])) {
                $eshop_product['featured'] = 'Yes';
                update_post_meta($id, '_eshop_featured', 'Yes');
            } else {
                $eshop_product['featured'] = 'no';
                delete_post_meta($id, '_eshop_featured');
            }
            if (isset($type['stkavail'])) {
                $stkav = '1';
            } else {
                $stkav = '0';
            }
            if ($stkav == '1' && ($eshop_product['description'] == '' || $eshop_product['sku'] == '' || $eshop_product['products']['1']['option'] == '' || $eshop_product['products']['1']['price'] == '')) {
                $stkav = '0';
                $emsg[0] = 'set';
            }
            if ($stkav == '1' && ($total == 0 && 'yes' == $eshopoptions['stock_control'])) {
                $stkav = '0';
                $emsg[1] = 'set';
            }
            if ($stkav == '1') {
                update_post_meta($pid, '_eshop_stock', $stkav);
            } else {
                delete_post_meta($id, '_eshop_stock');
            }
            update_post_meta($pid, '_eshop_product', $eshop_product);
        }
        $msg = '';
        if (isset($emsg)) {
            if (isset($emsg[0])) {
                $msg .= __(' Some products were marked as not available due to missing information, check the individual product pages.', 'eshop');
            }
            if (isset($emsg[1])) {
                $msg .= __(' Some products were marked as not available as no stock was found.', 'eshop');
            }
        }
        echo '<div id="message" class="updated fade">' . __('Products have been updated.', 'eshop') . $msg . "</div>\n";
    }
    //sort by switch statement
    $csa = $csb = $csc = $csd = $cse = $csf = '';
    if (isset($_GET['by'])) {
        switch ($_GET['by']) {
            case 'sa':
                //date descending
                $sortby = 'sku';
                $csa = ' class="current"';
                break;
            case 'sb':
                //description alphabetically
                $sortby = 'description';
                $csb = ' class="current"';
                break;
                /*
                	case'sc'://name alphabetically (last name)
                		$sortby='shiprate';
                		$csc=' class="current"';
                		break;
                */
            /*
            	case'sc'://name alphabetically (last name)
            		$sortby='shiprate';
            		$csc=' class="current"';
            		break;
            */
            case 'sd':
                //stock availability
                $sortby = '_stock';
                $csd = ' class="current"';
                break;
            case 'se':
                //transaction id numerically
                $sortby = '_featured';
                $cse = ' class="current"';
                break;
            case 'sf':
                //date ascending
            //date ascending
            default:
                $sortby = 'id';
                $csf = ' class="current"';
        }
    } else {
        $csf = ' class="current"';
        $sortby = 'id';
    }
    if (current_user_can('eShop_admin')) {
        if ($eshopfilter == 'all') {
            $addtoq = '';
        } elseif (is_numeric($eshopfilter)) {
            $addtoq = "AND posts.post_author = {$eshopfilter}";
        } else {
            die('There was an error');
        }
    } else {
        $addtoq = "AND posts.post_author = {$user_ID} ";
    }
    $numoptions = $eshopoptions['options_num'];
    $metatable = $wpdb->prefix . 'postmeta';
    $poststable = $wpdb->prefix . 'posts';
    $range = 10;
    $max = $wpdb->get_var("SELECT COUNT(meta.post_id) FROM {$metatable} as meta, {$poststable} as posts where meta.meta_key='_eshop_product' \r\n\tAND posts.ID = meta.post_id \r\n\tAND posts.post_status != 'trash' AND posts.post_status != 'revision'" . $addtoq);
    if ($eshopoptions['records'] != '' && is_numeric($eshopoptions['records'])) {
        $records = $eshopoptions['records'];
    } else {
        $records = '10';
    }
    if (isset($_GET['_p']) && is_numeric($_GET['_p'])) {
        $epage = $_GET['_p'];
    } else {
        $epage = '1';
    }
    if (!isset($_GET['eshopall'])) {
        $page_links = paginate_links(array('base' => add_query_arg('_p', '%#%'), 'format' => '', 'total' => ceil($max / $records), 'current' => $epage, 'type' => 'array'));
        $offset = $epage * $records - $records;
    } else {
        $page_links = paginate_links(array('base' => add_query_arg('_p', '%#%'), 'format' => '', 'total' => ceil($max / $records), 'current' => $epage, 'type' => 'array', 'show_all' => true));
        $offset = '0';
        $records = $max;
    }
    if ($max > 0) {
        $apge = get_admin_url() . 'admin.php?page=' . $_GET['page'];
        echo '<ul id="eshopsubmenu" class="stuffbox">';
        echo '<li><span>' . __('Sort Products by &raquo;', 'eshop') . '</span></li>';
        echo '<li><a href="' . $apge . '&amp;by=sf"' . $csf . '>' . __('ID Number', 'eshop') . '</a></li>';
        echo '<li><a href="' . $apge . '&amp;by=sa"' . $csa . '>' . __('Sku', 'eshop') . '</a></li>';
        echo '<li><a href="' . $apge . '&amp;by=sb"' . $csb . '>' . __('Product', 'eshop') . '</a></li>';
        // echo '<li><a href="'.$apge.'&amp;by=sc"'.$csc.'>'.__('Shipping','eshop').'</a></li>';
        echo '<li><a href="' . $apge . '&amp;by=sd"' . $csd . '>' . __('Stock', 'eshop') . '</a></li>';
        echo '<li><a href="' . $apge . '&amp;by=se"' . $cse . '>' . __('Featured', 'eshop') . '</a></li>';
        echo '</ul>';
        if (current_user_can('eShop_admin')) {
            if ($eshopfilter == 'all') {
                $addtoq = '';
            } elseif (is_numeric($eshopfilter)) {
                $addtoq = "AND posts.post_author = '{$eshopfilter}'";
            } else {
                die('There was an error');
            }
        } else {
            $addtoq = "AND posts.post_author = '{$user_ID}' ";
        }
        $myrowres = $wpdb->get_results("\r\n\t\tSELECT DISTINCT meta.post_id\r\n\t\tFROM {$metatable} as meta, {$poststable} as posts\r\n\t\tWHERE meta.meta_key = '_eshop_product'\r\n\t\tAND posts.ID = meta.post_id\r\n\t\t{$addtoq}\r\n\t\tAND posts.post_status != 'trash' AND posts.post_status != 'revision'\r\n\t\tORDER BY meta.post_id");
        $calt = 0;
        $currsymbol = $eshopoptions['currency_symbol'];
        $x = 0;
        //add in post id( doh! )
        foreach ($myrowres as $row) {
            $grabit[$x] = maybe_unserialize(get_post_meta($row->post_id, '_eshop_product', true));
            //get_post_custom($row->post_id);
            $grabit[$x]['_eshop_stock'] = get_post_meta($row->post_id, '_eshop_stock', true);
            //get_post_custom($row->post_id);
            $grabit[$x]['id'] = $row->post_id;
            $grabit[$x]['_featured'] = '1';
            $grabit[$x]['_stock'] = '1';
            if (strtolower($grabit[$x]['featured']) == 'yes') {
                $grabit[$x]['_featured'] = '0';
            }
            if (strtolower($grabit[$x]['_eshop_stock']) == '1') {
                $grabit[$x]['_stock'] = '0';
            }
            $x++;
        }
        $array = $grabit;
        $grab = subval_sort($array, $sortby);
        //grabs some tax data
        if (!isset($eshopoptions['etax'])) {
            $eshopoptions['etax'] = array();
        }
        $etax = $eshopoptions['etax'];
        if (!isset($etax['bands']) || $etax['bands'] == '') {
            $etax['bands'] = '0';
        }
        ?>
	
		<form action="" method="post" class="eshop">
		<div class="eshopwidetable">
		<table class="hidealllabels widefat" summary="product listing">
		<caption><?php 
        _e('Product Quick reference table', 'eshop');
        ?>
</caption>
		<thead>
		<tr>
		<th id="sku"><?php 
        _e('Sku', 'eshop');
        ?>
</th>
		<th id="ids"><?php 
        _e('ID', 'eshop');
        ?>
</th>
		<th id="page"><?php 
        _e('Page', 'eshop');
        ?>
</th>
		<th id="desc"><?php 
        _e('Description', 'eshop');
        ?>
</th>
		<th id="down"><abbr title="<?php 
        _e('Downloads', 'eshop');
        ?>
"><?php 
        _e('DL', 'eshop');
        ?>
</abbr></th>
		<th id="ship"><abbr title="<?php 
        _e('Shipping Rate', 'eshop');
        ?>
"><?php 
        _e('S/R', 'eshop');
        ?>
</abbr></th>
		<th id="stkavail"><abbr title="<?php 
        _e('Stock Available', 'eshop');
        ?>
"><?php 
        _e('Stk avail.', 'eshop');
        ?>
</abbr></th>
		<th id="purc"><abbr title="<?php 
        _e('Number of Purchases', 'eshop');
        ?>
"><?php 
        _e('Purc.', 'eshop');
        ?>
</abbr></th>
		<th id="ftrd"><abbr title="<?php 
        _e('Marked as Featured', 'eshop');
        ?>
"><?php 
        _e('Feat.', 'eshop');
        ?>
</abbr></th>
		<th id="onsale" title="<?php 
        _e('Product on sale', 'eshop');
        ?>
"><?php 
        _e('Sale', 'eshop');
        ?>
</th>
		<th id="opt"><?php 
        _e('Option/Price', 'eshop');
        ?>
</th>
		<?php 
        if ($etax['bands'] > 0) {
            ?>
		<th id="tax"><?php 
            _e('Tax', 'eshop');
            ?>
</th>
		<?php 
        }
        ?>
		<th id="stk"><abbr title="<?php 
        _e('Stock Level', 'eshop');
        ?>
"><?php 
        _e('Stk', 'eshop');
        ?>
</abbr></th>
		<th id="associmg"><?php 
        _e('Thumbnail', 'eshop');
        ?>
</th>
		</tr>
		</thead>
		<tbody>
		<?php 
        $scc = 0;
        $start = $epage * $records - $records;
        $grab = array_slice($grab, $start, $records);
        foreach ($grab as $grabit) {
            $eshop_product = $grabit;
            if (isset($grabit['_eshop_stock']) && is_numeric($grabit['_eshop_stock'])) {
                $stkav = $grabit['_eshop_stock'];
            } else {
                $stkav = 0;
            }
            $pdownloads = 'no';
            if (isset($eshop_product['products']['1']['price']) && $eshop_product['products']['1']['price'] != '') {
                //reset array
                $purcharray = array();
                //get page title
                $ptitle = get_post($grabit['id']);
                $getid = $grabit['id'];
                //get download file title
                $pdown = '';
                //check if downloadable product
                for ($i = 1; $i <= $eshopoptions['options_num']; $i++) {
                    if ($eshop_product['products'][$i]['option'] != '') {
                        if (isset($eshop_product['products'][$i]['download']) && $eshop_product['products'][$i]['download'] != '') {
                            $dltable = $wpdb->prefix . 'eshop_downloads';
                            $fileid = $eshop_product['products'][$i]['download'];
                            $filetitle = $wpdb->get_var("SELECT title FROM {$dltable} WHERE id='{$fileid}'");
                            $pdown .= '<a href="admin.php?page=eshop-downloads.php&amp;edit=' . $fileid . '">' . $filetitle . '</a>';
                            $pdownloads = 'yes';
                        } else {
                            $pdown .= '<br />';
                        }
                    }
                }
                if ($ptitle->post_title == '') {
                    $posttitle = __('(no title)');
                } else {
                    $posttitle = $ptitle->post_title;
                }
                $calt++;
                $alt = $calt % 2 ? '' : ' class="alternate"';
                echo '<tr' . $alt . '>';
                echo '<td id="sku' . $calt . '" headers="sku">' . $eshop_product['sku'] . '</td>';
                echo '<td headers="ids sku' . $calt . '">' . $getid . '<input type="hidden" value="1" name="product[' . $getid . '][theid]" /></td>';
                echo '<td headers="page sku' . $calt . '"><a href="post.php?action=edit&amp;post=' . $getid . '" title="id: ' . $getid . '">' . $posttitle . '</a></td>';
                echo '<td headers="desc sku' . $calt . '">' . stripslashes(esc_attr($eshop_product['description'])) . '</td>';
                echo '<td headers="down sku' . $calt . '">' . $pdown . '</td>';
                echo '<td headers="ship sku' . $calt . '">' . $eshop_product['shiprate'] . '</td>';
                if ($stkav == '1') {
                    $stkchk = ' checked="checked"';
                } else {
                    $stkchk = '';
                }
                echo '<td headers="stkavail sku' . $calt . '"><label for="stkavail' . $calt . '">' . __('Stock Available', 'eshop') . '</label><input type="checkbox" value="1" name="product[' . $getid . '][stkavail]" id="stkavail' . $calt . '"' . $stkchk . ' /></td>';
                $purcharray = array();
                $dltable = $wpdb->prefix . "eshop_downloads";
                $stocktable = $wpdb->prefix . "eshop_stock";
                for ($i = 1; $i <= $eshopoptions['options_num']; $i++) {
                    if ($eshop_product['products'][$i]['option'] != '') {
                        if (isset($eshop_product['products'][$i]['download']) && $eshop_product['products'][$i]['download'] != '') {
                            $fileid = $eshop_product['products'][$i]['download'];
                            $purchases = $wpdb->get_var("SELECT purchases FROM {$dltable} WHERE id='{$fileid}'");
                            if ($purchases != '') {
                                $purcharray[] = $purchases;
                            } else {
                                $purcharray[] = '0';
                            }
                        } else {
                            $purchases = $wpdb->get_var("select purchases from {$stocktable} where post_id={$getid} && option_id={$i} limit 1");
                            if ($purchases != '') {
                                $purcharray[] = $purchases;
                            } else {
                                $purcharray[] = '0';
                            }
                        }
                    }
                    if ($pdownloads == 'no') {
                        break;
                    }
                }
                //Featured Product
                if ($eshop_product['featured'] == 'Yes') {
                    $fchk = ' checked="checked"';
                } else {
                    $fchk = '';
                }
                $feat = '<label for="featured' . $calt . '">' . __('Featured Product', 'eshop') . '</label><input type="checkbox" value="1" name="product[' . $getid . '][featured]" id="featured' . $calt . '"' . $fchk . ' />';
                echo '<td headers="purc sku' . $calt . '">' . implode("<br />", $purcharray) . '</td>';
                echo '<td headers="ftrd sku' . $calt . '">' . $feat . '</td>';
                //Sale Product
                if (isset($eshop_product['sale']) && $eshop_product['sale'] == 'yes') {
                    $salechk = ' checked="checked"';
                } else {
                    $salechk = '';
                }
                $onsale = '<label for="sale' . $calt . '">' . __('Product On Sale', 'eshop') . '</label><input type="checkbox" value="1" name="product[' . $getid . '][sale]" id="sale' . $calt . '"' . $salechk . ' />';
                echo '<td headers="onsale sku' . $calt . '">' . $onsale . '</td>';
                echo '<td headers="opt sku' . $calt . '" class="optline">';
                for ($i = 1; $i <= $numoptions; $i++) {
                    if ($eshop_product['products'][$i]['option'] != '') {
                        echo sprintf(__('%1$s @ %2$s%3$s', 'eshop'), stripslashes(esc_attr($eshop_product['products'][$i]['option'])), $currsymbol, number_format_i18n($eshop_product['products'][$i]['price'], __('2', 'eshop'))) . '<br />';
                    }
                }
                echo '</td>';
                if ($etax['bands'] > 0) {
                    echo '<td headers="tax sku' . $calt . '" class="optline">';
                    for ($i = 1; $i <= $numoptions; $i++) {
                        if (isset($eshop_product['products'][$i]['tax']) && $eshop_product['products'][$i]['tax'] != '') {
                            $tzone = sprintf(__('Band %1$d', 'eshop'), $eshop_product['products'][$i]['tax']);
                            $disptzone = apply_filters('eshop_rename_tax_zone', array());
                            if (isset($disptzone[$eshop_product['products'][$i]['tax']])) {
                                $tzone = $disptzone[$eshop_product['products'][$i]['tax']];
                            }
                            echo $tzone . '<br />';
                        } else {
                            echo '<br />';
                        }
                    }
                    echo '</td>';
                }
                //reset the string to stop multiple boxes!
                $pravailable = '';
                if ($eshopoptions['stock_control'] == 'yes') {
                    for ($i = 1; $i <= $numoptions; $i++) {
                        if ($eshop_product['products'][$i]['option'] != '') {
                            $available = $wpdb->get_var("select available from {$stocktable} where post_id={$getid} && option_id={$i} limit 1");
                            if ($available == '') {
                                $available = '0';
                            }
                            if (is_numeric($available) && $eshopoptions['stock_control'] == 'yes') {
                                $pravailable .= '<label for="stock' . $calt . '">' . __('Stock', 'eshop') . '</label><input type="text" value="' . $available . '" id="stock' . $scc . '" name="product[' . $getid . '][' . $i . '][stkqty]" size="4" /><br />' . "\n";
                                $scc++;
                            }
                        }
                    }
                } else {
                    $pravailable .= __('n/a', 'eshop') . '<br />';
                }
                echo '<td headers="stk sku' . $calt . '">' . $pravailable . '</td>';
                echo '<td headers="associmg sku' . $calt . '">';
                $w = get_option('thumbnail_size_w');
                $h = get_option('thumbnail_size_h');
                $imgsize = '50';
                $w = round($w * $imgsize / 100);
                $h = round($h * $imgsize / 100);
                if (has_post_thumbnail($getid)) {
                    echo '<a class="itemref" href="' . get_permalink($getid) . '" title="view page">' . get_the_post_thumbnail($getid, array($w, $h)) . '</a>' . "\n";
                } else {
                    $eimage = eshop_files_directory();
                    $eshopnoimage = apply_filters('eshop_no_image', $eimage['1'] . 'noimage.png');
                    echo '<a class="itemref" href="' . get_permalink($getid) . '" title="view page"><img src="' . $eshopnoimage . '" height="' . $h . '" width="' . $w . '" alt="" /></a>' . "\n";
                }
                echo '</td>';
                echo '</tr>' . "\n";
            }
        }
        ?>
		</tbody>
		</table>
		</div>
		<p><input type="submit" name="eshopqp" id="submitit" class="submit button-primary" value="<?php 
        _e('Update Products', 'eshop');
        ?>
" /></p>
		</form>
		<?php 
        //paginate
        echo '<div class="paginate tablenav-pages stuffbox">';
        if ($records != $max) {
            $eecho = $page_links;
        } else {
            --$records;
        }
        echo sprintf('<span class="displaying-num">' . __('Displaying %s&#8211;%s of %s') . '</span>', number_format_i18n(($epage - 1) * $records + 1), number_format_i18n(min($epage * $records, $max)), number_format_i18n($max));
        if (isset($eecho)) {
            $thispage = esc_url(add_query_arg('eshopall', 'yes', $_SERVER['REQUEST_URI']));
            echo "<ul class='page-numbers'>\n\t<li>" . join("</li>\n\t<li>", $eecho) . "</li>\n<li>" . '<a href="' . $thispage . '">' . __('View All', 'eshop') . '</a>' . "</li>\n</ul>\n";
        }
        echo '<br /></div>';
        //end
    } else {
        echo '<p>' . __('There are no products available.', 'eshop') . '</p>';
    }
    echo '</div>';
}
Пример #22
0
/**
 * sorts by "parent_slug / page_slug"
 * @param  array $pages pages array
 * @return array        sorted
 */
function sortParentPath($pages)
{
    $seperator = '/';
    foreach ($pages as $slug => &$page) {
        $page['path'] = $page['parent'] ? $pages[$page['parent']]["url"] . $seperator : '';
        $page['path'] .= $page['url'];
    }
    return subval_sort($pages, 'path');
}
Пример #23
0
//fin choix de la semaine
for ($tid = 0; $tid <= $nb_display; $tid++) {
    $searchstamp = $mondaystamp + $tid * 60 * 60 * 24;
    $myquery = "SELECT * FROM `calend_{$name}` WHERE start_time = '{$searchstamp}';";
    //echo "$myquery<br>";
    $Resultat = mysql_query($myquery);
    for ($Compteur = 0; $Compteur < mysql_numrows($Resultat); $Compteur++) {
        for ($i = 0; $i < $nb_item; $i++) {
            $item_name = $data[$i]['item_name'];
            $tab[$item_name]['date' . $tid] = mysql_result($Resultat, $Compteur, "item{$i}");
        }
    }
}
//tri des tableaux
$data = subval_sort($data, 'order');
$data2 = subval_sort($data2, 'sub_tab_order');
?>

<br>
<table class="tabstd" align="center">
<tr>
		
		
		<?php 
$i_col = 0;
for ($uu = 0; $uu < $nb_sub_tab; $uu++) {
    echo "<table class='tabstd' align='center'>";
    echo "<tr>";
    echo "<td width='150' class='td5'> <h3>" . $data2[$uu]['sub_tab_name'] . "</h3></td>";
    for ($ia = 1; $ia < $nb_display + 1; $ia++) {
        $affstamp_tab = $mondaystamp + ($ia - 1) * 60 * 60 * 24;
                     break;
                 case 'hometown':
                     $player_details[$player->ID][$stat] = '<img class="flag" src="' . WPCM_URL . 'assets/images/flags/' . $natl . '.png" /> ' . $hometown;
                     break;
                 case 'joined':
                     $player_details[$player->ID][$stat] = date_i18n(get_option('date_format'), strtotime($player->post_date));
                     break;
                 case 'subs':
                     $player_details[$player->ID][$stat] = get_player_subs_total($player->ID, $season, $team);
                     break;
             }
         }
     }
 }
 if (array_key_exists($orderby, $player_stats_labels)) {
     $player_details = subval_sort($player_details, $orderby);
     if ($order == 'DESC') {
         $player_details = array_reverse($player_details);
     }
 }
 $count = 0;
 foreach ($player_details as $player_detail) {
     $count++;
     if ($limit > 0 && $count > $limit) {
         break;
     }
     $output .= '<div>';
     foreach ($stats as $stat) {
         if ($stat !== 'subs') {
             $output .= '<div class="' . $stat . '">';
             if ($stat == 'rating') {
Пример #25
0
if (count($pages) > 0) {
    foreach ($pages as &$page) {
        if ($page['parent'] && !isset($pages[$page['parent']])) {
            $page['parent'] = null;
        }
        $level = -1;
        $sort = '';
        for ($p = $page; $p && $level < 20; $p = $p['parent'] ? $pages[$p['parent']] : null) {
            $sort = sprintf('%03d', $p['menuOrder']) . $p['title'] . ' ' . $sort;
            $level++;
        }
        $page['level'] = $level;
        $page['sort'] = $sort;
    }
}
$pages = subval_sort($pages, 'sort');
$i = 0;
?>
		<h3 class="floated" style="float:left"><?php 
echo i18n_r('i18n_navigation/NAVIGATION');
?>
</h3>
    <p class="clear"><?php 
i18n('i18n_navigation/NAVIGATION_DESCR');
?>
</p>
<?php 
if (count($languages) > 0) {
    ?>
    <p>
      <?php 
Пример #26
0
if ($this->canEdit) {
    echo "var isReadOnly = false;";
} else {
    echo "var isReadOnly = true;";
}
?>
var readOnly = null;
if (isReadOnly)
	readOnly = "readOnly";

//DEGERLENDIRME
<?php 
$dataO = array_merge($this->teorikOlcme, $this->performansOlcme);
$dataO = subval_sort($dataO, 'DEGERLENDIRME_ARAC_ADI');
$dataB = array_merge($this->bilgi, $this->beceri, $this->yetkinlik);
$dataB = subval_sort($dataB, 'BECERI_YETKINLIK_ADI');
$r = 'dTables.degerlendirme = new Array(new Array("combo", new Array(';
$so = 'new Array ("Seçiniz", "Seçiniz"),';
if (isset($dataO)) {
    foreach ($dataO as $row) {
        $id = $row["DEGERLENDIRME_ARAC_ID"];
        $value = FormFactory::normalizeVariable($row["DEGERLENDIRME_ARAC_ADI"]);
        $so .= 'new Array ("' . $id . '","' . $value . '"),';
    }
}
$sb = 'new Array ("Seçiniz", "Seçiniz"),';
if (isset($dataB)) {
    foreach ($dataB as $row) {
        $id = $row["BECERI_YETKINLIK_ID"];
        $value = FormFactory::normalizeVariable($row["BECERI_YETKINLIK_ADI"]);
        $sb .= 'new Array ("' . $id . '","' . $value . '"),';
Пример #27
0
// initialize magento environment for 'default' store
require_once '../../app/Mage.php';
Mage::app('default');
$categories = array(array('name' => "T Shirts", 'parent_id' => 4));
function subval_sort($a, $subkey)
{
    foreach ($a as $k => $v) {
        $b[$k] = strtolower($v[$subkey]);
    }
    asort($b);
    foreach ($b as $key => $val) {
        $c[] = $a[$key];
    }
    return $c;
}
$categories = subval_sort($categories, 'name');
foreach ($categories as $cat) {
    //get a new category object
    $category = Mage::getModel('catalog/category');
    $category->setStoreId(0);
    //default/all
    //if update
    if ($id) {
        $category->load($id);
    }
    if ($cat['parent_id']) {
        $parent = '/' . $cat['parent_id'];
    } else {
        $parent = "";
    }
    $subcategory['entity_id'] = 21;
Пример #28
0
/**
 * Get Main Navigation
 *
 * This will return unordered list of main navigation
 * This function uses the menu opitions listed within the 'Edit Page' control panel screen
 *
 * @since 1.0
 * @uses GSDATAOTHERPATH
 * @uses getXML
 * @uses subval_sort
 * @uses find_url
 * @uses strip_quotes 
 * @uses exec_filter 
 *
 * @param string $currentpage This is the ID of the current page the visitor is on
 * @param string $classPrefix Prefix that gets added to the parent and slug classnames
 * @return string 
 */
function get_navigation($currentpage = "", $classPrefix = "")
{
    $menu = '';
    global $pagesArray;
    $pagesSorted = subval_sort($pagesArray, 'menuOrder');
    if (count($pagesSorted) != 0) {
        foreach ($pagesSorted as $page) {
            $sel = $classes = '';
            $url_nav = (string) $page['url'];
            if ($page['menuStatus'] == 'Y') {
                $parentClass = !empty($page['parent']) ? $classPrefix . $page['parent'] . " " : "";
                $classes = trim($parentClass . $classPrefix . $url_nav);
                if ((string) $currentpage == $url_nav) {
                    $classes .= " current active";
                }
                if ($page['menu'] == '') {
                    $page['menu'] = $page['title'];
                }
                if ($page['title'] == '') {
                    $page['title'] = $page['menu'];
                }
                $menu .= '<li class="' . $classes . '"><a href="' . find_url($page['url'], $page['parent']) . '" title="' . encode_quotes(cl($page['title'])) . '">' . strip_decode($page['menu']) . '</a></li>' . "\n";
            }
        }
    }
    echo exec_filter('menuitems', $menu);
    // @filter menuitems (str) menu items html in get_navigation
}
Пример #29
0
getPagesXmlValues();
$count = 0;
foreach ($pagesArray as $page) {
    if ($page['parent'] != '') {
        $parentdata = getXML(GSDATAPAGESPATH . $page['parent'] . '.xml');
        $parentTitle = $parentdata->title;
        $sort = $parentTitle . ' ' . $page['title'];
    } else {
        $sort = $page['title'];
    }
    $page = array_merge($page, array('sort' => $sort));
    $pagesArray_tmp[$count] = $page;
    $count++;
}
$pagesArray = $pagesArray_tmp;
$pagesSorted = subval_sort($pagesArray, 'sort');
$table = get_pages_menu('', '', 0);
get_template('header', cl($SITENAME) . ' &raquo; ' . i18n_r('PAGE_MANAGEMENT'));
?>

<?php 
include 'template/include-nav.php';
?>
	
<div class="bodycontent clearfix">
	
	<div id="maincontent">
	<?php 
exec_action('pages-main');
?>
		<div class="main">
Пример #30
0
    $last_value = count($url_split2);
    $last_value = $last_value - 1;
    $final_array[] = array('value' => $url_split2[$last_value], 'folder' => $url_split2[4], 'url' => $url_row[0], 'post' => $url_row[1]);
}
function subval_sort($a, $subkey)
{
    foreach ($a as $k => $v) {
        $b[$k] = strtolower($v[$subkey]);
    }
    asort($b);
    foreach ($b as $key => $val) {
        $c[] = $a[$key];
    }
    return $c;
}
$sorted = subval_sort($final_array, 'value');
print_r($sorted);
?>
</pre>
<table width="100%">
  <tr><TD>
	<textarea cols="100" rows="30">VALUE,FOLDER,URL,POST<?php 
echo "\n";
foreach ($sorted as $key1 => $val1) {
    print "{$val1['value']},{$val1['folder']},{$val1['url']},{$val['post']}\n";
}
//end foreach
?>
</textarea>		
  </TD></TR>
</table>