function TrimArray($arr) { foreach ($arr as $key => $value) { if (!is_array($value)) { $value = str_replace('"', "'", $value); $arr[$key] = trim(str_replace('$', '', $value)); } else { $arr[$key] = TrimArray($arr[$key]); } } return $arr; }
} $m_row = DB::fetch_first("SELECT `Package`, `Version`, `Architecture`, `Filename`, `Tag`, `DownloadTimes`, `Level` FROM `" . DCRM_CON_PREFIX . "Packages` WHERE `ID` = '" . (string) $request_id . "'"); if (!$m_row) { httpinfo(404); } else { $download_path = substr($m_row['Filename'], 1); } if (!empty($download_path)) { if (file_exists($download_path)) { $fake_name = $m_row['Package'] . "_" . $m_row['Version'] . "_" . $m_row['Architecture'] . ".deb"; if (check_commercial_tag($m_row['Tag'])) { if (isset($_SERVER['HTTP_X_UNIQUE_ID'])) { $udid_status = DB::fetch_first("SELECT `Packages`, `Level`, `Downloads` FROM `" . DCRM_CON_PREFIX . "UDID` WHERE `UDID` = '" . $_SERVER['HTTP_X_UNIQUE_ID'] . "' LIMIT 1"); if (!empty($udid_status)) { if (!empty($udid_status['Packages'])) { $udid_packages = TrimArray(explode(',', $udid_status['Packages'])); if (!in_array($m_row['Package'], $udid_packages, true)) { httpinfo(4033); } } else { $udid_level = (int) $udid_status['Level']; $package_level = (int) $m_row['Level']; if ($udid_level <= $package_level) { httpinfo(4033); } } DB::update(DCRM_CON_PREFIX . 'UDID', array('Downloads' => (int) $udid_status['Downloads'] + 1), array('UDID' => $_SERVER['HTTP_X_UNIQUE_ID'])); } else { httpinfo(4033); } } else {
echo $request_id; ?> " style="display: none;" checked="checked" /> <h2><?php _e('View Details'); ?> </h2> <br /> <?php if (!$package_info) { $alert = __('No specified item.'); } else { $screenshots = empty($package_info['ScreenShots']) ? null : maybe_unserialize($package_info['ScreenShots']); unset($package_info['ScreenShots']); if (isset($_GET['action']) && $_GET['action'] == "image" && isset($_POST['image']) && strlen($_POST['image']) > 0) { $images_array = array_filter(TrimArray(explode(',', $_POST['image']))); if (is_array($screenshots)) { $screenshots = array_merge($screenshots, $images_array); } else { $screenshots = $images_array; } DB::update(DCRM_CON_PREFIX . 'Packages', array('ScreenShots' => maybe_serialize($screenshots)), array('ID' => $request_id)); } elseif (isset($_GET['action']) && $_GET['action'] == "del" && isset($_POST['image']) && is_numeric($_POST['image']) && !empty($screenshots)) { array_splice($screenshots, (int) $_POST['image'], 1); if (empty($screenshots)) { $screenshots = null; } DB::update(DCRM_CON_PREFIX . 'Packages', array('ScreenShots' => maybe_serialize($screenshots)), array('ID' => $request_id)); } unset($package_info['Multi']); unset($package_info['System_Support']);
function AddAddresses($s_list) { $a_addrs = TrimArray(explode(",", $s_list)); foreach ($a_addrs as $s_addr) { $this->AddAddress($s_addr); } }
function show_table($list_query) { $level_option = get_option('udid_level'); ?> <style> .udid-packages { max-width: 11em; min-width: 11em; width: 11em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .udid-comments { max-width: 10em; min-width: 10em; width: 10em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .udid-name { min-width: 5em; width: 5em; } .udid-create-time { min-width: 11em; width: 11em; } </style> <div class="row wrapper border-bottom white-bg page-heading"> <div class="col-sm-4"> <h2>Manage UDID</h2> <ol class="breadcrumb"> <li> <a href="index.html">Home</a> </li> <li> <a href="index.html">Packages</a> </li> <li class="active"> <strong><?php _e('Manage UDID'); ?> </strong> </li> </ol> </div> <div class="col-sm-8"> <div class="title-action"> <button id="step5" type="button" onclick="addUDID(event);" class="btn btn-primary"><i class="fa fa-plus"></i> <span class="bold"><?php _e('Add UDID'); ?> </span></button> </div> </div> </div> <div class="wrapper wrapper-content animated fadeInRight"> <div class="ibox float-e-margins"> <div class="ibox-title"> <h5><?php _e('All UDIDs'); ?> </h5> <div class="ibox-tools"> <a class="collapse-link"> <i class="fa fa-chevron-up"></i> </a> <a class="dropdown-toggle" data-toggle="dropdown" href="#"> <i class="fa fa-wrench"></i> </a> <ul class="dropdown-menu dropdown-user"> <li><a href="udid.php?action=level"><?php _e('Manage Level'); ?> </a> </li> <li><a href="#">Config option 2</a> </li> </ul> <a class="close-link"> <i class="fa fa-times"></i> </a> </div> </div> <div class="ibox-content"> <link href="css/plugins/footable/footable.core.css" rel="stylesheet"> <table id="udid-table" class="footable table" data-page-size="9000" data-filter="#top-search"><thead><tr> <th><?php _e('UDID'); ?> </th> <th style="text-align: center;"><?php _e('Level'); ?> </ul></th> <th data-sort-ignore="true"><?php _e('Comment'); ?> </th> <th style="width:7%;" data-sort-ignore="true" ><?php _e('Packages'); ?> </th> <th><?php _e('Downloads'); ?> </th> <th><?php _e('Last IP'); ?> </th> <th><?php _e('Create Time'); ?> </th> <th style="text-align: center;" data-sort-ignore="true"><?php _e('Delete'); ?> </th> <th style="text-align: center;" data-sort-ignore="true"><?php _e('Edit'); ?> </th> </tr></thead><tbody> <?php foreach ($list_query as $list) { ?> <tr id="udid-<?php echo $list['ID']; ?> "> <td class="udid-name"><a href = "udid.php?action=edit&id=<?php echo $list['ID']; ?> "><?php echo htmlspecialchars($list['UDID']); ?> </a></td> <td style="text-align: center;"><?php echo $list['Level']; echo isset($level_option[$list['Level']]) ? $level_option[$list['Level']] : ''; ?> </td> <td class="udid-comments"><?php echo htmlspecialchars($list['Comment']); ?> </td> <td class="udid-packages"><?php echo htmlspecialchars($list['Packages']); ?> </td> <td><?php echo $list['Downloads']; ?> </td> <td><?php echo long2ip($list['IP']); ?> </td> <td class="udid-create-time"><?php echo htmlspecialchars($list['CreateStamp']); ?> </ul></td> <td style="text-align: center;"><a data-udid-id="<?php echo $list['ID']; ?> " data-udid-name="<?php echo htmlspecialchars($list['UDID']); ?> " onclick="deleteUDID(event);" class="fa fa-trash" style="text-align: center; color:#ed5565;"></a></td> <td style="text-align: center;"><a data-udid-id="<?php echo $list['ID']; ?> " onclick="editUDID(event);" class="fa fa-edit" style="color:#1ab394;"></a></td> <?php if (isset($_GET['package'])) { $package_udid = TrimArray(explode(',', $list['Packages'])); if (in_array($_GET['package'], $package_udid, true)) { ?> <td><a href="udid.php?action=binding&contents=<?php echo $_GET['package']; ?> &udid=<?php echo $list['UDID']; ?> &delete=true" class="close" title="<?php _e('Delete'); ?> ">×</a></td> <?php } else { ?> <?php } } else { ?> <?php } ?> </tr> <?php } if (count($list_query, false) < 10) { $page_c = $page; } else { $page_c = $page + 1; } ?> </tbody></table> </div> </div> <?php return $page_c; }
* Auto-detection * * if $send (the form button's name) contains "\n" as the first char * and the script is compose.php, then trim everything. Otherwise, we * don't have to worry. * * This is for a RedHat package bug and a Konqueror (pre 2.1.1?) bug */ global $send, $PHP_SELF; if (isset($send) && substr($send, 0, 1) == "\n" && substr($PHP_SELF, -12) == '/compose.php') { if ($REQUEST_METHOD == 'POST') { global $HTTP_POST_VARS; TrimArray($HTTP_POST_VARS); } else { global $HTTP_GET_VARS; TrimArray($HTTP_GET_VARS); } } require_once SM_PATH . 'include/load_prefs.php'; require_once SM_PATH . 'functions/page_header.php'; require_once SM_PATH . 'functions/prefs.php'; /* Set up the language (i18n.php was included by auth.php). */ global $username, $data_dir; set_up_language(getPref($data_dir, $username, 'language')); $timeZone = getPref($data_dir, $username, 'timezone'); /* Check to see if we are allowed to set the TZ environment variable. * We are able to do this if ... * safe_mode is disabled OR * safe_mode_allowed_env_vars is empty (you are allowed to set any) OR * safe_mode_allowed_env_vars contains TZ */
</th> <th data-sort-ignore="true" style="width:5%;">Edit</th> <?php if (isset($_GET['udid'])) { ?> <th style="width:5%;"><?php _e('Binding'); ?> </th><?php } ?> </tr></thead><tbody> <?php if (isset($_GET['udid'])) { $udid_query = DB::result_first("SELECT `Packages` FROM `" . DCRM_CON_PREFIX . "UDID` WHERE `UDID` = '" . $_GET['udid'] . "'"); $packages_udid = TrimArray(explode(',', $udid_query)); } foreach ($lists as $list) { ?> <tr> <td><label class="checkbox"><input class="i-checks" type="checkbox" data-toggle="checkbox" name="package" value="<?php echo $list['ID']; ?> " onclick="javascript:show(<?php echo $list['Stat']; ?> );" /></label></td> <?php if (empty($list['Name'])) { $list['Name'] = AUTOFILL_NONAME; }
function show_table($list_query) { $level_option = get_option('udid_level'); ?> <table class="table"><thead><tr> <th style="width:20%;"><ul class="ctl"><?php _e('UDID'); ?> </ul></th> <th style="width:10%;"><ul class="ctl"><?php _e('Level'); ?> </ul></th> <th style="width:15%;"><ul class="ctl"><?php _e('Comment'); ?> </ul></th> <th><ul class="ctl"><?php _e('Packages'); ?> </ul></th> <th style="width:10%;"><ul class="ctl"><?php _e('Downloads'); ?> </ul></th> <th style="width:10%;"><ul class="ctl"><?php _e('Last IP'); ?> </ul></th> <th style="width:10%;"><ul class="ctl"><?php _e('Create Time'); ?> </ul></th> <th style="width:5%;"><ul class="ctl"><?php _e('Delete'); ?> </ul></th> <th style="width:5%;"><ul class="ctl"><?php _e('Binding'); ?> </ul></th> </tr></thead><tbody> <?php foreach ($list_query as $list) { ?> <tr> <td><a href = "udid.php?action=edit&id=<?php echo $list['ID']; ?> "><ul class="ctl"><?php echo htmlspecialchars($list['UDID']); ?> </ul></a></td> <td><ul class="ctl"><?php echo $list['Level'] . ' - '; echo isset($level_option[$list['Level']]) ? $level_option[$list['Level']] : ''; ?> </ul></td> <td><ul class="ctl"><?php echo htmlspecialchars($list['Comment']); ?> </ul></td> <td><ul class="ctl"><?php echo htmlspecialchars($list['Packages']); ?> </ul></td> <td><ul class="ctl"><?php echo $list['Downloads']; ?> </ul></td> <td><ul class="ctl"><?php echo long2ip($list['IP']); ?> </ul></td> <td><ul class="ctl"><?php echo htmlspecialchars($list['CreateStamp']); ?> </ul></td> <td><a href="udid.php?action=delete_confirm&name=<?php echo $list['UDID']; ?> &id=<?php echo $list['ID']; ?> " class="close">×</a></td> <?php if (isset($_GET['package'])) { $package_udid = TrimArray(explode(',', $list['Packages'])); if (in_array($_GET['package'], $package_udid, true)) { ?> <td><a href="udid.php?action=binding&contents=<?php echo $_GET['package']; ?> &udid=<?php echo $list['UDID']; ?> &delete=true" class="close" title="<?php _e('Delete'); ?> ">×</a></td> <?php } else { ?> <td><a href="udid.php?action=binding&contents=<?php echo $_GET['package']; ?> &udid=<?php echo $list['UDID']; ?> " class="close" title="<?php _e('Binding'); ?> ">※</a></td> <?php } } else { ?> <td><a href="center.php?action=search&contents=cydia::commercial&type=8&udid=<?php echo $list['UDID']; ?> " class="close">※</a></td> <?php } ?> </tr> <?php } if (count($list_query, false) < 10) { $page_c = $page; } else { $page_c = $page + 1; } ?> </tbody></table> <?php return $page_c; }
/** * 字符串处理 * * 用于商业软件包处理,可在标签中添加或删除cydia::commercial等 * * @param string $input 输入字符串 * @param bool $switch 在字符串中添加(true)或删除(false)$switch_string * @param string $switch_string 要添加或删除的字符串 * @param string $separator 分隔符 * @return string 处理完成的字符串 */ function _string_handle($input, $switch, $switch_string = 'cydia::commercial', $separator = ' ') { if (is_array($input)) { $input = $input[0]; } $input_array = TrimArray(explode($separator, $input)); if ($switch) { if (!in_array($switch_string, $input_array, true)) { $input_array[] = $switch_string; } } else { if (in_array($switch_string, $input_array, true)) { $input_array = array_diff($input_array, array($switch_string)); } } if (!strpos(' ', $separator)) { $separator = $separator . ' '; } return trim(implode($separator, array_filter($input_array))); }
function WriteCSVFile($s_csv_file, $a_vars) { global $SPECIAL_VALUES, $CSVSEP, $CSVINTSEP, $CSVQUOTE, $CSVOPEN, $CSVLINE; // // create an array of column values in the order specified // in $SPECIAL_VALUES["csvcolumns"] // $a_column_list = $SPECIAL_VALUES["csvcolumns"]; if (!isset($a_column_list) || empty($a_column_list) || !is_string($a_column_list)) { SendAlert(GetMessage(MSG_CSVCOLUMNS, array("VALUE" => $a_column_list))); return; } if (!isset($s_csv_file) || empty($s_csv_file) || !is_string($s_csv_file)) { SendAlert(GetMessage(MSG_CSVFILE, array("VALUE" => $s_csv_file))); return; } @($fp = fopen($s_csv_file, "a" . $CSVOPEN)); if ($fp === false) { SendAlert(GetMessage(MSG_FILE_OPEN_ERROR, array("NAME" => $s_csv_file, "TYPE" => "CSV", "ERROR" => CheckString($php_errormsg)))); return; } // // convert the column list to an array, trim the names too // $a_column_list = TrimArray(explode(",", $a_column_list)); $n_columns = count($a_column_list); // // if the file is currently empty, put the column names in the first line // if (filesize($s_csv_file) == 0) { for ($ii = 0; $ii < $n_columns; $ii++) { fwrite($fp, $CSVQUOTE . $a_column_list[$ii] . $CSVQUOTE); if ($ii < $n_columns - 1) { fwrite($fp, "{$CSVSEP}"); } } fwrite($fp, $CSVLINE); } // $debug = ""; // $debug .= "gpc -> ".get_magic_quotes_gpc()."\n"; // $debug .= "runtime -> ".get_magic_quotes_runtime()."\n"; for ($ii = 0; $ii < $n_columns; $ii++) { $s_col_name = $a_column_list[$ii]; // // columns can be missing from some form submission and present // from others // if (isset($a_vars[$s_col_name])) { $m_value = $a_vars[$s_col_name]; } else { $m_value = ""; } if (LIMITED_IMPORT) { // // the target database doesn't understand escapes, so // remove various things, including newlines and truncate // $m_value = CleanValue($m_value, false); } else { // // the target database does understand escapes, so // we have to slash any slashes // $m_value = str_replace("\\", "\\\\", $m_value); } // // convert quotes, depending on the setting of $CSVQUOTE // switch ($CSVQUOTE) { case '"': // // convert double quotes in the data to single quotes // $m_value = str_replace("\"", "'", $m_value); break; case '\'': // // convert single quotes in the data to double quotes // $m_value = str_replace("'", "\"", $m_value); break; default: // // otherwise, leave the data unchanged // break; } // // we handle arrays and strings // if (is_array($m_value)) { // // separate the values with the internal field separator // $m_value = implode("{$CSVINTSEP}", $m_value); } // $debug .= $a_column_list[$ii]." => ".$m_value."\n"; fwrite($fp, $CSVQUOTE . $m_value . $CSVQUOTE); if ($ii < $n_columns - 1) { fwrite($fp, "{$CSVSEP}"); } } fwrite($fp, $CSVLINE); fclose($fp); // CreatePage($debug); // exit; }
while (list($k, $v) = each($HTTP_COOKIE_VARS)) { if (is_array($HTTP_COOKIE_VARS[$k])) { while (list($k2, $v2) = each($HTTP_COOKIE_VARS[$k])) { $HTTP_COOKIE_VARS[$k][$k2] = addslashes($v2); } @reset($HTTP_COOKIE_VARS[$k]); } else { $HTTP_COOKIE_VARS[$k] = addslashes($v); } } @reset($HTTP_COOKIE_VARS); } } } TrimArray($_GET); TrimArray($_POST); /** * Concatena nombres y variables de GET */ function doValFromGET() { $keys_get = array_keys($_GET); foreach ($keys_get as $key_get) { if ($key_get !== 'setLang') { $i = ++$i; ${$key_get} = $_GET[$key_get]; } } if ($i) { return '&' . $key_get . '=' . ${$key_get}; }
function MultiKeep() { global $SPECIAL_VALUES, $aSessionVars, $aRawDataValues; if (isset($SPECIAL_VALUES["multi_keep"]) && !empty($SPECIAL_VALUES["multi_keep"])) { $a_list = TrimArray(explode(",", $SPECIAL_VALUES["multi_keep"])); if (!isset($aSessionVars["FormKeep"])) { $aSessionVars["FormKeep"] = array(); } // // For each data field specified in "multi_keep" store its // value in the FormKeep session variable. // If a field is specified and does not exist in the // recent submission, its value is discarded. // foreach ($a_list as $s_fld_name) { if (!empty($s_fld_name)) { if (isset($aRawDataValues[$s_fld_name])) { $aSessionVars["FormKeep"][$s_fld_name] = $aRawDataValues[$s_fld_name]; } else { unset($aSessionVars["FormKeep"][$s_fld_name]); } } } } }