예제 #1
0
 public function parse($comment)
 {
     $lines = $this->getLines($comment);
     $lines = array_map(function ($line) {
         return $this->parseLine($line);
     }, $lines);
     $lines = array_filter($lines, function ($line) {
         return $line && $this->isParam($line) && $this->hasExtra($line);
     });
     $lines = array_map(function ($line) {
         return array_slice($line, 1);
     }, $lines);
     if (count($lines) > 0) {
         $method = new Method();
         $index = 0;
         foreach ($lines as $line) {
             if (count($line) == 1) {
                 // @param {type}
                 $method->addParam($index++, $line[0]);
             } else {
                 if (count($line) >= 2) {
                     // @param {type} ${name} [...]
                     $method->addParam($index++, $line[0], ltrim($line[1], '$'));
                 }
             }
         }
         return $method;
     }
     return false;
 }
예제 #2
0
파일: klass.php 프로젝트: bermi/akelos
 public function &updateClassDetails(&$File, &$Component, &$SourceAnalyzer)
 {
     $MethodInstance = new Method(array('init' => false));
     $MethodInstance->setConnection($this->getConnection());
     $MethodInstance->init();
     $parsed_details = $SourceAnalyzer->getParsedArray($File->body);
     $available_classes = empty($parsed_details['classes']) ? array() : array_keys($parsed_details['classes']);
     if (empty($available_classes)) {
         return $available_classes;
     }
     $Classes = array();
     foreach ($available_classes as $class_name) {
         $extends = !empty($parsed_details['classes'][$class_name]['extends']) ? $parsed_details['classes'][$class_name]['extends'] : false;
         if ($extends) {
             $SourceAnalyzer->log('Looking for parent class: ' . $extends);
             $ParentClass = $this->_addOrUpdateClassDetails($extends, $File, $Component, $SourceAnalyzer, array(), true);
         }
         $Class = $this->_addOrUpdateClassDetails($class_name, $File, $Component, $SourceAnalyzer, $parsed_details['classes'][$class_name]);
         if (!empty($ParentClass)) {
             $SourceAnalyzer->log('Setting ' . $extends . ' as the parent of ' . $class_name);
             $ParentClass->tree->addChild($Class);
             $ParentClass->save();
         }
         $Class->methods = array();
         if (!empty($parsed_details['classes'][$class_name]['methods'])) {
             foreach ($parsed_details['classes'][$class_name]['methods'] as $method_name => $method_details) {
                 $Class->methods[] = $MethodInstance->updateMethodDetails($Class, $method_name, $method_details, $SourceAnalyzer);
             }
         }
         $Classes[] = $Class;
     }
     return $Classes;
 }
예제 #3
0
 /**
  * @covers Puml\Model\Method::hasParameters
  */
 public function testHasParameters()
 {
     $this->assertFalse($this->object->hasParameters());
     $parameter = $this->getMock('\\Puml\\Model\\MethodParameter');
     $this->object->addParameter($parameter);
     $this->assertTrue($this->object->hasParameters());
 }
예제 #4
0
 /**
  * __construct() should set the exception's names and message if names is string
  */
 public function test___construct_returnsSelf_ifNamesIsString()
 {
     $name = 'foo';
     $e = new Method($name);
     $this->assertEquals([$name], $e->getNames());
     $this->assertEquals("Method {$name} could not be found", $e->getMessage());
     return;
 }
 public function testScenario1()
 {
     $name = 'setDoctrine';
     $injectionKeys = array('doctrine');
     $method = new Method();
     $method->setName($name);
     $method->setInjectionKeys($injectionKeys);
     $this->assertEquals($name, $method->getName());
     $this->assertEquals($injectionKeys, $method->getInjectionKeys());
     $this->assertTrue($method->hasInjectionKeys());
     $this->assertEquals($method, new Method($method->__toArray()));
     $newMethod = new Method($method->__toArray());
     $this->assertEquals($method->__toArray(), $newMethod->__toArray());
 }
function print_debug_info($method, $endpoint, $headers)
{
    print "\n";
    print "Method: " . Method::nameForEnumValue($method) . "\n";
    print "Endpoint: " . $endpoint . "\n";
    print_r($headers);
}
예제 #7
0
파일: SpiritMethod.php 프로젝트: neel/bong
 /**
  * @load
  * @param ReflectionMethod $reflection
  */
 protected function _createFromReflection($reflection)
 {
     $this->_type = Method::SpiritMethod;
     parent::_createFromReflection($reflection);
     //{ Add Views
     if ($this->isPublic()) {
         $viewPath = \Path::instance()->evaluate(':' . $this->controller()->project()->name() . '.*' . $this->controller()->name() . '.view.-' . $this->name());
         if (file_exists($viewPath)) {
             $dh = opendir($viewPath);
             $viewsFound = array();
             while (false !== ($file = readdir($dh))) {
                 if ($file != "." && $file != ".." && strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'php') {
                     $viewFilePath = rtrim($viewPath, '/') . "/{$file}";
                     $viewsFound[$file] = $viewFilePath;
                     $this->addView(SpiritView::create($this, pathinfo($file, PATHINFO_FILENAME)));
                 }
             }
             closedir($dh);
             if (array_key_exists('view.php', $viewsFound)) {
                 $this->setHasDefaultView();
             }
         }
     }
     //}
 }
예제 #8
0
파일: CodeBase.php 프로젝트: PHPforks/phan
 /**
  * @param string[] $function_name_list
  * A list of function names to load type information for
  */
 private function addFunctionsByNames(array $function_name_list)
 {
     foreach ($function_name_list as $i => $function_name) {
         foreach (Method::methodListFromFunctionName($this, $function_name) as $method) {
             $this->addMethod($method);
         }
     }
 }
예제 #9
0
파일: method.php 프로젝트: habari/system
 /**
  * Dispatch a method, whether a filter or function
  * @param Callable|string $method The method to call
  * @param array $args An array of arguments to be passed to the method
  * @return bool|mixed The return value from the dispatched method
  */
 public static function dispatch_array($method, $args = array())
 {
     if (is_callable($method)) {
         return call_user_func_array($method, $args);
     } elseif (is_string($method)) {
         array_unshift($args, $method, false);
         return call_user_func_array(Method::create('\\Habari\\Plugins', 'filter'), $args);
     }
     return false;
 }
예제 #10
0
파일: Controller.php 프로젝트: neel/bong
 /**
  * @param ReflectionClass $reflection
  */
 protected function _createFromReflection($reflection)
 {
     $this->_className = $reflection->getName();
     $this->_endLine = $reflection->getEndLine();
     $this->_filePath = $reflection->getFileName();
     foreach ($reflection->getMethods() as $method) {
         //Method::create($this, $method);
         $this->addMethod(Method::create($this, $method));
     }
 }
 function actionMethod($id = null)
 {
     if ($id == null) {
         $this->render('methods', array('methods' => Method::model()->findAll()));
     } else {
         $c = Method::model()->findByPk($id);
         if ($c == null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
         $this->render('method', array('method' => $c));
     }
 }
예제 #12
0
 /**
  * Gets a new instance of the Method class.
  *
  * @param   string      The name or instance of the Method to link to
  * @return  Method
  */
 public static function forge($method = 'default')
 {
     if (is_string($method)) {
         $set = \Method::instance($method) and $method = $set;
     }
     if ($method instanceof Method_Template) {
         if ($method->template(false) != null) {
             throw new \DomainException('Form instance already exists, cannot be recreated. Use instance() instead of forge() to retrieve the existing instance.');
         }
     }
     return new static($method);
 }
예제 #13
0
 /**
  * toDocTypeString
  * @param Method $method
  * @return string
  */
 public function toDocTypeString(Method $method)
 {
     $longestType = 0;
     $longestName = 0;
     foreach ($method->getParameters() as $parameter) {
         if (strlen($parameter->getType()) > $longestType) {
             $longestType = strlen($parameter->getType());
         }
         if (strlen($parameter->getName()) > $longestName) {
             $longestName = strlen($parameter->getName());
         }
     }
     $returnVar = '	 * @param';
     $returnVar .= ' ' . $this->getType() . str_repeat(' ', $longestType - strlen($this->getType()));
     $returnVar .= ' $' . $this->getName();
     if (strlen($this->getDescription()) > 0) {
         $returnVar .= str_repeat(' ', $longestName - strlen($this->getName())) . ' ' . $this->getDescription();
     }
     $returnVar .= "\n";
     return $returnVar;
 }
예제 #14
0
 function campaignAction()
 {
     $this->filter();
     $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params));
     $models = AFActiveDataProvider::models('Pixelrate', $this->params, $pagination);
     $pixelrates = $models->getAllGroupByCampaign();
     $id = AF::get($this->params, 'campaign_id');
     $methods = Method::model()->cache()->findAllInArray();
     Assets::js('jquery.form');
     $this->addToPageTitle('Pixel rates');
     $this->render('campaign', array('pixelrates' => $pixelrates, 'pagination' => $pagination, 'methods' => $methods, 'campaign_id' => $id));
 }
예제 #15
0
 protected function _methodNval($name = '', $val = '', $met = '')
 {
     if ($met === "post") {
         return Method::post($name, $val);
     }
     if ($met === "get") {
         return Method::get($name, $val);
     }
     if ($met === "request") {
         return Method::request($name, $val);
     }
 }
예제 #16
0
파일: Method.php 프로젝트: djnewtown/judge
 /**
  * validate param type for {$offset}th param
  * !!!will return true if we are not sure about the type!!!
  *
  * @param int    $offset Param offset
  * @param string $type   Doctype styled type
  * @return bool
  */
 public function isParamType($offset, $expectedType)
 {
     $param = $this->_params[$offset];
     $value = $param->value;
     $type = self::TYPE_MIXED;
     if ($param->value instanceof \PHPParser_Node_Expr_MethodCall) {
         $method = new Method($param->value->name, $param->value->args, null);
         $type = $method->getReturnType();
     } elseif ($param->value instanceof \PHPParser_Node_Scalar_String || $param->value instanceof \PHPParser_Node_Scalar_ClassConst || $param->value instanceof \PHPParser_Node_Scalar_DirConst || $param->value instanceof \PHPParser_Node_Scalar_FileConst || $param->value instanceof \PHPParser_Node_Scalar_FuncConst || $param->value instanceof \PHPParser_Node_Scalar_LineConst || $param->value instanceof \PHPParser_Node_Scalar_MethodConst || $param->value instanceof \PHPParser_Node_Scalar_NSConst || $param->value instanceof \PHPParser_Node_Scalar_TraitConst) {
         $type = self::TYPE_STRING;
     } elseif ($param->value instanceof \PHPParser_Node_Scalar_DNumber) {
         $type = self::TYPE_FLOAT;
     } elseif ($param->value instanceof \PHPParser_Node_Scalar_LNumber) {
         $type = self::TYPE_INT;
     } elseif ($param->value instanceof \PHPParser_Node_Expr_Array) {
         $type = self::TYPE_FLOAT;
     }
     if (in_array($expectedType, array(self::TYPE_UNKNOWN, self::TYPE_MIXED))) {
         return true;
     }
     return $type == $expectedType;
 }
예제 #17
0
 /**
  * Add pre-defined rules to an array of rules only if rules with their names don't already exist
  *
  * @param array $rules An array of RewriteRule objects
  * @return array An array of rules with the system rules potentially added
  */
 public static function add_system_rules($rules)
 {
     $default_rules = array(array('name' => 'display_home', 'parse_regex' => '#^(?:page/(?P<page>0|1))?/?$#', 'build_str' => '(page/{$page})', 'handler' => 'UserThemeHandler', 'action' => 'display_home', 'priority' => 1000, 'description' => 'Homepage (index) display'), array('name' => 'display_entries', 'parse_regex' => '#^(?:page/(?P<page>[2-9]|[1-9][0-9]+))/?$#', 'build_str' => '(page/{$page})', 'handler' => 'UserThemeHandler', 'action' => 'display_entries', 'priority' => 999, 'description' => 'Display multiple entries'), array('name' => 'display_entries_by_date', 'parse_regex' => '#^(?P<year>[1,2]{1}[\\d]{3})(?:/(?P<month>[\\d]{2}))?(?:/(?P<day>[\\d]{2}))?(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => '{$year}(/{$month})(/{$day})(/page/{$page})', 'handler' => 'UserThemeHandler', 'action' => 'display_date', 'priority' => 2, 'description' => 'Displays posts for a specific date.'), array('name' => 'display_entries_by_tag', 'parse_regex' => '#^tag/(?P<tag>[^/]*)(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => 'tag/{$tag}(/page/{$page})', 'handler' => 'UserThemeHandler', 'action' => 'display_tag', 'priority' => 5, 'description' => 'Return posts matching specified tag.', 'parameters' => serialize(array('require_match' => Method::create('\\Habari\\Tag', 'rewrite_tag_exists')))), array('name' => 'display_entry', 'parse_regex' => '#^(?P<slug>[^/]+)(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => '{$slug}(/page/{$page})', 'handler' => 'UserThemeHandler', 'action' => 'display_post', 'priority' => 100, 'description' => 'Return entry matching specified slug', 'parameters' => serialize(array('require_match' => Method::create('\\Habari\\Posts', 'rewrite_match_type'), 'content_type' => 'entry', 'request_types' => array('display_post')))), array('name' => 'display_page', 'parse_regex' => '#^(?P<slug>[^/]+)(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => '{$slug}(/page/{$page})', 'handler' => 'UserThemeHandler', 'action' => 'display_post', 'priority' => 100, 'description' => 'Return page matching specified slug', 'parameters' => serialize(array('require_match' => Method::create('\\Habari\\Posts', 'rewrite_match_type'), 'content_type' => 'page', 'request_types' => array('display_post')))), array('name' => 'display_search', 'parse_regex' => '#^search(?:/(?P<criteria>[^/]+))?(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => 'search(/{$criteria})(/page/{$page})', 'handler' => 'UserThemeHandler', 'action' => 'search', 'priority' => 8, 'description' => 'Searches posts'), array('name' => 'display_404', 'parse_regex' => '/^.*$/', 'build_str' => '', 'handler' => 'UserThemeHandler', 'action' => 'display_404', 'priority' => 9999, 'description' => 'Displays an error page when a URL is not matched.'), array('name' => 'display_post', 'parse_regex' => '#^(?P<slug>[^/]+)(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => '{$slug}(/page/{$page})', 'handler' => 'UserThemeHandler', 'action' => 'display_post', 'priority' => 9998, 'description' => 'Fallback to return post matching specified slug if no content_type match'), array('name' => 'submit_feedback', 'parse_regex' => '#^(?P<id>[0-9]+)/feedback/?$#i', 'build_str' => '{$id}/feedback', 'handler' => 'FeedbackHandler', 'action' => 'add_comment', 'priority' => 8, 'description' => 'Adds a comment to a post'), array('name' => 'display_dashboard', 'parse_regex' => '#^admin/?$#', 'build_str' => 'admin', 'handler' => 'AdminDashboardHandler', 'action' => 'dashboard', 'priority' => 4, 'description' => 'Display the admin dashboard'), array('name' => 'display_publish', 'parse_regex' => '#^admin/publish/(?P<content_type_name>[^/]+)(?:/(?P<id>.+))?/?$#', 'build_str' => 'admin/publish/{$content_type_name}(/{$id})', 'handler' => 'AdminPostsHandler', 'action' => 'publish', 'priority' => 4, 'description' => 'Manage publishing posts'), array('name' => 'display_posts', 'parse_regex' => '#^admin/posts/?$#', 'build_str' => 'admin/posts', 'handler' => 'AdminPostsHandler', 'action' => 'posts', 'priority' => 4, 'description' => 'Manage posts'), array('name' => 'delete_post', 'parse_regex' => '#^admin/delete_post/?$#', 'build_str' => 'admin/delete_post', 'handler' => 'AdminPostsHandler', 'action' => 'delete_post', 'priority' => 4, 'description' => 'Delete a post'), array('name' => 'user_profile', 'parse_regex' => '#^admin/user/(?P<user>[^/]+)/?$#', 'build_str' => 'admin/user/{$user}', 'handler' => 'AdminUsersHandler', 'action' => 'user', 'priority' => 4, 'description' => 'The profile page for a specific user'), array('name' => 'display_users', 'parse_regex' => '#^admin/users/?$#', 'build_str' => 'admin/users', 'handler' => 'AdminUsersHandler', 'action' => 'users', 'priority' => 4, 'description' => 'Manage users'), array('name' => 'own_user_profile', 'parse_regex' => '#^admin/user/?$#', 'build_str' => 'admin/user', 'handler' => 'AdminUsersHandler', 'action' => 'user', 'priority' => 4, 'description' => 'The profile page for a specific user'), array('name' => 'display_themes', 'parse_regex' => '#^admin/themes/?$#', 'build_str' => 'admin/themes', 'handler' => 'AdminThemesHandler', 'action' => 'themes', 'priority' => 4, 'description' => 'Manage themes'), array('name' => 'activate_theme', 'parse_regex' => '#^admin/activate_theme/?$#', 'build_str' => 'admin/activate_theme', 'handler' => 'AdminThemesHandler', 'action' => 'activate_theme', 'priority' => 4, 'description' => 'Activate a theme'), array('name' => 'preview_theme', 'parse_regex' => '#^admin/preview_theme/?$#', 'build_str' => 'admin/preview_theme', 'handler' => 'AdminThemesHandler', 'action' => 'preview_theme', 'priority' => 4, 'description' => 'Preview a theme'), array('name' => 'configure_block', 'parse_regex' => '#^admin/configure_block/?$#i', 'build_str' => 'admin/configure_block', 'handler' => 'AdminThemesHandler', 'action' => 'configure_block', 'priority' => 4, 'description' => 'Configure a block in an iframe'), array('name' => 'display_plugins', 'parse_regex' => '#^admin/plugins(?:/(?P<configure>[0-9a-f]{8})/(?P<action>.+))?/?$#', 'build_str' => 'admin/plugins(/{$configure}/{$action})', 'handler' => 'AdminPluginsHandler', 'action' => 'plugins', 'priority' => 4, 'description' => 'Manage plugins'), array('name' => 'plugin_toggle', 'parse_regex' => '#^admin/plugin_toggle/?$#', 'build_str' => 'admin/plugin_toggle', 'handler' => 'AdminPluginsHandler', 'action' => 'plugin_toggle', 'priority' => 4, 'description' => 'Activate or deactivate a plugin'), array('name' => 'display_options', 'parse_regex' => '#^admin/options/?$#', 'build_str' => 'admin/options', 'handler' => 'AdminOptionsHandler', 'action' => 'options', 'priority' => 4, 'description' => 'The options page for the blog'), array('name' => 'display_comments', 'parse_regex' => '#^admin/comments/?$#', 'build_str' => 'admin/comments', 'handler' => 'AdminCommentsHandler', 'action' => 'comments', 'priority' => 4, 'description' => 'Manage comments'), array('name' => 'edit_comment', 'parse_regex' => '#^admin/comment/(?P<id>[0-9]+)/?$#i', 'build_str' => 'admin/comment/{$id}', 'handler' => 'AdminCommentsHandler', 'action' => 'comment', 'priority' => 4, 'description' => 'Edit a comment'), array('name' => 'display_groups', 'parse_regex' => '#^admin/groups/?$#', 'build_str' => 'admin/groups', 'handler' => 'AdminGroupsHandler', 'action' => 'groups', 'priority' => 4, 'description' => 'Manage groups'), array('name' => 'display_group', 'parse_regex' => '#^admin/group/(?P<id>[0-9]+)/?$#i', 'build_str' => 'admin/group/{$id}', 'handler' => 'AdminGroupsHandler', 'action' => 'group', 'priority' => 4, 'description' => 'Manage a group'), array('name' => 'display_tags', 'parse_regex' => '#^admin/tags/?$#i', 'build_str' => 'admin/tags', 'handler' => 'AdminTagsHandler', 'action' => 'tags', 'priority' => 4, 'description' => 'Manage tags'), array('name' => 'display_logs', 'parse_regex' => '#^admin/logs/?$#i', 'build_str' => 'admin/logs', 'handler' => 'AdminLogsHandler', 'action' => 'logs', 'priority' => 4, 'description' => 'Manage logs'), array('name' => 'display_import', 'parse_regex' => '#^admin/import/?$#i', 'build_str' => 'admin/import', 'handler' => 'AdminImportHandler', 'action' => 'import', 'priority' => 4, 'description' => 'Manage importing content'), array('name' => 'get_locale', 'parse_regex' => '#^admin/locale/?$#i', 'build_str' => 'admin/locale', 'handler' => 'AdminLocaleHandler', 'action' => 'locale', 'priority' => 4, 'description' => 'Fetch the locale data as javascript'), array('name' => 'display_sysinfo', 'parse_regex' => '#^admin/sysinfo/?$#i', 'build_str' => 'admin/sysinfo', 'handler' => 'AdminHandler', 'action' => 'sysinfo', 'priority' => 4, 'description' => 'Display system info'), array('name' => 'admin', 'parse_regex' => '#^admin(?:/?$|/(?P<page>[^/]*))/?$#i', 'build_str' => 'admin/({$page})', 'handler' => 'AdminHandler', 'action' => 'admin', 'priority' => 6, 'description' => 'An admin action'), array('name' => 'admin_ajax_dashboard', 'parse_regex' => '#^admin_ajax/(?P<context>dashboard)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminDashboardHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for the admin dashboard'), array('name' => 'admin_ajax_posts', 'parse_regex' => '#^admin_ajax/(?P<context>posts)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminPostsHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for the managing posts'), array('name' => 'admin_ajax_update_posts', 'parse_regex' => '#^admin_ajax/(?P<context>update_posts)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminPostsHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for the updating posts'), array('name' => 'admin_ajax_facets', 'parse_regex' => '#^admin_ajax/(?P<context>facets)/(?P<page>manage|tags)/(?P<component>facets|values)/?$#i', 'build_str' => 'admin_ajax/{$context}/{$page}/{$component}', 'handler' => 'AdminHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for retrieving post search facets'), array('name' => 'admin_ajax_media', 'parse_regex' => '#^admin_ajax/(?P<context>media)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminPostsHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling from media silos'), array('name' => 'admin_ajax_media_panel', 'parse_regex' => '#^admin_ajax/(?P<context>media_panel)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminPostsHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling from media panels'), array('name' => 'admin_ajax_media_upload', 'parse_regex' => '#^admin_ajax/(?P<context>media_upload)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminPostsHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling from media panel uploads'), array('name' => 'admin_ajax_add_block', 'parse_regex' => '#^admin_ajax/(?P<context>add_block)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminThemesHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for adding a block', 'parameters' => serialize(array('require_permission' => array('manage_theme_config' => true)))), array('name' => 'admin_ajax_delete_block', 'parse_regex' => '#^admin_ajax/(?P<context>delete_block)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminThemesHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for deleting a block'), array('name' => 'admin_ajax_save_areas', 'parse_regex' => '#^admin_ajax/(?P<context>save_areas)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminThemesHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for saving areas'), array('name' => 'admin_ajax_comments', 'parse_regex' => '#^admin_ajax/(?P<context>comments)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminCommentsHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for managing comments'), array('name' => 'admin_ajax_update_comment', 'parse_regex' => '#^admin_ajax/(?P<context>update_comment)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminCommentsHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for updating a comment'), array('name' => 'admin_ajax_groups', 'parse_regex' => '#^admin_ajax/(?P<context>groups)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminGroupsHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for managing groups'), array('name' => 'admin_ajax_update_groups', 'parse_regex' => '#^admin_ajax/(?P<context>update_groups)/?$#', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminGroupsHandler', 'action' => 'admin_ajax', 'priority' => 4, 'description' => 'Authenticated ajax handler for updating a group'), array('name' => 'admin_ajax_tags', 'parse_regex' => '#^admin_ajax/(?P<context>tags)/?$#', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminTagsHandler', 'action' => 'admin_ajax', 'priority' => 4, 'description' => 'Authenticated ajax handler for managing tags'), array('name' => 'admin_ajax_get_tags', 'parse_regex' => '#^admin_ajax/(?P<context>get_tags)/?$#', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminTagsHandler', 'action' => 'admin_ajax', 'priority' => 4, 'description' => 'Authenticated ajax handler for retrieving tags'), array('name' => 'admin_ajax_logs', 'parse_regex' => '#^admin_ajax/(?P<context>logs)/?$#', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminLogsHandler', 'action' => 'admin_ajax', 'priority' => 4, 'description' => 'Authenticated ajax handler for managing logs'), array('name' => 'admin_ajax_delete_logs', 'parse_regex' => '#^admin_ajax/(?P<context>delete_logs)/?$#', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminLogsHandler', 'action' => 'admin_ajax', 'priority' => 4, 'description' => 'Authenticated ajax handler for deleting logs'), array('name' => 'admin_ajax', 'parse_regex' => '#^admin_ajax/(?P<context>[^/]+)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminHandler', 'action' => 'admin_ajax', 'priority' => 10, 'description' => 'Authenticated ajax handling for the admin'), array('name' => 'auth', 'parse_regex' => '#^auth/(?P<page>[^/]*)$#i', 'build_str' => 'auth/{$page}', 'handler' => 'UserHandler', 'action' => '{$page}', 'priority' => 7, 'description' => 'A user action or display, for instance the login screen'), array('name' => 'ajax', 'parse_regex' => '#^ajax/(?P<context>[^/]+)/?$#i', 'build_str' => 'ajax/{$context}', 'handler' => 'AjaxHandler', 'action' => 'ajax', 'priority' => 8, 'description' => 'Ajax handling'), array('name' => 'auth_ajax', 'parse_regex' => '#^auth_ajax/(?P<context>[^/]+)/?$#i', 'build_str' => 'auth_ajax/{$context}', 'handler' => 'AjaxHandler', 'action' => 'auth_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling'), array('name' => 'rsd', 'parse_regex' => '/^rsd$/i', 'build_str' => 'rsd', 'handler' => 'AtomHandler', 'action' => 'rsd', 'priority' => 1, 'description' => 'RSD output'), array('name' => 'atom_entry', 'parse_regex' => '#^(?P<slug>[^/]+)/atom/?$#i', 'build_str' => '{$slug}/atom', 'handler' => 'AtomHandler', 'action' => 'entry', 'priority' => 8, 'description' => 'Atom Publishing Protocol'), array('name' => 'atom_feed', 'parse_regex' => '#^atom/(?P<index>[^/]+)(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => 'atom/{$index}(/page/{$page})', 'handler' => 'AtomHandler', 'action' => 'collection', 'priority' => 8, 'description' => 'Atom collection'), array('name' => 'atom_feed_comments', 'parse_regex' => '#^atom/comments(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => 'atom/comments(/page/{$page})', 'handler' => 'AtomHandler', 'action' => 'comments', 'priority' => 7, 'description' => 'Entries comments'), array('name' => 'atom_feed_tag', 'parse_regex' => '#^tag/(?P<tag>[^/]+)/atom(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => 'tag/{$tag}/atom(/page/{$page})', 'handler' => 'AtomHandler', 'action' => 'tag_collection', 'priority' => 8, 'description' => 'Atom Tag Collection', 'parameters' => serialize(array('require_match' => Method::create('\\Habari\\Tag', 'rewrite_tag_exists')))), array('name' => 'atom_feed_entry_comments', 'parse_regex' => '#^(?P<slug>[^/]+)/atom/comments(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => '{$slug}/atom/comments(/page/{$page})', 'handler' => 'AtomHandler', 'action' => 'entry_comments', 'priority' => 8, 'description' => 'Entry comments'), array('name' => 'atom_feed_page_comments', 'parse_regex' => '#^(?P<slug>[^/]+)/atom/comments(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => '{$slug}/atom/comments(/page/{$page})', 'handler' => 'AtomHandler', 'action' => 'entry_comments', 'priority' => 8, 'description' => 'Page comments'), array('name' => 'atompub_servicedocument', 'parse_regex' => '/^atom$/i', 'build_str' => 'atom', 'handler' => 'AtomHandler', 'action' => 'introspection', 'priority' => 1, 'description' => 'Atom introspection'), array('name' => 'cron', 'parse_regex' => '#^cron/(?P<time>[0-9.]+)/?$#i', 'build_str' => 'cron/{$time}', 'handler' => 'CronHandler', 'action' => 'poll_cron', 'priority' => 1, 'description' => 'Asyncronous cron processing'), array('name' => 'xmlrpc', 'parse_regex' => '#^xmlrpc/?$#i', 'build_str' => 'xmlrpc', 'handler' => 'XMLRPCServer', 'action' => 'xmlrpc_call', 'priority' => 8, 'description' => 'Handle incoming XMLRPC requests.'));
     $default_rules = Plugins::filter('default_rewrite_rules', $default_rules);
     $default_rules_properties = array('is_active' => 1, 'rule_class' => RewriteRule::RULE_SYSTEM);
     $rule_names = array_flip(Utils::array_map_field($rules, 'name'));
     foreach ($default_rules as $default_rule) {
         if (!isset($rule_names[$default_rule['name']])) {
             $rule_properties = array_merge($default_rule, $default_rules_properties);
             $rules[] = new RewriteRule($rule_properties);
         }
     }
     return $rules;
 }
예제 #18
0
 public function testGetOutput()
 {
     $this->inst->setReturn('string');
     $this->inst->setArgument(new Argument('string:name=\'username\''));
     $this->inst->setArgument(new Argument('int:age'));
     $this->inst->setDescription('Description test method');
     $output = $this->inst->getOutput();
     $this->assertEquals('string test(string $name = \'username\', int $age) Description test method', $output);
 }
예제 #19
0
파일: Timer.php 프로젝트: nochso/benchmark
 /**
  * @return float The time it took to execute in milliseconds
  */
 private function measure()
 {
     $closure = $this->method->getMethod();
     if ($this->parameter !== null) {
         // Make sure getParameter() won't be measured.
         $parameterValue = $this->parameter->getParameter();
         $start = microtime(true);
         $closure($this->iterationCount, $parameterValue);
         return (microtime(true) - $start) * 1000.0;
     }
     // Have to omit the parameter because the closure won't accept it.
     $start = microtime(true);
     $closure($this->iterationCount);
     return (microtime(true) - $start) * 1000.0;
 }
예제 #20
0
 public function add_routes()
 {
     $routes = func_get_args();
     \_u::each($routes, function ($route, $index) {
         $method = key($route);
         $items = $route[$method];
         if (!Method::has_method(strtolower($method))) {
             continue;
         }
         $route = new Route($items);
         $route->method = new Method($method);
         if (isset($items['headers']) && is_array($items['headers'])) {
             $route->headers = Headers::set_for_route($items['headers']);
         }
         $this->routes[] = $route;
     });
 }
예제 #21
0
 public function loadConfig(Model\Aop $aop)
 {
     foreach ($this->objectReflectionClass->getMethods() as $reflectionMethod) {
         $annotations = $this->reader->getMethodAnnotations($reflectionMethod);
         $beforeAdvices = [];
         $afterAdvices = [];
         $insteadAdvices = [];
         $canceled = null;
         $group = null;
         switch (get_class($annotation)) {
             case Annotation::After:
                 $afterAdvices[] = new Model\Advice($annotation->context, $annotation->method, $annotation->args);
                 break;
             case Annotation::Before:
                 $beforeAdvices[] = new Model\Advice($annotation->context, $annotation->method, $annotation->args);
                 break;
             case Annotation::Cancel:
                 $canceled = true;
                 break;
             case Annotation::Group:
                 $group = $annotation->id;
                 break;
             case Annotation::Instead:
                 $insteadAdvices[] = new Model\Advice($annotation->context, $annotation->method, $annotation->args);
                 break;
         }
         $method = new Method();
         if (!empty($beforeAdvices)) {
             $method->setBeforeAdvices($beforeAdvices);
         }
         if (!empty($afterAdvices)) {
             $method->setAfterAdvices($afterAdvices);
         }
         if (!empty($insteadAdvices)) {
             $method->setInsteadAdvices($insteadAdvices);
         }
         if (isset($group)) {
             $method->setGroup($group);
         }
         if (isset($canceled)) {
             $method->setCanceled($canceled);
         }
         $aop->addMethod($method);
     }
 }
예제 #22
0
 public function duzenle($id)
 {
     $head['title'] = 'Haberler';
     $head['meta']['author'] = 'Bursa yazılım';
     $headData["kullaniciAdi"] = Session::select('kisi');
     if (!empty($_POST["baslik"]) and !empty($_POST["detay"])) {
         $data["baslik"] = Method::post("baslik");
         $data["resim"] = Method::post("resim");
         $data["detay"] = Method::post("detay");
         $data["etiketler"] = Method::post("etiketler");
         $data["durum"] = Method::post("durum");
         $ekle = $this->haberler->guncelle($id, $data);
         if ($ekle) {
             redirect('haber/form/' . $id, 0, array('uyariData' => $data, 'uyari' => '<div class="alert alert-success"><strong>TEBRİKLER!</strong> Güncelleme işlemi başarı ile gerçekleşti.</div>'));
         } else {
             redirect('haber/form/' . $id, 0, array('uyariData' => $data, 'uyari' => '<div class="alert alert-error"><strong>HATA!</strong> Güncelleme işlemi gerçekleşemedi Lütfen sistem yöneticinize başvurunuz.</div>'));
         }
     } else {
         redirect('haber/form/' . $id, 0, array('uyariData' => $data, 'uyari' => '<div class="alert alert-info"><strong>HATA!</strong>Lütfen Gerekli Tüm Alanları Doldurunuz !</div>'));
     }
 }
예제 #23
0
파일: session.php 프로젝트: habari/system
 /**
  * Initialize the session handlers
  */
 public static function init()
 {
     // the default path for the session cookie is /, but let's make that potentially more restrictive so no one steals our cookehs
     // we also can't use 'null' when we set a secure-only value, because that doesn't mean the same as the default like it should
     $path = Site::get_path('base', true);
     // the default is not to require a secure session
     $secure = false;
     // if we want to always require secure
     if (Config::get('force_secure_session') == true) {
         $secure = true;
     }
     // if this is an HTTPS connection by default we will
     // IIS sets HTTPS == 'off', so we have to check the value too
     if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
         $secure = true;
     }
     // but if we have explicitly disabled it, don't
     // note the ===. not setting it (ie: null) should not be the same as setting it to false
     if (Config::get('force_secure_session') === false) {
         $secure = false;
     }
     // now we've got a path and secure, so set the cookie values
     session_set_cookie_params(null, $path, null, $secure);
     // figure out the session lifetime and let plugins change it
     $lifetime = ini_get('session.gc_maxlifetime');
     self::$lifetime = Plugins::filter('session_lifetime', $lifetime);
     //$_SESSION = new SessionStorage();
     if (isset($_COOKIE[self::HABARI_SESSION_COOKIE_NAME])) {
         self::$session_id = $_COOKIE[self::HABARI_SESSION_COOKIE_NAME];
         self::read();
         self::$stored_session_hash = self::session_data_hash();
     }
     // make sure we check whether or not we should write the session after the page is rendered
     register_shutdown_function(Method::create('\\Habari\\Session', 'shutdown'));
     // process the write queue
     register_shutdown_function(Method::create('\\Habari\\Session', 'process_queue'));
     return true;
 }
예제 #24
0
 public function duzenle($id)
 {
     $head['title'] = 'Yönetici Güncelle';
     $head['meta']['author'] = 'Bursa yazılım';
     $headData["kullaniciAdi"] = Session::select('kisi');
     if (!empty($_POST["username"])) {
         $data["username"] = Method::post("username");
         $data["pass"] = Method::post("pass");
         $data["email"] = Method::post("email");
         $data["isim"] = Method::post("isim");
         $data["soyisim"] = Method::post("soyisim");
         $data["durum"] = Method::post("durum");
         $data["ban_durum"] = Method::post("ban_durum");
         $duzenle = $this->yonetici->guncelle($id, $data);
         if ($duzenle) {
             redirect('yonetim/form/' . $id, 0, array('uyariData' => $data, 'uyari' => '<div class="alert alert-success"><strong>TEBRİKLER!</strong> Güncelleme işlemi başarı ile gerçekleşti.</div>'));
         } else {
             redirect('yonetim/form/' . $id, 0, array('uyariData' => $data, 'uyari' => '<div class="alert alert-error"><strong>HATA!</strong> Güncelleme işlemi gerçekleşemedi Lütfen sistem yöneticinize başvurunuz.</div>'));
         }
     } else {
         redirect('yonetim/form/' . $id, 0, array('uyariData' => $data, 'uyari' => '<div class="alert alert-info"><strong>HATA!</strong>Lütfen Gerekli Tüm Alanları Doldurunuz !</div>'));
     }
 }
예제 #25
0
 /**
  * @load
  * @param ReflectionMethod $reflection
  */
 protected function _createFromReflection($reflection)
 {
     $this->_type = Method::ControllerMethod;
     parent::_createFromReflection($reflection);
     //{ Add Views
     if ($this->isPublic()) {
         $viewPath = \Path::instance()->evaluate(':' . $this->controller()->project()->name() . '.apps.view.+' . $this->controller()->name() . '.-' . $this->name());
         if (file_exists($viewPath)) {
             $this->setViewDirectoryCreated();
             $dh = opendir($viewPath);
             $viewsFound = array();
             while (false !== ($file = readdir($dh))) {
                 if ($file != "." && $file != ".." && strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'php') {
                     $viewFilePath = rtrim($viewPath, '/') . "/{$file}";
                     if ($file == 'layout.php') {
                         $this->setHasLayout();
                         $this->_layout = ControllerLayout::create($viewPath . '/layout.php');
                     } else {
                         if ($file == 'params.php') {
                             $this->setHasParams();
                             $this->_params = Params::create($viewPath . '/params.php');
                         } else {
                             $viewsFound[$file] = $viewFilePath;
                             $this->addView(ControllerView::create($this, pathinfo($file, PATHINFO_FILENAME)));
                         }
                     }
                 }
             }
             closedir($dh);
             if (array_key_exists('view.php', $viewsFound)) {
                 $this->setHasDefaultView();
             }
         }
     }
     //}
 }
예제 #26
0
 /**
  * Analyze the parameters and arguments for a call
  * to the given method or function
  *
  * @param CodeBase $code_base
  * @param Method $method
  * @param Node $node
  *
  * @return null
  */
 private function analyzeCallToMethod(CodeBase $code_base, Method $method, Node $node)
 {
     if (Database::isEnabled()) {
         // Store the call to the method so we can track
         // dependencies later
         (new CalledBy((string) $method->getFQSEN(), $this->context))->write(Database::get());
     }
     // Create variables for any pass-by-reference
     // parameters
     $argument_list = $node->children['args'];
     foreach ($argument_list->children as $i => $argument) {
         $parameter = $method->getParameterList()[$i] ?? null;
         if (!$parameter) {
             continue;
         }
         // If pass-by-reference, make sure the variable exists
         // or create it if it doesn't.
         if ($parameter->isPassByReference()) {
             if ($argument->kind == \ast\AST_VAR) {
                 // We don't do anything with it; just create it
                 // if it doesn't exist
                 $variable = AST::getOrCreateVariableFromNodeInContext($argument, $this->context, $this->code_base);
             } else {
                 if ($argument->kind == \ast\AST_STATIC_PROP || $argument->kind == \ast\AST_PROP) {
                     $property_name = $argument->children['prop'];
                     if (is_string($property_name)) {
                         // We don't do anything with it; just create it
                         // if it doesn't exist
                         try {
                             $property = AST::getOrCreatePropertyFromNodeInContext($argument->children['prop'], $argument, $this->context, $this->code_base);
                         } catch (CodeBaseException $exception) {
                             Log::err(Log::EUNDEF, $exception->getMessage(), $this->context->getFile(), $node->lineno);
                         } catch (NodeException $exception) {
                             // If we can't figure out what kind of a call
                             // this is, don't worry about it
                         }
                     } else {
                         // This is stuff like `Class->$foo`. I'm ignoring
                         // it.
                     }
                 }
             }
         }
     }
     // Confirm the argument types are clean
     ArgumentType::analyze($method, $node, $this->context, $this->code_base);
     // Take another pass over pass-by-reference parameters
     // and assign types to passed in variables
     foreach ($argument_list->children as $i => $argument) {
         $parameter = $method->getParameterList()[$i] ?? null;
         if (!$parameter) {
             continue;
         }
         // If the parameter is pass-by-reference and we're
         // passing a variable in, see if we should pass
         // the parameter and variable types to eachother
         $variable = null;
         if ($parameter->isPassByReference()) {
             if ($argument->kind == \ast\AST_VAR) {
                 $variable = AST::getOrCreateVariableFromNodeInContext($argument, $this->context, $this->code_base);
             } else {
                 if ($argument->kind == \ast\AST_STATIC_PROP || $argument->kind == \ast\AST_PROP) {
                     $property_name = $argument->children['prop'];
                     if (is_string($property_name)) {
                         // We don't do anything with it; just create it
                         // if it doesn't exist
                         try {
                             $variable = AST::getOrCreatePropertyFromNodeInContext($argument->children['prop'], $argument, $this->context, $this->code_base);
                         } catch (CodeBaseException $exception) {
                             Log::err(Log::EUNDEF, $exception->getMessage(), $this->context->getFile(), $node->lineno);
                         } catch (NodeException $exception) {
                             // If we can't figure out what kind of a call
                             // this is, don't worry about it
                         }
                     } else {
                         // This is stuff like `Class->$foo`. I'm ignoring
                         // it.
                     }
                 }
             }
             if ($variable) {
                 $variable->getUnionType()->addUnionType($parameter->getUnionType());
             }
         }
     }
     // If we're in quick mode, don't retest methods based on
     // parameter types passed in
     if (Config::get()->quick_mode) {
         return;
     }
     // We're going to hunt to see if any of the arguments
     // have a mismatch with the parameters. If so, we'll
     // re-check the method to see how the parameters impact
     // its return type
     $has_argument_parameter_mismatch = false;
     // Now that we've made sure the arguments are sufficient
     // for definitions on the method, we iterate over the
     // arguments again and add their types to the parameter
     // types so we can test the method again
     $argument_list = $node->children['args'];
     // We create a copy of the parameter list so we can switch
     // back to it after
     $original_parameter_list = $method->getParameterList();
     foreach ($argument_list->children as $i => $argument) {
         $parameter = $method->getParameterList()[$i] ?? null;
         if (!$parameter) {
             continue;
         }
         // If the parameter has no type, pass the
         // argument's type to it
         if ($parameter->getUnionType()->isEmpty()) {
             $has_argument_parameter_mismatch = true;
             $argument_type = UnionType::fromNode($this->context, $this->code_base, $argument);
             // If this isn't an internal function or method
             // and it has no type, add the argument's type
             // to it so we can compare it to subsequent
             // calls
             if (!$parameter->getContext()->isInternal()) {
                 // Clone the parameter in the original
                 // parameter list so we can reset it
                 // later
                 $original_parameter_list[$i] = clone $parameter;
                 // Then set the new type on that parameter based
                 // on the argument's type. We'll use this to
                 // retest the method with the passed in types
                 $parameter->getUnionType()->addUnionType($argument_type);
             }
         }
     }
     // Now that we know something about the parameters used
     // to call the method, we can reanalyze the method with
     // the types of the parameter, making sure we don't get
     // into an infinite loop of checking calls to the current
     // method in scope
     if ($has_argument_parameter_mismatch && !$method->getContext()->isInternal() && (!$this->context->isMethodScope() || $method->getFQSEN() !== $this->context->getMethodFQSEN())) {
         $method->analyze($method->getContext(), $code_base);
     }
     // Reset to the original parameter list after having
     // tested the parameters with the types passed in
     $method->setParameterList($original_parameter_list);
 }
예제 #27
0
 function updateAction()
 {
     $model = new Profile();
     if (isset($_POST['ajax'])) {
         // Add method to profile
         if (isset($_POST['model']) && $_POST['model'] == 'profiles_methods') {
             $profileMethod = new ProfileMethod();
             @$this->performAjaxValidation($profileMethod);
             // Uncomment the line if AJAX validation is needed
             if ($_POST['action'] == 'create') {
                 $profileMethod->fillFromArray($_POST, TRUE);
             } elseif ($_POST['action'] == 'update') {
                 $methodID = (int) AF::get($_POST, 'method_id');
                 $profileID = (int) AF::get($_POST, 'profile_id');
                 $profileMethod = ProfileMethod::model()->findByPk(array('method_id' => $methodID, 'profile_id' => $profileID));
                 $profileMethod->fillFromArray($_POST);
             }
             if ($profileMethod->method_id == Method::METHOD_CC) {
                 if (isset($_POST['flags']['filter']) && $_POST['flags']['filter']) {
                     if (!$profileMethod->flags) {
                         $profileMethod->flags = '';
                     }
                     @$profileMethod->addFlags('filter');
                 } else {
                     $profileMethod->removeFlags('filter');
                 }
             }
             if (!$profileMethod->flags) {
                 $profileMethod->flags = '';
             }
             if ($profileMethod->save()) {
                 $link = AF::link(array('profiles' => 'update'), array('id' => $profileMethod->profile_id));
                 Message::echoJson('success', array('redirect' => $link));
             } else {
                 Message::echoJsonError(__('profile_method_not_' . $_POST['action'] . 'd') . '. ' . $profileMethod->errors2string);
             }
         }
         if (isset($_POST['getprofilemethodinfo'])) {
             $methodID = (int) AF::get($_POST, 'method_id');
             $profileID = (int) AF::get($_POST, 'profile_id');
             $methods = Method::model()->cache()->findAllInArray();
             //$model = ProfileMethod::model()->find("profiles_methods_id=:profiles_methods_id", array(':profiles_methods_id'=>$id));
             $model = ProfileMethod::model()->findByPk(array('method_id' => $methodID, 'profile_id' => $profileID));
             echo $this->view->includeFile('_methods_form', array('application', 'views', 'profiles'), array('action' => 'update', 'ajax' => TRUE, 'popup' => TRUE, 'methodModel' => $model, 'methods' => $methods));
             die;
         }
     }
     if (isset($_POST['model'])) {
         // Change profile_name
         if ($_POST['model'] == 'profile') {
             if (isset($_POST['ajax'])) {
                 $this->performAjaxValidation($model);
                 // Uncomment the line if AJAX validation is needed
                 $model->fillFromArray($_POST, FALSE);
                 $model->user_id_updated = $this->user->user_id;
                 $model->updated = 'NOW():sql';
                 $model->model_uset_id = $this->user->user_id;
                 if ($model->save()) {
                     $link = AF::link(array('profiles' => 'update'), array('id' => $model->PkValue));
                     Message::echoJson('success', array('redirect' => $link));
                 } else {
                     Message::echoJsonError(__('profile_no_updated'));
                 }
                 die;
             }
             $this->redirect();
             die;
         }
         // Add gateway to profile
         if ($_POST['model'] == 'profiles_gateways') {
             $profileGateway = new ProfileGateway();
             $this->performAjaxValidation($profileGateway);
             // Uncomment the line if AJAX validation is needed
             $profileGateway->fillFromArray($_POST, TRUE);
             $profileGateway->addGateway();
         }
     }
     $id = AF::get($this->params, 'id', FALSE);
     $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params));
     $models = AFActiveDataProvider::models('ProfileGateway', $this->params, $pagination);
     $profile_methods = ProfileMethod::model()->getProfileMethodsByProfile($id);
     //$method_ids = '0';
     if ($profile_methods) {
         foreach ($profile_methods as $key => $value) {
             $method_id_array[] = $value['method_id'];
         }
         $method_ids = implode(',', $method_id_array);
     }
     $methods = Method::model()->cache()->findAllInArray();
     $gateways = Gateway::model()->getGateways();
     if (!$id) {
         throw new AFHttpException(0, 'no_id');
     }
     if (!$model->findByPk($id)) {
         throw new AFHttpException(0, 'incorrect_id');
     }
     //for create profile method
     $modelProfileMethod = new ProfileMethod();
     $modelProfileMethod->profile_id = $model->profile_id;
     Assets::js('jquery.form');
     $this->addToPageTitle('Edit Profile');
     $this->render('update', array('model' => $model, 'gateways' => $gateways, 'models' => $models, 'methods' => $methods, 'profile_methods' => $profile_methods, 'modelProfileMethod' => $modelProfileMethod));
 }
예제 #28
0
 public function login($un = 'username', $pw = 'password', $rememberMe = false)
 {
     if (!is_string($un)) {
         return Error::set(lang('Error', 'stringParameter', 'un'));
     }
     if (!is_string($pw)) {
         return Error::set(lang('Error', 'stringParameter', 'pw'));
     }
     if (!isValue($rememberMe)) {
         $rememberMe = false;
     }
     $username = $un;
     $password = Encode::super($pw);
     // ------------------------------------------------------------------------------
     // CONFIG/USER.PHP AYARLARI
     // Config/User.php dosyasında belirtilmiş ayarlar alınıyor.
     // ------------------------------------------------------------------------------
     $userConfig = $this->config;
     $passwordColumn = $userConfig['passwordColumn'];
     $usernameColumn = $userConfig['usernameColumn'];
     $emailColumn = $userConfig['emailColumn'];
     $tableName = $userConfig['tableName'];
     $bannedColumn = $userConfig['bannedColumn'];
     $activeColumn = $userConfig['activeColumn'];
     $activationColumn = $userConfig['activationColumn'];
     // ------------------------------------------------------------------------------
     $db = uselib('DB');
     $r = $db->where($usernameColumn . ' =', $username)->get($tableName)->row();
     if (empty($r)) {
         $this->error = lang('User', 'loginError');
         return Error::set($this->error);
     }
     if (!isset($r->{$passwordColumn})) {
         $this->error = lang('User', 'loginError');
         return Error::set($this->error);
     }
     $passwordControl = $r->{$passwordColumn};
     $bannedControl = '';
     $activationControl = '';
     if (!empty($bannedColumn)) {
         $banned = $bannedColumn;
         $bannedControl = $r->{$banned};
     }
     if (!empty($activationColumn)) {
         $activationControl = $r->{$activationColumn};
     }
     if (!empty($r->{$usernameColumn}) && $passwordControl == $password) {
         if (!empty($bannedColumn) && !empty($bannedControl)) {
             $this->error = lang('User', 'bannedError');
             return Error::set($this->error);
         }
         if (!empty($activationColumn) && empty($activationControl)) {
             $this->error = lang('User', 'activationError');
             return Error::set($this->error);
         }
         if (!isset($_SESSION)) {
             session_start();
         }
         $_SESSION[md5($usernameColumn)] = $username;
         session_regenerate_id();
         if (Method::post($rememberMe) || !empty($rememberMe)) {
             if (Cookie::select(md5($usernameColumn)) != $username) {
                 Cookie::insert(md5($usernameColumn), $username);
                 Cookie::insert(md5($passwordColumn), $password);
             }
         }
         if (!empty($activeColumn)) {
             $db->where($usernameColumn . ' =', $username)->update($tableName, array($activeColumn => 1));
         }
         $this->error = false;
         $this->success = lang('User', 'loginSuccess');
         return true;
     } else {
         $this->error = lang('User', 'loginError');
         return Error::set($this->error);
     }
 }
예제 #29
0
 /**
  * Calls the success callback for the form, and saves the form value to the control's storage location
  * @param FormUI $form The form this control belongs to
  * @return boolean|string A string to replace the rendering of the form with, or false
  */
 public function do_success($form)
 {
     $output = false;
     foreach ($this->on_success as $success) {
         $callback = array_shift($success);
         array_unshift($success, $this->get_form(), $this);
         if (!$form->get_setting('found_success', false)) {
             $result = Method::dispatch_array($callback, $success);
             if (is_string($result)) {
                 $output = $result;
             }
         }
     }
     $this->save();
     return $output;
 }
예제 #30
0
 /**
  * Visit a node with kind `\ast\AST_CLOSURE`
  *
  * @param Node $node
  * A node to parse
  *
  * @return Context
  * A new or an unchanged context resulting from
  * parsing the node
  */
 public function visitClosure(Node $node) : Context
 {
     $closure_fqsen = FullyQualifiedFunctionName::fromClosureInContext($this->context);
     $method = Method::fromNode($this->context, $this->code_base, $node);
     // Override the FQSEN with the found alternate ID
     $method->setFQSEN($closure_fqsen);
     // Make the closure reachable by FQSEN from anywhere
     $this->code_base->addMethod($method);
     // If we have a 'this' variable in our current scope,
     // pass it down into the closure
     $context = $this->context->withScope(new Scope());
     if ($context->getScope()->hasVariableWithName('this')) {
         $context = $context->addScopeVariable($this->context->getScope()->getVariableWithName('this'));
     }
     if (!empty($node->children['uses']) && $node->children['uses']->kind == \ast\AST_CLOSURE_USES) {
         $uses = $node->children['uses'];
         foreach ($uses->children as $use) {
             if ($use->kind != \ast\AST_CLOSURE_VAR) {
                 Log::err(Log::EVAR, "You can only have variables in a closure use() clause", $this->context->getFile(), $node->lineno);
                 continue;
             }
             $variable_name = AST::variableName($use->children['name']);
             if (empty($variable_name)) {
                 continue;
             }
             $variable = null;
             // Check to see if the variable exists in this scope
             if (!$this->context->getScope()->hasVariableWithName($variable_name)) {
                 // If this is not pass-by-reference variable we
                 // have a problem
                 if (!($use->flags & \ast\flags\PARAM_REF)) {
                     Log::err(Log::EVAR, "Variable \${$variable_name} is not defined", $this->context->getFile(), $node->lineno);
                     continue;
                 } else {
                     // If the variable doesn't exist, but its
                     // a pass-by-reference variable, we can
                     // just create it
                     $variable = Variable::fromNodeInContext($use, $this->context, $this->code_base, false);
                 }
             } else {
                 $variable = $this->context->getScope()->getVariableWithName($variable_name);
                 // If this isn't a pass-by-reference variable, we
                 // clone the variable so state within this scope
                 // doesn't update the outer scope
                 if (!($use->flags & \ast\flags\PARAM_REF)) {
                     $variable = clone $variable;
                 }
             }
             // Pass the variable into a new scope
             $context = $context->withScopeVariable($variable);
         }
     }
     // Add all parameters to the scope
     if (!empty($node->children['params']) && $node->children['params']->kind == \ast\AST_PARAM_LIST) {
         $params = $node->children['params'];
         foreach ($params->children as $param) {
             // Read the parameter
             $parameter = Parameter::fromNode($this->context, $this->code_base, $param);
             // Add it to the scope
             $context = $context->withScopeVariable($parameter);
         }
     }
     return $context->withClosureFQSEN($closure_fqsen);
 }