function renice($pid, $app) { $root = 0; $salida = null; $root = comp(); $process = find($pid, $app); if ($process != null) { $put = $app->request(); $ni = $put->put('ni'); if (is_numeric($ni)) { if ((int) $ni > -21 && (int) $ni < 20) { if ($root == 1) { $par = "sudo ./renice.sh norberfaraz@gmail.com " . $ni . " " . $pid; } else { $par = "renice " . $ni . " " . $pid; } $salida = shell_exec($par); if ($salida == null) { $salida = "No tiene permisos para repriorizar el proceso con ID:" . $pid; $app->render(202, array('msg' => $salida, 'error' => 'true')); } else { $app->render(200, array('msg' => $salida, 'error' => 'false')); } } else { $app->render(202, array('msg' => 'la variable ni(prioridad) no esta bien definida, debe ser un valor numerico entre 20 y -20 2 ', 'error' => 'true')); } } else { $app->render(202, array('msg' => 'la variable ni(prioridad) no esta bien definida, debe ser un valor numerico entre 20 y -20 1 ' . $ni . 'h', 'error' => 'true')); } } else { $app->render(202, array('msg' => 'Proceso inexistente', 'error' => true)); } }
function add() { if (!in_array($this->_get_param('type'), array('IssueCustomField', 'UserCustomField', 'ProjectCustomField', 'TimeEntryCustomField'))) { $this->redirect('index'); } $this->CustomField->bindModel(array('hasMany' => array('CustomFieldsTracker')), false); $custom_field = array($this->CustomField->name => array('type' => $this->_get_param('type'))); if (!empty($this->request->data)) { $this->CustomField->set($this->request->data); if ($this->CustomField->save()) { $event = new CakeEvent('Controller.Candy.customFieldsNewAfterSave', $this, array('custom_field' => $this->request->data)); $this->getEventManager()->dispatch($event); $this->Session->setFlash(__('Successful update.'), 'default', array('class' => 'flash flash_notice')); $this->redirect(array('action' => 'index', '?' => array('tab' => $this->_get_param('type')))); } } else { $this->request->data = $custom_field; } if ($this->_get_param('type') == "IssueCustomField" && $this->_get_param('tracker_ids')) { $custom_field['Tracker'] = $this->CustomFieldsTracker->Tracker . find('list', array('conditions' => array('id' => $this->_get_param('tracker_ids')))); } $Tracker = ClassRegistry::init('Tracker'); $this->set('trackers', $Tracker->find('list', array('order' => 'position'))); $this->set('custom_field', $custom_field); $this->render("new"); }
function __construct($page_object, $array_menu) { parent::__construct(); $this->render = new Menu(); $wsp_admin_url = WSP_ADMIN_URL; $menu_items = new MenuItems(); foreach ($array_menu['MenuItems']['MenuItem'] as $menuitems) { eval("\$page_icon_16 = \"" . $menuitems['Menu_attr']['icon_16'] . "\";"); if (find($menuitems['Menu_attr']['name'], "__(", 0, 0) > 0) { eval("\$page_title = " . $menuitems['Menu_attr']['name'] . ";"); } else { eval("\$page_title = \"" . $menuitems['Menu_attr']['name'] . "\";"); } eval("\$page_link = \"" . $menuitems['Menu_attr']['url'] . "\";"); if ($menuitems['Menu_attr']['url'] == "\$wsp_admin_url/admin.html") { $page_title = ""; } $menu_item = new MenuItem($page_title, $page_link, $page_icon_16); if (isset($_GET['menu'])) { if ($page_link == $wsp_admin_url . "/admin.html?menu=" . $_GET['menu']) { $menu_item->setCurrent(); } } $menu_items->add($menu_item); $sub_menu_items = new MenuItems(); if (!isset($menuitems['MenuItems']['MenuItem'][0])) { $sub_menuitems = $menuitems['MenuItems']; } else { $sub_menuitems = $menuitems['MenuItems']['MenuItem']; } $nb_sub_menu = 0; foreach ($sub_menuitems as $menuitem) { eval("\$page_icon_16 = \"" . $menuitem['Menu_attr']['icon_16'] . "\";"); if (find($menuitem['Menu_attr']['name'], "__(", 0, 0) > 0) { eval("\$page_title = " . $menuitem['Menu_attr']['name'] . ";"); } else { eval("\$page_title = \"" . $menuitem['Menu_attr']['name'] . "\";"); } eval("\$page_link = \"" . $menuitem['Menu_attr']['url'] . "\";"); $sub_menu_item = new MenuItem($page_title, $page_link, $page_icon_16); if ($page_link == $_GET['p'] . ".html") { $sub_menu_item->setCurrent(); $menu_item->setCurrent(); } $sub_menu_items->add($sub_menu_item); $nb_sub_menu++; } if ($nb_sub_menu > 0) { $menu_item->setMenuItems($sub_menu_items); } } $this->render->setMenuItems($menu_items); $this->render->activateSupersubs(); list($strAdminLogin, $strAdminPasswd, $strAdminRights) = getWspUserRightsInfo("admin"); if ($strAdminLogin == "admin" && $strAdminPasswd == sha1("admin")) { $modalbox = new DialogBox(__(CHANGE_PASSWD), new Url($page_object->getBaseLanguageURL() . "wsp-admin/change-passwd.call")); $modalbox->modal()->setWidth(400); $page_object->addObject($modalbox); } }
function dictionary($words) { if ($words) { switch ($words) { case 'apple': find($words, '蘋果'); break; case 'orange': find($words, '橘子'); break; case 'watermelon': find($words, '西瓜'); break; case 'strawberry': find($words, '草莓'); break; case 'pineapple': find($words, '鳳梨'); break; default: echo "水果字典中沒有" . $words . "這個單字"; break; } } }
/** * Constructor JavaScript * @param string $code_javascript * @param boolean $add_js_to_page [default value: false] */ function __construct($code_javascript, $add_js_to_page = false) { parent::__construct(); if (!isset($code_javascript)) { throw new NewException("1 argument for " . get_class($this) . "::__construct() is mandatory", 0, getDebugBacktrace(1)); } $this->code_javascript = $code_javascript; $this->is_javascript_object = true; if ($add_js_to_page) { $page_object = Page::getInstance($_GET['p']); if (gettype($code_javascript) != "object") { // search in javascript if begin by $(document).ready( // then put javascript to the end (for AJAX because doc is already loaded) $tmp_code_javascript = trim(str_replace("\t", "", $code_javascript)); $pos_doc_ready = find($tmp_code_javascript, "\$(document).ready(", 1); $pos_jquery_ready = find($tmp_code_javascript, "jQuery(document).ready(", 1); if ($pos_doc_ready >= 18 && $pos_doc_ready <= 30 || $pos_jquery_ready >= 23 && $pos_jquery_ready <= 35) { // 30|35: beacause of tag //<![CDATA[ $page_object->addObject($this, false, true); } else { $page_object->addObject($this); } } else { $page_object->addObject($this); } } }
function isNewBrowscapVersion() { if (!isset($_SESSION['user_browscap_version'])) { $_SESSION['user_browscap_version'] = getCurrentBrowscapRelease(); } if (!isset($_SESSION['server_browscap_version'])) { $server_browscap_version = ""; if (extension_loaded('soap')) { $http = new Http(); $http->setTimeout(2); $http->execute("http://www.website-php.com/en/webservices/wsp-information-server.wsdl?wsdl"); $wsdl = $http->getResult(); if ($wsdl != "" && find($wsdl, "<?xml", 1) > 0) { $client = new WebSitePhpSoapClient("http://www.website-php.com/en/webservices/wsp-information-server.wsdl?wsdl"); $server_browscap_version = $client->getBrowscapVersionNumber(); } } else { /*$http = new Http(); $http->setTimeout(2); $http->execute("http://browsers.garykeith.com/versions/version-number.asp"); $server_browscap_version = $http->getResult();*/ $server_browscap_version = ""; } if (trim($server_browscap_version) != "") { $_SESSION['server_browscap_version'] = $server_browscap_version; } } if (trim($_SESSION['user_browscap_version']) != trim($_SESSION['server_browscap_version'])) { return trim($_SESSION['server_browscap_version']); } return false; }
function index() { $this->pagedata['statusId'] = $this->system->getConf('shopex.wss.enable'); if (!IN_AJAX) { $lang = $_GET['_lang'] ? $_GET['_lang'] : $this->op->get('lang'); $lang = $lang ? $lang : 'zh_CN'; $setting = array('lang' => $lang); foreach ($_GET as $k => $v) { if (substr($k, 0, 1) == '_' && strlen($k) > 1) { $setting[substr($k, 1)] = $v; } } $this->op->load(); if (defined('SAAS_MODE') && SAAS_MODE) { $this->pagedata['saas_mode'] = true; $saas = $this->system->loadModel('service/saas'); if ($shopinfo = $saas->native_svc('host.getinfo', array('host_id' => HOST_ID))) { if ($shopinfo['response_code'] > 0) { $this->pagedata['shop_service_info'] = $shopinfo['response_error']; } else { $this->pagedata['shop_service_info'] .= $shopinfo['service_name']; $this->pagedata['shop_service_info'] .= $shopinfo['status'] == 'tryout' ? '(试用)' : ''; $this->pagedata['shop_service_info'] .= '[' . date('y/m/d', $shopinfo['add_time']) . '-' . date('y/m/d', $shopinfo['finish_time']) . ']'; } } } $titlename = $this->system->getConf('system.shopname'); $this->pagedata['title'] = $titlename . ' - Powered By ShopEx'; $this->pagedata['shopname'] = empty($titlename) ? "点此设置商店名称" : $titlename; $this->pagedata['session_id'] = $this->system->session->sess_id; $this->pagedata['shopadmin_dir'] = dirname($_SERVER['PHP_SELF']) . '/'; $this->pagedata['shop_base'] = $this->system->base_url(); $this->pagedata['setting_query'] = http_build_query($setting) . '&_lang=' . $lang; $this->pagedata['uname'] = $this->op->name ? $this->op->name : $this->op->loginName; include_once 'adminSchema.php'; $this->pagedata['menu'] = $this->op->getMenu(null, $this->op->is_super); $this->_fetchM($this->pagedata['menu'], $menus, array()); $menus = array_values($menus); foreach ($menus as $i => $m) { foreach ($menus[$i]['key'] as $k => $v) { $mkey[] = array($k, $i); } unset($menus[$i]['key']); } $i = count($menus); foreach ($mlist as $k => $v) { $menus[$i] = $v; $mkey[] = array($k, $i); $i++; } $this->pagedata['guide'] = $this->system->getConf('system.guide'); $this->pagedata['scripts'] = find(dirname($_SERVER['SCRIPT_FILENAME']) . '/js', 'js'); $this->pagedata['mlist'] = array('menus' => &$menus, 'key' => &$mkey); $this->setView('index.html'); $this->output(); } else { $this->system->error(401); } }
/** * Constructor File * @param mixed $filename path to the file * @param boolean $binary [default value: false] * @param boolean $delete_if_exists [default value: false] * @param boolean $debug [default value: true] */ function __construct($filename, $binary = false, $delete_if_exists = false, $debug = true) { $this->debug = $debug; $filename = str_replace("\\", "/", $filename); $this->name = $filename; $this->binary = $binary; if (file_exists($filename)) { $this->exists = true; } else { if (find($filename, "http://") == 0 && find($filename, "https://") == 0 && find($filename, "ftp://") == 0) { // we don't create a directory if it's a web file if (!is_dir(substr(0, strrpos($filename, "/"), $filename))) { $create_folder = ""; $tmp_filename = $filename; if (ini_get('open_basedir') != "") { $open_basedir_array = explode(":", ini_get('open_basedir')); for ($i = 0; $i < sizeof($open_basedir_array); $i++) { if (trim($open_basedir_array[$i]) != "" && substr($filename, 0, strlen($open_basedir_array[$i])) == $open_basedir_array[$i]) { $create_folder = $open_basedir_array[$i]; if ($create_folder[strlen($create_folder) - 1] != "/") { $create_folder .= "/"; } $tmp_filename = substr($filename, strlen($create_folder)); break; } } } $array_dir = explode("/", $tmp_filename); for ($i = 0; $i < sizeof($array_dir) - 1; $i++) { $create_folder_before = $create_folder; $create_folder .= $array_dir[$i] . "/"; if (!file_exists($dir) && !is_dir($create_folder) && $create_folder != "/") { if (!mkdir($create_folder)) { if (!mkdir(realpath($create_folder_before) . "/" . $array_dir[$i] . "/")) { $this->halt("Can't create folder " . $create_folder . "."); } } } } } } } if ($delete_if_exists && $this->exists) { if (!unlink($filename)) { $this->halt("Can't delete exists file " . $filename . "."); } } if ($binary) { $this->file = @fopen($filename, "a+b"); if (!$this->file) { $this->file = @fopen($filename, "rb"); } } else { $this->file = @fopen($filename, "a+"); if (!$this->file) { $this->file = @fopen($filename, "r"); } } }
/** * Autoload * * @param $class Class name. * @return boolean */ function autoload($class) { $filename = str_replace('_', DS, $class); if ($path = find($filename . EXT)) { include $path; return TRUE; } return FALSE; }
function index() { $this->pagedata['statusId'] = $this->system->getConf('shopex.wss.enable'); if (!IN_AJAX) { foreach ($_GET as $k => $v) { if (substr($k, 0, 1) == '_' && strlen($k) > 1) { $setting[substr($k, 1)] = $v; } } if (constant('SAAS_MODE')) { $saas =& $this->system->loadModel('service/saas'); if ($shopinfo = $saas->native_svc('host.getinfo', array('host_id' => HOST_ID))) { if ($shopinfo['response_code'] > 0) { $this->pagedata['shop_service_info'] = $shopinfo['response_error']; } else { $this->pagedata['shop_service_info'] .= $shopinfo['service_name']; $this->pagedata['shop_service_info'] .= $shopinfo['status'] == 'tryout' ? __('(试用)') : ''; $this->pagedata['shop_service_info'] .= '[' . date('y/m/d', $shopinfo['add_time']) . '-' . date('y/m/d', $shopinfo['finish_time']) . ']'; } } } $titlename = $this->system->getConf('system.shopname'); $this->pagedata['title'] = $titlename . ' - Powered By ShopEx'; $this->pagedata['shopname'] = empty($titlename) ? __("点此设置商店名称") : $titlename; $this->pagedata['session_id'] = $this->system->sess_id; $this->pagedata['status_url'] = urlencode(PHP_SELF . '?ctl=default&act=status&sess_id=' . $this->system->sess_id); $this->pagedata['shopadmin_dir'] = '/' . SHOPADMIN_PATH . '/'; $this->pagedata['shop_base'] = $this->system->base_url(); $this->pagedata['uname'] = $this->system->op_name; $this->pagedata['shop_type_info'] = '1to1' == $this->system->getConf('system.b2c_shop_type') ? '批零店' : '加盟连锁店'; if (!function_exists('admin_menu_filter')) { require CORE_INCLUDE_DIR . '/shop/admin.menu_filter.php'; } $this->pagedata['menu'] =& admin_menu_filter($this->system, null); $this->_fetchM($this->pagedata['menu'], $menus, array()); $menus = array_values($menus); foreach ($menus as $i => $m) { foreach ($menus[$i]['key'] as $k => $v) { $mkey[] = array($k, $i); } unset($menus[$i]['key']); } $i = count($menus); foreach ($mlist as $k => $v) { $menus[$i] = $v; $mkey[] = array($k, $i); $i++; } $this->pagedata['guide'] = $this->system->getConf('system.guide'); $this->pagedata['scripts'] = find(dirname($_SERVER['SCRIPT_FILENAME']) . '/js_src', 'js'); $this->pagedata['mlist'] = array('menus' => &$menus, 'key' => &$mkey); $this->display('index.html'); } else { $this->system->error(401); } }
public function approve($id) { return $this->db->query("UPDATE users SET user_level = ? WHERE id = ?", array(4, $id)); $user = find($id); $to = $user['email']; $password = $user['password']; $subject = "Welcome to LINK! Your membership has been approved!"; $message = "Congratulations! You are now officially a Rescue Team Member. You can login with your email. Your temporrary password is {$password}. Please change it when you first log into your account."; mail($to, $subject, $message); }
/** * Method getLocalPath * @access public * @return string * @since 1.0.35 */ public function getLocalPath() { $path = $this->getPath(); if ($this->treeview_object == null) { $this->treeview_object = $this->getTreeViewObject(); } if ($this->treeview_object->isRootFolder()) { $path = substr($path, find($path, "/", 0, 0), strlen($path)); } return str_replace("\\", "/", $this->treeview_object->getLoadedPath() . $path); }
public function set_template($template_name) { if (file_exists(find("template/") . $template_name)) { $this->template_dir = str_replace($this->template, $template_name, $this->template_dir); $this->template = $template_name; $this->compile_id = $this->template; $this->assign("template_dir", $this->template_dir); return true; } else { return false; } }
function sw($q) { switch ($q) { case "find": find(); break; case "explore": explore("https://www.mashape.com/explore"); break; } // print_r(error_get_last()); }
function write_rss_feed() { $feed_home = find("feed/"); if (($fh = @fopen($feed_home . "feed.xml", "w")) === false) { trigger_error("write_rss_feed could not lock file for writing", E_USER_WARNING); return false; } else { fwrite($fh, generate_rss_feed()); fclose($fh); return true; } }
/** * 根据名称在目录下查找文件&文件夹 * @param string $pattern 匹配规则 * @param string $dir 搜索目标根目录 * @return array */ function find($pattern, $dir = __ROOT__) { $dir = trim($dir, '/\\') . DS; if (!is_dir($dir)) { return error('dir ' . $dir . ' not exists'); } $pattern = '*' . trim($pattern, '*') . '*'; $matches = glob($dir . $pattern); $children_dir = glob($dir . '*', GLOB_ONLYDIR); foreach ($children_dir as $children_dir) { $matches = array_merge($matches, find($pattern, $children_dir)); } return $matches; }
/** * find $obj * * @param mixed $obj * @return boolean True */ function find($node, $obj) { if (!isset($node)) { return NULL; } $diff = compare($node['root'], $obj); if ($diff == 0) { return $node['root']; } elseif ($diff < 0) { return find($node['left'], $obj); } else { return find($node['right'], $obj); } }
function start() { $unix = new unix(); $pidpath = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = @file_get_contents($pidpath); if ($unix->process_exists($pid)) { $unix->events(basename(__FILE__) . ":: " . __FUNCTION__ . " Already process {$pid} running.. Aborting"); return; } $sql = "SELECT * FROM postfinder WHERE finish=0 ORDER BY date_start"; $q = new mysql(); $results = $q->QUERY_SQL($sql, "artica_events"); while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { find($ligne["pattern"]); } }
function render($region = "") { if ($region == "project") { $page = find($this, "Page", "path", $this->path); if ($page == null) { if (strpos($this->path, "/") !== false) { $parts = explode("/", $this->path); $page = find($this, "Page", "path", $parts[0]); if ($page == null) { $page = new Page($this, '{ "name":"404", "file":"threephp/inc/404.php" }'); } } } echo $page->render("page"); } }
function __construct($parent = null, $params_json = "{}") { $this->dice1 = 6; $this->dice2 = 6; $this->js = 'dice_roll'; $this->numhouses = 0; parent::__construct($parent, $params_json); find($this->root(), "Scene")->physics = true; $this->name = "dice"; //load last value?? $db_dices = root($this)->db->load("Dice", "", "", true); if (count($db_dices)) { $dice = json_decode($db_dices[0]->object); $this->dice1 = $dice->dice1; $this->dice2 = $dice->dice2; } }
public function delete($id = '') { if (empty($id)) { $this->ajaxReturn(array('status' => 'error')); } $where = array('id' => $id, 'isAvailable' => 1); $publisher = M('Publisher'); if ($publisher->where($where)->find()) { $book = M('Book'); $flag = $book->where(array('isAvailable' => 1, 'publisher_id' => $id) - find()); if (empty($flag)) { $res = $publisher->where($where)->save(array('isAvailable' => 0)); } } $data['status'] = empty($res) ? 'error' : 'success'; $this->ajaxReturn($data); }
/** * 用户登录判断 * * @param string $user * @param string $pass * @return int */ public function login($user, $pass) { $sql = "select username,password,privileges from mpos_user where username='******'"; $info = find($sql); if (!$info) { return '-1'; } //用户名不存在 if ($info['password'] != md5($pass)) { return '-2'; } //密码错误 #添加session变量 $_SESSION['account']['username'] = $info['username']; $_SESSION['account']['privileges'] = $info['privileges']; return '1'; }
function find($dir, $pattern) { // escape any character in a string that might be used to trick // a shell command into executing arbitrary commands $dir = escapeshellcmd($dir); // get a list of all matching files in the current directory $files = glob($dir . '/' . $pattern); // find a list of all directories in the current directory // directories beginning with a dot are also included foreach (glob($dir . '/*', GLOB_ONLYDIR) as $sub_dir) { $arr = find($sub_dir, $pattern); // recursive call $files = array_merge($files, $arr); // merge array with files from subdirectory } return $files; }
function find($sizes, $mustMatch, $matches = [], $depth = 1) { $sizes = array_filter($sizes, function ($v) use($mustMatch) { return $v <= $mustMatch; }); while ($size = array_shift($sizes)) { if ($mustMatch == $size) { isset($matches[$depth]) ? $matches[$depth]++ : ($matches[$depth] = 1); } else { if ($mustMatch < $size) { continue; } else { $matches = find($sizes, $mustMatch - $size, $matches, $depth + 1); } } } return $matches; }
function find($num, $boucle = 0) { if (file_exists("Public_Trolls.txt")) { $fichier = file_get_contents("Public_Trolls.txt"); $deb = $num == 1 ? '^' : '\\n'; preg_match('/' . $deb . $num . ';(.+);/U', $fichier, $out); if (!isset($out[1])) { if ($boucle == 0) { maj(); find($num, 1); } else { return '####'; } } else { return $out[1]; } } else { maj(); find($num, 1); } }
function smarty_function_header($params, &$smarty) { $system =& $GLOBALS['system']; $data['title'] = $smarty->_tpl_vars['title']; if ($GLOBALS['runtime']['query'] == 'index.html' && $system->getConf('system.index_title')) { $data['title'] = $system->getConf('system.index_title'); } $data['headers'] = $system->ctl->header; $data['base_url'] = $system->base_url(); $shop = array('set' => array()); $shop['set']['path'] = substr(PHP_SELF, 0, strrpos(PHP_SELF, '/') + 1); $shop['set']['buytarget'] = $system->getConf('site.buy.target'); //ajax加入购物车 $shop['set']['dragcart'] = $system->getConf('ux.dragcart'); //拖动购物 $shop['set']['refer_timeout'] = $system->getConf('site.refer_timeout'); //refer过期时间 $shop['url']['addcart'] = $system->mkUrl('cart', 'ajaxadd'); $shop['url']['shipping'] = $system->mkUrl('cart', 'shipping'); $shop['url']['payment'] = $system->mkUrl('cart', 'payment'); $shop['url']['total'] = $system->mkUrl('cart', 'total'); $shop['url']['viewcart'] = $system->mkUrl('cart', 'view'); $shop['url']['ordertotal'] = $system->mkUrl('cart', 'total'); $shop['url']['applycoupon'] = $system->mkUrl('cart', 'applycoupon'); $shop['url']['product_diff'] = $system->mkUrl('product', 'diff'); $data['shopDefine'] = json_encode($shop); $output =& $system->loadModel('system/frontend'); $theme_dir = $system->base_url() . 'themes/' . $output->theme; $data['theme_dir'] = $theme_dir; if (defined('DEBUG_JS') && DEBUG_JS) { $data['scripts'] = find(BASE_DIR . '/statics/headjs', 'js', 'statics/headjs'); } elseif (defined('GZIP_JS') && GZIP_JS) { $data['scripts'] = array('statics/head.jgz'); } else { $data['scripts'] = array('statics/head.js'); } $smarty->_smarty_include(array('smarty_include_tpl_file' => 'shop:common/header.html', 'smarty_include_vars' => $data)); }
/** * WebSite-PHP file utils_ajax.inc.php * * WebSite-PHP : PHP Framework 100% object (http://www.website-php.com) * Copyright (c) 2009-2015 WebSite-PHP.com * PHP versions >= 5.2 * * Licensed under The MIT License * Redistributions of files must retain the above copyright notice. * * @author Emilien MOREL <*****@*****.**> * @link http://www.website-php.com * @copyright WebSite-PHP.com 12/05/2015 * @version 1.2.13 * @access public * @since 1.0.19 */ function extract_javascript($html) { $array_html_js = array(); $array_html_js[0] = $html; $pos = find($html, "<script", 1, 0); while ($pos > 0) { $pos = $pos - 7; $pos2 = find($html, "</script>", 1, $pos); if ($pos2 > 0) { $sub_html1 = substr($html, 0, $pos); $sub_html2 = substr($html, $pos2, strlen($html)); $pos3 = find($html, ">", 1, $pos); $script = substr($html, $pos3, $pos2 - $pos3 - 9); $array_html_js[] = $script; $html = $sub_html1 . " " . $sub_html2; } else { break; } $pos = find($html, "<script", 1, 0); } $array_html_js[0] = $html; return $array_html_js; }
/** * 查找指定目录下的文件或目录 * @static * @param string $path 目录路径 * @param null $include 要包含的文件正则,如果设置了,则只有符合这个正则的文件才能被请求到 * @param null $exclude 要排除的文件正则,如果设置了,即使是包含的文件,也会被排除 * @param bool $recursion 是否递归查找,默认是true * @param bool $include_dir 找到的结果是否包含目录,默认为false,不包含 * @param array $files 递归用的存储容器,不应该被用到 * @return array 数组 */ function find($path, $include = null, $exclude = null, $recursion = true, $include_dir = false, &$files = array()) { // $path = self::realpath($path); if (is_dir($path)) { $path .= '/'; $dir = dir($path); while (false !== ($entry = $dir->read())) { if ($entry == '.' || $entry == '..' || $entry[0] == '.' && is_dir($path . $entry)) { continue; } $entry = $path . $entry; if (is_dir($entry)) { if ($include_dir && filter($entry, $include, $exclude)) { $files[] = $entry; } if ($recursion) { find($entry, $include, $exclude, true, $include_dir, $files); } } else { if (!filter($entry, $include, $exclude)) { continue; } $files[] = $entry; } } $dir->close(); return $files; } else { if (is_file($path) && filter($path, $include, $exclude)) { $files[] = $path; } } return $files; }
public function login() { $this->layout = 'sesion'; //Registro de asistencia if ($this->request->is('post')) { $cedula = $this->request->data['Personal']['cedula']; if (!empty($cedula)) { $this->request->data['usuario'] = "argemen"; $this->request->data['clave'] = "argenis"; $usuario = $this->Usuario->validateLogin($this->request->data); if ($usuario) { App::import('Model', 'Personal'); $personal = new Personal(); $this->set('cedula', $personal_ > find('all', array('conditions' => array('cedula' => $cedula)))); //$this->render('login','ajax'); } } else { if (!empty($this->request->data)) { if (($usuario = $this->Usuario->validateLogin($this->request->data)) == true) { $this->Session->write('usuario', $usuario); //$this->Session->setFlash('You\'ve successfully logged in.'); $this->redirect(array('action' => 'inicio')); exit; } else { $this->Session->setFlash('Usuario Invalido!!', 'default', array('class' => 'error')); $this->redirect(array('action' => 'login')); } } } } //Fin verificación método post }
public function run() { $this->req('id'); $this->req('link_god'); if ($id && ($user = find("\\System\\User", $id))) { $heading = $locales->trans('godmode_user_edit_passwd'); $f = $ren->form(array("id" => 'edit_user_groups', "heading" => $heading)); $f->input_password('password', $locales->trans('godmode_user_password'), true); $f->input_password('password_check', $locales->trans('godmode_user_password_check'), true); $f->submit($locales->trans('godmode_save')); if ($f->passed()) { $p = $f->get_data(); if ($p['password'] === $p['password_check']) { $p['password'] = hash_passwd($p['password']); $user->update_attrs($p)->save(); $flow->redirect(\Godmode\Router::url($request, $link_god, 'detail', array($user->id))); } else { $f->out($this); } } else { $f->out($this); } } else { throw new System\Error\NotFound(); } }