\documentclass[twoside]{book}


\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usepackage{titleps,ptext}

\colorlet{sectcolor}{gray!30}
\newcommand\graysquare{\textcolor{sectcolor}{\rule{1ex}{1ex}}}
\newcommand{\helv}{\fontfamily{phv}\fontseries{}\fontsize{10}{12}\selectfont}

\titleformat{\section}
  {\normalfont\Large\bfseries}
  {{\colorbox{sectcolor}{\makebox[2em][r]  {\thesection}}\hspace{1em}}}
  {0em}{#1}


\usepackage{xepersian}





\newpagestyle{main}{%
  \sethead
    [\chaptertitle]% even-left
    []% even-centre
    [\thepage]% even-right
    {\thepage}% odd-left
    {}% odd-centre
    {\thesection~\sectiontitle}% odd-right
}

\pagestyle{main}
\begin{document}
\headrule
\chapter{یک فصل}\ptext[1-10]
\section{یک بخش}\ptext[1-10]
\end{document}