欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

linux bash shell 脚本 crontab 脚本命令行 执行 drupal 有大用 有大大用

//判断用户是否登录 未登录 就跳到login页面
function shipingzhongcustomfive_init()
{
  global $user;


  //这是命令行执行的话 就返回  为的是drupal 能够顺利执行
  if ('root' == $_SERVER["USER"])
   {
     return;
  }
  $q=$_GET['q'];


  empty($q) && $q='';




  global $base_url;
  $base_url_parts = parse_url($base_url);
  $host = $base_url_parts['host'];



  if((empty($user) || empty($user->uid)) && $q!='user/login' && !_startWith($q,'image_captcha') && !_startWith($q,'captcha/refresh')){
     
     //header("location: /user/login");
     drupal_goto('user/login?destination='.$q);
  }

  else if( (!empty($user) && !empty($user->uid)) && $q=='user/login'){
     drupal_goto('<front>');
  }
  if(drupal_is_front_page() && ( $host == 'zg.wzfzxx.com' || $host == 'w.shrszg.com' )){
     $_GET['q'] = 'listkefuzg';
  }
// if($q == 'listyijimingxi' ){
//    $array_dian_roles = array('ybbqjd'=>'仅仅松和188旗舰店_角色','szzxd'=>'仅仅松和苏州中心店_角色','yshqjd'=>'仅仅松和易生活店_角色');
//    foreach($array_dian_roles as $key=>$array_dian_role){
//       if(in_array($array_dian_role, $user->roles)){
//          if($_GET['field_yjmx_dianming_value_many_to_one'] != $key){
//             $get = $_GET;
//             unset($get['q']);
//             unset($get['field_yjmx_dianming_value_many_to_one']);
//             $get['field_yjmx_dianming_value_many_to_one'] = $key;
//             $link = url($q, array('query' => $get,'absolute'=>TRUE));
//             drupal_goto($link);
//             exit;
//          }
//       }
//
//    }
// }
}





function shipingzhongcustomtwelve_init()
{
   //这是命令行执行的话 就返回  为的是drupal 能够顺利执行
   if ('root' == $_SERVER["USER"])
   {
       $param_arr = getopt('q:');
       $_GET = $param_arr;
       return;
   }

}





function _command_line_access()
{
   if ('root' == $_SERVER["USER"]){
       return true;
   }
   else {
       return false;
   }
}


普通分类: