/** * @dataProvider array_remove_provider */ public function test_array_remove($path) { $array = []; array_set($array, $path, 'foo'); $this->assertTrue(array_has($array, $path)); array_remove($array, $path); $this->assertFalse(array_has($array, $path)); }
function check_wait($pid) { global $pids, $procs; array_push($pids, $pid); if (count($pids) > $procs) { $pid = pcntl_wait($status); array_remove($pid, $pids); } }
static function getShellList() { global $gbl, $sgbl, $login, $ghtml; $shell_file = "__path_real_etc_root/shells"; $newcont = lfile_trim($shell_file); $newcont = array_remove($newcont, $sgbl->__var_noaccess_shell); $shells = add_disabled($newcont); return $shells; }
static function getServiceList() { global $gbl, $sgbl, $login, $ghtml; $val = lscandir_without_dot("__path_real_etc_root/init.d"); $val = array_remove($val, $sgbl->__var_programname_web); $val = array_remove($val, $sgbl->__var_programname_dns); $val = array_remove($val, $sgbl->__var_programname_imap); $val = array_remove($val, $sgbl->__var_programname_mmail); $nval = self::getMainServiceList(); $nval = lx_array_merge(array($nval, $val)); return $nval; }
/** * Sets config value * * @param string $path * @param mixed $value * @param string $canonical_path */ public function set($path, $value, $canonical_path = null) { if ($canonical_path === null) { $canonical_path = $this->getCanonicalPath($path); } // remove if the path isn't protected and it's empty or has a default value $default_value = $this->getDefault($canonical_path); if (!isset($this->persistKeys[$canonical_path]) && ($value == $default_value || empty($value) && empty($default_value))) { array_remove($path, $_SESSION['ConfigFile']); } else { array_write($path, $_SESSION['ConfigFile'], $value); } }
public static function generatePage(&$tpl, &$session, &$account, &$perso) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante $errorUrl = '?popup=1&m=Action_Perso_Parler'; //Valider si: Aucun message tappé et on essaie pas de montrer un Badge if ((!isset($_POST['msg']) || empty($_POST['msg'])) && (!isset($_POST['badge']) || $_POST['badge'] == '0')) { return fctErrorMSG('Aucun message à envoyer.', $errorUrl); } $msg_type = 'parler'; //Charger les informations sur le badge et cr.er l'entête du message si nécéssaire. if (isset($_POST['badge']) && $_POST['badge'] != '0') { $badge_txt = ''; $msg_type = 'parlerbadge'; if ($_POST['badge'] == 'VISAVERT' && $perso->getVisaPerm() == '1') { $badge_txt = 'Une personne vous présente son Visa Vert: ' . $perso->getNom() . '[hr]'; } else { //Trouver le badge sélectionné $i = 0; $trouve = false; while ($item = $perso->getInventaire($i++)) { if ($item->getInvId() == $_POST['badge']) { $trouve = true; break; } } if ($trouve) { $badge_txt = 'Une personne vous présente son ' . $item->getNom() . ': ' . $item->getTitre() . ' (' . $item->getContenu() . ') [hr]'; } else { return fctErrorMSG('Le badge que vous avez sélectionné n\'existe pas.', $errorUrl); } } $_POST['msg'] = $badge_txt . $_POST['msg']; } if (!isset($_POST['to'])) { $_POST['to'] = 'Note perso.'; } else { //Si des destinataires sont recu, les valider et leur faire parvenir le message for ($i = 0; $i < count($_POST['to']); $i++) { if (!$perso->getLieu()->confirmPerso($perso, $_POST['to'][$i])) { array_remove($_POST['to'], $i); } } } //Copier le message dans les HE Member_He::add($perso->getId(), $_POST['to'], $msg_type, $_POST['msg']); //Rafraichir le HE return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/herefresh.htm', __FILE__, __LINE__); }
function __construct() { // 检测语言 if (isset($_COOKIE['tt2_lang'])) { $GLOBALS['i18n'] = z(t(basename($_COOKIE['tt2_lang']))); } else { $GLOBALS['i18n'] = c('default_language'); } __('TEST'); // force to load langua array before plugin // 安装时不启用插件 if (g('c') != 'install') { // 载入插件 $plugins = c('plugins'); if (my_sql("SHOW COLUMNS FROM `plugin`")) { if ($pinfos = get_data("SELECT * FROM `plugin`")) { foreach ($pinfos as $pinfo) { if (intval($pinfo['on']) == 0) { $plugins = array_remove($pinfo['folder_name'], $plugins); } elseif (!in_array($pinfo['folder_name'], $plugins)) { $plugins[] = $pinfo['folder_name']; } } } } if (is_array($plugins)) { $plugins = array_unique($plugins); } if (isset($plugins) && is_array($plugins)) { foreach ($plugins as $plugin) { $plugin_file = c('plugin_path') . DS . basename($plugin) . DS . 'app.php'; if (file_exists($plugin_file)) { require_once $plugin_file; } } } $GLOBALS['config']['plugins'] = $plugins; } // update config for this time // 载入默认的 parent::__construct(); do_action('CTRL_ALL'); apply_filter('CTRL_' . g('c') . '_' . g('a') . '_INPUT_FILTER'); if (g('c') != 'api') { // set session time session_set_cookie_params(c('session_time')); @session_start(); } do_action('CTRL_SESSION_STARTED'); }
/** * @param $key */ public function removeByName($key) { /** @var ICookie $cookie */ $cookie = array_get($this->cookies, $key); array_remove($this->cookies, $key); if ($cookie !== null) { $cookie = $cookie->toString(); $headers = $this->holder->getHeaders()->get('set-cookie'); foreach ($headers as $index => $header) { if ($header == $cookie) { $this->holder->getHeaders()->remove(s('%s.%s', 'set-cookie', $index)); } } } }
protected static function getEntityConfig($relation_type, $collection_name, $field, $config) { // collection names are always plural $collection = array_remove($config, 'collection') ?: $field; $config['collection'] = str_plural($collection); $foreign_key = array_remove($config, 'foreign_key'); if (!$foreign_key) { $foreign_key = $relation_type == 'has_many' ? str_singular($collection_name) . '_id' : str_singular($field) . '_id'; } $config['foreign_key'] = $foreign_key; $config['primary_key'] = array_remove($config, 'primary_key') ?: '_id'; if ($relation_type == 'belongs_to') { // belongs_to relation types have the following additional config keys: $config['required'] = array_remove($config, 'required') ?: false; $config['on_delete'] = array_remove($config, 'on_delete') ?: 'none'; $config['on_update'] = array_remove($config, 'on_update') ?: 'none'; } return $config; }
public static function select($args, $attributes) { $options = array_remove($attributes, 'options'); $selected_option = array_remove($attributes, 'selected'); if (!isset($attributes['name']) && isset($args[0])) { // TODO: analyse context recursively if (Slim\Views\Lightncandy::$context->count() > 0) { $attributes['name'] = Slim\Views\Lightncandy::$context->top() . '[' . $args[0] . ']'; } else { $attributes['name'] = $args[0]; } } $html_options = ''; foreach ($options as $key => $value) { $key = isset($value['_id']) ? $value['_id'] : $key; $value = isset($value['name']) ? $value['name'] : $value; $is_selected = $selected_option == $key ? ' selected="selected"' : ''; $html_options .= '<option value="' . $key . '"' . $is_selected . '>' . $value . '</option>'; } return array('<select' . static::html_attributes($attributes) . '>' . $html_options . '</select>', 'raw'); }
static function orderBy($field, $label) { $Dispatcher = Dispatcher::getInstance(); $params = $Dispatcher->getParams(); $orderby = $field; $dir = 'asc'; $reverse = 'desc'; $class = ''; $filter = Config::get('pagination.filter'); $path = UrlComponent::whitelist(array_remove($filter, array('orderby', 'dir'))); if (isset($params['orderby']) && $params['orderby'] == $field) { $orderby = $params['orderby']; if (isset($params['dir']) && $params['dir'] == 'asc') { $class = 'class="order-asc"'; $reverse = 'desc'; } else { $class = 'class="order-desc"'; $reverse = 'asc'; } } return '<a href="' . $path . '/orderby/' . $orderby . '/dir/' . $reverse . '" ' . $class . '>' . $label . '</a>'; }
function updateform($subaction, $param) { global $gbl, $sgbl, $login, $ghtml; switch ($subaction) { case "installatron": $vlist['__v_button'] = array(); return $vlist; case "ostemplatelist": getResourceOstemplate($vlist, 'all'); $vlist['__v_updateall_button'] = array(); return $vlist; case "createinvoice_m": $vlist['month'] = null; return $vlist; case "createinvoice_s": $vlist['month'] = array('s', $this->getInvoiceMonthList()); return $vlist; case "search_engine": $vlist['se_url'] = array('M', "http://"); $vlist['se_email'] = null; return $vlist; case "cron_mailto": $vlist['cron_mailto'] = null; return $vlist; case "default_domain": $vlist['default_domain'] = array('s', add_disabled(get_namelist_from_objectlist($this->getList('domain')))); return $vlist; case "shell_access": $res[] = "/bin/bash"; $res[] = "/usr/bin/lxjailshell"; $res = add_disabled($res); $vlist['nname'] = array('M', null); $vlist['disable_system_flag'] = null; $vlist['shell'] = array('s', $res); $vlist['__v_updateall_button'] = array(); return $vlist; case "generate_csr": include "lib/countrycode.inc"; foreach ($gl_country_code as $key => $name) { $temp[$key] = $name; } $s = new sslcert(null, null, null); $this->ssl_data_b = new ssl_data_b(null, null, null); $vlist['contactemail'] = array('M', null); $vlist["ssl_data_b_s_commonName_r"] = null; $vlist["ssl_data_b_s_emailAddress_r"] = null; $vlist["ssl_data_b_s_countryName_r"] = array('A', $temp); $vlist["ssl_data_b_s_stateOrProvinceName_r"] = null; $vlist["ssl_data_b_s_localityName_r"] = null; $vlist["ssl_data_b_s_organizationName_r"] = null; $vlist["ssl_data_b_s_organizationalUnitName_r"] = null; return $vlist; case "domainpserver": if ($this->isAdmin()) { $parent = $this; } else { $parent = $this->getParentO(); } self::getDomainServerVlist($parent, $this, $vlist); return $vlist; case "forcedeletepserver": if_not_admin_complain_and_exit(); $list = get_namelist_from_objectlist($this->getList('pserver')); $vlist['pserver_delete_f'] = array('s', array_remove($list, "localhost")); return $vlist; case "deleteorphanedvps": $sq = new Sqlite(null, 'vps'); $slist = get_namelist_from_objectlist($this->getList('pserver')); $res = $sq->getTable(array('nname', 'syncserver', 'parent_clname')); $list = null; foreach ($res as $r) { if (!array_search_bool($r['syncserver'], $slist)) { $list[$r['nname']] = "{$r['nname']} ({$r['syncserver']}) (orphaned)"; } } if ($list) { $vlist['vps_delete_f'] = array('A', $list); } else { $vlist['vps_delete_f'] = array('M', 'No Orphaned vm'); } return $vlist; case "multivpscreate": $vlist['vps_basename_f'] = null; $vlist['vps_admin_password_f'] = null; $vlist['vps_count_f'] = null; $vlist['vps_template_name_f'] = array('s', get_namelist_from_objectlist($this->getList('vpstemplate'))); return $vlist; case "disable_url": $vlist['disable_url'] = array('m', array('pretext' => 'http://')); return $vlist; case "message": $vlist['wall_from_f'] = array('M', $login->nname); $vlist['send_to_f'] = array('M', $this->nname); $vlist['wall_subject_f'] = null; $vlist['wall_message_f'] = null; $vlist['__v_button'] = 'Send'; return $vlist; case "skeleton": $vlist['skeletonarchive'] = array('M', null); $vlist['skeletonarchive_f'] = null; return $vlist; case "wall": $vlist['wall_from_f'] = array('M', $this->nname); //Can't do this. If he has 10000 client, this itelf will hang the machine. //$vlist['send_to_f'] = array('M', $namlist); $vlist['wall_subject_f'] = null; $vlist['wall_message_f'] = null; $vlist['__v_button'] = 'Send'; return $vlist; case "dnstemplatelist": $parent = $this->getParentO(); $nlist = domain::getDnsTemplateList($parent); $vlist['dnstemplate_list'] = array('U', $nlist); $vlist['__v_updateall_button'] = array(); return $vlist; case "information": $vlist['nname'] = array('M', $this->nname); if ($this->isAdmin()) { $gen = $login->getObject('general'); $this->disable_admin = $gen->disable_admin; $vlist['disable_admin'] = null; } if ($this->isLogin()) { $vlist['cttype'] = array('M', $this->cttype); } else { $parent = $this->getParentO(); $res = null; if (check_if_many_server()) { $ctlist = array('reseller', 'customer', 'wholesale'); } else { $ctlist = array('reseller', 'customer'); } foreach ($ctlist as $v) { if ($parent->isGte($v)) { continue; } $res[] = $v; } if ($res) { $vlist['cttype'] = array('s', $res); } else { $vlist['cttype'] = array('M', $this->cttype); } } $vlist['ddate'] = array('M', @date('d-m-Y', $this->ddate)); if (!$this->isAdmin()) { $vlist['parent_name_f'] = array('M', $this->getParentName()); } $vlist['contactemail'] = ""; if (!$this->isLogin()) { $vlist['text_comment'] = null; } return $vlist; case "license": $lic = $login->getObject('license')->licensecom_b; if ($login->isAdmin()) { $vlist['lic_pserver_num_f'] = array('M', $lic->lic_pserver_num); $vlist['lic_client_num_f'] = array('M', $lic->lic_client_num); $vlist['lic_maindomain_num_f'] = array('M', $lic->lic_maindomain_num); } else { $vlist['lic_node_num_f'] = array('M', $lic->node_num); } $vlist['lic_live_support_f'] = array('M', $lic->lic_live_support); //$vlist['lic_ipaddress_f'] = array('M', $lic->lic_ipaddress); $vlist['lic_client_f'] = array('M', $lic->lic_client); //$vlist['lic_current_f'] = array('t', lfile_get_contents('__path_program_etc/license.txt')); $vlist['license_upload_f'] = null; return $vlist; case "ipaddress": $parent = $this->getParentO(); if ($this->isLogin() || !$this->isRightParent()) { $vlist['ipaddress_list'] = array('M', $this->getIpaddress($this->listpriv->webpserver_list)); $vlist['__v_button'] = array(); } else { if (check_if_many_server()) { dprintr($this->listpriv->webpserver_list); $iplist = $parent->getIpaddress($this->listpriv->webpserver_list); } else { $iplist = $parent->getIpaddress(array('localhost')); } dprintr($iplist); $vlist['ipaddress_list'] = array('Q', $iplist); } return $vlist; case "pserver_s": $parent = $this->getParentO(); $list = null; $serverlist = client::getPserverListPriv(); if ($this->isLogin() || !$this->isRightParent()) { foreach ($serverlist as $s) { $slist = "{$s}_list"; $vlist["{$s}_list"] = array('M', $this->listpriv->{$slist}); } $vlist['__v_button'] = array(); //$vlist['dbtype_list'] = array('M', $this->listpriv->dbtype_list); return $vlist; } else { $vlist['server_detail_f'] = null; foreach ($serverlist as $s) { $slist = "{$s}_list"; // Hack.. Actually, admin's listpriv should be empty so that the __get inside the listpriv will get automatically called. if ($parent->isAdmin()) { unset($parent->listpriv->{$slist}); } $vlist["{$s}_list"] = null; $list = lx_array_merge(array($list, $parent->getServerList(strtilfirst($s, "pserver")))); } $sinfo = pservercore::createServerInfo($list); $sinfo = get_warning_for_server_info($parent, $sinfo); $vlist['server_detail_f'] = array('M', $sinfo); //$vlist['dbtype_list'] = null; return $vlist; } case "description": $vlist['description'] = null; //$vlist['share_status'] = null; if (!$this->isRightParent()) { $this->convertToUnmodifiable($vlist); } return $vlist; } return parent::updateform($subaction, $param); }
public function setInternalParam($mountpoint) { $name = $this->main->ostemplate; if ($this->main->isWindows()) { return; } if (!$mountpoint) { return; } if ($name === 'unknown') { return; } $name = strtolower($name); $mountpoint = expand_real_root($mountpoint); $result = $this->getScriptS($name); dprint("Distro Name {$name}, Scripts: \n"); dprintr($result); $init = strtilfirst($name, "-"); dprint("File is {$init}.inittab\n"); if (lxfile_exists("../file/sysfile/inittab/{$init}.inittab")) { dprint("Copying {$init}.inittab\n"); $content = lfile_get_contents("../file/sysfile/inittab/{$init}.inittab"); if ($this->main->text_inittab) { $content .= "\n{$this->main->text_inittab}"; } lfile_put_contents("{$mountpoint}/etc/inittab", $content); } $iplist = get_namelist_from_objectlist($this->main->vmipaddress_a); if ($this->main->mainipaddress) { $main_ip = $this->main->mainipaddress; $iplist = array_remove($iplist, $main_ip); } else { $main_ip = array_shift($iplist); } if ($this->main->networknetmask) { $main_netmask = $this->main->networknetmask; } else { $main_netmask = "255.255.255.0"; } $iplist = implode(" ", $iplist); $ipadd = $result['ADD_IP']; $sethostname = $result['SET_HOSTNAME']; $setuserpass = $result['SET_USERPASS']; $ipdel = $result['DEL_IP']; if ($this->main->networkgateway) { $gw = $this->main->networkgateway; } else { $gw = os_get_network_gateway(); } $gwn = strtil($gw, '.') . '.0'; $hostname = $this->main->hostname; if (!$hostname) { $hostname = os_get_hostname(); } if ($result['STARTUP_SCRIPT'] != 'systemd') { $name = createTempDir("{$mountpoint}/tmp", 'xen-scripts'); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/functions", $name); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/{$ipadd}", $name); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/{$sethostname}", $name); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/{$setuserpass}", $name); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/{$ipdel}", $name); $basepath = strfrom($name, $mountpoint); lfile_put_contents("{$name}/tmpfile.sh", "source /{$basepath}/functions\nsource /{$basepath}/{$ipdel}\n"); $delipstring = "IPDELALL=yes chroot {$mountpoint} bash /{$basepath}/tmpfile.sh"; log_shell($delipstring); log_shell(system($delipstring, $ret1) . ":return {$ret1}"); putenv("VE_STATE=stopped"); lfile_put_contents("{$name}/tmpfile.sh", "source /{$basepath}/functions\n source /{$basepath}/{$ipadd}\n"); $string = "IPDELALL=yes MAIN_NETMASK={$main_netmask} MAIN_IP_ADDRESS={$main_ip} IP_ADDR=\"{$iplist}\" NETWORK_GATEWAY={$gw} NETWORK_GATEWAY_NET={$gwn} chroot {$mountpoint} bash /{$basepath}/tmpfile.sh"; log_shell($string); log_shell(system($string, $ret1) . ":return {$ret1}"); lfile_put_contents("{$name}/tmpfile.sh", "source /{$basepath}/functions\n source /{$basepath}/{$sethostname}\n"); $string = "HOSTNM={$hostname} chroot {$mountpoint} bash /{$basepath}/tmpfile.sh"; log_shell($string); log_shell(system($string, $ret1) . ":return {$ret1}"); if ($this->main->subaction === 'rebuild' || $this->main->dbaction === 'add' || $this->main->isOn('__var_rootpassword_changed') && $this->main->rootpassword) { $rootpass = "******"; lfile_put_contents("{$name}/tmpfile.sh", "source /{$basepath}/functions\n source /{$basepath}/{$setuserpass}\n"); $string = "USERPW={$rootpass} chroot {$mountpoint} bash /{$basepath}/tmpfile.sh"; log_shell($string); log_shell(system($string)); } lxfile_rm_rec($name); } else { if ($result['STARTUP_SCRIPT'] == 'systemd') { $script_dir = createTempDir("{$mountpoint}", "hypervm-runonce"); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/functions", $script_dir); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/{$ipadd}", $script_dir); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/{$sethostname}", $script_dir); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/{$setuserpass}", $script_dir); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/{$ipdel}", $script_dir); $basepath = strfrom($script_dir, $mountpoint); $startupdir = 'lib/systemd/system'; $startupscript = 'fedora-startup.service'; $setrootpass = ''; if ($this->main->subaction === 'rebuild' || $this->main->dbaction === 'add' || $this->main->isOn('__var_rootpassword_changed') && $this->main->rootpassword) { $rootpass = "******"; $setrootpass = "******"; } $run_once_script = "#!/bin/bash\n" . "source {$basepath}/functions\n" . '(' . "IPDELALL=yes source {$basepath}/{$ipdel}" . " & IPDELALL=yes VE_STATE=stopped MAIN_NETMASK={$main_netmask} MAIN_IP_ADDRESS={$main_ip} IP_ADDR=\"{$iplist}\" NETWORK_GATEWAY={$gw} NETWORK_GATEWAY_NET={$gwn} source {$basepath}/{$ipadd}" . " & HOSTNM={$hostname} source {$basepath}/{$sethostname}" . "{$setrootpass})\n" . "service fedora-startup disable\nrm -f /{$startupdir}/{$startupscript}\nrm -rf {$basepath}"; lfile_put_contents("{$script_dir}/hypervm-runonce.sh", $run_once_script); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/{$startupscript}", "{$mountpoint}/{$startupdir}"); lfile_put_contents("{$mountpoint}/{$startupdir}/{$startupscript}", lfile_get_contents("{$mountpoint}/{$startupdir}/{$startupscript}") . "ExecStart={$basepath}/hypervm-runonce.sh\n"); system("ln -s /lib/systemd/system/fedora-startup.service {$mountpoint}/etc/systemd/system/multi-user.target.wants/fedora-startup.service"); system("chmod 755 {$script_dir}/hypervm-runonce.sh"); } } if ($this->main->nameserver) { $nlist = explode(" ", $this->main->nameserver); $nstring = null; foreach ($nlist as $l) { $nstring .= "nameserver {$l}\n"; } lfile_put_contents("{$mountpoint}/etc/resolv.conf", $nstring); } if ($this->main->timezone) { lxfile_rm("{$mountpoint}/etc/localtime"); $cmdstring = "ln -sf ../usr/share/zoneinfo/{$this->main->timezone} {$mountpoint}/etc/localtime"; log_log("localtime", $cmdstring); do_exec_system('__system__', "/", $cmdstring, $out, $err, $ret, null); //lxfile_cp("/usr/share/zoneinfo/{$this->main->timezone}", "$mountpoint/etc/localtime"); } lunlink("{$mountpoint}/etc/sysconfig/network-scripts/ifcfg-venet0"); lunlink("{$mountpoint}/etc/sysconfig/network-scripts/ifcfg-venet0:0"); $this->main->doKloxoInit($mountpoint); }
function emailITticket($id, $scenario, $admin = false, $debug = false) { global $_josh, $page; $ticket = db_grab('SELECT u.id, (SELECT COUNT(*) FROM users_to_modules a WHERE a.user_id = u.id AND a.module_id = 3) isUserAdmin, t.title, t.created_user, t.description, t.departmentID, ISNULL(u.nickname, u.firstname) first, u.lastname last, u.email, ' . db_updated('u') . ', t.created_date, t.priorityID, t.statusID, d.shortName department, t.type_id, y.description type, u2.email as ownerEmail, t.ownerID, ISNULL(u2.nickname, u2.firstname) as ownerName FROM helpdesk_tickets t LEFT JOIN helpdesk_tickets_types y ON t.type_id = y.id JOIN users u ON t.created_user = u.id JOIN departments d ON t.departmentID = d.departmentID LEFT JOIN users u2 ON t.ownerID = u2.id WHERE t.id = ' . $id); //yellow box if ($scenario == "followup") { $subject = "Followup On Your Helpdesk Ticket"; $message = drawMessage('There\'s been followup on your Helpdesk ticket - please see below. <b>Don\'t reply to this email!</b> Instead, please ' . draw_link('/helpdesk/ticket.php?id=' . $id, 'view your ticket') . ' in the intranet ticketing system.<br><br><b>Note:</b> if you add this sender to your "safe senders list," pictures will always download.'); } elseif ($scenario == "followupadmin") { $subject = "Admin Followup on Helpdesk Ticket"; $message = drawMessage(draw_link('/staff/view.php?id=' . user(), $_SESSION['full_name']) . ' just made an administrative followup on this Helpdesk ticket. Regular staff were not copied on this message.'); } elseif ($scenario == "closed") { $subject = "Your Ticket Has Been Closed"; $message = drawMessage('This is to let you know that your ticket has been closed. <b>Don\'t reply to this email!</b> You can still followup on this thread by ' . draw_link('/helpdesk/ticket.php?id=' . $id, 'viewing your ticket') . ' in the intranet ticketing system.<br><br><b>Note:</b> if you add this sender to your "safe senders list," pictures will always download.'); } elseif ($scenario == "assign") { $subject = "Your Ticket Has Been Assigned"; $message = drawMessage(draw_link('/staff/view.php?id=' . user(), $_SESSION["full_name"]) . ' has assigned this ticket to ' . draw_link('/staff/view.php?id=' . $ticket['ownerID'], $ticket["ownerName"]) . '<b>Don\'t reply to this email!</b> Instead, please ' . draw_link('/helpdesk/ticket.php?id=' . $id, 'view your ticket') . ' in the intranet ticketing system.<br><br><b>Note:</b> if you add this sender to your "safe senders list," pictures will always download.'); } elseif ($scenario == "new") { $subject = "New " . $ticket["department"] . " Ticket Posted"; $message = drawMessage('This is to let you know that a new ticket has just been posted to the Helpdesk. You can ' . draw_link('/helpdesk/ticket.php?id=' . $id, 'view the ticket') . ' in the intranet ticketing system.'); } elseif ($scenario == "critical") { $subject = "Critical " . $ticket["department"] . " Ticket Still Open"; $message = drawMessage('A ticket flagged "Critical" is open on the Helpdesk. You can ' . draw_link('/helpdesk/ticket.php?id=' . $id, 'view the ticket') . ' in the intranet ticketing system.'); } //$message .= drawtableStart() . drawHeaderRow(false, 2); //recipients arrays $users = array(); $admins = array(); if ($ticket["isUserAdmin"]) { $admins[] = $ticket["email"]; } else { $users[] = $ticket["email"]; } if ($page['is_admin']) { $admins[] = $_SESSION["email"]; } else { $users[] = $_SESSION["email"]; } //add owner if ticket is assigned if ($ticket["ownerEmail"]) { $admins[] = $ticket["ownerEmail"]; } //owner logically has to be admin $d_user = new display($page['breadcrumbs'] . $ticket['title'], false, false, 'thread'); $d_admin = new display($page['breadcrumbs'] . $ticket['title'], false, false, 'thread'); $d_user->row(drawName($ticket['created_user'], $ticket['first'] . ' ' . $ticket['last'], $ticket['created_date'], true, BR, $ticket['updated']), draw_h1($ticket['title']) . $ticket['description']); $d_admin->row(drawName($ticket['created_user'], $ticket['first'] . ' ' . $ticket['last'], $ticket['created_date'], true, BR, $ticket['updated']), draw_h1($ticket['title']) . $ticket['description']); //get followups $followups = db_query('SELECT u.id, f.message, (SELECT COUNT(*) FROM users_to_modules u2m WHERE u2m.user_id = u.id AND u2m.module_id = 3 AND u2m.is_admin = 1) isUserAdmin, ISNULL(u.nickname, u.firstname) firstname, u.lastname, u.email, f.created_date, f.is_admin, f.created_user, ' . db_updated('u') . ' FROM helpdesk_tickets_followups f INNER JOIN users u ON f.created_user = u.id WHERE f.ticketID = ' . $id . ' ORDER BY f.created_date'); while ($f = db_fetch($followups)) { $d_admin->row(drawName($f['created_user'], $f['firstname'] . ' ' . $f['lastname'], $f['created_date'], true, BR, $f['updated']), $f['message']); if (!$f['is_admin']) { $d_user->row(drawName($f['created_user'], $f['firstname'] . ' ' . $f['lastname'], $f['created_date'], true, BR, $f['updated']), $f['message']); } if ($f['isUserAdmin']) { $admins[] = $f['email']; } else { $users[] = $f['email']; } } $admins = array_remove($_SESSION['email'], array_unique($admins)); $users = array_remove($_SESSION['email'], array_unique($users)); if ($debug) { die(drawEmail($message . $d_admin->draw())); } //special codes for email //todo: put this in db, possibly by adding something to the users table or something if ($scenario == "new" && $ticket["departmentID"] == 3) { $admins = array('*****@*****.**', '*****@*****.**', '*****@*****.**'); } if ($scenario == "new" && $ticket["departmentID"] == 13) { $admins = array('*****@*****.**', '*****@*****.**'); } if ($scenario == "new" && $ticket["departmentID"] == 2) { $admins = array('*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'); } if ($scenario == "critical" && $ticket["departmentID"] == 8) { $admins = array('*****@*****.**'); } if (count($admins)) { //$admins = join(", ", $admins); email($admins, drawEmail($message . $d_admin->draw()), $subject); error_debug('admin message emailed to ' . implode(', ', $admins) . ' admins', __FILE__, __LINE__); } if (count($users) && $scenario != "followupadmin" && !$admin) { //$users = join(", ", $users); email($users, drawEmail($message . $d_user->draw()), $subject); error_debug('user message emailed to ' . implode(', ', $users) . ' users', __FILE__, __LINE__); } }
/** * Overloaded version of Html::submitButton(), adds icon option */ function submitButton($text, $options) { $icon = array_remove($options, 'icon'); $prefix = "<span class='glyphicon glyphicon-{$icon}'></span> "; return \yii\helpers\Html::submitButton($prefix . $text, $options); }
public static function RUN($application) { try { $config = Config::SetApplication($application); if (is_readable($config->dir . 'config.php')) { require_once $config->dir . 'config.php'; } } catch (InvalidApplicationException $e) { echo self::Error($e->getMessage()); return FALSE; } $request = Request::getInstance(); // Router em implementação $router = Router::getInstance(); $route = $router->GetByRequest(); if ($config->onlyroutes && !$route) { $route = Router::notfound(); } if ($route) { $request->controller = $route->controller; $request->action = $route->action; $request->params = (object) $route->attributes; } else { $request->parseRoute(); } $class = "\\Controller\\{$request->controller}Controller"; // Retorno caso configuração $outputreturn do controller seja true $output = ''; try { if (!class_exists($class)) { throw new Exception("A URL {$request->uri} é inválida."); } $app = new $class(); } catch (Exception $e) { echo self::Error($e->getMessage()); return FALSE; } if (!empty($request->post['mvc:model'])) { $model = '\\Model\\' . array_remove($request->post, 'mvc:model') . 'Model'; try { $param = new $model($request->post); if ($param) { $param = [$param]; } } catch (Exception $e) { $app->setOutput($app->index()); $app->output(); return FALSE; } } else { if (!!$route && count($route->attributes) > 0) { $param = $route->attributes; } else { if (empty($request->lost) && !is_numeric($request->lost)) { $param = NULL; } else { $param = [$request->lost]; } } } try { $output = $app->execute($param); } catch (Exception $e) { echo self::Error($e->getMessage()); return FALSE; } if ($app->outputreturn) { $app->setOutput($output); } $app->output(); return TRUE; }
/** * migrate * * @param Hook\Model\Collection $model * @param array $collection_config * * @return bool */ public function migrate($model, $collection_config, $is_dynamic = false) { $that = $this; $result = false; $connection = $model->getConnectionResolver()->connection(); // Ignore NoSQL databases. if (!$connection->getPdo()) { return; } // Get modified Schema\Grammar for hook features. $connection->setSchemaGrammar($this->getSchemaGrammar($connection)); // Set custom blueprint resolver $builder = $connection->getSchemaBuilder(); $builder->blueprintResolver(function ($table, $callback) { return new \Hook\Database\Schema\Blueprint($table, $callback); }); $table = $model->getTable(); $table_schema = Cache::get($table); $table_prefix = Context::getPrefix(); $collection_config = $this->sanitizeConfigs($table, $collection_config, $is_dynamic); $is_creating = !$builder->hasTable($table); if (!empty($collection_config['attributes']) || !empty($collection_config['relationships'])) { $migrate = function ($t) use($that, &$table, &$table_prefix, &$builder, &$is_creating, &$table_schema, $collection_config, &$result) { $table_columns = array('created_at', 'updated_at', 'deleted_at'); if ($is_creating) { $that->createCollection($t); } else { $table_columns = array_merge($table_columns, $builder->getColumnListing($table)); } foreach ($collection_config['attributes'] as $attribute) { if (!isset($attribute['name'])) { throw new MethodFailureException('invalid_schema'); } $field_name = strtolower(array_remove($attribute, 'name')); $type = camel_case(array_remove($attribute, 'type') ?: 'string'); $default = array_remove($attribute, 'default'); $index = array_remove($attribute, 'index'); $unique = array_remove($attribute, 'unique') || $index == 'unique'; $required = array_remove($attribute, 'required'); // Skip if column already exists // TODO: deprecate strtolower if (in_array($field_name, array_map('strtolower', $table_columns))) { continue; } // include field_name to list of collection columns array_push($table_columns, $field_name); if (count($attribute) > 0) { // the remaining attributes on field definition are // the data-type related collection_config, such as 'length', // 'allowed', 'total', 'places', etc. $column = $t->newColumn($type, $field_name, $attribute); } else { $column = $t->{$type}($field_name); } // apply default value if ($default !== NULL) { $required = true; $column->default($default); } // spatial indexes are NOT NULL by default $nullable = !$required && $type !== 'point'; // columns are nullable unless specified as 'required' if ($nullable) { $column->nullable(); } if ($index == 'spatial') { // apply geospatial index, only MyISAM $t->spatialIndex($field_name); } else { if ($index && !$unique) { // apply index if specified $column->index(); } } if ($unique) { // apply unique index if specified $unique_fields = !is_array($unique) ? $field_name : array_unique(array_merge(array($field_name), $unique)); $t->unique($unique_fields); } } // onDelete / onUpdate actions $actions = array('restrict' => "RESTRICT", 'cascade' => "CASCADE", 'none' => "NO ACTION", 'null' => "SET NULL", 'default' => "SET DEFAULT"); if (!isset($collection_config['relationships'])) { $collection_config['relationships'] = array(); } foreach ($collection_config['relationships'] as $relation => $fields) { // only create field on belongs_to relationships if ($relation == "belongs_to") { foreach ($fields as $field => $config) { // create 'foreign_key' column on collection. if (!in_array($config['foreign_key'], array_map('strtolower', $table_columns))) { $column = $t->unsignedInteger($config['foreign_key']); $column->nullable(); } // create collection if it doesn't exists if (!$builder->hasTable($config['collection'])) { $builder->create($table_prefix . $config['collection'], function ($t) use($that) { $that->createCollection($t); }); } // // // // create foreign key on database // // // // TODO: list foreign keys already defined before // // trying to create it. // // // $t->foreign($config['foreign_key']) // ->references($config['primary_key']) // ->on($table_prefix . $config['collection']) // ->onDelete($actions[$config['on_delete']]) // ->onUpdate($actions[$config['on_update']]); } } } // return true when any modification is present if (count($t->getColumns()) > 0 || count($t->getCommands()) > 0) { $result = true; } }; if ($is_creating) { // CREATE TABLE statement $builder->create($table_prefix . $table, $migrate); } else { // ALTER TABLE statement. $builder->table($table_prefix . $table, $migrate); } } // merge previous schema with new one. $table_schema = $this->mergeSchema($table_schema, $collection_config, $is_dynamic); // Cache table schema for further reference Cache::forever($table, $table_schema); $app_collections = Cache::get('app_collections'); Cache::forever('app_collections', array_unique(array_merge($app_collections, array($table)))); return $result; }
/** * @param $id */ public function removeDefinition($id) { $index = $this->getDefinitionIndex($id); if ($index !== null) { $definition = $this->definitions[$index]; if ($definition instanceof IDefinition && !$definition instanceof WildcardDefinition) { array_remove($this->definitions, $index); } } }
/** * @param string $key */ public function remove($key) { array_remove($this->query, $key); }
function reply() { global $CJob; $CJob->requireLogin(); global $params, $MMessage; // Params to vars // Processes message data function viewData($c, $entry = NULL) { global $MMessage; $messages = array_reverse(iterator_to_array($MMessage->findByParticipant($_SESSION['_id']->{'$id'}))); $replies = array(); $unread = 0; foreach ($messages as $m) { $reply = array_pop($m['replies']); $reply['_id'] = $m['_id']; $from = $reply['from']; if (!$reply['read']) { $reply['read'] = strcmp($from, $_SESSION['_id']) == 0; } if (!$reply['read']) { $unread++; } $c->setFromNamePic($reply, $from); if (strcmp($m['_id'], $entry['_id']) == 0) { $reply['current'] = true; } else { $reply['current'] = false; } $reply['time'] = timeAgo($reply['time']); if (strlen($reply['msg']) > 100) { $reply['msg'] = substr($reply['msg'], 0, 97) . '...'; } array_push($replies, $reply); } // Handle current message if (!is_null($entry)) { $currentreplies = $entry['replies']; $current = array(); foreach ($currentreplies as $m) { $c->setFromNamePic($m, $m['from']); $m['time'] = timeAgo($m['time']); array_push($current, $m); } $to = 'Message To: ' . $c->getName($entry['participants'][0]); foreach ($entry['participants'] as $p) { if (strcmp($p, $_SESSION['_id']) != 0) { $to = 'Message To: ' . $c->getName($p); } } $currentid = $entry['_id']; } else { $current = null; $currentid = null; $to = ''; } $data = array('messages' => $replies, 'current' => $current, 'currentid' => $currentid, 'unread' => $unread, 'to' => $to); if (isset($_GET['msg'])) { $data['msg'] = $_GET['msg']; } return $data; } if (!isset($_GET['id'])) { $this->render('messages', viewData($this)); return; } /* ACTUALLY SEND MESSAGES */ // Validations $this->startValidations(); $this->validate(MongoId::isValid($id = $_GET['id']) and ($entry = $MMessage->get($id)) !== NULL, $err, 'unknown message'); if ($this->isValid()) { $this->validate(in_array($myid = $_SESSION['_id']->{'$id'}, $entry['participants']), $err, 'permission denied'); } if ($this->isValid()) { // Set replies to read $repliesn = count($entry['replies']); for ($i = 0; $i < $repliesn; $i++) { if (strcmp($entry['replies'][$i]['from'], $_SESSION['_id']) != 0) { $entry['replies'][$i]['read'] = true; } } $MMessage->save($entry); if (!isset($_POST['reply'])) { $this->render('messages', viewData($this, $entry)); return; } extract($data = $this->data($params)); // Validations $this->validate(strlen($msg) > 0, $err, 'message empty'); if ($repliesn > 0) { $replylast = $entry['replies'][$repliesn - 1]; $this->validate($msg != $replylast['msg'] or time() - $replylast['time'] > 10, $err, 'message sent'); } if ($this->isValid()) { // Send the message $msgid = $entry['_id']->{'$id'}; $from = $myid; $fromname = $this->getName($from); $tos = array_remove($entry['participants'], $from); $entry = $MMessage->reply($msgid, $from, $msg); $emails = array(); foreach ($tos as $to) { $emails[] = $this->getEmail($to); } // Notify recipients by email $link = "http://sublite.net/housing/messages.php?id={$msgid}"; $message = "\n {$fromname} has sent you a message on SubLite:\n <br /><br />\n View the message on SubLite: <a href='{$link}'>{$link}</a>\n <br />\n ---\n <br /><br />\n {$msg}\n <br /><br />\n ---\n <br />\n Reply to this message <a href='{$link}'>on SubLite</a>. DO NOT REPLY DIRECTLY TO THIS EMAIL.\n "; sendgmail($emails, array("*****@*****.**", "SubLite, LLC."), "Message from {$fromname} | SubLite", $message); // Notify us of the message $toemails = implode(', ', $emails); $fromemail = $this->getEmail($from); $prevmsgs = ''; $replies = array_reverse($entry['replies']); foreach ($replies as $reply) { $pfromemail = $this->getEmail($reply['from']); $pmsg = $reply['msg']; $prevmsgs .= "<b>{$pfromemail}</b>: <br />{$pmsg}<br />"; } $message = "\n <b>{$fromemail}</b> has sent a message to <b>{$toemails}</b>:\n <br /><br />\n {$msg}\n <br /><br />\n msgid: {$msgid}\n <br /><br />\n The thread:\n <br /><br />\n {$prevmsgs}\n "; sendgmail(array('*****@*****.**', '*****@*****.**'), "*****@*****.**", 'Message sent on SubLite!', $message); $this->render('messages', viewData($this, $entry)); return; } $this->render('messages', viewData($this, $entry)); return; } $this->error($err); $this->render('notice'); }
public static function persistPedido($request) { $db = new DBAL(); $itens = array_remove($request, 'itens'); $request['idPessoa'] = $request['idPessoa'] ?: null; $request['idUsuario'] = $_SESSION['usuario']['idUsuario']; $request['vlDesconto'] = $request['vlDesconto'] / 100; $id = $db->insert("pedido", $request); foreach ($itens as $key => $val) { $itens[$key]['idPedido'] = $id; } $ids = $db->insertMultiple("item", $itens); return self::find($id); }
protected function get_subtract_link($tags, $tag) { if (in_array("-{$tag}", $tags)) { return ""; } else { $tags = array_remove($tags, $tag); $tags = array_add($tags, "-{$tag}"); return "<a href='" . $this->tag_link(join(' ', $tags)) . "' title='Subtract' rel='nofollow'>S</a>"; } }
$registerid = $_POST['registerid']; //echo "Class string".$class_string; if (strlen($class_string) > 1) { $class_ary = explode(",", $class_string); } else { $class_ary = array(); } //echo "initial array"; //print_r($class_ary); // echo "classes to remove "; // print_r($classes_to_remove); // echo "<br>classes to add "; // print_r($classes_to_add); // echo "<br>class array starting "; // print_r($class_ary); $class_ary = array_remove($classes_to_remove, $class_ary); // echo "<br>array after removing "; // print_r($class_ary); $class_ary = array_add($classes_to_add, $class_ary); // echo "<br>array after adding "; // print_r($class_ary); // // echo "<br>class array final "; // print_r($class_ary); if (sizeof($class_ary) > 1) { $new_class_str = implode(",", $class_ary); } else { if (sizeof($class_ary) == 1) { $new_class_str = $class_ary[0]; } else { $new_class_str = "";
function handle_search() { if (check_valid_entries() == true) { $trans_ref = false; $sql = get_sql_for_view_transactions($_POST['filterType'], $_POST['FromTransNo'], $_POST['ToTransNo'], $trans_ref); if ($sql == "") { return; } $print_type = $_POST['filterType']; $print_out = $print_type == ST_SALESINVOICE || $print_type == ST_CUSTCREDIT || $print_type == ST_CUSTDELIVERY || $print_type == ST_PURCHORDER || $print_type == ST_SALESORDER || $print_type == ST_SALESQUOTE || $print_type == ST_CUSTPAYMENT || $print_type == ST_SUPPAYMENT || $print_type == ST_WORKORDER; $cols = array(_("#") => array('insert' => true, 'fun' => 'view_link'), _("Reference") => array('fun' => 'ref_view'), _("Date") => array('type' => 'date', 'fun' => 'date_view'), _("Print") => array('insert' => true, 'fun' => 'prt_link'), _("GL") => array('insert' => true, 'fun' => 'gl_view')); if (!$print_out) { array_remove($cols, 3); } if (!$trans_ref) { array_remove($cols, 1); } $table =& new_db_pager('transactions', $sql, $cols); $table->width = "40%"; display_db_pager($table); } }
function InlineTransformer($markup_types = false) { global $request; // We need to extend the inline parsers by certain actions, like SearchHighlight, // SpellCheck and maybe CreateToc. if (!$markup_types) { $non_default = false; $markup_types = array('escape', 'wikicreolebracketlink', 'bracketlink', 'url', 'html_comment', 'placeholder', 'interwiki', 'semanticlink', 'wikiword', 'linebreak', 'wikicreole_superscript', 'wikicreole_subscript', 'wikicreole_italics', 'wikicreole_bold', 'wikicreole_monospace', 'old_emphasis', 'nestled_emphasis', 'html_emphasis', 'html_abbr', 'plugin', 'plugin_wikicreole', 'isonumchars', 'isohexchars'); if (DISABLE_MARKUP_WIKIWORD) { $markup_types = array_remove($markup_types, 'wikiword'); } $action = $request->getArg('action'); if ($action == 'SpellCheck' and $request->getArg('suggestions')) { // insert it after url array_splice($markup_types, 2, 1, array('url', 'spellcheck')); } if (isset($request->_searchhighlight)) { // insert it after url array_splice($markup_types, 2, 1, array('url', 'searchhighlight')); //$request->setArg('searchhighlight', false); } } else { $non_default = true; } foreach ($markup_types as $mtype) { $class = "Markup_{$mtype}"; $this->_addMarkup(new $class()); } $this->_addMarkup(new Markup_nowiki()); if (ENABLE_MARKUP_DIVSPAN and !$non_default) { $this->_addMarkup(new Markup_html_divspan()); } if (ENABLE_MARKUP_COLOR and !$non_default) { $this->_addMarkup(new Markup_color()); } // Markup_wikicreole_preformatted must be before Markup_template_plugin $this->_addMarkup(new Markup_wikicreole_preformatted()); if (ENABLE_MARKUP_TEMPLATE and !$non_default) { $this->_addMarkup(new Markup_template_plugin()); } // This does not work yet if (PLUGIN_MARKUP_MAP and !$non_default) { $this->_addMarkup(new Markup_xml_plugin()); } }
/** * Remove Custom User Role * * @param string $remove_role name of custom role to remove * @param string $move_to name of role to move existing users to * @return bool */ public function removeCustomRole($h, $remove_role = '', $move_to = '') { if (!$remove_role) { return false; } $remove_role = mb_strtolower($remove_role, 'UTF-8'); // return false if this is a default role: $default_roles = $this->getDefaultRoles(); if (in_array($remove_role, $default_roles)) { return false; } // return false if this is not a custom role: $custom_roles = $this->getCustomRoles($h); if (!$custom_roles || !in_array($remove_role, $custom_roles)) { return false; } // update all users with the old role if ($move_to) { $this->bulkRoleChange($h, $remove_role, $move_to); } // remove role from custom roles $custom_roles = array_remove($custom_roles, $remove_role); // custom Hotaru function // update custom_roles record $sql = "UPDATE " . TABLE_MISCDATA . " SET miscdata_value = %s, miscdata_updateby = %d WHERE miscdata_key = %s"; $h->db->query($h->db->prepare($sql, serialize($custom_roles), $h->currentUser->id, 'custom_roles')); // remove the role from Hotaru's base permissions $base_perms = $h->getDefaultPermissions('all', 'base'); $base_perms = $this->removeRolePerms($h, $base_perms, $remove_role); $h->updateDefaultPermissions($base_perms, 'base', true); // remove the role from Hotaru's site permissions $site_perms = $h->getDefaultPermissions('all', 'site'); $site_perms = $this->removeRolePerms($h, $site_perms, $remove_role); $h->updateDefaultPermissions($site_perms, 'site', true); return true; }
/** * Remove all registered headers. * * @param $key */ public function remove($key) { $key = $this->formatKey($key); array_remove($this->headers, $key); }
<? if (isset($Pager)) : ?> <? if ($Pager->haveToPaginate()): $range = $Pager->getRange('Sliding', array('chunk' => Config::get('pagination.chunk'))); $pages = $range->rangeAroundPage(); $filter = Config::get('pagination.filter'); $path = UrlComponent::whitelist(array_remove($filter, 'page')); ?> <ul class="pagination"> <? if ($Pager->getPage() > 1) : ?> <li class="previous"><a href="<?php echo $path; ?> /page/<?php echo $Pager->getPreviousPage(); ?> ">« Précédente</a></li> <? else: ?> <li class="previous-off">« Précédente</li> <? endif ?> <? if (isset($pages[0]) && $pages[0] > 1) : ?> <li><a href="<?php echo $path; ?> /page/1">1</a></li> <? endif ?> <? if (isset($pages[0]) && $pages[0] > 2) : ?> <li class="more">...</li> <? endif ?> <? foreach($pages as $page): ?> <? if ($page == $Pager->getPage()): ?>
<?php function array_remove(&$arr, $offset) { array_splice($arr, $offset, 1); } if (isset($_POST['d'])) { $dstPath = 'public/data/' . $_POST['d'] . '.js'; $srcPath = 'public/data/' . $_POST['s'] . '.js'; $id = $_POST['id']; $srcData = json_decode(file_get_contents($srcPath), true); $dstData = json_decode(file_get_contents($dstPath), true); $l = count($dstData['photo']); $dstData['photo'][$l] = $srcData['photo'][$id]; array_remove($srcData['photo'], $id); file_put_contents($srcPath, json_encode($srcData)); file_put_contents($dstPath, json_encode($dstData)); } elseif (isset($_POST['order'])) { file_put_contents('public/data/list.js', json_encode($_POST)); } echo 'success'; die(0);
protected final function writeAChildList($class, $flag = NULL) { global $gbl, $sgbl, $login, $ghtml; $list = "{$class}_l"; $desc = "__desc_{$list}"; $pclass = $this->get__table(); $desc = get_real_class_variable($pclass, $desc); if (csa($desc[0], "r")) { dprint("Readonly {$class} in {$this->get__table()} {$this->nname} <br> "); return; } dprintr("Warning... Writing {$class} in {$this->get__table()} {$this->nname}...<br> "); if (!$this->{$list}) { return; } //dprint(" element {$class} \n"); foreach ((array) $this->{$list} as $element) { if (!$element) { continue; } //dprint("Inside: {$element->getClName()} {$element->dbaction} <br> "); if (!$element->__parent_o) { $element->__parent_o = $this; } $element->was(); if ($element->dbaction === "delete_done") { unset($this->{$list}[$element->nname]); } } // Virtual stuff is 'wased' anyway. This is not a problem since, the object will be written to Db only once. if ($this->isVirtual($class)) { $this->__virtual_list = array_remove($this->__virtual_list, $class); // Try adding this whole list to the $login... dprint("{$list} in {$this->getClass()}:{$this->nname} is virtual; present in Virtual List... Removing <br> ", 2); $this->{$list} = NULL; return; } if (get_real_class_variable($class, "__ttype") === "transient") { $this->{$list} = NULL; unset($this->{$list}); } if (!$flag) { $this->__list_list = array_remove($this->__list_list, $class); } }