Example #1
0
 /**
  * Sort the widgets by order number
  *
  * @param array $widgets
  * @return array - sorted widgets
  */
 public function orderWidgets($widgets = array())
 {
     if (!$widgets) {
         return false;
     }
     return sksort($widgets, "order", "int", true);
 }
function snort_widget_get_alerts()
{
    global $config, $a_instance, $snort_nentries;
    $snort_alerts = array();
    /* read log file(s) */
    $counter = 0;
    foreach ($a_instance as $instanceid => $instance) {
        $snort_uuid = $a_instance[$instanceid]['uuid'];
        $if_real = get_real_interface($a_instance[$instanceid]['interface']);
        /* make sure alert file exists, then "tail" the last '$snort_nentries' from it */
        if (file_exists("/var/log/snort/snort_{$if_real}{$snort_uuid}/alert")) {
            exec("tail -{$snort_nentries} -r /var/log/snort/snort_{$if_real}{$snort_uuid}/alert > /tmp/alert_snort{$snort_uuid}");
            if (file_exists("/tmp/alert_snort{$snort_uuid}")) {
                /*              0         1            2      3       4   5     6   7       8   9       10 11             12       */
                /* File format: timestamp,generator_id,sig_id,sig_rev,msg,proto,src,srcport,dst,dstport,id,classification,priority */
                if (!($fd = fopen("/tmp/alert_snort{$snort_uuid}", "r"))) {
                    log_error(gettext("[Snort Widget] Failed to open file /tmp/alert_snort{$snort_uuid}"));
                    continue;
                }
                while (($fields = fgetcsv($fd, 1000, ',', '"')) !== FALSE) {
                    if (count($fields) < 13) {
                        continue;
                    }
                    // Get the Snort interface this alert was received from
                    $snort_alerts[$counter]['instanceid'] = strtoupper($a_instance[$instanceid]['interface']);
                    // "fields[0]" is the complete timestamp in ASCII form. Convert
                    // to a UNIX timestamp so we can use it for various date and
                    // time formatting.  Also extract the MM/DD/YY component and
                    // reverse its order to YY/MM/DD for proper sorting.
                    $fields[0] = trim($fields[0]);
                    // remove trailing space before comma delimiter
                    $tstamp = strtotime(str_replace("-", " ", $fields[0]));
                    // remove "-" between date and time components
                    $tmp = substr($fields[0], 6, 2) . '/' . substr($fields[0], 0, 2) . '/' . substr($fields[0], 3, 2);
                    $snort_alerts[$counter]['timestamp'] = str_replace(substr($fields[0], 0, 8), $tmp, $fields[0]);
                    $snort_alerts[$counter]['timeonly'] = date("H:i:s", $tstamp);
                    $snort_alerts[$counter]['dateonly'] = date("M d", $tstamp);
                    // Add square brackets around any any IPv6 address
                    if (strpos($fields[6], ":") === FALSE) {
                        $snort_alerts[$counter]['src'] = trim($fields[6]);
                    } else {
                        $snort_alerts[$counter]['src'] = "[" . trim($fields[6]) . "]";
                    }
                    // Add the SRC PORT if not null
                    if (!empty($fields[7])) {
                        $snort_alerts[$counter]['src'] .= ":" . trim($fields[7]);
                    }
                    // Add square brackets around any any IPv6 address
                    if (strpos($fields[8], ":") === FALSE) {
                        $snort_alerts[$counter]['dst'] = trim($fields[8]);
                    } else {
                        $snort_alerts[$counter]['dst'] = "[" . trim($fields[8]) . "]";
                    }
                    // Add the DST PORT if not null
                    if (!empty($fields[9])) {
                        $snort_alerts[$counter]['dst'] .= ":" . trim($fields[9]);
                    }
                    $snort_alerts[$counter]['msg'] = trim($fields[4]);
                    $counter++;
                }
                fclose($fd);
                @unlink("/tmp/alert_snort{$snort_uuid}");
            }
        }
    }
    /* sort the alerts array */
    if (isset($config['syslog']['reverse'])) {
        sksort($snort_alerts, 'timestamp', false);
    } else {
        sksort($snort_alerts, 'timestamp', true);
    }
    return $snort_alerts;
}
Example #3
0
 /**
  * Call functions based on user actions in Plugin Management
  */
 public function adminPlugins($h)
 {
     $pfolder = $h->cage->get->testAlnumLines('plugin');
     $h->plugin->folder = $pfolder;
     // assign this plugin to Hotaru
     $action = $h->cage->get->testAlnumLines('action');
     $order = $h->cage->get->testAlnumLines('order');
     require_once LIBS . 'PluginManagement.php';
     $plugman = new PluginManagement();
     switch ($action) {
         case "activate":
             $plugman->activateDeactivate($h, 1);
             break;
         case "deactivate":
             $plugman->activateDeactivate($h, 0);
             break;
         case "activate_all":
             $plugman->activateDeactivateAll($h, 1);
             break;
         case "deactivate_all":
             $plugman->activateDeactivateAll($h, 0);
             break;
         case "uninstall_all":
             $plugman->uninstallAll($h);
             break;
         case "install":
             $plugman->install($h);
             break;
         case "uninstall":
             $plugman->uninstall($h);
             break;
         case "orderup":
             $plugman->pluginOrder($h, $order, "up");
             break;
         case "orderdown":
             $plugman->pluginOrder($h, $order, "down");
             break;
         default:
             // nothing to do here...
             break;
     }
     // get and sort all the plugins ready for display:
     $allplugins = $plugman->getPlugins($h);
     // get plugins
     $installed_plugins = array_filter($allplugins, array($plugman, 'getInstalledPlugins'));
     $h->vars['installed_plugins'] = sksort($installed_plugins, "order", "int", true);
     $uninstalled_plugins = array_filter($allplugins, array($plugman, 'getUninstalledPlugins'));
     $h->vars['uninstalled_plugins'] = sksort($uninstalled_plugins, 'name', 'char', true);
     return true;
 }
function PhalanxEventList($planet_id)
{
    $planet = GetPlanet($planet_id);
    $user = LoadUser($planet['owner_id']);
    $fleetmap = array(202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215);
    $result = EnumPlanetFleets($planet_id);
    $rows = dbrows($result);
    $task = array();
    $tasknum = 0;
    $unions = array();
    while ($rows--) {
        $fleet_obj = dbarray($result);
        $queue = GetFleetQueue($fleet_obj['fleet_id']);
        // Союзные флоты собираются отдельно
        if ($fleet_obj['union_id'] > 0 && $fleet_obj['target_planet'] == $planet_id && !$unions[$fleet_obj['union_id']]) {
            $task[$tasknum]['end_time'] = $queue['end'];
            // Флоты
            $acs_result = EnumUnionFleets($fleet_obj['union_id']);
            $task[$tasknum]['fleets'] = $acs_rows = dbrows($acs_result);
            $f = 0;
            while ($acs_rows--) {
                $fleet_obj = dbarray($acs_result);
                $task[$tasknum]['fleet'][$f] = array();
                foreach ($fleetmap as $id => $gid) {
                    $task[$tasknum]['fleet'][$f][$gid] = $fleet_obj["ship{$gid}"];
                }
                $task[$tasknum]['fleet'][$f]['owner_id'] = $fleet_obj['owner_id'];
                $task[$tasknum]['fleet'][$f]['origin_id'] = $fleet_obj['start_planet'];
                $task[$tasknum]['fleet'][$f]['target_id'] = $fleet_obj['target_planet'];
                $task[$tasknum]['fleet'][$f]['mission'] = GetMission($fleet_obj);
                $task[$tasknum]['fleet'][$f]['dir'] = 1;
                // на планету
                $f++;
            }
            $unions[$fleet_obj['union_id']] = 1;
            $tasknum++;
            continue;
        }
        if ($fleet_obj['union_id'] > 0 && $fleet_obj['target_planet'] == $planet_id && $fleet_obj['mission'] != 21) {
            continue;
        }
        // Не показывать отправление и возврат Оставить.
        if ($fleet_obj['mission'] == 104) {
            continue;
        }
        if ($fleet_obj['mission'] == 4 && $fleet_obj['start_planet'] == $planet_id) {
            continue;
        }
        // Не показывать возвращающиеся с целевой планеты флоты.
        if ($fleet_obj['mission'] > 100 && $fleet_obj['mission'] < 200 && $fleet_obj['target_planet'] == $planet_id) {
            continue;
        }
        // Время прибытия
        if ($fleet_obj['mission'] < 100 && $fleet_obj['start_planet'] == $planet_id) {
            if ($fleet_obj['mission'] != 15) {
                $task[$tasknum]['end_time'] = $queue['end'] + $fleet_obj['flight_time'];
            } else {
                $task[$tasknum]['end_time'] = $queue['end'];
            }
        } else {
            $task[$tasknum]['end_time'] = $queue['end'];
        }
        // Флот
        $task[$tasknum]['fleets'] = 1;
        $task[$tasknum]['fleet'][0] = array();
        foreach ($fleetmap as $i => $gid) {
            $task[$tasknum]['fleet'][0][$gid] = $fleet_obj["ship{$gid}"];
        }
        $task[$tasknum]['fleet'][0]['owner_id'] = $fleet_obj['owner_id'];
        $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['start_planet'];
        $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['target_planet'];
        $task[$tasknum]['fleet'][0]['mission'] = GetMission($fleet_obj);
        if (GetMission($fleet_obj) == 15) {
            if ($fleet_obj['mission'] < 100) {
                $task[$tasknum]['fleet'][0]['dir'] = 1;
            } else {
                if ($fleet_obj['mission'] < 200) {
                    $task[$tasknum]['fleet'][0]['dir'] = 0;
                } else {
                    $task[$tasknum]['fleet'][0]['dir'] = 2;
                }
            }
        } else {
            if (GetMission($fleet_obj) == 5) {
                if ($fleet_obj['mission'] < 100) {
                    $task[$tasknum]['fleet'][0]['dir'] = 1;
                } else {
                    if ($fleet_obj['mission'] < 200) {
                        $task[$tasknum]['fleet'][0]['dir'] = 0;
                    } else {
                        $task[$tasknum]['fleet'][0]['dir'] = 2;
                    }
                }
            } else {
                if ($fleet_obj['target_planet'] == $planet_id) {
                    $task[$tasknum]['fleet'][0]['dir'] = 1;
                } else {
                    $task[$tasknum]['fleet'][0]['dir'] = 0;
                }
                // возврат
            }
        }
        if ($fleet_obj['mission'] == 20) {
            $task[$tasknum]['fleet'][0]['ipm_amount'] = $fleet_obj['ipm_amount'];
            $task[$tasknum]['fleet'][0]['ipm_target'] = $fleet_obj['ipm_target'];
        }
        $tasknum++;
        // Для убывающей экспедиции добавить псевдозадание удерживания.
        // Не показывать чужие флоты.
        if ($fleet_obj['mission'] == 15 && $fleet_obj['owner_id'] == $user['player_id']) {
            // Время отправления и прибытия
            $task[$tasknum]['end_time'] = $queue['end'] + $fleet_obj['deploy_time'];
            // Флот
            $task[$tasknum]['fleets'] = 1;
            $task[$tasknum]['fleet'][0] = array();
            foreach ($fleetmap as $i => $gid) {
                $task[$tasknum]['fleet'][0][$gid] = $fleet_obj["ship{$gid}"];
            }
            $task[$tasknum]['fleet'][0]['owner_id'] = $fleet_obj['owner_id'];
            $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['start_planet'];
            $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['target_planet'];
            $task[$tasknum]['fleet'][0]['mission'] = GetMission($fleet_obj);
            $task[$tasknum]['fleet'][0]['dir'] = 2;
            $tasknum++;
        }
        // Для прибывающего задания Держаться добавить псевдозадание удерживания.
        if ($fleet_obj['mission'] == 5 && $fleet_obj['owner_id'] != $user['player_id']) {
            // Время отправления и прибытия
            $task[$tasknum]['end_time'] = $queue['end'] + $fleet_obj['deploy_time'];
            // Флот
            $task[$tasknum]['fleets'] = 1;
            $task[$tasknum]['fleet'][0] = array();
            foreach ($fleetmap as $i => $gid) {
                $task[$tasknum]['fleet'][0][$gid] = $fleet_obj["ship{$gid}"];
            }
            $task[$tasknum]['fleet'][0]['owner_id'] = $fleet_obj['owner_id'];
            $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['start_planet'];
            $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['target_planet'];
            $task[$tasknum]['fleet'][0]['mission'] = GetMission($fleet_obj);
            $task[$tasknum]['fleet'][0]['dir'] = 2;
            $tasknum++;
        }
        // Для убывающих или удерживаемых экспедиций добавить псевдозадание возврата.
        if (($fleet_obj['mission'] == 15 || $fleet_obj['mission'] == 215) && $fleet_obj['owner_id'] == $user['player_id']) {
            // Время отправления и прибытия
            if ($fleet_obj['mission'] > 200) {
                $task[$tasknum]['end_time'] = $queue['end'] + $fleet_obj['deploy_time'];
            } else {
                $task[$tasknum]['end_time'] = $queue['end'] + $fleet_obj['deploy_time'] + $fleet_obj['flight_time'];
            }
            // Флот
            $task[$tasknum]['fleets'] = 1;
            $task[$tasknum]['fleet'][0] = array();
            foreach ($fleetmap as $i => $gid) {
                $task[$tasknum]['fleet'][0][$gid] = $fleet_obj["ship{$gid}"];
            }
            $task[$tasknum]['fleet'][0]['owner_id'] = $fleet_obj['owner_id'];
            $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['target_planet'];
            $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['start_planet'];
            $task[$tasknum]['fleet'][0]['mission'] = GetMission($fleet_obj);
            $task[$tasknum]['fleet'][0]['dir'] = 0;
            $tasknum++;
        }
    }
    $anz = 0;
    if ($tasknum > 0) {
        sksort($task, 'end_time', true);
        // Сортировать по времени прибытия.
        $now = time();
        foreach ($task as $i => $t) {
            $seconds = max($t['end_time'] - $now, 0);
            if ($seconds <= 0) {
                continue;
            }
            if ($t['fleets'] > 1) {
                echo "<tr class=''>\n";
            } else {
                if ($t['direction'] == 1) {
                    echo "<tr class='flight'>\n";
                } else {
                    if ($t['direction'] == 0) {
                        echo "<tr class='return'>\n";
                    } else {
                        if ($t['direction'] == 2) {
                            echo "<tr class='holding'>\n";
                        }
                    }
                }
            }
            echo "<th><div id='bxx" . ($i + 1) . "' title='" . $seconds . "'star='" . $t['end_time'] . "'></div></th>\n";
            echo "<th colspan='3'>";
            for ($fl = 0; $fl < $t['fleets']; $fl++) {
                echo FleetSpan($t['fleet'][$fl]);
                if ($t['fleets'] > 1) {
                    echo "<br /><br />";
                }
            }
            echo "</th></tr>\n\n";
            $anz++;
        }
        if ($anz) {
            echo "<script language=javascript>anz=" . $anz . ";t();</script>\n\n";
        }
    }
}
Example #5
0
    } else {
        $array = $temp_array;
    }
}
global $CONFIG;
$url = $CONFIG->wwwroot;
$page_owner = page_owner_entity();
if ($page_owner === false || is_null($page_owner)) {
    $page_owner = $_SESSION['user'];
    set_page_owner($page_owner->getGUID());
}
// List tasks
$area2 = elgg_view_title(sprintf(elgg_echo('tasks:read'), $page_owner->name));
set_context('search');
$items = get_entities('object', 'tasks', page_owner(), '', 1000);
sksort($items, "title", true);
//$area2.= '';
set_context('tasks');
// Format page
//$body = elgg_view_layout('two_column_left_sidebar', $area1, $area2);
// Draw it
//echo page_draw(elgg_echo('tasks:read'),$body);
?>
<style>
	th { cursor: pointer; }
	th { font-weight: bold; background:#000000;color:#ffffff; }
	.task_name { width: 350px; }
	table
{
    border-color: #600;
    border-width: 0 0 1px 1px;
                $snort_alerts[$counter]['dst'] = $fields[8];
                $snort_alerts[$counter]['dstport'] = $fields[9];
                $snort_alerts[$counter]['priority'] = $fields[12];
                $snort_alerts[$counter]['category'] = $fields[11];
                $counter++;
            }
            fclose($fd);
            @unlink("/tmp/alert_{$snort_uuid}");
        }
    }
}
/* sort the array */
if (isset($config['syslog']['reverse'])) {
    sksort($snort_alerts, 'timestamp', false);
} else {
    sksort($snort_alerts, 'timestamp', true);
}
/* display the result */
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tbody>
		<tr class="snort-alert-header">
		  <td width="30%" class="widgetsubheader" >IF/Date</td>
			<td width="40%" class="widgetsubheader">Src/Dst</td>
			<td width="40%" class="widgetsubheader">Details</td>
		</tr>
<?php 
$counter = 0;
if (is_array($snort_alerts)) {
    foreach ($snort_alerts as $alert) {
        echo "\t<tr class='snort-alert-entry'" . $activerow . ">\n\t\t\t\t<td width='30%' class='listr'>" . $alert['instanceid'] . "<br>" . $alert['timeonly'] . " " . $alert['dateonly'] . "</td>\t\t\n\t\t\t\t<td width='40%' class='listr'>" . $alert['src'] . ":" . $alert['srcport'] . "<br>" . $alert['dst'] . ":" . $alert['dstport'] . "</td>\n\t\t\t\t<td width='40%' class='listr'>Pri : " . $alert['priority'] . "<br>Cat : " . $alert['category'] . "</td>\n\t\t\t</tr>";
Example #7
0
    $distance = round($distance, 2);
    $arr = array("locationID" => $locationID, "name" => $info["name"], "address" => $info["address_obj"]["address_string"], "distance" => $distance, "img" => $img, "rating_img" => $rating_img);
    array_push($content, $arr);
}
$place = $places['geos'];
foreach ($place as $info) {
    $locationID = $info["location_id"];
    $photoUrl = 'http://api.tripadvisor.com/api/partner/2.0/location/' . $locationID . '/photos?key=4FDDE1CDF4C2402980BABF84989B111D';
    $photo = json_decode(file_get_contents($photoUrl), true);
    if ($photo['data'] == null) {
        $img = "";
    } else {
        $img = $photo["data"][0]["images"]["large"]["url"];
        //there are other images and the size of the image omitted.
    }
    if (!$img) {
        $img = "";
    }
    $rating_img = "";
    $lat2 = $info["latitude"] * M_PI / 180;
    $lon2 = $info["longitude"] * M_PI / 180;
    $lat1 = $latitude * M_PI / 180;
    $lon1 = $longitude * M_PI / 180;
    $distance = sqrt(pow($lat1 - $lat2, 2) + pow($lon1 - $lon2, 2)) * 3960;
    $distance = round($distance, 2);
    $arr = array("locationID" => $locationID, "name" => $info["name"], "address" => $info["address_obj"]["address_string"], "distance" => $distance, "img" => $img, "rating_img" => $rating_img);
    array_push($content, $arr);
}
sksort($content, "distance", true);
$my_array = array("status" => "OK", "data" => array("places" => $content));
echo json_encode($my_array);
        the_post();
        $event_date = get_post_meta($post->ID, 'event_date', true);
        $event_date = date('Y-m-d h:i:s', strtotime($event_date));
        $ympost = mysql2date("M Y", $event_date);
        if (!isset($array_month[$ympost])) {
            $array_month[$ympost] = array();
        }
        array_push($array_month[$ympost], array('date' => date('d/m', strtotime($event_date)), 'hour' => get_post_meta(get_the_ID(), 'event_start_time', true), 'link' => get_the_permalink(), 'title' => get_the_title(), 'location' => get_post_meta(get_the_ID(), 'event_location', true), 'city' => get_post_meta(get_the_ID(), 'event_city', true), 'description' => get_the_excerpt()));
    }
}
foreach ($array_month as $key => $value) {
    echo '<div class="month">
                                        <h3>' . $key . '</h3>
                                        <ul>';
    // Ordernar DESC array multidimentsional por key
    sksort($value, 'date');
    foreach ($value as $a) {
        ?>
                                <li>
                                    <div class="large-2 columns details">
                                        <p class="date"><span class="icon-calendar" aria-hidden="true"></span> <?php 
        echo $a['date'];
        ?>
</p>
                                        <p><span class="icon-clock" aria-hidden="true"></span> <?php 
        echo $a['hour'];
        ?>
</p>
                                    </div>
                                    <div class="large-10 columns">
                                        <p class="title">
Example #9
0
 /**
  * Call functions based on user actions in Plugin Management
  */
 public function adminPlugins($h)
 {
     $pfolder = $h->cage->get->testAlnumLines('plugin');
     $h->plugin->folder = $pfolder;
     // assign this plugin to Hotaru
     $action = $h->cage->get->testAlnumLines('action');
     $order = $h->cage->get->testAlnumLines('order');
     $ajax = $h->cage->get->testAlnumLines('ajax') ? true : false;
     $clearCache = $ajax ? false : true;
     $plugman = new PluginManagement();
     switch ($action) {
         case "orderAjax":
             $sort = $h->cage->post->testAlnumLines('sort');
             $plugman->pluginReorder($h, $sort);
             //echo 1;
             die;
         case "activate":
             $plugman->activateDeactivate($h, 1, $clearCache);
             if ($ajax) {
                 echo json_encode(1);
                 die;
             }
             break;
         case "reactivateAjax":
             $plugman->uninstall($h, 0, $clearCache);
             $result2 = $plugman->install($h, 0, $clearCache);
             $result = $result2 ? 1 : 0;
             echo json_encode($result);
             die;
         case "activateAjax":
             $result = $plugman->activateDeactivate($h, 1, true);
             echo json_encode($result);
             die;
         case "deactivate":
             $plugman->activateDeactivate($h, 0);
             break;
         case "deactivateAjax":
             $result = $plugman->activateDeactivate($h, 0, true);
             echo json_encode($result);
             die;
         case "activate_all":
             $plugman->activateDeactivateAll($h, 1);
             break;
         case "deactivate_all":
             $plugman->activateDeactivateAll($h, 0);
             break;
         case "uninstall_all":
             $plugman->uninstallAll($h);
             break;
         case "install":
             $plugman->install($h, 0, $clearCache);
             if ($ajax) {
                 echo json_encode(1);
                 die;
             }
             break;
         case "uninstall":
             $plugman->uninstall($h);
             break;
         case "orderup":
             $plugman->pluginOrder($h, $order, "up");
             break;
         case "orderdown":
             $plugman->pluginOrder($h, $order, "down");
             break;
         case "update":
             $plugman->activateDeactivate($h, 0);
             $plugman->update($h);
             $plugman->activateDeactivate($h, 1);
             break;
         case "version_check":
             $plugman->versionCheck($h);
             break;
         default:
             // nothing to do here...
             break;
     }
     $plugman->refreshPluginDetails($h);
     // get and sort all the plugins ready for display:
     $allplugins = $plugman->getPlugins($h);
     // get plugins
     $installed_plugins = array_filter($allplugins, array($plugman, 'getInstalledPlugins'));
     $h->vars['installed_plugins'] = sksort($installed_plugins, "order", "int", true);
     $uninstalled_plugins = array_filter($allplugins, array($plugman, 'getUninstalledPlugins'));
     $h->vars['uninstalled_plugins'] = sksort($uninstalled_plugins, 'name', 'char', true);
     return true;
 }
Example #10
0
        }
    }
    if ($sort_ascending) {
        $array = array_reverse($temp_array);
    } else {
        $array = $temp_array;
    }
}
function get_curl($url)
{
    if (function_exists('curl_init')) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        $output = curl_exec($ch);
        echo curl_error($ch);
        curl_close($ch);
        return $output;
    } else {
        return file_get_contents($url);
    }
}
$instagramResponse = json_decode(get_curl($instagramApi), true);
$twitterResponse = json_decode(get_curl($twitterApi), true);
$result = array_merge($instagramResponse, $twitterResponse);
sksort($result, "createdAt");
print_r(json_encode($result));
die;
Example #11
0
 $sort_options = array("popularity", "default_sort", "provider", "access");
 if (is_null($sort) || !in_array($sort, $sort_options)) {
     $sort = "default_sort";
 }
 if ($sort == "access") {
     $sort = "public";
 }
 if ($sort == "provider") {
     $sort = "default_sort";
 }
 //read contents of json config file
 $config_file_string = file_get_contents('services.json');
 //parse json content into associative array
 $json = json_decode($config_file_string, true);
 //sort array by sort option
 sksort($json, $sort, "true");
 //if there is a sort cookie present and $sort is default order by sort cookie
 $sort_cookie = $app->getCookie('sort_cookie');
 if (isset($sort_cookie)) {
     $costum_order = unserialize($sort_cookie);
     if ($costum_order != NULL && !empty($costum_order)) {
         //check if lengths are the same (only sort if logged in and see all services)
         if (count($costum_order) == count($json)) {
             //only costum resort if default sort is chosen
             if ($sort == 'default_sort') {
                 $json = resort_array($json, $costum_order);
             }
         }
     }
 }
 get_services_json($json, $env['logged_in']);
 /**
  * Enables or disables all plugins, installing if necessary
  *
  * @param int $enabled 
  * Note: This function does not uninstall/delete a plugin.
  */
 public function activateDeactivateAll($h, $enabled = 0)
 {
     // 0 = deactivate, 1 = activate
     // if you want to activate, find all the inactive plugins and vice-versa:
     if ($enabled == 0) {
         $active_plugins = $this->activePlugins($h->db, '*', 1);
     }
     if ($enabled == 1) {
         $active_plugins = $this->activePlugins($h->db, '*', 0);
     }
     if (!$active_plugins) {
         return false;
     }
     /*  The problem with upgrading plugins is many of them require other plugins to work, 
     			therefore half the plugins can't be upgraded if the upgrade is attempted in a 
     			random order. So let's minimize the problem by sorting the plugins by number of 
     			requirements, i.e. plugins that have no requirements (Users, Submit, Sidebar Widgets)
     			are upgraded first, then plugins with one requirement... and finally Pligg Importer,
     			which has about 7 requirements. */
     $i = 0;
     foreach ($active_plugins as $active) {
         $h->plugin->folder = $active->plugin_folder;
         $ordered[$i]['name'] = $active->plugin_folder;
         if (!$active->plugin_requires) {
             $ordered[$i]['req_count'] = 0;
         } else {
             $requires = explode(', ', $active->plugin_requires);
             $ordered[$i]['req_count'] = count($requires);
         }
         $i++;
     }
     $ordered = sksort($ordered, 'req_count', 'int', true);
     foreach ($ordered as $ord) {
         $plugin_row = $h->db->get_row($h->db->prepare("SELECT plugin_folder, plugin_enabled FROM " . TABLE_PLUGINS . " WHERE plugin_folder = %s", $ord['name']));
         $h->plugin->folder = $plugin_row->plugin_folder;
         $this->activateDeactivateDo($h, $plugin_row, $enabled);
     }
 }
 */
if ($h->vars['plugin_settings_csrf_error']) {
    $h->showMessage($h->lang['error_csrf'], 'red');
    return false;
}
?>

<div id="plugin_settings">
	<?php 
$result = '';
if ($h->vars['settings_plugin']) {
    $result = $h->pluginHook('admin_plugin_settings', $h->vars['settings_plugin']);
}
if (!$result) {
    ?>
		<h3><?php 
    echo $h->lang["admin_theme_plugin_settings"];
    ?>
</h3>
	<?php 
    $sb_links = $h->pluginHook('admin_sidebar_plugin_settings');
    if ($sb_links) {
        $sb_links = sksort($sb_links, $subkey = "name", $type = "char", true);
        foreach ($sb_links as $plugin => $details) {
            echo "<li><a href='" . BASEURL . "admin_index.php?page=plugin_settings&amp;plugin=" . $details['plugin'] . "'>" . $details['name'] . "</a></li>";
        }
    }
}
?>
</div>
Example #14
0
 /**
  * Enables or disables all plugins, installing if necessary
  *
  * @param int $enabled 
  * Note: This function does not uninstall/delete a plugin.
  */
 public function activateDeactivateAll($h, $enabled = 0)
 {
     // 0 = deactivate, 1 = activate
     // Clear the database cache to ensure plugins and hooks are up-to-date.
     $h->deleteFiles(CACHE . 'db_cache');
     // Clear the css/js cache to ensure any new ones get included
     $h->deleteFiles(CACHE . 'css_js_cache');
     $h->messages['db, css caches cleared'] = 'alert-info';
     // if you want to deactivate, just go ahead and do it:
     if ($enabled == 0) {
         $sql = "UPDATE " . TABLE_PLUGINS . " SET plugin_enabled = %d, plugin_updateby = %d";
         $h->db->query($h->db->prepare($sql, $enabled, $h->currentUser->id));
         $h->messages[$h->lang("admin_plugins_deactivated")] = 'green';
         return false;
         //$active_plugins = $this->activePlugins($h->db, '*', 1);
     }
     // if you want to activate, find all the inactive plugins
     if ($enabled == 1) {
         $active_plugins = $this->activePlugins($h->db, '*', 0);
     }
     if (!$active_plugins) {
         return false;
     }
     /*  The problem with upgrading plugins is many of them require other plugins to work, 
     			therefore half the plugins can't be upgraded if the upgrade is attempted in a 
     			random order. So let's minimize the problem by sorting the plugins by number of 
     			requirements, i.e. plugins that have no requirements (Users, Submit, Sidebar Widgets)
     			are upgraded first, then plugins with one requirement. */
     $i = 0;
     foreach ($active_plugins as $active) {
         $h->plugin->folder = $active->plugin_folder;
         $ordered[$i]['name'] = $active->plugin_folder;
         if (!$active->plugin_requires) {
             $ordered[$i]['req_count'] = 0;
         } else {
             $requires = explode(', ', $active->plugin_requires);
             $ordered[$i]['req_count'] = count($requires);
         }
         $i++;
     }
     $ordered = sksort($ordered, 'req_count', 'int', true);
     foreach ($ordered as $ord) {
         $plugin_row = $h->db->get_row($h->db->prepare("SELECT plugin_folder, plugin_enabled FROM " . TABLE_PLUGINS . " WHERE plugin_folder = %s", $ord['name']));
         $h->plugin->folder = $plugin_row->plugin_folder;
         $this->activateDeactivateDo($h, $plugin_row, $enabled);
     }
 }
function EventList()
{
    global $GlobalUser;
    $fleetmap = array(202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215);
    // Одиночные флоты
    $tasklist = EnumFleetQueue($GlobalUser['player_id']);
    $rows = dbrows($tasklist);
    $task = array();
    $tasknum = 0;
    while ($rows--) {
        $queue = dbarray($tasklist);
        // Время отправления и прибытия
        $task[$tasknum]['start_time'] = $queue['start'];
        $task[$tasknum]['end_time'] = $queue['end'];
        $fleet_obj = LoadFleet($queue['sub_id']);
        if ($fleet_obj['union_id'] > 0) {
            continue;
        }
        // Союзные флоты собираются отдельно
        // Флот
        $task[$tasknum]['fleets'] = 1;
        $task[$tasknum]['fleet'][0] = array();
        foreach ($fleetmap as $i => $gid) {
            $task[$tasknum]['fleet'][0][$gid] = $fleet_obj["ship{$gid}"];
        }
        $task[$tasknum]['fleet'][0]['owner_id'] = $fleet_obj['owner_id'];
        $task[$tasknum]['fleet'][0]['m'] = $fleet_obj['m'];
        $task[$tasknum]['fleet'][0]['k'] = $fleet_obj['k'];
        $task[$tasknum]['fleet'][0]['d'] = $fleet_obj['d'];
        if ($fleet_obj['mission'] < 100 || $fleet_obj['mission'] > 200) {
            $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['start_planet'];
            $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['target_planet'];
        } else {
            $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['target_planet'];
            $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['start_planet'];
        }
        $task[$tasknum]['fleet'][0]['mission'] = GetMission($fleet_obj);
        if ($fleet_obj['mission'] == 20) {
            $task[$tasknum]['fleet'][0]['ipm_amount'] = $fleet_obj['ipm_amount'];
            $task[$tasknum]['fleet'][0]['ipm_target'] = $fleet_obj['ipm_target'];
        }
        GetDirectionAssignment($fleet_obj, $task[$tasknum]['fleet'][0]['dir'], $task[$tasknum]['fleet'][0]['assign']);
        $tasknum++;
        // Для убывающей экспедиции или держаться добавить псевдозадание удерживания.
        // Не показывать чужие флоты.
        if (($fleet_obj['mission'] == 5 || $fleet_obj['mission'] == 15) && $fleet_obj['owner_id'] == $GlobalUser['player_id']) {
            // Время отправления и прибытия
            $task[$tasknum]['start_time'] = $queue['end'];
            $task[$tasknum]['end_time'] = $task[$tasknum]['start_time'] + $fleet_obj['deploy_time'];
            // Флот
            $task[$tasknum]['fleets'] = 1;
            $task[$tasknum]['fleet'][0] = array();
            foreach ($fleetmap as $i => $gid) {
                $task[$tasknum]['fleet'][0][$gid] = $fleet_obj["ship{$gid}"];
            }
            $task[$tasknum]['fleet'][0]['owner_id'] = $fleet_obj['owner_id'];
            $task[$tasknum]['fleet'][0]['m'] = $task[$tasknum]['fleet'][0]['k'] = $task[$tasknum]['fleet'][0]['d'] = 0;
            $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['start_planet'];
            $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['target_planet'];
            $task[$tasknum]['fleet'][0]['mission'] = GetMission($fleet_obj);
            $task[$tasknum]['fleet'][0]['dir'] = 2;
            $task[$tasknum]['fleet'][0]['assign'] = 0;
            $tasknum++;
        }
        // Для прибывающего задания Держаться добавить псевдозадание удерживания.
        if ($fleet_obj['mission'] == 5 && $fleet_obj['owner_id'] != $GlobalUser['player_id']) {
            // Время отправления и прибытия
            $task[$tasknum]['start_time'] = $queue['end'];
            $task[$tasknum]['end_time'] = $task[$tasknum]['start_time'] + $fleet_obj['deploy_time'];
            // Флот
            $task[$tasknum]['fleets'] = 1;
            $task[$tasknum]['fleet'][0] = array();
            foreach ($fleetmap as $i => $gid) {
                $task[$tasknum]['fleet'][0][$gid] = $fleet_obj["ship{$gid}"];
            }
            $task[$tasknum]['fleet'][0]['owner_id'] = $fleet_obj['owner_id'];
            $task[$tasknum]['fleet'][0]['m'] = $task[$tasknum]['fleet'][0]['k'] = $task[$tasknum]['fleet'][0]['d'] = 0;
            $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['start_planet'];
            $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['target_planet'];
            $task[$tasknum]['fleet'][0]['mission'] = GetMission($fleet_obj);
            $task[$tasknum]['fleet'][0]['dir'] = 2;
            $task[$tasknum]['fleet'][0]['assign'] = 2;
            $tasknum++;
        }
        // Для убывающих или удерживаемых флотов добавить псевдозадание возврата.
        // Не показывать возвраты чужих флотов, задание Оставить и Ракетную атаку.
        if (($fleet_obj['mission'] < 100 || $fleet_obj['mission'] > 200) && $fleet_obj['owner_id'] == $GlobalUser['player_id'] && $fleet_obj['mission'] != 4 && $fleet_obj['mission'] != 20) {
            // Время отправления и прибытия
            $task[$tasknum]['start_time'] = $queue['end'];
            $task[$tasknum]['end_time'] = 2 * $queue['end'] - $queue['start'];
            if (GetMission($fleet_obj) == 5 || GetMission($fleet_obj) == 15) {
                if ($fleet_obj['mission'] > 200) {
                    $task[$tasknum]['end_time'] = $task[$tasknum]['start_time'] + $fleet_obj['deploy_time'];
                } else {
                    $task[$tasknum]['end_time'] = $task[$tasknum]['start_time'] + $fleet_obj['deploy_time'] + $fleet_obj['flight_time'];
                }
            }
            // Флот
            $task[$tasknum]['fleets'] = 1;
            $task[$tasknum]['fleet'][0] = array();
            foreach ($fleetmap as $i => $gid) {
                $task[$tasknum]['fleet'][0][$gid] = $fleet_obj["ship{$gid}"];
            }
            $task[$tasknum]['fleet'][0]['owner_id'] = $fleet_obj['owner_id'];
            $task[$tasknum]['fleet'][0]['m'] = $task[$tasknum]['fleet'][0]['k'] = $task[$tasknum]['fleet'][0]['d'] = 0;
            $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['target_planet'];
            $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['start_planet'];
            $task[$tasknum]['fleet'][0]['mission'] = GetMission($fleet_obj);
            $task[$tasknum]['fleet'][0]['dir'] = 1;
            $task[$tasknum]['fleet'][0]['assign'] = 0;
            $tasknum++;
        }
    }
    // Союзные флоты
    $unions = EnumUnion($GlobalUser['player_id']);
    foreach ($unions as $u => $union) {
        // Флоты
        $result = EnumUnionFleets($union['union_id']);
        $rows = dbrows($result);
        if ($rows > 0) {
            $task[$tasknum]['fleets'] = $rows;
            $f = 0;
            $tn = $tasknum;
            while ($rows--) {
                $fleet_obj = dbarray($result);
                $queue = GetFleetQueue($fleet_obj['fleet_id']);
                $task[$tn]['end_time'] = $queue['end'];
                // Для убывающих или удерживаемых флотов добавить псевдозадание возврата.
                // Не показывать возвраты чужих флотов и задание Оставить.
                if ($fleet_obj['mission'] < 100 && $fleet_obj['owner_id'] == $GlobalUser['player_id']) {
                    $tasknum++;
                    // Время отправления и прибытия
                    $task[$tasknum]['end_time'] = $queue['end'] + $fleet_obj['flight_time'];
                    // Флот
                    $task[$tasknum]['fleets'] = 1;
                    $task[$tasknum]['fleet'][0] = array();
                    foreach ($fleetmap as $i => $gid) {
                        $task[$tasknum]['fleet'][0][$gid] = $fleet_obj["ship{$gid}"];
                    }
                    $task[$tasknum]['fleet'][0]['owner_id'] = $fleet_obj['owner_id'];
                    $task[$tasknum]['fleet'][0]['m'] = $task[$tasknum]['fleet'][0]['k'] = $task[$tasknum]['fleet'][0]['d'] = 0;
                    $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['target_planet'];
                    $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['start_planet'];
                    $task[$tasknum]['fleet'][0]['mission'] = GetMission($fleet_obj);
                    $task[$tasknum]['fleet'][0]['dir'] = 1;
                    $task[$tasknum]['fleet'][0]['assign'] = 0;
                }
                $task[$tn]['fleet'][$f] = array();
                foreach ($fleetmap as $id => $gid) {
                    $task[$tn]['fleet'][$f][$gid] = $fleet_obj["ship{$gid}"];
                }
                $task[$tn]['fleet'][$f]['owner_id'] = $fleet_obj['owner_id'];
                $task[$tn]['fleet'][$f]['m'] = $fleet_obj['m'];
                $task[$tn]['fleet'][$f]['k'] = $fleet_obj['k'];
                $task[$tn]['fleet'][$f]['d'] = $fleet_obj['d'];
                $task[$tn]['fleet'][$f]['origin_id'] = $fleet_obj['start_planet'];
                $task[$tn]['fleet'][$f]['target_id'] = $fleet_obj['target_planet'];
                $task[$tn]['fleet'][$f]['mission'] = GetMission($fleet_obj);
                GetDirectionAssignment($fleet_obj, $task[$tn]['fleet'][$f]['dir'], $task[$tn]['fleet'][$f]['assign']);
                $f++;
            }
            $tasknum++;
        }
    }
    $anz = 0;
    if ($tasknum > 0) {
        sksort($task, 'end_time', true);
        // Сортировать по времени прибытия.
        $now = time();
        foreach ($task as $i => $t) {
            $seconds = max($t['end_time'] - $now, 0);
            if ($seconds <= 0) {
                continue;
            }
            if ($t['fleets'] > 1) {
                echo "<tr class=''>\n";
            } else {
                if ($t['dir'] == 0) {
                    echo "<tr class='flight'>\n";
                } else {
                    if ($t['dir'] == 1) {
                        echo "<tr class='return'>\n";
                    } else {
                        if ($t['dir'] == 2) {
                            echo "<tr class='holding'>\n";
                        }
                    }
                }
            }
            echo "<th><div id='bxx" . ($i + 1) . "' title='" . $seconds . "'star='" . $t['end_time'] . "'></div></th>\n";
            echo "<th colspan='3'>";
            for ($fl = 0; $fl < $t['fleets']; $fl++) {
                echo FleetSpan($t['fleet'][$fl]);
                if ($t['fleets'] > 1) {
                    echo "<br /><br />";
                }
            }
            echo "</th></tr>\n\n";
            $anz++;
        }
        if ($anz) {
            echo "<script language=javascript>anz=" . $anz . ";t();</script>\n\n";
        }
    }
}
Example #16
0
    $rows[$i]['rank'] = $e['rank'];
    $rows[$i]['name'] = $e['character']['name'];
    $rows[$i]['class'] = $e['character']['class'];
    $rows[$i]['race'] = $e['character']['race'];
    $rows[$i]['level'] = $e['character']['level'];
    $rows[$i]['gender'] = $e['character']['gender'];
    $rows[$i]['achiev'] = $e['character']['achievementPoints'];
    $rows[$i]['thumbnail'] = $e['character']['thumbnail'];
    $rows[$i]['spec'] = @$e['character']['spec']['name'];
}
$s = isset($_GET['s']) ? $_GET['s'] : '';
$u = isset($_GET['u']) ? $_GET['u'] : '0';
if ($s != '') {
    sksort($rows, $s, $u);
} else {
    sksort($rows, 'rank', true);
}
//Character Arrays
foreach ($rows as $p) {
    $mrank = $p['rank'];
    $mname = $p['name'];
    $mclass = $p['class'];
    $mrace = $p['race'];
    $mlevel = $p['level'];
    $mgender = $p['gender'];
    $machiev = $p['achiev'];
    $mthumb = $p['thumbnail'];
    $mrole = $p['spec'];
    $classes = array('1', '2', '4', '5', '6', '7', '8', '9', '10', '11');
    $replacements = array('Warrior', 'Paladin', 'Hunter', 'Rogue', 'Priest', 'Death Knight', 'Shaman', 'Mage', 'Warlock', 'Monk', 'Druid');
    $resultclass = $replacements[$p['class'] - 1];
             $temp_array = array_merge($temp_array, array($key => $val));
         }
     }
     if ($sort_ascending == true) {
         $array = array_reverse($temp_array);
     } else {
         $array = $temp_array;
     }
 }
 foreach ($tweets as $i => $t) {
     $tweets[$i]['created_at_timestamp'] = strtotime($t['created_at']);
 }
 if ($sortDir == 'ASC') {
     sksort($tweets, 'created_at_timestamp', true);
 } else {
     sksort($tweets, 'created_at_timestamp', false);
 }
 array_splice($tweets, $limit);
 $tweets = json_decode(json_encode($tweets));
 $feed = $tweets;
 if ($feed === null) {
     $message['message'] = 'No tweets returned.';
     $output = $modx->getChunk($tpl, $message);
 } else {
     $i = 0;
     foreach ($feed as $message) {
         foreach ($excludeEmpty as $k) {
             if ($message->{$k} == '') {
                 continue 2;
             }
         }
                echo ucfirst($key) . ": <a href='" . $meta['authorurl'] . "'>" . $value . "</a>";
                break;
            }
        }
        echo "<br /><br />";
        require_once THEMES . $theme . '/settings.php';
    } else {
        echo '<i>' . make_name($theme, '-') . $h->lang['admin_theme_theme_no_settings'] . '</i>';
    }
} else {
    ?>
		<h3><?php 
    echo $h->lang["admin_theme_theme_settings"];
    ?>
</h3>
		<ul id="plugin_settings_list">
			<?php 
    $themes = $h->getFiles(THEMES, array('404error.php'));
    if ($themes) {
        $themes = sksort($themes, $subkey = "name", $type = "char", true);
        foreach ($themes as $theme) {
            echo "<li><a href='" . BASEURL . "admin_index.php?page=theme_settings&amp;theme=" . $theme . "'>" . $theme . "</a></li>";
        }
    }
    ?>
		</ul>
	<?php 
}
?>
</div>
Example #19
0
    /**
       getPickSeparated 2222222  Template - START
        ************************************************/
    public function getPickSeparated2($orders = array(), $from_shipment = false)
    {
        if (function_exists('sksort')) {
        } else {
            function sksort(&$array, $subkey, $sort_ascending = false)
            {
                if (count($array)) {
                    $temp_array[key($array)] = array_shift($array);
                }
                foreach ($array as $key => $val) {
                    $offset = 0;
                    $found = false;
                    foreach ($temp_array as $tmp_key => $tmp_val) {
                        if (!$found and strtolower($val[$subkey]) > strtolower($tmp_val[$subkey])) {
                            $temp_array = array_merge((array) array_slice($temp_array, 0, $offset), array($key => $val), array_slice($temp_array, $offset));
                            $found = true;
                        }
                        $offset++;
                    }
                    if (!$found) {
                        $temp_array = array_merge($temp_array, array($key => $val));
                    }
                }
                if ($sort_ascending) {
                    $array = array_reverse($temp_array);
                } else {
                    $array = $temp_array;
                }
            }
        }
        #die($from_shipment);
        $debug = 0;
        $this->_beforeGetPdf();
        $this->_initRenderer('invoices');
        $pdf = new Zend_Pdf();
        $this->_setPdf($pdf);
        $style = new Zend_Pdf_Style();
        $page_size = $this->_getConfig('page_size', 'a4', false, 'general');
        if ($page_size == 'letter') {
            $page = $pdf->newPage(Zend_Pdf_Page::SIZE_LETTER);
            $page_top = 770;
            $padded_right = 587;
        } elseif ($page_size == 'a4') {
            $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
            $page_top = 820;
            $padded_right = 570;
        } elseif ($page_size == 'a5landscape') {
            $page = $pdf->newPage('596:421');
            $page_top = 395;
            $padded_right = 573;
        }
        $pdf->pages[] = $page;
        $page_width = $padded_right;
        $skuX = 67;
        $qtyX = 40;
        $productX = 250;
        $fontsize_overall = 15;
        $fontsize_productline = 9;
        $total_quantity = 0;
        $total_cost = 0;
        $red_bkg_color = new Zend_Pdf_Color_Html('lightCoral');
        $grey_bkg_color = new Zend_Pdf_Color_GrayScale(0.7);
        $lt_grey_bkg_color = new Zend_Pdf_Color_GrayScale(0.9);
        $dk_grey_bkg_color = new Zend_Pdf_Color_GrayScale(0.3);
        //darkCyan
        $dk_cyan_bkg_color = new Zend_Pdf_Color_Html('darkCyan');
        //darkOliveGreen
        $dk_og_bkg_color = new Zend_Pdf_Color_Html('darkOliveGreen');
        //darkOliveGreen
        $white_bkg_color = new Zend_Pdf_Color_Html('white');
        $orange_bkg_color = new Zend_Pdf_Color_Html('Orange');
        $black_color = new Zend_Pdf_Color_Rgb(0, 0, 0);
        $grey_color = new Zend_Pdf_Color_GrayScale(0.3);
        $greyout_color = new Zend_Pdf_Color_GrayScale(0.6);
        $white_color = new Zend_Pdf_Color_GrayScale(1);
        $dk_green_color = new Zend_Pdf_Color_Html('darkGreen');
        //darkOliveGreen
        $font_family_header_default = 'helvetica';
        $font_size_header_default = 16;
        $font_style_header_default = 'bolditalic';
        $font_color_header_default = 'darkOliveGreen';
        $font_family_subtitles_default = 'helvetica';
        $font_style_subtitles_default = 'bold';
        $font_size_subtitles_default = 15;
        $font_color_subtitles_default = 'darkOliveGreen';
        //'#222222';
        $background_color_subtitles_default = 'lightGrey';
        //'#999999';
        $font_family_body_default = 'helvetica';
        $font_size_body_default = 10;
        $font_style_body_default = 'regular';
        $font_color_body_default = 'Black';
        $font_family_header = $this->_getConfig('font_family_header', $font_family_header_default, false, 'general');
        $font_style_header = $this->_getConfig('font_style_header', $font_style_header_default, false, 'general');
        $font_size_header = $this->_getConfig('font_size_header', $font_size_header_default, false, 'general');
        $font_color_header = $this->_getConfig('font_color_header', $font_color_header_default, false, 'general');
        $font_family_subtitles = $this->_getConfig('font_family_subtitles', $font_family_subtitles_default, false, 'general');
        $font_style_subtitles = $this->_getConfig('font_style_subtitles', $font_style_subtitles_default, false, 'general');
        $font_size_subtitles = $this->_getConfig('font_size_subtitles', $font_size_subtitles_default, false, 'general');
        $font_color_subtitles = $this->_getConfig('font_color_subtitles', $font_color_subtitles_default, false, 'general');
        $background_color_subtitles = $this->_getConfig('background_color_subtitles', $background_color_subtitles_default, false, 'general');
        $font_family_body = $this->_getConfig('font_family_body', $font_family_body_default, false, 'general');
        $font_style_body = $this->_getConfig('font_style_body', $font_style_body_default, false, 'general');
        $font_size_body = $this->_getConfig('font_size_body', $font_size_body_default, false, 'general');
        $font_color_body = $this->_getConfig('font_color_body', $font_color_body_default, false, 'general');
        $background_color_subtitles_zend = new Zend_Pdf_Color_Html('' . $background_color_subtitles . '');
        $font_color_header_zend = new Zend_Pdf_Color_Html('' . $font_color_header . '');
        $font_color_subtitles_zend = new Zend_Pdf_Color_Html('' . $font_color_subtitles . '');
        $font_color_body_zend = new Zend_Pdf_Color_Html('' . $font_color_body . '');
        $non_standard_characters = $this->_getConfig('non_standard_characters', 0, false, 'general');
        $shelvingpos = $this->_getConfig('shelvingpos', 'col', false, 'general');
        //col/sku
        // $address_country_yn = $this->_getConfig('address_country_yn', 1, false,'general'); //col/sku
        $order_address_yn = $this->_getConfig('pickpack_order_address_yn', 0, false, 'picks');
        //col/sku
        $configurable_names = $this->_getConfig('pickpack_configname_separated', 'simple', false, 'picks');
        //col/sku
        $configurable_names_attribute = trim($this->_getConfig('pickpack_configname_attribute_separated', '', false, 'picks'));
        //col/sku
        if ($configurable_names != 'custom') {
            $configurable_names_attribute = '';
        }
        $barcodes = Mage::getStoreConfig('pickpack_options/picks/pickpack_pickbarcode');
        $product_id = NULL;
        // get it's ID
        $stock = NULL;
        $sku_stock = array();
        // pickpack_cost
        $showcost_yn_default = 0;
        $showcount_yn_default = 0;
        $currency_default = 'USD';
        $shelving_yn_default = 0;
        $shelving_attribute_default = 'shelf';
        $shelvingX_default = 200;
        $supplier_yn_default = 0;
        $supplier_attribute_default = 'supplier';
        $namenudgeYN_default = 0;
        $stockcheck_yn_default = 0;
        $stockcheck_default = 1;
        $shipping_method_x = 0;
        /////// from 1
        $product_id = NULL;
        // get it's ID
        $stock = NULL;
        ///////// /from 1
        $split_supplier_yn_default = 'no';
        $supplier_attribute_default = 'supplier';
        $supplier_options_default = 'filter';
        $supplier_login_default = '';
        $tickbox_default = 'no';
        //no, pick, pickpack
        // $split_supplier_yn 			= $this->_getConfig('pickpack_split_supplier_yn', $split_supplier_yn_default, false,'general');
        $split_supplier_yn_temp = $this->_getConfig('pickpack_split_supplier_yn', $split_supplier_yn_default, false, 'general');
        $split_supplier_options = $this->_getConfig('pickpack_split_supplier_options', 'no', false, 'general');
        $split_supplier_yn = 'no';
        if ($split_supplier_yn_temp == 1) {
            $split_supplier_yn = $split_supplier_options;
        }
        $supplier_attribute = $this->_getConfig('pickpack_supplier_attribute', $supplier_attribute_default, false, 'general');
        $supplier_options = $this->_getConfig('pickpack_supplier_options', $supplier_options_default, false, 'general');
        //$supplier_login 			= $this->_getConfig('pickpack_supplier_login', $supplier_login_default, false,'general');
        $userId = Mage::getSingleton('admin/session')->getUser()->getId();
        $user = Mage::getModel('admin/user')->load($userId);
        $username = $user['username'];
        $supplier_login_pre = $this->_getConfig('pickpack_supplier_login', '', false, 'general');
        $supplier_login_pre = str_replace(array("\n", ','), ';', $supplier_login_pre);
        $supplier_login_pre = explode(';', $supplier_login_pre);
        foreach ($supplier_login_pre as $key => $value) {
            $supplier_login_single = explode(':', $value);
            if (preg_match('~' . $username . '~i', $supplier_login_single[0])) {
                if ($supplier_login_single[1] != 'all') {
                    $supplier_login = trim($supplier_login_single[1]);
                } else {
                    $supplier_login = '';
                }
            }
        }
        $tickbox = $this->_getConfig('pickpack_tickbox', $tickbox_default, false, 'general');
        $picklogo = $this->_getConfig('pickpack_picklogo', 0, false, 'general');
        $showcount_yn = $this->_getConfig('pickpack_count', $showcount_yn_default, false, 'picks');
        $showcost_yn = $this->_getConfig('pickpack_cost', $showcost_yn_default, false, 'picks');
        $currency = $this->_getConfig('pickpack_currency', $currency_default, false, 'picks');
        $currency_symbol = Mage::app()->getLocale()->currency($currency)->getSymbol();
        $stockcheck_yn = $this->_getConfig('pickpack_stock_yn_separated', $stockcheck_yn_default, false, 'picks');
        $stockcheck = $this->_getConfig('pickpack_stock_separated', $stockcheck_default, false, 'picks');
        $shelving_yn = $this->_getConfig('pickpack_shelving_yn_separated', $shelving_yn_default, false, 'picks');
        $shelving_attribute = $this->_getConfig('pickpack_shelving_separated', $shelving_attribute_default, false, 'picks');
        $shelvingX = intval($this->_getConfig('shelving_nudge', $shelvingX_default, true, 'general'));
        $nameyn = $this->_getConfig('pickpack_name_yn_separated', $namenudgeYN_default, false, 'picks');
        $namenudge = intval($this->_getConfig('pickpack_namenudge_separated', 0, false, 'picks'));
        $override_address_format_yn = 1;
        //$this->_getConfig('override_address_format_yn', 0,false,'general');
        // $address_country_yn 	= $this->_getConfig('address_country_yn', 1, false,'general'); //col/sku
        $address_format_default = '{if company}{company},|{/if company}
{if name}{name},|{/if name}
{if street}{street},|{/if street}
{if city}{city}, |{/if city}
{if postcode}{postcode}{/if postcode} {if region}{region},{/if region}|
{country}';
        $address_format = $this->_getConfig('address_format', $address_format_default, false, 'general');
        //col/sku
        $address_countryskip = $this->_getConfig('address_countryskip', 0, false, 'general');
        $shmethod = Mage::getStoreConfig('pickpack_options/picks/pickpack_shipmethod');
        $options_yn_base = $this->_getConfig('separated_options_yn', 0, false, 'picks');
        // no, inline, newline
        $options_yn = $this->_getConfig('separated_options_yn', 0, false, 'picks');
        // no, inline, newline
        if ($options_yn_base == 0) {
            $options_yn = 0;
        }
        $pickpack_options_filter_yn = $this->_getConfig('separated_options_filter_yn', 0, false, 'picks');
        $pickpack_options_filter = $this->_getConfig('separated_options_filter', 0, false, 'picks');
        $pickpack_options_filter_array = array();
        if ($pickpack_options_filter_yn == 0) {
            $pickpack_options_filter = '';
        } elseif (trim($pickpack_options_filter) != '') {
            $pickpack_options_filter_array = explode(',', $pickpack_options_filter);
            foreach ($pickpack_options_filter_array as $key => $value) {
                $pickpack_options_filter_array[$key] = trim($value);
            }
        }
        $pickpack_options_count_filter_array = array();
        $pickpack_options_count_filter = $this->_getConfig('separated_options_count_filter', 0, false, 'picks');
        if ($pickpack_options_filter_yn == 0) {
            $pickpack_options_count_filter = '';
        } elseif (trim($pickpack_options_count_filter) != '') {
            $pickpack_options_count_filter_array = explode(',', $pickpack_options_count_filter);
            foreach ($pickpack_options_count_filter_array as $key => $value) {
                $pickpack_options_count_filter_array[$key] = trim($value);
            }
        }
        $sort_packing_yn = $this->_getConfig('sort_packing_yn', 1, false, 'general');
        $sort_packing = $this->_getConfig('sort_packing', 'sku', false, 'general');
        $sortorder_packing = $this->_getConfig('sort_packing_order', 'ascending', false, 'general');
        $sort_packing_attribute = trim($this->_getConfig('sort_packing_attribute', '', false, 'general'));
        if ($sort_packing_yn == 0) {
            $sortorder_packing = 'none';
        } elseif ($sort_packing == 'Mcategory') {
            $sort_packing = 'Mcategory';
        } elseif ($sort_packing_attribute != '') {
            $sort_packing = $sort_packing_attribute;
        }
        $skuXInc = 0;
        /**
         * get store id
         */
        $storeId = Mage::app()->getStore()->getId();
        $order_id_master = array();
        $sku_order_suppliers = array();
        $sku_shelving = array();
        $sku_shipping_address = array();
        $sku_order_id_options = array();
        $sku_bundle = array();
        $product_build_item = array();
        $product_build = array();
        foreach ($orders as $orderSingle) {
            $order = Mage::getModel('sales/order')->load($orderSingle);
            $putOrderId = $order->getRealOrderId();
            $order_id = $putOrderId;
            $sku_shipping_address_temp = '';
            $sku_shipping_address[$order_id] = '';
            // $sku_shipping_address[$order_id] = str_replace(array('<br />','<br/>',"\n","\p"),'',implode(',',$this->_formatAddress($order->getShippingAddress()->format('pdf'))));
            $shippingAddressFlat = implode(',', $this->_formatAddress($order->getShippingAddress()->format('pdf')));
            $shippingAddressArray = explode(',', str_replace(',', '~,', $shippingAddressFlat));
            // if($override_address_format_yn == 1)
            // 		{
            //
            $shippingAddressArray = array();
            $addy = array();
            $if_contents = array();
            $addy['company'] = $order->getShippingAddress()->getCompany();
            $addy['name'] = $order->getShippingAddress()->getName();
            $addy['first_name'] = $order->getShippingAddress()->getFirstName();
            $addy['last_name'] = $order->getShippingAddress()->getLastName();
            $addy['telephone'] = $order->getShippingAddress()->getTelephone();
            // $addy['email'] = $order->getBillingAddress()->getEmail();
            $i = 0;
            while ($i < 10) {
                if ($order->getShippingAddress()->getStreet($i) && !is_array($order->getShippingAddress()->getStreet($i))) {
                    if (isset($addy['street'])) {
                        $addy['street'] .= ", \n";
                    } else {
                        $addy['street'] = '';
                    }
                    $addy['street'] .= $order->getShippingAddress()->getStreet($i);
                }
                $i++;
            }
            $addy['city'] = $order->getShippingAddress()->getCity();
            $addy['postcode'] = $order->getShippingAddress()->getPostcode();
            $addy['region'] = $order->getShippingAddress()->getRegion();
            $addy['prefix'] = $order->getShippingAddress()->getPrefix();
            $addy['suffix'] = $order->getShippingAddress()->getSuffix();
            $addy['country'] = Mage::app()->getLocale()->getCountryTranslation($order->getShippingAddress()->getCountryId());
            $address_format_set = str_replace(array("\n", '<br />', '<br/>', "\r"), '', $address_format);
            if (trim($address_countryskip) != '') {
                $addy['country'] = str_ireplace($address_countryskip, '', $addy['country']);
            }
            foreach ($addy as $key => $value) {
                $value = trim($value);
                $value = preg_replace('~,$~', '', $value);
                $value = str_replace(',,', ',', $value);
                if ($value != '' && !is_array($value)) {
                    $pre_value = '';
                    // if($key == 'country') $pre_value = '##country##';
                    // 					elseif($key == 'telephone') $pre_value = '##telephone##';
                    preg_match('~\\{if ' . $key . '\\}(.*)\\{\\/if ' . $key . '\\}~ims', $address_format_set, $if_contents);
                    if (isset($if_contents[1])) {
                        $if_contents[1] = str_replace('{' . $key . '}', $value, $if_contents[1]);
                    } else {
                        $if_contents[1] = '';
                    }
                    $address_format_set = preg_replace('~\\{if ' . $key . '\\}(.*)\\{/if ' . $key . '\\}~ims', $pre_value . $if_contents[1], $address_format_set);
                    $address_format_set = str_ireplace('{' . $key . '}', $pre_value . $value, $address_format_set);
                    $address_format_set = str_ireplace('{/' . $key . '}', '', $address_format_set);
                    $address_format_set = str_ireplace('{/if ' . $key . '}', '', $address_format_set);
                } else {
                    $address_format_set = preg_replace('~\\{if ' . $key . '\\}(.*)\\{/if ' . $key . '\\}~i', '', $address_format_set);
                    $address_format_set = str_ireplace('{' . $key . '}', '', $address_format_set);
                    $address_format_set = str_ireplace('{/' . $key . '}', '', $address_format_set);
                    $address_format_set = str_ireplace('{/if ' . $key . '}', '', $address_format_set);
                }
            }
            // $address_format_set = str_replace(array('##telephone##|','##country##|'),array('|##telephone##','|##country##'),$address_format_set);
            // 			$address_format_set = str_replace(array('##telephone##','##country##'),'',$address_format_set);
            $address_format_set = str_replace(array('||', '|'), "\n", trim($address_format_set));
            $shippingAddressArray = explode("\n", $address_format_set);
            // }
            $i = 0;
            $stop_address = FALSE;
            $skip_entry = FALSE;
            foreach ($shippingAddressArray as $i => $value) {
                $value = trim($value);
                $skip_entry = FALSE;
                if (isset($value) && $value != '~') {
                    // remove fax
                    $value = preg_replace('!<(.*)$!', '', $value);
                    if (preg_match('~T:~', $value)) {
                        // if($show_phone_yn == 1)
                        // 				{
                        $value = str_replace('~', '', $value);
                        $value = '[ ' . $value . ' ]';
                    } elseif ($stop_address === FALSE) {
                        if (!isset($shippingAddressArray[$i + 1]) || preg_match('~T:~', $shippingAddressArray[$i + 1])) {
                            // last line, lets bold it and make it a bit bigger
                            $value = str_replace('~', '', $value);
                        } else {
                            if (!isset($shippingAddressArray[$i + 2]) || preg_match('~T:~', $shippingAddressArray[$i + 2])) {
                                $value = str_replace('~', '', $value);
                            } else {
                                $value = str_replace('~', ',', $value);
                            }
                        }
                        $page->setFillColor($black_color);
                    }
                    if ($stop_address === FALSE && $skip_entry === FALSE) {
                        $sku_shipping_address_temp .= ',' . $value;
                    }
                }
                $i++;
            }
            $sku_shipping_address_temp = str_replace(array('  ', ',,', '<br />', '<br/>', "\n", "\\p", ',,', ',,', ','), array(' ', ',', '', '', '', '', ',', ',', ', '), $sku_shipping_address_temp);
            $sku_shipping_address_temp = preg_replace('~, $~', '', $sku_shipping_address_temp);
            $sku_shipping_address[$order_id] = preg_replace('~^\\s?,\\s?~', '', $sku_shipping_address_temp);
            //
            if (!isset($order_id_master[$order_id])) {
                $order_id_master[$order_id] = 0;
            }
            $itemsCollection = $order->getAllVisibleItems();
            //$order->getItemsCollection();
            // $total_items     = count($itemsCollection);
            $max_name_length = 0;
            $test_name = 'abcdefghij';
            //10
            $font_temp = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
            $test_name_length = round($this->parseString($test_name, $font_temp, $font_size_body));
            //*0.77)); // bigger = left
            $pt_per_char = $test_name_length / 10;
            $max_name_length = 550 - $skuX;
            if (!isset($productXInc)) {
                $productXInc = 0;
            }
            $max_sku_length = $productX + $productXInc - 27 - $skuX;
            $breakpoint_name = round($max_name_length / $pt_per_char);
            $breakpoint_sku = round($max_sku_length / $pt_per_char);
            // $product_build_item = array();
            // 	$product_build = array();
            $sku_category = array();
            $coun = 1;
            foreach ($itemsCollection as $item) {
                if ($item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
                    // any products actually go thru here?
                    $sku = $item->getProductOptionByCode('simple_sku');
                    $product_id = Mage::getModel('catalog/product')->setStoreId($storeId)->getIdBySku($sku);
                } else {
                    $sku = $item->getSku();
                    $product_id = $item->getProductId();
                    // get it's ID
                }
                #nu
                // if show options as counted groups
                if ($options_yn == 1) {
                    $full_sku = trim($item->getSku());
                    $parent_sku = preg_replace('~\\-(.*)$~', '', $full_sku);
                    $sku = $parent_sku;
                    // $product_build[$sku]['sku'] = $sku;
                    // 				$product_build[$sku.'-'.$coun]['sku'] = $sku;
                    $product_build_item[] = $sku;
                    //.'-'.$coun;
                    // $product_build[$sku]['sku'] = $sku;
                    $product_sku = $sku;
                    // $sku = $sku.'-'.$coun;
                    // $product_build[$sku]['sku'] = $product_sku;
                    $product_build[$order_id][$sku]['sku'] = $product_sku;
                } else {
                    // unique item id
                    $product_build_item[] = $sku . '-' . $coun;
                    // $product_build[$sku.'-'.$coun]['sku'] = $sku;
                    $product_sku = $sku;
                    $sku = $sku . '-' . $coun;
                    // $product_build[$sku]['sku'] = $product_sku;
                    $product_build[$order_id][$sku]['sku'] = $product_sku;
                }
                $product = Mage::getModel('catalog/product')->setStoreId($storeId)->loadByAttribute('sku', $sku, array('cost', $shelving_attribute, 'name', 'simple_sku', 'qty'));
                if (Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_id)->getQty()) {
                    $stock = round(Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_id)->getQty());
                }
                $options = $item->getProductOptions();
                // $sku_bundle = array();
                if (isset($options['bundle_options']) && is_array($options['bundle_options'])) {
                    /*
                    	$offset = 10;
                    	$this->y -= 10;
                    
                    	$this->_setFont($page, $font_style_body, ($font_size_body-2), $font_family_body, $non_standard_characters, $font_color_body);
                    	$page->drawText($bundle_options_sku, ($productX+$productXInc+$offset) , $this->y , 'UTF-8');						                    
                    	$this->y -= 10;
                    	$page->drawText('Bundle Options : ', ($productX+$productXInc+$offset) , $this->y , 'UTF-8');						                    
                    */
                    $children = $item->getChildrenItems();
                    if (count($children)) {
                        foreach ($children as $child) {
                            $product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($child->getProductId());
                            $sku_b = $child->getSku();
                            $price_b = $child->getPriceInclTax();
                            $qty_b = (int) $child->getQtyOrdered();
                            $name_b = $child->getName();
                            $this->y -= 10;
                            $offset = 20;
                            $shelving_real = '';
                            $shelving_real_b = '';
                            if (isset($shelving_real_yn) && $shelving_real_yn == 1) {
                                if ($product->getData($shelving_real_attribute)) {
                                    $shelving_real_b = $product->getData($shelving_real_attribute);
                                } elseif (Mage::getModel('catalog/product')->setStoreId($storeId)->load($child->getProductId())->getAttributeText($shelving_real_attribute)) {
                                    $shelving_real_b = Mage::getModel('catalog/product')->setStoreId($storeId)->load($child->getProductId())->getAttributeText($shelving_real_attribute);
                                } elseif ($product[$shelving_real_attribute]) {
                                    $shelving_real_b = $product[$shelving_real_attribute];
                                } else {
                                    $shelving_real_b = '';
                                }
                                if (is_array($shelving_real)) {
                                    $shelving_real_b = implode(',', $shelving_real_b);
                                }
                                if (isset($shelving_real_b)) {
                                    $shelving_real_b = trim($shelving_real_b);
                                }
                                // $page->drawText($shelving_real, $shelfX, $this->y , 'UTF-8');
                            }
                            if ($from_shipment) {
                                $qty_string_b = 's:' . (int) $item->getQtyShipped() . ' / o:' . $qty;
                                $price_qty_b = (int) $item->getQtyShipped();
                                $productXInc = 25;
                            } else {
                                $qty_string_b = $qty_b;
                                $price_qty_b = $qty_b;
                                $productXInc = 0;
                            }
                            // echo 'name_b:'.$name_b.' $breakpoint:'.$breakpoint.' strlen($name_b):'.strlen($name_b);exit;
                            $display_name_b = '';
                            if (strlen($name_b) > $breakpoint_name + 2) {
                                $display_name_b = substr(htmlspecialchars_decode($name_b), 0, $breakpoint_name) . '…';
                            } else {
                                $display_name_b = htmlspecialchars_decode($name_b);
                            }
                            $sku_bundle[$order_id][$sku][] = $sku_b . '##' . $display_name_b . '##' . $shelving_real_b . '##' . $qty_string_b;
                        }
                    }
                } else {
                    $sku_bundle[$order_id][$sku] = '';
                }
                $category_label = '';
                $product = Mage::getModel('catalog/product')->load($product_id);
                # Get product's category collection object
                $catCollection = $product->getCategoryCollection();
                # export this collection to array so we could iterate on it's elements
                $categs = $catCollection->exportToArray();
                $categsToLinks = array();
                # Get categories names
                foreach ($categs as $cat) {
                    $categsToLinks[] = Mage::getModel('catalog/category')->load($cat['entity_id'])->getName();
                }
                foreach ($categsToLinks as $ind => $cat) {
                    if ($category_label != '') {
                        $category_label = $category_label . ', ' . $cat;
                    } else {
                        $category_label = $cat;
                    }
                }
                $sku_category[$sku] = $category_label;
                unset($category_label);
                $shelving = '';
                $supplier = '';
                if ($shelving_yn == 1) {
                    if (Mage::getModel('catalog/product')->setStoreId($storeId)->load($product_id)) {
                        $_newProduct = Mage::getModel('catalog/product')->setStoreId($storeId)->load($product_id);
                        if ($_newProduct->getData($shelving_attribute)) {
                            $shelving = $_newProduct->getData('' . $shelving_attribute . '');
                        }
                    } elseif ($product->getData('' . $shelving_attribute . '')) {
                        $shelving = $product->getData($shelving_attribute);
                    } else {
                        $shelving = '';
                    }
                    if (trim($shelving) != '') {
                        if (Mage::getModel('catalog/product')->setStoreId($storeId)->load($product_id)->getAttributeText($shelving_attribute)) {
                            $shelving = Mage::getModel('catalog/product')->setStoreId($storeId)->load($product_id)->getAttributeText($shelving_attribute);
                        } elseif ($product[$shelving_attribute]) {
                            $shelving = $product[$shelving_attribute];
                        } else {
                            $shelving = '';
                        }
                    }
                    if (trim($shelving) != '') {
                        if (is_array($shelving)) {
                            $shelving = implode(',', $shelving);
                        }
                        if (isset($sku_shelving[$sku]) && trim(strtoupper($sku_shelving[$sku])) != trim(strtoupper($shelving))) {
                            $sku_shelving[$sku] .= ',' . trim($shelving);
                        } else {
                            $sku_shelving[$sku] = trim($shelving);
                        }
                        $sku_shelving[$sku] = preg_replace('~,$~', '', $sku_shelving[$sku]);
                    } else {
                        $sku_shelving[$sku] = '';
                    }
                }
                if ($sort_packing != 'none' && $sort_packing != '') {
                    $product_build[$order_id][$sku][$sort_packing] = '';
                    $attributeName = $sort_packing;
                    if ($attributeName == 'Mcategory') {
                        $product_build[$order_id][$sku][$sort_packing] = $sku_category[$sku];
                        //$product_build[$sku]['%%category%%'];//$category_label;
                    } else {
                        $product = Mage::getModel('catalog/product');
                        if (Mage::getModel('catalog/product')->load($product_id)->getData($attributeName)) {
                            $attributeValue = Mage::getModel('catalog/product')->load($product_id)->getData($attributeName);
                            $collection = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter($product->getResource()->getTypeId())->addFieldToFilter('attribute_code', $attributeName);
                            $attribute = $collection->getFirstItem()->setEntity($product->getResource());
                            $attributeOptions = $attribute->getSource()->getAllOptions(false);
                            if (!empty($attributeOptions)) {
                                $result = search($attributeOptions, 'value', $attributeValue);
                                if (isset($result[0]['label'])) {
                                    $product_build[$order_id][$sku][$sort_packing] = preg_replace('/[^a-zA-Z0-9\\s\\-]/', '', $result[0]['label']);
                                }
                            } else {
                                $product_build[$order_id][$sku][$sort_packing] = preg_replace('/[^a-zA-Z0-9\\s\\-]/', '', $attributeValue);
                            }
                        }
                    }
                    unset($attributeName);
                    unset($attribute);
                    unset($attributeOptions);
                    unset($result);
                }
                // print_r($product_build);exit;
                if ($split_supplier_yn != 'no') {
                    if (Mage::getModel('catalog/product')->setStoreId($storeId)->load($product_id)) {
                        $_newProduct = Mage::getModel('catalog/product')->setStoreId($storeId)->load($product_id);
                        if ($_newProduct->getData($supplier_attribute)) {
                            $supplier = $_newProduct->getData('' . $supplier_attribute . '');
                        }
                    } elseif ($product->getData('' . $supplier_attribute . '')) {
                        $supplier = $product->getData($supplier_attribute);
                    }
                    if (Mage::getModel('catalog/product')->setStoreId($storeId)->load($product_id)->getAttributeText($supplier_attribute)) {
                        $supplier = Mage::getModel('catalog/product')->setStoreId($storeId)->load($product_id)->getAttributeText($supplier_attribute);
                    } elseif ($product[$supplier_attribute]) {
                        $supplier = $product[$supplier_attribute];
                    }
                    if (is_array($supplier)) {
                        $supplier = implode(',', $supplier);
                    }
                    if (!$supplier) {
                        $supplier = '~Not Set~';
                    }
                    $supplier = trim(strtoupper($supplier));
                    if (isset($sku_supplier[$sku]) && $sku_supplier[$sku] != $supplier) {
                        $sku_supplier[$sku] .= ',' . $supplier;
                    } else {
                        $sku_supplier[$sku] = $supplier;
                    }
                    $sku_supplier[$sku] = preg_replace('~,$~', '', $sku_supplier[$sku]);
                    if (!isset($supplier_master[$supplier])) {
                        $supplier_master[$supplier] = $supplier;
                    }
                    $order_id_master[$order_id] .= ',' . $supplier;
                }
                if ($shmethod == 1) {
                    // $sku_shipping_method[$order_id] = $order->getShippingDescription();
                    $sku_shipping_method[$order_id] = clean_method($order->getShippingDescription(), 'shipping');
                    // $sku_shipping_method[$order_id] = preg_replace('/[^A-Za-z0-9 _\-\+\&\(\{\}\)]/','',$sku_shipping_method[$order_id]);
                    //
                    // 				$sku_shipping_method[$order_id] = str_ireplace(array('Select Delivery Method','Method','Select postage','- '),'',$sku_shipping_method[$order_id]);
                    // 				$sku_shipping_method[$order_id] = str_ireplace(
                    // 					array("\n","\r",'  ','Free Shipping Free','Free shipping␣ Free','Paypal Express Checkout','Pick up Pick up','Pick up at our ','Cash on delivery','Courier Service','Delivery Charge','  '),
                    // 					array(' ',' ',' ','Free Shipping','Free Shipping','Paypal Express','Pick up','Pickup@','COD','Courier','Charge',' '),
                    // 				$sku_shipping_method[$order_id]);
                    // 				$sku_shipping_method[$order_id] = preg_replace('~Charge:$~i','',$sku_shipping_method[$order_id]);
                    // $sku_shipping_method[$order_id] = str_ireplace('Pick up Pick up','Pick up',$sku_shipping_method[$order_id]);
                    //Pick up at our
                    //Pick up Pick up
                    // $sku_shipping_method[$order_id] = trim(str_ireplace('Paypal Express Checkout','Paypal Express',$sku_shipping_method[$order_id]));
                    if ($sku_shipping_method[$order_id] != '') {
                        $sku_shipping_method[$order_id] = 'Ship: ' . $sku_shipping_method[$order_id];
                    }
                    // $sku_shipping_method[$order_id] = str_ireplace(array('Select Delivery Method','Method'),array('Delivery',''),$order->getShippingDescription());
                    $shipping_method_x = 260;
                    if ($barcodes == 1) {
                        $shipping_method_x = 300;
                    }
                    //$barcodeWidth = 250;
                    $max_shipping_description_length = 41;
                    //37
                    if (strlen($sku_shipping_method[$order_id]) > $max_shipping_description_length) {
                        $sku_shipping_method[$order_id] = trim(substr(htmlspecialchars_decode($sku_shipping_method[$order_id]), 0, $max_shipping_description_length) . '…');
                    }
                    $font_temp = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
                    $font_size_compare = $font_size_subtitles - 2;
                    $line_width = $this->parseString($sku_shipping_method[$order_id], $font_temp, $font_size_compare);
                    // bigger = left
                    //
                    /*
                    				$minXship = (240+($barcodeWidth*2));
                    								$maxLineWidth = ($page_width-$minXship);
                    								
                    								$font_temp = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
                    								$font_size_compare = ($font_size_subtitles - 2);
                    								$line_width = $this->parseString($sku_shipping_method[$order_id],$font_temp,$font_size_compare); // bigger = left
                    							
                    								if($shipping_method_x == 0) $shipping_method_x = 360;
                    								if(($line_width+$shipping_method_x+20)>$page_width)
                    								{
                    									$shipping_method_x = ($page_width-$line_width-20);
                    								}
                    								if(($line_width+$shipping_method_x+20)>$page_width)
                    								{
                    									$shipping_method_x = ($shipping_method_x-$line_width-20);
                    								}
                    								if($shipping_method_x>$minXship)
                    								{
                    									$shipping_method_x = $minXship;
                    								}*/
                }
                /********************************************************/
                // qty in this order of this sku
                $qty = $item->getIsQtyDecimal() ? $item->getQtyOrdered() : (int) $item->getQtyOrdered();
                $sqty = $item->getIsQtyDecimal() ? $item->getQtyShipped() : (int) $item->getQtyShipped();
                // total qty in all orders for this sku
                if (isset($sku_qty[$sku])) {
                    $sku_qty[$sku] = $sku_qty[$sku] + $qty;
                } else {
                    $sku_qty[$sku] = $qty;
                }
                $total_quantity = $total_quantity + $qty;
                $cost = $qty * (is_object($product) ? $product->getCost() : 0);
                $total_cost = $total_cost + $cost;
                $sku_master[$sku] = $sku;
                if (Mage::getModel('catalog/product')->setStoreId($storeId)->load($product_id) && $configurable_names == 'simple') {
                    $_newProduct = Mage::getModel('catalog/product')->setStoreId($storeId)->load($product_id);
                    if ($_newProduct->getData('name')) {
                        $sku_name[$sku] = $_newProduct->getData('name');
                    }
                } elseif ($configurable_names == 'configurable') {
                    $sku_name[$sku] = $item->getName();
                } elseif ($configurable_names == 'custom' && $configurable_names_attribute != '') {
                    $customname = '';
                    if (Mage::getModel('catalog/product')->setStoreId($storeId)->load($product_id)) {
                        $_newProduct = Mage::getModel('catalog/product')->setStoreId($storeId)->load($product_id);
                        if ($_newProduct->getData($configurable_names_attribute)) {
                            $customname = $_newProduct->getData('' . $configurable_names_attribute . '');
                        }
                    } elseif ($product->getData('' . $configurable_names_attribute . '')) {
                        $customname = $product->getData($configurable_names_attribute);
                    } else {
                        $customname = '';
                    }
                    if (trim($customname) != '') {
                        if (Mage::getModel('catalog/product')->setStoreId($storeId)->load($product_id)->getAttributeText($configurable_names_attribute)) {
                            $customname = Mage::getModel('catalog/product')->setStoreId($storeId)->load($product_id)->getAttributeText($configurable_names_attribute);
                        } elseif ($product[$configurable_names_attribute]) {
                            $customname = $product[$configurable_names_attribute];
                        } else {
                            $customname = '';
                        }
                    }
                    if (trim($customname) != '') {
                        if (is_array($customname)) {
                            $customname = implode(',', $customname);
                        }
                        $customname = preg_replace('~,$~', '', $customname);
                    } else {
                        $customname = '';
                    }
                    $sku_name[$sku] = $customname;
                }
                if (isset($options['options']) && is_array($options['options'])) {
                    $i = 0;
                    if (isset($options['options'][$i])) {
                        $continue = 1;
                    }
                    while ($continue == 1) {
                        $options_name_temp[$i] = trim(htmlspecialchars_decode($options['options'][$i]['label'] . ' : ' . $options['options'][$i]['value']));
                        $options_name_temp[$i] = preg_replace('~^select ~i', '', $options_name_temp[$i]);
                        $options_name_temp[$i] = preg_replace('~^enter ~i', '', $options_name_temp[$i]);
                        $options_name_temp[$i] = preg_replace('~^would you Like to ~i', '', $options_name_temp[$i]);
                        $options_name_temp[$i] = preg_replace('~^please enter ~i', '', $options_name_temp[$i]);
                        $options_name_temp[$i] = preg_replace('~^your ~i', '', $options_name_temp[$i]);
                        $options_name_temp[$i] = preg_replace('~\\((.*)\\)~i', '', $options_name_temp[$i]);
                        $i++;
                        $continue = 0;
                        if (isset($options['options'][$i])) {
                            $continue = 1;
                        }
                    }
                    //print_r($options_name_temp);exit;
                    $i = 0;
                    $continue = 0;
                    $opt_count = 0;
                    if (isset($options['options'][$i])) {
                        $continue = 1;
                    }
                    $sku_order_id_options[$order_id][$sku] = array();
                    while ($continue == 1) {
                        // echo 'options_yn:'.$options_yn.' here';exit;
                        if ($i > 0) {
                            $sku_order_id_options[$order_id][$sku] .= ' ';
                        }
                        $sku_order_id_options[$order_id][$sku] .= htmlspecialchars_decode('[ ' . $options['options'][$i]['label'] . ' : ' . $options['options'][$i]['value'] . ' ]');
                        // if show options as a group
                        if ($options_yn != 0 && $opt_count == 0) {
                            $full_sku = trim($item->getSku());
                            $parent_sku = preg_replace('~\\-(.*)$~', '', $full_sku);
                            $full_sku = preg_replace('~^' . $parent_sku . '\\-~', '', $full_sku);
                            $options_sku_array = array();
                            $options_sku_array = explode('-', $full_sku);
                            if (!isset($options_sku_parent[$order_id])) {
                                $options_sku_parent[$order_id] = array();
                            }
                            if (!isset($options_sku_parent[$order_id][$sku])) {
                                $options_sku_parent[$order_id][$sku] = array();
                            }
                            $opt_count = 0;
                            foreach ($options_sku_array as $k => $options_sku_single) {
                                if (!isset($options_sku_parent[$order_id][$sku][$options_sku_single])) {
                                    $options_sku_parent[$order_id][$sku][$options_sku_single] = '';
                                }
                                // if(!isset($options_name_count[$options_sku_single])) $options_name_count[$options_sku_single] = 0;
                                // 								else $options_name_count[$options_sku_single] ++;
                                $options_name[$order_id][$sku][$options_sku_single] = $options_name_temp[$opt_count];
                                if (isset($options_sku[$order_id][$options_sku_single]) && !in_array($options_sku_single, $pickpack_options_filter_array)) {
                                    $options_sku[$order_id][$options_sku_single] = $sku_qty[$sku] + $options_sku[$order_id][$options_sku_single];
                                    $options_sku_parent[$order_id][$sku][$options_sku_single] = $qty + $options_sku_parent[$order_id][$sku][$options_sku_single];
                                    // if($options_name_temp[$opt_count]) $sku_name[$options_sku_single] =  $options_name_temp[$opt_count];
                                } elseif (!in_array($options_sku_single, $pickpack_options_filter_array)) {
                                    $options_sku[$order_id][$options_sku_single] = $sku_qty[$sku];
                                    $options_sku_parent[$order_id][$sku][$options_sku_single] = $qty;
                                    //($sku_qty[$sku]);
                                    // if($options_name_temp[$opt_count]) $sku_name[$options_sku_single] =  $options_name_temp[$opt_count];
                                }
                                $opt_count++;
                            }
                            unset($options_name_temp);
                        }
                        // }
                        $i++;
                        $continue = 0;
                        if (isset($options['options'][$i])) {
                            $continue = 1;
                        }
                    }
                }
                unset($options_name_temp);
                // print_r($options_name);exit;
                $sku_stock[$sku] = $stock;
                if (isset($sku_order_id_qty[$order_id][$sku])) {
                    $sku_order_id_qty[$order_id][$sku] = $sku_order_id_qty[$order_id][$sku] + $qty;
                    $sku_order_id_sqty[$order_id][$sku] = $sku_order_id_sqty[$order_id][$sku] + $sqty;
                    $sku_order_id_sku[$order_id][$sku] = $product_sku;
                    $product_build[$order_id][$sku]['qty'] = $sku_order_id_qty[$order_id][$sku] + $qty;
                    $product_build[$order_id][$sku]['sqty'] = $sku_order_id_sqty[$order_id][$sku] + $sqty;
                    // $sku_order_id_sku[$order_id][$sku] = $product_sku;
                } else {
                    $sku_order_id_qty[$order_id][$sku] = $qty;
                    $sku_order_id_sqty[$order_id][$sku] = $sqty;
                    $sku_order_id_sku[$order_id][$sku] = $product_sku;
                    $product_build[$order_id][$sku]['qty'] = $qty;
                    $product_build[$order_id][$sku]['sqty'] = $sqty;
                }
                if (!isset($max_qty_length)) {
                    $max_qty_length = 2;
                }
                if (strlen($sku_order_id_qty[$order_id][$sku]) > $max_qty_length) {
                    $max_qty_length = strlen($sku_order_id_qty[$order_id][$sku]);
                }
                if (strlen($sku_order_id_sqty[$order_id][$sku]) > $max_qty_length) {
                    $max_qty_length = strlen($sku_order_id_sqty[$order_id][$sku]);
                }
                if ($split_supplier_yn != 'no') {
                    // if(!in_array($supplier,$sku_order_suppliers[$order_id])) $sku_order_suppliers[$order_id][] = $supplier;
                    if (!isset($sku_order_suppliers[$order_id])) {
                        $sku_order_suppliers[$order_id][] = $supplier;
                    } elseif (!in_array($supplier, $sku_order_suppliers[$order_id])) {
                        $sku_order_suppliers[$order_id][] = $supplier;
                    }
                }
                $coun++;
            }
            // echo 'order_id:'.$order_id.' sku:'.$sku;
            ksort($sku_bundle[$order_id]);
        }
        // print_r($sku_bundle);exit;
        $sku_test = array();
        ksort($order_id_master);
        ksort($sku_order_id_qty);
        // ksort($sku_bundle);
        ksort($sku_master);
        ksort($product_build);
        if (isset($supplier_master)) {
            ksort($supplier_master);
        }
        $supplier_previous = '';
        $supplier_item_action = '';
        $first_page_yn = 'y';
        // if($sort_packing != 'none')
        // {
        // 	if($sortorder_packing == 'ascending') $sortorder_packing_bool = true;
        // 	sksort($product_build,$sort_packing,$sortorder_packing_bool);
        // 	// sksort($product_build_item,$sort_packing,$sortorder_packing_bool);
        // }
        // foreach($sku_order_id_qty[$order_id] as $sku =>$qty)
        // print_r($product_build);exit;
        // print_r($sku_order_id_qty);exit;
        /*print_r($order_id_master);
          print_r($supplier_master);
          print_r($sku_order_id_qty);
          print_r($sku_master);
          exit;*/
        if ($split_supplier_yn != 'no') {
            foreach ($supplier_master as $key => $supplier) {
                if (isset($supplier_login) && $supplier_login != '' && strtoupper($supplier) == strtoupper($supplier_login) || !isset($supplier_login) || $supplier_login == '') {
                    if ($first_page_yn == 'n') {
                        $page = $this->newPage();
                    } else {
                        $first_page_yn = 'n';
                    }
                    if ($picklogo == 1) {
                        $packlogo = Mage::getStoreConfig('pickpack_options/wonder/pack_logo', $store);
                        if ($packlogo) {
                            $packlogo = Mage::getStoreConfig('system/filesystem/media', $store) . '/sales/store/logo_pack/' . $packlogo;
                            if (is_file($packlogo)) {
                                $packlogo = Zend_Pdf_Image::imageWithPath($packlogo);
                                $page->drawImage($packlogo, 27, $page_top - 31, 296, $page_top + 10);
                            }
                        }
                        //770 / 820 ($page_top-5)
                        $this->_setFont($page, $font_style_header, $font_size_header, $font_family_header, $non_standard_characters, $font_color_header);
                        $page->drawText('Order-separated Pick List', 325, $page_top - 5, 'UTF-8');
                        $page->drawText(Mage::helper('sales')->__('Supplier : ' . $supplier), 325, $page_top - 25, 'UTF-8');
                        $page->setFillColor($font_color_header_zend);
                        $page->setLineColor($font_color_header_zend);
                        $page->setLineWidth(0.5);
                        $page->drawRectangle(304, $page_top - 31, 316, $page_top + 10);
                        $this->y = 777;
                    } else {
                        $this->_setFont($page, $font_style_header, $font_size_header + 2, $font_family_header, $non_standard_characters, $font_color_header);
                        $page->drawText(Mage::helper('sales')->__('Order-separated Pick List, Supplier : ' . $supplier), 31, $page_top - 5, 'UTF-8');
                        //$page->drawText(Mage::helper('sales')->__('Supplier : '.$supplier), 325, ($page_top-25), 'UTF-8');
                        $page->setLineColor($font_color_header_zend);
                        $page->setFillColor($font_color_header_zend);
                        $page->drawRectangle(27, $page_top - 12, $padded_right, $page_top - 11);
                        $this->y = 800;
                    }
                    $this->_setFont($page, $font_style_body, $font_size_body, $font_family_body, $non_standard_characters, $font_color_body);
                    $sku_supplier_item_action = array();
                    $sku_supplier_item_action_master = array();
                    $page_count = 1;
                    foreach ($order_id_master as $order_id => $value) {
                        // if ($this->y<40) $page = $this->newPage();
                        if ($this->y < 60) {
                            if ($page_count == 1) {
                                $this->_setFont($page, $font_style_subtitles, $font_size_subtitles - 2, $font_family_subtitles, $non_standard_characters, $font_color_subtitles);
                                $page->drawText('-- ' . Mage::helper('sales')->__('Page') . ' ' . $page_count . ' --', 250, $this->y - 15, 'UTF-8');
                            }
                            $page = $this->newPage();
                            $page_count++;
                            $this->_setFont($page, $font_style_subtitles, $font_size_subtitles - 2, $font_family_subtitles, $non_standard_characters, $font_color_subtitles);
                            $page->drawText('-- ' . Mage::helper('sales')->__('Page') . ' ' . $page_count . ' --', 250, $this->y + 15, 'UTF-8');
                        }
                        $grey_title = FALSE;
                        $supplier_array = explode(',', $value);
                        $supplier_skip_order = TRUE;
                        if (in_array(strtoupper(trim($supplier)), $supplier_array)) {
                            $supplier_skip_order = FALSE;
                        } elseif ($supplier_options == 'grey') {
                            $supplier_skip_order = FALSE;
                            $grey_title = TRUE;
                        }
                        // hide only 'filter' settings, if 'grey' show non-fulfileld orders greyed out
                        if ($supplier_skip_order == FALSE) {
                            $page->setFillColor($background_color_subtitles_zend);
                            $page->setLineColor($background_color_subtitles_zend);
                            if ($grey_title == TRUE) {
                                $page->setFillColor($lt_grey_bkg_color);
                                $page->setLineColor($lt_grey_bkg_color);
                            }
                            $page->drawRectangle(27, $this->y, $padded_right, $this->y - 20);
                            $this->_setFont($page, 'bold', $font_size_subtitles, $font_family_subtitles, $non_standard_characters, $font_color_subtitles);
                            // order #
                            if ($grey_title == TRUE) {
                                $page->setFillColor(new Zend_Pdf_Color_GrayScale(0.4));
                            }
                            $page->drawText(Mage::helper('sales')->__('#') . $order_id, 31, $this->y - 15, 'UTF-8');
                            if ($tickbox != 'no' && $grey_title != TRUE) {
                                $page->setFillColor($white_color);
                                $page->setLineColor($black_color);
                                $page->drawRectangle(552, $this->y - 2, 568, $this->y - 18);
                            }
                            // $barcodes = Mage::getStoreConfig('pickpack_options/picks/pickpack_pickbarcode');
                            if ($barcodes == 1) {
                                $barcodeString = $this->convertToBarcodeString($order_id);
                                $barcodeWidth = $this->parseString($order_id, Zend_Pdf_Font::fontWithPath(dirname(__FILE__) . '/' . 'Code128bWin.ttf'), 24);
                                $page->setFillColor($white_color);
                                $page->setLineColor($white_color);
                                $page->drawRectangle($barcodeWidth + 38, $this->y - 2, 40 + $barcodeWidth + $barcodeWidth + 10, $this->y - 18);
                                $page->setFillColor($black_color);
                                if ($grey_title == TRUE) {
                                    $page->setFillColor(new Zend_Pdf_Color_GrayScale(0.4));
                                }
                                $page->setFont(Zend_Pdf_Font::fontWithPath(dirname(__FILE__) . '/' . 'Code128bWin.ttf'), 16);
                                $page->drawText($barcodeString, $barcodeWidth + 50, $this->y - 20, 'CP1252');
                            }
                            if ($shmethod == 1) {
                                if ($grey_title == TRUE) {
                                    $page->setFillColor(new Zend_Pdf_Color_GrayScale(0.4));
                                }
                                $this->_setFont($page, 'bold', $font_size_subtitles - 2, $font_family_subtitles, $non_standard_characters, $font_color_subtitles);
                                $page->drawText($sku_shipping_method[$order_id], $shipping_method_x, $this->y - 15, 'UTF-8');
                            }
                            if ($order_address_yn == 1) {
                                $this->y -= 30;
                                if ($grey_title == TRUE) {
                                    $page->setFillColor(new Zend_Pdf_Color_GrayScale(0.4));
                                }
                                $this->_setFont($page, 'regular', $font_size_subtitles - 4, $font_family_subtitles, $non_standard_characters, $font_color_subtitles);
                                $page->drawText($sku_shipping_address[$order_id], 60, $this->y - 15, 'UTF-8');
                            }
                            $this->y -= 30;
                            foreach ($sku_order_id_qty[$order_id] as $sku => $qty) {
                                $supplier_item_action = 'keep';
                                // if set to filter and a name and this is the name, then print
                                if ($supplier_options == 'filter' && isset($supplier_login) && strtoupper($sku_supplier[$sku]) == strtoupper($supplier_login)) {
                                    $supplier_item_action = 'keep';
                                } elseif ($supplier_options == 'filter' && isset($supplier_login) && $supplier_login != '' && strtoupper($sku_supplier[$sku]) != strtoupper($supplier_login)) {
                                    $supplier_item_action = 'hide';
                                } elseif ($supplier_options == 'grey' && isset($supplier_login) && strtoupper($sku_supplier[$sku]) == strtoupper($supplier_login)) {
                                    $supplier_item_action = 'keep';
                                } elseif ($supplier_options == 'grey' && isset($supplier_login) && $supplier_login != '' && strtoupper($sku_supplier[$sku]) != strtoupper($supplier_login)) {
                                    $supplier_item_action = 'keepGrey';
                                } elseif ($supplier_options == 'grey' && $supplier_login == '' && strtoupper($sku_supplier[$sku]) != strtoupper($supplier)) {
                                    $supplier_item_action = 'keepGrey';
                                } elseif ($supplier_options == 'filter' && $supplier_login == '' && strtoupper($sku_supplier[$sku]) != strtoupper($supplier)) {
                                    $supplier_item_action = 'hide';
                                } elseif ($supplier_options == 'grey' && $supplier_login == '' && strtoupper($sku_supplier[$sku]) == strtoupper($supplier)) {
                                    $supplier_item_action = 'keep';
                                } elseif ($supplier_options == 'filter' && $supplier_login == '' && strtoupper($sku_supplier[$sku]) == strtoupper($supplier)) {
                                    $supplier_item_action = 'keep';
                                } elseif ($supplier_options == 'grey') {
                                    $supplier_item_action = 'keepGrey';
                                } elseif ($supplier_options == 'filter') {
                                    $supplier_item_action = 'hide';
                                }
                                $this->_setFont($page, $font_style_body, $font_size_body, $font_family_body, $non_standard_characters, $font_color_body);
                                if ($supplier_item_action != 'hide' && trim($supplier_item_action) != '') {
                                    if ($this->y < 60) {
                                        if ($page_count == 1) {
                                            $this->_setFont($page, $font_style_subtitles, $font_size_subtitles - 2, $font_family_subtitles, $non_standard_characters, $font_color_subtitles);
                                            $page->drawText('-- ' . Mage::helper('sales')->__('Page') . ' ' . $page_count . ' --', 250, $this->y - 15, 'UTF-8');
                                        }
                                        $page = $this->newPage();
                                        $page_count++;
                                        $this->_setFont($page, $font_style_subtitles, $font_size_subtitles - 2, $font_family_subtitles, $non_standard_characters, $font_color_subtitles);
                                        $page->drawText('-- ' . Mage::helper('sales')->__('Page') . ' ' . $page_count . ' --', 250, $this->y + 15, 'UTF-8');
                                    }
                                    // if ($this->y<15) $page = $this->newPage();
                                    if ($supplier_item_action == 'keepGrey') {
                                        $page->setFillColor($greyout_color);
                                    } elseif ($tickbox != 'no') {
                                        $page->setFillColor($white_color);
                                        $page->setLineColor($black_color);
                                        $page->drawRectangle(27, $this->y, 34, $this->y + 7);
                                        $page->setFillColor($font_color_body_zend);
                                    }
                                    //
                                    $sku_addon = '';
                                    if ($shelving_yn == 1 && trim($sku_shelving[$sku]) != '') {
                                        if ($shelvingpos == 'col') {
                                            $page->drawText('[' . $sku_shelving[$sku] . ']', $shelvingX, $this->y, 'UTF-8');
                                        } else {
                                            $sku_addon = ' / [' . $sku_shelving[$sku] . ']';
                                        }
                                    }
                                    $max_qty_length_display = 0;
                                    if ($from_shipment) {
                                        $max_qty_length_display = ($max_qty_length + 5) * ($font_size_body * 1.1) - 57;
                                        $qty_string = 's:' . (int) $sku_order_id_sqty[$order_id][$sku] . ' / o:' . $qty;
                                    } else {
                                        $qty_string = $qty;
                                    }
                                    $page->drawText($qty_string, $qtyX, $this->y, 'UTF-8');
                                    $page->drawText(' x  ' . $sku . $sku_addon, $skuX + $max_qty_length_display, $this->y, 'UTF-8');
                                    if ($nameyn == 1) {
                                        $page->drawText($sku_name[$sku], intval($namenudge), $this->y, 'UTF-8');
                                    }
                                    //
                                    if ($sku_stock[$sku] < $stockcheck && $stockcheck_yn == 1 && $supplier_item_action != 'keepGrey') {
                                        $this->_setFont($page, $font_style_body, $font_size_body - 2, $font_family_body, $non_standard_characters, $font_color_body);
                                        $this->y -= 12;
                                        $page->setFillColor($red_bkg_color);
                                        $page->setLineColor(new Zend_Pdf_Color_Rgb(1, 1, 1));
                                        $page->drawRectangle(55, $this->y - 4, $padded_right, $this->y + 10);
                                        $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
                                        $warning = 'Stock Warning      SKU: ' . $sku . '    Net Stock After All Picks : ';
                                        if (isset($sku_stock[$sku])) {
                                            $warning .= $sku_stock[$sku];
                                        }
                                        $page->drawText($warning, 60, $this->y, 'UTF-8');
                                        $this->y -= 4;
                                    }
                                    if (isset($sku_order_id_options[$order_id][$sku]) && $sku_order_id_options[$order_id][$sku] != '') {
                                        $this->y -= 10;
                                        $this->_setFont($page, $font_style_body, $font_size_body - 2, $font_family_body, $non_standard_characters, $font_color_body);
                                        if ($options_yn == 0) {
                                            $page->drawText('Options: ' . $sku_order_id_options[$order_id][$sku], $namenudge + 20, $this->y, 'UTF-8');
                                        } else {
                                        }
                                    }
                                    if ($sku_bundle[$order_id][$sku]) {
                                        $offset = 10;
                                        $box_x = $qtyX - $offset;
                                        $this->y -= 10;
                                        $this->_setFont($page, $font_style_body, $font_size_body - 2, $font_family_body, $non_standard_characters, $font_color_body);
                                        $page->drawText('Bundle Options : ', $box_x, $this->y, 'UTF-8');
                                        foreach ($sku_bundle[$order_id][$sku] as $key => $value) {
                                            $sku = '';
                                            $name = '';
                                            $shelf = '';
                                            $qty = '';
                                            $sku_bundle_array = explode('##', $value);
                                            $sku = $sku_bundle_array[0];
                                            $name = $sku_bundle_array[1];
                                            $shelf = $sku_bundle_array[2];
                                            $qty = $sku_bundle_array[3];
                                            $this->_setFont($page, $font_style_body, $font_size_body - 2, $font_family_body, $non_standard_characters, $font_color_body);
                                            $this->y -= 10;
                                            $page->drawText($sku, $skuX + $skuXInc + 10, $this->y, 'UTF-8');
                                            $page->drawText($name, intval($namenudge + 10), $this->y, 'UTF-8');
                                            $page->drawText($shelf, $shelvingX, $this->y, 'UTF-8');
                                            $page->drawText($qty . '  x', $qtyX, $this->y, 'UTF-8');
                                            if ($sku_supplier_item_action[$supplier][$sku] != 'keepGrey' && $tickbox == 'pickpack') {
                                                $page->setLineWidth(0.5);
                                                $page->setFillColor($white_color);
                                                $page->setLineColor($black_color);
                                                $page->drawRectangle($box_x, $this->y - 1, $box_x + 7, $this->y + 6);
                                                $page->setFillColor($black_color);
                                            }
                                        }
                                    }
                                    $this->y -= 12;
                                }
                            }
                        }
                        //end if in supplier_array
                    }
                    // end roll_Order
                }
                // end hide/grey sheets for suppliers
            }
        } else {
            if ($picklogo == 1) {
                $packlogo = Mage::getStoreConfig('pickpack_options/wonder/pack_logo', $store);
                if ($packlogo) {
                    $packlogo = Mage::getStoreConfig('system/filesystem/media', $store) . '/sales/store/logo_pack/' . $packlogo;
                    if (is_file($packlogo)) {
                        $packlogo = Zend_Pdf_Image::imageWithPath($packlogo);
                        $page->drawImage($packlogo, 27, $page_top - 31, 296, $page_top + 10);
                    }
                }
                $this->_setFont($page, $font_style_header, $font_size_header, $font_family_header, $non_standard_characters, $font_color_header);
                if ($from_shipment === true) {
                    $page->drawText('Shipment-separated Pick List', 325, $page_top - 5, 'UTF-8');
                } else {
                    $page->drawText('Order-separated Pick List', 325, $page_top - 5, 'UTF-8');
                }
                // $page->drawText(Mage::helper('sales')->__('Supplier : '.$supplier), 325, 790, 'UTF-8');
                $page->setFillColor($font_color_header_zend);
                $page->setLineColor($font_color_header_zend);
                $page->setLineWidth(0.5);
                $page->drawRectangle(304, $page_top - 31, 316, $page_top + 10);
                $this->y = $page_top - 43;
                //777;
            } else {
                $this->_setFont($page, $font_style_header, $font_size_header + 2, $font_family_header, $non_standard_characters, $font_color_header);
                if ($from_shipment === true) {
                    $page->drawText(Mage::helper('sales')->__('Shipment-separated Pick List'), 31, $page_top - 5, 'UTF-8');
                } else {
                    $page->drawText(Mage::helper('sales')->__('Order-separated Pick List'), 31, $page_top - 5, 'UTF-8');
                }
                $page->setLineColor($font_color_header_zend);
                $page->setFillColor($font_color_header_zend);
                $page->drawRectangle(27, $page_top - 12, $padded_right, $page_top - 11);
                $this->y = $page_top - 20;
                //800;
            }
            $this->_setFont($page, $font_style_body, $font_size_body, $font_family_body, $non_standard_characters, $font_color_body);
            // roll_orderID
            $page_count = 1;
            // foreach($order_id_master as $order_id =>$value)
            // 			{
            foreach ($product_build as $order_id => $order_build) {
                if ($this->y < 60) {
                    if ($page_count == 1) {
                        $this->_setFont($page, $font_style_subtitles, $font_size_subtitles - 2, $font_family_subtitles, $non_standard_characters, $font_color_subtitles);
                        $page->drawText('-- ' . Mage::helper('sales')->__('Page') . ' ' . $page_count . ' --', 250, $this->y - 15, 'UTF-8');
                    }
                    $page = $this->newPage();
                    $page_count++;
                    $this->_setFont($page, $font_style_subtitles, $font_size_subtitles - 2, $font_family_subtitles, $non_standard_characters, $font_color_subtitles);
                    $page->drawText('-- ' . Mage::helper('sales')->__('Page') . ' ' . $page_count . ' --', 250, $this->y + 15, 'UTF-8');
                }
                $page->setFillColor($background_color_subtitles_zend);
                $page->setLineColor($background_color_subtitles_zend);
                $page->drawRectangle(27, $this->y, $padded_right, $this->y - 20);
                // order #
                $this->_setFont($page, 'bold', $font_size_subtitles, $font_family_subtitles, $non_standard_characters, $font_color_subtitles);
                $page->drawText(Mage::helper('sales')->__('#') . $order_id, 31, $this->y - 15, 'UTF-8');
                $barcodes = Mage::getStoreConfig('pickpack_options/picks/pickpack_pickbarcode');
                //587 / 570 ($padded_right-2)
                if ($tickbox != 'no') {
                    $page->setFillColor($white_color);
                    $page->setLineColor($black_color);
                    $page->drawRectangle($padded_right - 2 - 16, $this->y - 2, $padded_right - 2, $this->y - 18);
                    $page->setFillColor($black_color);
                }
                if ($barcodes == 1) {
                    $barcodeString = $this->convertToBarcodeString($order_id);
                    $barcodeWidth = $this->parseString($order_id, Zend_Pdf_Font::fontWithPath(dirname(__FILE__) . '/' . 'Code128bWin.ttf'), 24);
                    $page->setFillColor($white_color);
                    $page->setLineColor($white_color);
                    $page->drawRectangle($barcodeWidth + 38, $this->y - 2, 40 + $barcodeWidth + $barcodeWidth + 10, $this->y - 18);
                    $page->setFillColor(new Zend_Pdf_Color_RGB(0, 0, 0));
                    $page->setFont(Zend_Pdf_Font::fontWithPath(dirname(__FILE__) . '/' . 'Code128bWin.ttf'), 16);
                    $page->drawText($barcodeString, $barcodeWidth + 50, $this->y - 20, 'CP1252');
                }
                if ($shmethod == 1) {
                    $this->_setFont($page, 'bold', $font_size_subtitles - 2, $font_family_subtitles, $non_standard_characters, $font_color_subtitles);
                    $page->drawText($sku_shipping_method[$order_id], $shipping_method_x, $this->y - 15, 'UTF-8');
                }
                if ($order_address_yn == 1) {
                    $page->setFillColor($background_color_subtitles_zend);
                    $page->setLineColor($background_color_subtitles_zend);
                    $page->drawRectangle(27, $this->y - 31, $padded_right, $this->y - 20);
                    // order #
                    $this->_setFont($page, 'regular', $font_size_subtitles * 0.6, $font_family_subtitles, $non_standard_characters, $font_color_subtitles);
                    $this->y -= 28;
                    $page->drawText($sku_shipping_address[$order_id], 31, $this->y, 'UTF-8');
                    // $this->y += 5;
                    $this->y -= 16;
                } else {
                    $this->y -= $font_size_body + 20;
                }
                // 				echo 'sort_packing:'.$sort_packing;
                // print_r($product_build);exit;
                // foreach($product_build as $order_id => $order_build)
                // 				{
                if ($sort_packing != 'none') {
                    if ($sortorder_packing == 'ascending') {
                        $sortorder_packing_bool = true;
                    }
                    sksort($order_build, $sort_packing, $sortorder_packing_bool);
                    // sksort($product_build_item,$sort_packing,$sortorder_packing_bool);
                }
                // print_r($order_build);exit;
                foreach ($order_build as $sku => $value) {
                    // $sku = $key;
                    $dsku = $value['sku'];
                    $qty = $value['qty'];
                    $sqty = $value['sqty'];
                    // echo 'sku:'.$sku.'dsku:'.$dsku;exit;
                    // if ($this->y<15) $page = $this->newPage();
                    if ($this->y < 60) {
                        if ($page_count == 1) {
                            $this->_setFont($page, $font_style_subtitles, $font_size_subtitles - 2, $font_family_subtitles, $non_standard_characters, $font_color_subtitles);
                            $page->drawText('-- ' . Mage::helper('sales')->__('Page') . ' ' . $page_count . ' --', 250, $this->y - 15, 'UTF-8');
                        }
                        $page = $this->newPage();
                        $page_count++;
                        $this->_setFont($page, $font_style_subtitles, $font_size_subtitles - 2, $font_family_subtitles, $non_standard_characters, $font_color_subtitles);
                        $page->drawText('-- ' . Mage::helper('sales')->__('Page') . ' ' . $page_count . ' --', 250, $this->y + 15, 'UTF-8');
                    }
                    $this->_setFont($page, $font_style_body, $font_size_body, $font_family_body, $non_standard_characters, $font_color_body);
                    if ($tickbox != 'no') {
                        $page->setLineWidth(1);
                        $page->setFillColor($white_color);
                        $page->setLineColor($black_color);
                        $page->drawRectangle(27, $this->y, 27 + $font_size_body * 0.65, $this->y + $font_size_body * 0.65);
                        // $page->setLineWidth(0.5);
                        // 					$page->setFillColor($white_color);
                        // 					$page->setLineColor($black_color);
                        // 					$page->drawRectangle(27, $this->y, 34, ($this->y+7));
                        // 					$page->setFillColor($black_color);
                    }
                    $this->_setFont($page, $font_style_body, $font_size_body, $font_family_body, $non_standard_characters, $font_color_body);
                    //
                    $sku_addon = '';
                    if ($shelving_yn == 1 && trim($sku_shelving[$sku]) != '') {
                        if ($shelvingpos == 'col') {
                            $page->drawText('[' . $sku_shelving[$sku] . ']', $shelvingX, $this->y, 'UTF-8');
                        } else {
                            $sku_addon = ' / [' . $sku_shelving[$sku] . ']';
                        }
                    }
                    $max_qty_length_display = 0;
                    if ($from_shipment) {
                        $max_qty_length_display = ($max_qty_length + 5) * ($font_size_body * 1.1) - 57;
                        $qty_string = 's:' . (int) $sku_order_id_sqty[$order_id][$sku] . ' / o:' . $qty;
                    } else {
                        $qty_string = $qty;
                    }
                    $page->drawText($qty_string, $qtyX, $this->y, 'UTF-8');
                    $display_sku = '';
                    if (strlen($sku) > $breakpoint_sku + 2) {
                        // $display_sku = substr(htmlspecialchars_decode($sku_order_id_sku[$order_id][$sku]), 0, ($breakpoint_sku)).'…';
                        $display_sku = substr(htmlspecialchars_decode($dsku), 0, $breakpoint_sku) . '…';
                    } else {
                        $display_sku = htmlspecialchars_decode($dsku);
                    }
                    // $page->drawText(' x  '.$display_sku.$sku_addon, $skuX+$max_qty_length_display, $this->y , 'UTF-8');
                    $page->drawText($display_sku . $sku_addon, $skuX + $max_qty_length_display, $this->y, 'UTF-8');
                    if ($nameyn == 1) {
                        $page->drawText($sku_name[$sku], intval($namenudge), $this->y, 'UTF-8');
                    }
                    if ($sku_stock[$sku] < $stockcheck && $stockcheck_yn == 1) {
                        $this->_setFont($page, $font_style_body, $font_size_body - 2, $font_family_body, $non_standard_characters, $font_color_body);
                        $this->y -= $font_size_body + 2;
                        $page->setFillColor($red_bkg_color);
                        $page->setLineColor(new Zend_Pdf_Color_Rgb(1, 1, 1));
                        $page->drawRectangle(55, $this->y - 4, $padded_right, $this->y + 10);
                        $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
                        $warning = 'Stock Warning      SKU: ' . $sku . '    Net Stock After All Picks : ' . $sku_stock[$sku];
                        $page->drawText($warning, 60, $this->y, 'UTF-8');
                        $this->y -= 4;
                    }
                    if (isset($sku_order_id_options[$order_id][$sku]) && $sku_order_id_options[$order_id][$sku] != '') {
                        $this->_setFont($page, $font_style_body, $font_size_body - 2, $font_family_body, $non_standard_characters, $font_color_body);
                        if ($options_yn == 0) {
                            $this->y -= $font_size_body;
                            $page->drawText('Options: ' . $sku_order_id_options[$order_id][$sku], $namenudge + 20, $this->y, 'UTF-8');
                        } else {
                            ksort($options_sku_parent[$order_id][$sku]);
                            // print_r($options_sku_parent[$order_id][$sku]);exit;
                            foreach ($options_sku_parent[$order_id][$sku] as $options_sku => $options_qty) {
                                if (!in_array($options_sku, $pickpack_options_filter_array)) {
                                    $this->y -= $font_size_body - 2;
                                    if ($tickbox != 'no') {
                                        $page->setFillColor($white_color);
                                        $page->setLineColor($black_color);
                                        $page->setLineWidth(0.5);
                                        $page->drawRectangle(30, $this->y - 1, 36, $this->y + 5);
                                        $page->setLineWidth(1);
                                    }
                                    $this->_setFont($page, $font_style_body, $font_size_body - 2, $font_family_body, $non_standard_characters, $font_color_body);
                                    if (!in_array($options_sku, $pickpack_options_count_filter_array)) {
                                        $page->drawText($options_qty, $qtyX + 4, $this->y, 'UTF-8');
                                        // $page->drawText('x [ '.$options_sku.' ]', ($skuX+$max_qty_length_display + 4) , $this->y , 'UTF-8');
                                        $page->drawText(' [ ' . $options_sku . ' ]', $skuX + $max_qty_length_display + 6, $this->y, 'UTF-8');
                                    } else {
                                        $page->drawText('   [ ' . $options_sku . ' ]', $skuX + $max_qty_length_display + 6, $this->y, 'UTF-8');
                                    }
                                    if (isset($options_name[$order_id][$sku][$options_sku]) && $nameyn == 1) {
                                        $page->drawText($options_name[$order_id][$sku][$options_sku], $namenudge + 4, $this->y, 'UTF-8');
                                    }
                                }
                            }
                        }
                    }
                    if ($sku_bundle[$order_id][$sku]) {
                        $offset = 10;
                        $box_x = $qtyX - $offset;
                        $this->y -= $font_size_body;
                        $this->_setFont($page, $font_style_body, $font_size_body - 2, $font_family_body, $non_standard_characters, $font_color_body);
                        $page->drawText('Bundle Options : ', $box_x, $this->y, 'UTF-8');
                        foreach ($sku_bundle[$order_id][$sku] as $key => $value) {
                            $sku = '';
                            $name = '';
                            $shelf = '';
                            $qty = '';
                            $sku_bundle_array = explode('##', $value);
                            $sku = $sku_bundle_array[0];
                            $name = $sku_bundle_array[1];
                            $shelf = $sku_bundle_array[2];
                            $qty = $sku_bundle_array[3];
                            $this->_setFont($page, $font_style_body, $font_size_body - 2, $font_family_body, $non_standard_characters, $font_color_body);
                            $this->y -= $font_size_body - 2;
                            $page->drawText($sku, $skuX + $skuXInc + 10, $this->y, 'UTF-8');
                            $page->drawText($name, intval($namenudge + 10), $this->y, 'UTF-8');
                            $page->drawText($shelf, $shelvingX, $this->y, 'UTF-8');
                            // $page->drawText($qty.'  x', $qtyX , $this->y , 'UTF-8');
                            $page->drawText($qty, $qtyX, $this->y, 'UTF-8');
                            if ($tickbox != 'no') {
                                $page->setFillColor($white_color);
                                $page->setLineColor($black_color);
                                $page->setLineWidth(0.5);
                                $page->drawRectangle(30, $this->y - 1, 36, $this->y + 5);
                                $page->setLineWidth(1);
                            }
                            // if(((isset($sku_supplier_item_action[$supplier][$sku]) && $sku_supplier_item_action[$supplier][$sku] != 'keepGrey')) && ($tickbox == 'pickpack'))
                            // 						{
                            // 							$page->setLineWidth(0.5);
                            // 							$page->setFillColor($white_color);
                            // 							$page->setLineColor($black_color);
                            // 							$page->drawRectangle($box_x, ($this->y), ($box_x + ($font_size_body-2-4)), ($this->y+($font_size_body-2-4)));
                            // 							$page->setFillColor($black_color);
                            // 						}
                        }
                    }
                    $this->y -= $font_size_body + 1;
                    // }
                }
                // end roll_SKU
            }
            // end roll_Order
            $this->y -= 30;
            // $this->_setFontItalic($page,12);
            if ($showcount_yn == 1 || $showcost_yn == 1) {
                $page->setFillColor($white_bkg_color);
                $page->setLineColor($orange_bkg_color);
                $page->setLineWidth(4);
                $page->drawRectangle(355, $this->y - 34, 568, $this->y + 10 + $font_size_body);
                $this->_setFont($page, $font_style_body, $font_size_body, $font_family_body, $non_standard_characters, $font_color_body);
            }
            if ($showcount_yn == 1) {
                $page->drawText('Total quantity : ' . $total_quantity, 375, $this->y, 'UTF-8');
            }
            $this->y -= 20;
            if ($showcost_yn == 1) {
                $page->drawText('Total cost : ' . $currency_symbol . "  " . $total_cost, 375, $this->y, 'UTF-8');
            }
            $printdates = Mage::getStoreConfig('pickpack_options/picks/pickpack_packprint');
            if ($printdates != 1) {
                $this->_setFontBold($page);
                $page->drawText(Mage::helper('sales')->__('Printed:') . '   ' . date('l jS F Y h:i:s A', Mage::getModel('core/date')->timestamp(time())), 210, 18, 'UTF-8');
            }
        }
        $this->_afterGetPdf();
        return $pdf;
        /**
        	getPickseparated2 222222222 Template - END
        	*********************************************
        	************************************************/
    }
Example #20
0
function PlayerDetails($player_id)
{
    global $galaxy, $stats, $ally;
    if (!key_exists($player_id, $stats)) {
        return;
    }
    $planets = array();
    $moons = array();
    echo "<br><br><font size=+2>" . $stats[$player_id]['name'] . ":</font>";
    echo "<table cellpadding=0 cellspacing=0><tr>";
    echo "<td class=b style=\"vertical-align:top\">";
    echo va(loca("GALATOOL_POINTS"), nicenum($stats[$player_id]['points'] / 1000)) . "<br>";
    echo va(loca("GALATOOL_FLEET"), nicenum($stats[$player_id]['fpoints'])) . "<br>";
    echo va(loca("GALATOOL_RESEARCH"), nicenum($stats[$player_id]['rpoints'])) . "<br>";
    if ($stats[$player_id]['ally_id']) {
        echo va(loca("GALATOOL_ALLY"), $ally[$stats[$player_id]['ally_id']]['name']) . "<br>";
    }
    echo "</td>";
    foreach ($galaxy as $planet_id => $planet) {
        if ($planet['owner_id'] == $player_id && $planet['type'] < 10000) {
            $num = 1000000 * $planet['g'] + 1000 * $planet['s'] + 15 * $planet['p'];
            if ($planet['type'] == 0) {
                $moons[$num] = array();
                $moons[$num]['name'] = $planet['name'];
                $moons[$num]['type'] = 0;
                $moons[$num]['present'] = 1;
            } else {
                $planets[$planet_id] = array();
                $planets[$planet_id]['name'] = $planet['name'];
                $planets[$planet_id]['num'] = $num;
                $planets[$planet_id]['g'] = $planet['g'];
                $planets[$planet_id]['s'] = $planet['s'];
                $planets[$planet_id]['p'] = $planet['p'];
                $planets[$planet_id]['planet_id'] = $planet_id;
                $planets[$planet_id]['type'] = 1;
            }
        }
    }
    $planets = sksort($planets, 'num', true);
    echo "<td class=b><b>" . loca("GALATOOL_PLANETS") . "</b>:";
    echo "<table>";
    foreach ($planets as $id => $planet) {
        echo "<tr><td align=center><img src=\"" . GetPlanetSmallImage(hostname() . "/evolution/", $planet) . "\" height=30px><br>\n";
        echo $planet['name'];
        echo " [" . $planet['g'] . ":" . $planet['s'] . ":" . $planet['p'] . "]</td></tr>";
    }
    echo "</table></td>";
    echo "<td class=b><b>" . loca("GALATOOL_MOONS") . "</b>:";
    echo "<table>";
    if (key_exists($planet['num'], $moons)) {
        foreach ($planets as $id => $planet) {
            if ($moons[$planet['num']]['present'] == 1) {
                echo "<tr><td align=center><img src=\"" . GetPlanetSmallImage(hostname() . "/evolution/", $moons[$planet['num']]) . "\" height=30px><br>\n";
                echo $moons[$planet['num']]['name'] . "</td></tr>";
            } else {
                echo "<tr><td height=\"45px\"></td></tr>";
            }
        }
    }
    echo "</table></td>";
    echo "</tr></table>";
}
    $cover = array();
    $size;
    while ($entry = $hDir->read()) {
        if ($entry == "." || $entry == "..") {
        } else {
            if (preg_match("/.jpg/i", $entry) || preg_match("/.gif/i", $entry) || preg_match("/.jpeg/i", $entry) || preg_match("/.png/i", $entry) || preg_match("/.bmp/i", $entry)) {
                // Dimensionen ermitteln
                $size = getimagesize($dir . $entry);
                // Cover-Informationen in Objekt-Array schreiben
                $cover[] = array("path" => ABS_PATH . COVER_PATH, "src" => $entry, "width" => $size[0], "height" => $size[1]);
            }
        }
    }
    $hDir->close();
    // Array nach SubKey sortieren (Fkt. siehe ../srv/include/tools.php)
    sksort($cover, "src");
    // in JSON-String überführen
    echo json_encode($cover, JSON_NUMERIC_CHECK);
});
// ENDE  - Bilder-Service
// START - Externe APIs
// START: Discogs
/**
 * (GET)
 * Abfrage der Discogs-REST-Schnittstelle von Releases anhand der ID
 * Response (success): Objekt mit Infos zu tracks, artist ...
 */
$app->get('/discogs/:id', function ($id) use($app) {
    // Discogs-REST-Schnittstelle zur Abfrage von Releases anhand der ID
    $url = 'api.discogs.com/releases/' . $id;
    // curl-Objekt instanziieren
Example #22
-1
function dir_list($dir)
{
    $files = array();
    $handler = opendir($dir);
    while ($file = readdir($handler)) {
        if ($file != "." && $file != "..") {
            $results[] = array('mod' => filemtime($dir . '/' . $file), 'file' => $file);
        }
    }
    closedir($handler);
    sksort($results, 'mod', false);
    foreach ($results as $m => $f) {
        $out[] = $f['file'];
    }
    return $out;
}